| 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>
This commit was merged in pull request #3.
This commit is contained in:
16
frontend/services/dto/reception-data.ts
Normal file
16
frontend/services/dto/reception-data.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export interface ReceptionData {
|
||||
id: number
|
||||
licensePlate: string | null
|
||||
weights?: WeightEntryData[] | null
|
||||
receptionDate: string
|
||||
currentStep: number
|
||||
isValid: boolean
|
||||
}
|
||||
|
||||
export interface WeightEntryData {
|
||||
id?: number
|
||||
type: 'gross' | 'tare'
|
||||
dsd: number | null
|
||||
weight: number | null
|
||||
weighedAt: string | null
|
||||
}
|
||||
5
frontend/services/dto/weight-data.ts
Normal file
5
frontend/services/dto/weight-data.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export interface WeightData {
|
||||
weight: number | null
|
||||
dsd: number | null
|
||||
weighedAt: string | null
|
||||
}
|
||||
50
frontend/services/reception.ts
Normal file
50
frontend/services/reception.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
30
frontend/services/weight.ts
Normal file
30
frontend/services/weight.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { WeightEntryData } from '~/services/dto/reception-data'
|
||||
|
||||
const api = useApi()
|
||||
|
||||
export type WeightPayload = {
|
||||
reception: string
|
||||
type: 'gross' | 'tare'
|
||||
dsd: number | null
|
||||
weight: number | null
|
||||
weighedAt: string | null
|
||||
}
|
||||
|
||||
export async function createWeight(payload: WeightPayload) {
|
||||
try {
|
||||
return await api.post<WeightEntryData>('weights', payload)
|
||||
} catch (error) {
|
||||
console.error(error.message, error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateWeight(id: number, payload: Partial<WeightPayload>) {
|
||||
try {
|
||||
return await api.patch<WeightEntryData>(`weights/${id}`, payload)
|
||||
} catch (error) {
|
||||
console.error(error.message, error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user