From 5e8068f59658c7f7e9436b73a48f4f9c38934988 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Thu, 13 Jul 2023 11:35:43 +0200 Subject: [PATCH] Condition gear on board validation to control check in mission form --- .../SideWindow/MissionForm/ActionForm/schemas.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/features/SideWindow/MissionForm/ActionForm/schemas.ts b/frontend/src/features/SideWindow/MissionForm/ActionForm/schemas.ts index 3d22a7cb28..104a63d823 100644 --- a/frontend/src/features/SideWindow/MissionForm/ActionForm/schemas.ts +++ b/frontend/src/features/SideWindow/MissionForm/ActionForm/schemas.ts @@ -36,11 +36,13 @@ const actionDatetimeUtcValidator = string() }) export const GearOnboardSchema = object({ - declaredMesh: number().required('Veuillez indiquer le maillage déclaré.'), - controlledMesh: number().when('hasUncontrolledMesh', { - is: false, - then: number().required('Veuillez indiquer le maillage mesuré.'), - otherwise: number() + declaredMesh: number().when('gearWasControlled', { + is: true, + then: number().required('Veuillez indiquer le maillage déclaré.') + }), + controlledMesh: number().when(['hasUncontrolledMesh', 'gearWasControlled'], { + is: (hasUncontrolledMesh: boolean, gearWasControlled: boolean) => !hasUncontrolledMesh && gearWasControlled, + then: number().required('Veuillez indiquer le maillage mesuré.') }), gearWasControlled: boolean().required("Veuillez indiquer si l'engin a été contrôlé.") })