From 015a8c49fbcedb711a3cbe4156d9aff5646b161e Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 4 Feb 2026 13:04:23 +0100 Subject: [PATCH] =?UTF-8?q?feat=20:=20Ajout=20de=20la=20s=C3=A9lection=20d?= =?UTF-8?q?es=20bovins=20=C3=A9tape=203=20d'une=20r=C3=A9ception=20(WIP)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 113 +++++++++++------- .../reception/reception-bovine-received.vue | 79 +++++++++--- .../reception/reception-product-received.vue | 8 -- frontend/components/ui/UiNumberInput.vue | 55 ++++----- frontend/pages/reception/[[id]].vue | 4 +- .../services/dto/reception-bovine-data.ts | 8 ++ frontend/services/dto/reception-data.ts | 3 + frontend/services/reception-bovine.ts | 49 ++++++++ 8 files changed, 219 insertions(+), 100 deletions(-) create mode 100644 frontend/services/dto/reception-bovine-data.ts create mode 100644 frontend/services/reception-bovine.ts diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 640ad2e..31f36e9 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,18 +4,16 @@ - @@ -740,7 +752,8 @@ - @@ -750,10 +763,16 @@ 6 @@ -762,4 +781,12 @@ diff --git a/frontend/pages/reception/[[id]].vue b/frontend/pages/reception/[[id]].vue index 9be5d9a..dbbbe78 100644 --- a/frontend/pages/reception/[[id]].vue +++ b/frontend/pages/reception/[[id]].vue @@ -16,7 +16,8 @@ - + + @@ -25,6 +26,7 @@ import {useReceptionStore} from '~/stores/reception' import {storeToRefs} from 'pinia' import {RECEPTION_STEP_LABELS} from '~/constants/steps' +import {RECEPTION_TYPE_CODES} from "~/utils/constants"; const route = useRoute() const router = useRouter() diff --git a/frontend/services/dto/reception-bovine-data.ts b/frontend/services/dto/reception-bovine-data.ts new file mode 100644 index 0000000..d23f984 --- /dev/null +++ b/frontend/services/dto/reception-bovine-data.ts @@ -0,0 +1,8 @@ +import type {BovineTypeData} from "~/services/dto/bovine-type-data"; + +export interface ReceptionBovineTypeData{ + id: number + quantity : number + reception?: string + bovineType: BovineTypeData +} diff --git a/frontend/services/dto/reception-data.ts b/frontend/services/dto/reception-data.ts index 857fa07..31168a9 100644 --- a/frontend/services/dto/reception-data.ts +++ b/frontend/services/dto/reception-data.ts @@ -8,6 +8,7 @@ import type { AddressData } from '~/services/dto/address-data' import type { TruckData } from '~/services/dto/truck-data' import type { CarrierData } from '~/services/dto/carrier-data' import type { DriverData } from '~/services/dto/driver-data' +import type {BovineTypeData} from "~/services/dto/bovine-type-data"; export interface ReceptionData { id: number @@ -21,6 +22,7 @@ export interface ReceptionData { merchandiseType?: MerchandiseTypeData | null merchandiseDetail?: string | null buildings?: BuildingData[] | null + bovinesTypes?: BovineTypeData[] | null pelletBuildings?: ReceptionPelletBuildingData[] | null user?: UserData | null supplier?: SupplierData | null @@ -47,6 +49,7 @@ export type ReceptionPayload = { merchandiseType?: string | null merchandiseDetail?: string | null buildings?: string[] | null + bovinesTypes?: string[] | null user?: string | null supplier?: string | null address?: string | null diff --git a/frontend/services/reception-bovine.ts b/frontend/services/reception-bovine.ts new file mode 100644 index 0000000..4ae5265 --- /dev/null +++ b/frontend/services/reception-bovine.ts @@ -0,0 +1,49 @@ +import { useApi } from '~/composables/useApi' +import type { ReceptionBovineTypeData } from '~/services/dto/reception-bovine-data' + +export type ReceptionBovineListResponse = + | ReceptionBovineTypeData[] + | { 'hydra:member'?: ReceptionBovineTypeData[] } + +export type ReceptionBovinePayload = { + quantity: number + reception: string + bovineType: string +} + +export async function getReceptionBovineList( + receptionIri: string +): Promise { + const api = useApi() + const response = await api.get( + 'reception_bovines', + { reception: receptionIri }, + { + toastErrorKey: 'errors.receptionBovine.list' + } + ) + + if (Array.isArray(response)) { + return response + } + if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) { + return response['hydra:member'] + } + return [] +} + +export async function createReceptionBovine( + payload: ReceptionBovinePayload +): Promise { + const api = useApi() + return api.post('reception_bovines', payload, { + toastErrorKey: 'errors.receptionBovine.create' + }) +} + +export async function deleteReceptionBovine(id: number): Promise { + const api = useApi() + await api.delete(`reception_bovines/${id}`, {}, { + toastErrorKey: 'errors.receptionBovine.delete' + }) +}