| Numéro du ticket | Titre du ticket | |------------------|-----------------| | #203 | Réceptions — Parcours de pesée multi-étapes | ## Description de la PR [#203] Réceptions — Parcours de pesée multi-étapes ## Modification du .env ## Check list - [x] Pas de régression - [x] TU/TI/TF rédigée - [x] TU/TI/TF OK - [x] CHANGELOG modifié Reviewed-on: #3 Reviewed-by: THOLOT DECHENE Matthieu <matthieu@yuno.malio.fr> Co-authored-by: AUTIN Tristan <tristan@yuno.malio.fr> Co-committed-by: AUTIN Tristan <tristan@yuno.malio.fr>
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import { useApi } from '~/composables/useApi'
|
|
import type { ReceptionData } from '~/services/dto/reception-data'
|
|
import type { WeightData } from '~/services/dto/weight-data'
|
|
|
|
const api = useApi()
|
|
|
|
export async function getReceptionList() {
|
|
try {
|
|
return await api.get<ReceptionData>(`receptions`)
|
|
} catch (error) {
|
|
console.error(error.message, error)
|
|
return error
|
|
}
|
|
}
|
|
|
|
export async function getReception(id: number) {
|
|
try {
|
|
return await api.get<ReceptionData>(`receptions/${id}`)
|
|
} catch (error) {
|
|
console.error(error.message, error)
|
|
return error
|
|
}
|
|
}
|
|
|
|
export async function createReception(payload: Partial<ReceptionData> = {}) {
|
|
try {
|
|
return await api.post<ReceptionData>('receptions', payload)
|
|
} catch (error) {
|
|
console.error(error.message, error)
|
|
return error
|
|
}
|
|
}
|
|
|
|
export async function updateReception(id: number, payload: Partial<ReceptionData>) {
|
|
try {
|
|
return await api.patch<ReceptionData>(`receptions/${id}`, payload)
|
|
} catch (error) {
|
|
console.error(error.message, error)
|
|
return error
|
|
}
|
|
}
|
|
|
|
export async function getWeight(): Promise<WeightData> {
|
|
try {
|
|
return await api.get<WeightData>('receptions/weigh')
|
|
} catch (error) {
|
|
console.error(error.message, error)
|
|
throw error
|
|
}
|
|
}
|