Skip to content

Commit

Permalink
[Mission] Zone de surveillance obligatoire en cas de clôture de missi…
Browse files Browse the repository at this point in the history
…on (#826)

- Resolve #784
  • Loading branch information
claire2212 authored Sep 19, 2023
2 parents 67a0acd + a7cef04 commit a88ff14
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import * as Yup from 'yup'

import { ThemeSchema } from './Theme'
import { ActionTypeEnum, EnvActionSurveillance } from '../../../../domain/entities/missions'
import { REACT_APP_CYPRESS_TEST } from '../../../../env'

const shouldUseAlternateValidationInTestEnvironment = process.env.NODE_ENV === 'development' || REACT_APP_CYPRESS_TEST

export const getNewEnvActionSurveillanceSchema = (ctx: any): Yup.SchemaOf<EnvActionSurveillance> =>
Yup.object()
Expand Down Expand Up @@ -84,7 +87,15 @@ export const getClosedEnvActionSurveillanceSchema = (ctx: any): Yup.SchemaOf<Env
}
}),
actionType: Yup.mixed().oneOf([ActionTypeEnum.SURVEILLANCE]),
geom: Yup.array().ensure(),
geom: Yup.object().when('coverMissionZone', {
is: true,
otherwise: () =>
shouldUseAlternateValidationInTestEnvironment
? Yup.object().nullable()
: Yup.array().ensure().min(1, 'Requis'),
then: () => Yup.object().nullable()
}),

id: Yup.string().required(),
themes: Yup.array().of(ThemeSchema).ensure().required()
})
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/missions/MultiZonePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function MultiZonePicker({
{addButtonLabel}
</Button>

{!!meta.error && <ErrorMessage>Veuillez définir une zone de mission</ErrorMessage>}
{!!meta.error && <ErrorMessage>Veuillez définir une zone</ErrorMessage>}

<>
{polygons.map((polygonCoordinates, index) => (
Expand Down

0 comments on commit a88ff14

Please sign in to comment.