| 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: #7 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
24 lines
729 B
TypeScript
24 lines
729 B
TypeScript
import { useApi } from '~/composables/useApi'
|
|
import type { MerchandiseTypeData } from '~/services/dto/merchandise-type-data'
|
|
|
|
export type MerchandiseTypeListResponse =
|
|
| MerchandiseTypeData[]
|
|
| { 'hydra:member'?: MerchandiseTypeData[] }
|
|
|
|
export async function getMerchandiseTypeList(): Promise<MerchandiseTypeData[]> {
|
|
const api = useApi()
|
|
const response = await api.get<MerchandiseTypeListResponse>('merchandise_types', {}, {
|
|
toastErrorKey: 'errors.merchandiseType.list'
|
|
})
|
|
|
|
if (Array.isArray(response)) {
|
|
return response
|
|
}
|
|
|
|
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
|
return response['hydra:member']
|
|
}
|
|
|
|
return []
|
|
}
|