feat : M5 — Tickets de pesée (ERP-188 → ERP-193) #144

Merged
tristan merged 20 commits from feat/erp-191-i18n-site-courant into develop 2026-06-24 14:38:02 +00:00
2 changed files with 16 additions and 2 deletions
Showing only changes of commit 9b476f22bb - Show all commits
@@ -192,6 +192,7 @@ import { useWeighbridge } from '~/modules/logistique/composables/useWeighbridge'
import { useWeighingTicket } from '~/modules/logistique/composables/useWeighingTicket'
import { useWeighingTicketReferentials, type RefOption } from '~/modules/logistique/composables/useWeighingTicketReferentials'
import { NUMERIC_MASK, PLATE_MASK, FREE_PLATE_MASK } from '~/modules/logistique/utils/weighingMasks'
import { mapViolationsToRecord } from '~/shared/utils/api'
const { t } = useI18n()
const api = useApi()
@@ -344,7 +345,13 @@ async function confirmManual(): Promise<void> {
await saveDraft()
}
catch (e) {
manualModal.errors = { weight: weighbridge.extractWeighbridgeError(e) }
// 422 de pesée (poids/DSD ≤ 0, Assert\Positive) → erreur sous le BON champ
// (le propertyPath back `weight`/`dsd` = nom du champ de la modale). Sinon
// (503 pont indispo, réseau) → message générique sous le champ Poids.
const violations = mapViolationsToRecord((e as { response?: { _data?: unknown } })?.response?._data)
manualModal.errors = Object.keys(violations).length > 0
? violations
: { weight: weighbridge.extractWeighbridgeError(e) }
}
finally {
manualModal.loading = false
1
@@ -181,6 +181,7 @@ import { useWeighingTicketForm, type WeighingBlockState } from '~/modules/logist
import { useWeighbridge } from '~/modules/logistique/composables/useWeighbridge'
import { useWeighingTicketReferentials, type RefOption } from '~/modules/logistique/composables/useWeighingTicketReferentials'
import { NUMERIC_MASK, PLATE_MASK, FREE_PLATE_MASK } from '~/modules/logistique/utils/weighingMasks'
import { mapViolationsToRecord } from '~/shared/utils/api'
const { t } = useI18n()
const api = useApi()
1
@@ -309,7 +310,13 @@ async function confirmManual(): Promise<void> {
await saveDraft()
}
catch (error) {
Review

🟡 Bug UX — un 422 sur le DSD s'affiche sous le champ Poids

dsd porte #[Assert\Positive] côté WeighbridgeReadingResource. Si l'opérateur saisit 0 (ou ≤ 0), le POST /weighbridge_readings renvoie une 422 de propertyPath dsd, mais le catch mappe toujours le message sous weight ({ weight: extractWeighbridgeError(error) }). L'erreur DSD apparaît sous Poids, le champ DSD reste vierge. Router le message vers le bon champ (réutiliser mapViolationsToRecord). Idem dans [id]/edit.vue.

🟡 **Bug UX — un 422 sur le DSD s'affiche sous le champ Poids** `dsd` porte `#[Assert\Positive]` côté `WeighbridgeReadingResource`. Si l'opérateur saisit `0` (ou ≤ 0), le `POST /weighbridge_readings` renvoie une 422 de `propertyPath` **`dsd`**, mais le `catch` mappe **toujours** le message sous `weight` (`{ weight: extractWeighbridgeError(error) }`). L'erreur DSD apparaît sous Poids, le champ DSD reste vierge. Router le message vers le bon champ (réutiliser `mapViolationsToRecord`). Idem dans `[id]/edit.vue`.
manualModal.errors = { weight: weighbridge.extractWeighbridgeError(error) }
// 422 de pesée (poids/DSD ≤ 0, Assert\Positive) → erreur sous le BON champ
// (le propertyPath back `weight`/`dsd` = nom du champ de la modale). Sinon
// (503 pont indispo, réseau) → message générique sous le champ Poids.
const violations = mapViolationsToRecord((error as { response?: { _data?: unknown } })?.response?._data)
manualModal.errors = Object.keys(violations).length > 0
? violations
: { weight: weighbridge.extractWeighbridgeError(error) }
}
finally {
manualModal.loading = false