24 lines
696 B
TypeScript
24 lines
696 B
TypeScript
import { useApi } from '~/composables/useApi'
|
|
import type { BuildingCaseStatusData } from '~/services/dto/building-case-status-data'
|
|
|
|
export type StatutListResponse =
|
|
| BuildingCaseStatusData[]
|
|
| { 'hydra:member'?: BuildingCaseStatusData[] }
|
|
|
|
export async function getStatutList(): Promise<BuildingCaseStatusData[]> {
|
|
const api = useApi()
|
|
const response = await api.get<StatutListResponse>('statuts', {}, {
|
|
toastErrorKey: 'errors.http.get'
|
|
})
|
|
|
|
if (Array.isArray(response)) {
|
|
return response
|
|
}
|
|
|
|
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
|
return response['hydra:member']
|
|
}
|
|
|
|
return []
|
|
}
|