Finalisation réception marchandise, ajout de composant UI et ajout de fixtures (!7)
| Numéro du ticket | Titre du ticket | |------------------|-----------------| | | | ## Description de la PR ## Modification du .env ## Check list - [x] Pas de régression - [ ] TU/TI/TF rédigée - [x] TU/TI/TF OK - [x] CHANGELOG modifié Reviewed-on: #7 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #7.
This commit is contained in:
51
frontend/services/reception-pellet-building.ts
Normal file
51
frontend/services/reception-pellet-building.ts
Normal 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'
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user