1ce6357c1d
| 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: https://gitea.malio.fr/MALIO-DEV/Ferme/pulls/7 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import {useApi} from '~/composables/useApi'
|
|
import type {ReceptionData, ReceptionPayload} from '~/services/dto/reception-data'
|
|
import type {WeightData} from '~/services/dto/weight-data'
|
|
|
|
export async function getReceptionList() {
|
|
const api = useApi()
|
|
return api.get<ReceptionData>(`receptions`, {}, {
|
|
toastErrorKey: 'errors.reception.list'
|
|
})
|
|
}
|
|
|
|
export async function getReception(id: number) {
|
|
const api = useApi()
|
|
return api.get<ReceptionData>(`receptions/${id}`, {}, {
|
|
toastErrorKey: 'errors.reception.fetch'
|
|
})
|
|
}
|
|
|
|
export async function createReception(payload: ReceptionPayload = {}) {
|
|
const api = useApi()
|
|
return api.post<ReceptionData>('receptions', payload, {
|
|
toastErrorKey: 'errors.reception.create'
|
|
})
|
|
}
|
|
|
|
export async function updateReception(id: number, payload: ReceptionPayload) {
|
|
const api = useApi()
|
|
return api.patch<ReceptionData>(`receptions/${id}`, payload, {
|
|
toastErrorKey: 'errors.reception.update',
|
|
toastSuccessKey: 'success.reception.update'
|
|
})
|
|
}
|
|
|
|
export async function getWeight(): Promise<WeightData> {
|
|
const api = useApi()
|
|
return api.get<WeightData>('receptions/weigh', {}, {
|
|
toastErrorKey: 'errors.reception.weigh'
|
|
})
|
|
}
|