b1c3952d09
| Numéro du ticket | Titre du ticket | |------------------|-----------------| | #271 | Créer une nouvelle expédition (étape 1) | ## 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é Co-authored-by: kevin <kevin@yuno.malio.fr> Reviewed-on: https://gitea.malio.fr/MALIO-DEV/Ferme/pulls/12 Reviewed-by: Autin <tristan@yuno.malio.fr> Co-authored-by: Matteo <matteo@yuno.malio.fr> Co-committed-by: Matteo <matteo@yuno.malio.fr>
25 lines
699 B
TypeScript
25 lines
699 B
TypeScript
import { useApi } from '~/composables/useApi'
|
|
import type {ShipmentTypeData} from "~/services/dto/shipment-type-data";
|
|
|
|
export type ShipmentTypeListResponse =
|
|
| ShipmentTypeData[]
|
|
| { 'hydra:member'?: ShipmentTypeData[] }
|
|
|
|
|
|
export async function getShipmentTypeList(): Promise<ShipmentTypeData[]> {
|
|
const api = useApi()
|
|
const response = await api.get<ShipmentTypeListResponse>('shipment_types', {}, {
|
|
toastErrorKey: 'errors.shipmentType.list'
|
|
})
|
|
|
|
if (Array.isArray(response)) {
|
|
return response
|
|
}
|
|
|
|
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
|
return response['hydra:member']
|
|
}
|
|
|
|
return []
|
|
}
|