1ce6357c1d
| 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: https://gitea.malio.fr/MALIO-DEV/Ferme/pulls/7 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
24 lines
637 B
TypeScript
24 lines
637 B
TypeScript
import { useApi } from '~/composables/useApi'
|
|
import type { DriverData } from '~/services/dto/driver-data'
|
|
|
|
export type DriverListResponse =
|
|
| DriverData[]
|
|
| { 'hydra:member'?: DriverData[] }
|
|
|
|
export async function getDriverList(): Promise<DriverData[]> {
|
|
const api = useApi()
|
|
const response = await api.get<DriverListResponse>('drivers', {}, {
|
|
toastErrorKey: 'errors.driver.list'
|
|
})
|
|
|
|
if (Array.isArray(response)) {
|
|
return response
|
|
}
|
|
|
|
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
|
return response['hydra:member']
|
|
}
|
|
|
|
return []
|
|
}
|