feat : ajout de la partie reception des marchandises (étape 3) et modification du bon de réception

This commit is contained in:
2026-01-29 16:33:37 +01:00
parent cff80b5ab2
commit 07be7e8d14
26 changed files with 1141 additions and 107 deletions

View File

@@ -0,0 +1,51 @@
import { useApi } from '~/composables/useApi'
import type { ReceptionPelletBuildingData } from '~/services/dto/reception-pellet-building-data'
export type ReceptionPelletBuildingListResponse =
| ReceptionPelletBuildingData[]
| { 'hydra:member'?: ReceptionPelletBuildingData[] }
export type ReceptionPelletBuildingPayload = {
reception: string
pelletType: string
building: string
}
export async function getReceptionPelletBuildingList(
receptionIri: string
): Promise<ReceptionPelletBuildingData[]> {
const api = useApi()
const response = await api.get<ReceptionPelletBuildingListResponse>(
'reception_pellet_buildings',
{ reception: receptionIri },
{
toastErrorKey: 'errors.receptionPelletBuilding.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 createReceptionPelletBuilding(
payload: ReceptionPelletBuildingPayload
): Promise<ReceptionPelletBuildingData> {
const api = useApi()
return api.post<ReceptionPelletBuildingData>('reception_pellet_buildings', payload, {
toastErrorKey: 'errors.receptionPelletBuilding.create'
})
}
export async function deleteReceptionPelletBuilding(id: number): Promise<void> {
const api = useApi()
await api.delete<void>(`reception_pellet_buildings/${id}`, {}, {
toastErrorKey: 'errors.receptionPelletBuilding.delete'
})
}