| Numéro du ticket | Titre du ticket | |------------------|-----------------| | 256 | Créer une nouvelle réception (étape 3 - bovin) | ## 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: tristan <tristan@yuno.malio.fr> Reviewed-on: #11 Co-authored-by: kevin <kevin@yuno.malio.fr> Co-committed-by: kevin <kevin@yuno.malio.fr>
24 lines
673 B
TypeScript
24 lines
673 B
TypeScript
import { useApi } from '~/composables/useApi'
|
|
import type {BovineTypeData} from "~/services/dto/bovine-type-data";
|
|
|
|
export type BovineTypeListResponse =
|
|
| BovineTypeData[]
|
|
| { 'hydra:member'?: BovineTypeData[] }
|
|
|
|
export async function getBovineTypeList(): Promise<BovineTypeData[]> {
|
|
const api = useApi()
|
|
const response = await api.get<BovineTypeListResponse>('bovine_types', {}, {
|
|
toastErrorKey: 'errors.bovin.list'
|
|
})
|
|
|
|
if (Array.isArray(response)) {
|
|
return response
|
|
}
|
|
|
|
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
|
return response['hydra:member']
|
|
}
|
|
|
|
return []
|
|
}
|