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>
24 lines
657 B
TypeScript
24 lines
657 B
TypeScript
import { useApi } from '~/composables/useApi'
|
|
import type { CustomerData } from '~/services/dto/customer-data'
|
|
|
|
export type CustomerListResponse =
|
|
| CustomerData[]
|
|
| { 'hydra:member'?: CustomerData[] }
|
|
|
|
export async function getCustomerList(): Promise<CustomerData[]> {
|
|
const api = useApi()
|
|
const response = await api.get<CustomerListResponse>('customers', {}, {
|
|
toastErrorKey: 'errors.customer.list'
|
|
})
|
|
|
|
if (Array.isArray(response)) {
|
|
return response
|
|
}
|
|
|
|
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
|
return response['hydra:member']
|
|
}
|
|
|
|
return []
|
|
}
|