Files
Ferme/frontend/services/weight.ts
2026-02-10 16:01:40 +01:00

24 lines
691 B
TypeScript

import { useApi } from '~/composables/useApi'
import type { WeightEntryData } from '~/services/dto/reception-data'
export type WeightPayload = {
reception: string
type: 'gross' | 'tare'
dsd: number | null
weight: number | null
weighedAt: string | null
}
export async function createWeight(payload: WeightPayload) {
const api = useApi()
return api.post<WeightEntryData>('weights', payload)
}
export async function updateWeight(id: number, payload: Partial<WeightPayload>) {
const api = useApi()
return api.patch<WeightEntryData>(`weights/${id}`, payload,{
toastErrorKey: 'errors.weight.update',
toastSuccessKey: 'success.weight.update'
})
}