25 lines
714 B
TypeScript
25 lines
714 B
TypeScript
import { useApi } from '~/composables/useApi'
|
|
import type { WeightEntryData } from '~/services/dto/reception-data'
|
|
|
|
export type WeightPayload = {
|
|
reception?: string
|
|
shipment?: 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'
|
|
})
|
|
}
|