fix : correction des retours de la V0
This commit is contained in:
@@ -1,42 +1,22 @@
|
||||
import {useApi} from '~/composables/useApi'
|
||||
import type {ReceptionData, ReceptionPayload} from '~/services/dto/reception-data'
|
||||
import type {WeightData} from '~/services/dto/weight-data'
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import { createWorkflowService } from '~/services/workflow-service'
|
||||
import type { ReceptionData, ReceptionPayload } from '~/services/dto/reception-data'
|
||||
import type { WeightData } from '~/services/dto/weight-data'
|
||||
|
||||
export async function getReceptionList(isValid: boolean|null = null) {
|
||||
const service = createWorkflowService<ReceptionData, ReceptionPayload>('receptions', 'reception')
|
||||
|
||||
export const getReceptionList = service.getList
|
||||
export const getReception = service.get
|
||||
export const createReception = service.create
|
||||
export const updateReception = service.update
|
||||
export const getWeight = service.getWeight as () => Promise<WeightData>
|
||||
|
||||
export async function deleteReception(id: number) {
|
||||
const api = useApi()
|
||||
const query = isValid !== null ? { isValid: isValid} : {}
|
||||
return api.get<ReceptionData[]>('receptions', query, {
|
||||
toastErrorKey: 'errors.reception.list'
|
||||
return api.delete(`receptions/${id}`, {}, {
|
||||
toastSuccessKey: 'success.reception.delete',
|
||||
toastErrorKey: 'errors.reception.delete'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
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, {
|
||||
toastSuccessKey: 'success.reception.create',
|
||||
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'
|
||||
})
|
||||
}
|
||||
export { service as receptionService }
|
||||
|
||||
Reference in New Issue
Block a user