feat : finalisation de l'étape 1 "Réception" (formulaire)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { TruckData } from '~/services/dto/truck-data'
|
||||
|
||||
export type TruckListResponse =
|
||||
| TruckData[]
|
||||
| { 'hydra:member'?: TruckData[] }
|
||||
|
||||
export async function getTruckList(): Promise<TruckData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<TruckListResponse>('trucks', {}, {
|
||||
toastErrorKey: 'errors.truck.list'
|
||||
})
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
Reference in New Issue
Block a user