fix(front) : 422 de pesée manuelle mappé sous le bon champ (poids/DSD) (ERP-193)
Pull Request — Quality gate / Frontend (lint + Vitest + build) (pull_request) Successful in 1m56s
Pull Request — Quality gate / Backend (PHP CS + PHPUnit) (pull_request) Successful in 5m21s

La modale de pesée manuelle plaçait toute erreur du POST /weighbridge_readings
sous le champ Poids : un 422 Assert\Positive sur le DSD (DSD ≤ 0) s'affichait
donc sous Poids, le champ DSD restant vierge.

confirmManual mappe désormais les violations par propertyPath via
mapViolationsToRecord (le nom du champ front = le propertyPath back), et ne
retombe sur le message générique sous Poids que pour les erreurs sans
violations (503 pont indisponible, réseau). Appliqué à new.vue et [id]/edit.vue.
This commit is contained in:
2026-06-24 16:14:32 +02:00
parent 391f383c4b
commit 9b476f22bb
2 changed files with 16 additions and 2 deletions
@@ -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
@@ -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()
@@ -309,7 +310,13 @@ async function confirmManual(): Promise<void> {
await saveDraft()
}
catch (error) {
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