feat : Ajout d'un écran pour afficher les informations d'un bovin
This commit is contained in:
22
frontend/services/dto/identification-bovin-data.ts
Normal file
22
frontend/services/dto/identification-bovin-data.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
interface IdentificationBovinData {
|
||||
numeroNational: string,
|
||||
sex: string | null,
|
||||
breedType: string | null,
|
||||
workNumber: string | null,
|
||||
birthDate: string | null,
|
||||
birthDateCompletenessFlag: string | null,
|
||||
isFilie: boolean | null,
|
||||
motherNationalNumber: string | null,
|
||||
motherBreedType: string | null,
|
||||
fatherNationalNumber: string | null,
|
||||
fatherBreedType: string | null,
|
||||
birthExploitationNumber: string | null,
|
||||
presencePeriod: PresencePeriod[]
|
||||
}
|
||||
|
||||
interface PresencePeriod {
|
||||
entryDate: string | null,
|
||||
entryCause: string | null,
|
||||
exitDate: string | null,
|
||||
exitCause: string | null
|
||||
}
|
||||
25
frontend/services/identification-bovin.ts
Normal file
25
frontend/services/identification-bovin.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
|
||||
export type BovinDataResponse =
|
||||
| IdentificationBovinData
|
||||
| { 'hydra:member'?: IdentificationBovinData }
|
||||
|
||||
export async function getBovinData(
|
||||
nationalNumber: string
|
||||
): Promise<IdentificationBovinData | null> {
|
||||
const api = useApi()
|
||||
const response = await api.get<BovinDataResponse>(
|
||||
`bovins/${nationalNumber}/identification`,
|
||||
{},
|
||||
{ toastErrorKey: 'errors.building.list' }
|
||||
)
|
||||
|
||||
if (response && typeof response === 'object') {
|
||||
// direct item
|
||||
if (!('hydra:member' in response)) return response as IdentificationBovinData
|
||||
// hydra format
|
||||
if (response['hydra:member']) return response['hydra:member']
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
Reference in New Issue
Block a user