@@ -176,8 +178,7 @@ const RessourceUnitWrapper = styled.div`
const FormGroupFixed = styled.div`
display: flex;
- flex-direction: row;
- height: 52px;
+ flex-direction: column;
width: 100%;
:not(:last-child) {
diff --git a/frontend/src/features/missions/MissionForm/GeneralInformationsForm.tsx b/frontend/src/features/missions/MissionForm/GeneralInformationsForm.tsx
index 28ee19daa..8db1247cb 100644
--- a/frontend/src/features/missions/MissionForm/GeneralInformationsForm.tsx
+++ b/frontend/src/features/missions/MissionForm/GeneralInformationsForm.tsx
@@ -86,20 +86,24 @@ export function GeneralInformationsForm() {
{errors.endDateTimeUtc && {errors.endDateTimeUtc}}
-
-
- {(missionSourceField.value === MissionSourceEnum.MONITORFISH ||
- missionSourceField.value === MissionSourceEnum.POSEIDON_CNSP) && (
-
- )}
-
+
+
+
+
+ {(missionSourceField.value === MissionSourceEnum.MONITORFISH ||
+ missionSourceField.value === MissionSourceEnum.POSEIDON_CNSP) && (
+
+ )}
+
+ {errors.missionTypes && {errors.missionTypes}}
+
{(missionSourceField.value === MissionSourceEnum.MONITORFISH ||
missionSourceField.value === MissionSourceEnum.POSEIDON_CNSP) && (
{
if (_.isEmpty(errors)) {
handleSubmit()
-
- return
+ } else {
+ setShouldValidateOnChange(true)
}
- setShouldValidateOnChange(true)
})
}
diff --git a/frontend/src/features/missions/MissionForm/Schemas/Control.ts b/frontend/src/features/missions/MissionForm/Schemas/Control.ts
index 0ab8d651d..b61411a73 100644
--- a/frontend/src/features/missions/MissionForm/Schemas/Control.ts
+++ b/frontend/src/features/missions/MissionForm/Schemas/Control.ts
@@ -1,3 +1,4 @@
+import _ from 'lodash'
import * as Yup from 'yup'
import { ClosedInfractionSchema, NewInfractionSchema } from './Infraction'
@@ -8,6 +9,12 @@ import { REACT_APP_CYPRESS_TEST } from '../../../../env'
const shouldUseAlternateValidationInTestEnvironment = process.env.NODE_ENV === 'development' || REACT_APP_CYPRESS_TEST
+const ControlPointSchema = Yup.object().test({
+ message: 'Point de contrôle requis',
+ name: 'has-geom',
+ test: val => val && !_.isEmpty(val?.coordinates)
+})
+
export const getNewEnvActionControlSchema = (ctx: any): Yup.SchemaOf =>
Yup.object()
.shape({
@@ -59,10 +66,10 @@ export const getClosedEnvActionControlSchema = (ctx: any): Yup.SchemaOf {
if (!actionTargetType || actionTargetType === TargetTypeEnum.VEHICLE) {
return schema.nullable().required('Requis')
diff --git a/frontend/src/features/missions/MissionForm/Schemas/Surveillance.ts b/frontend/src/features/missions/MissionForm/Schemas/Surveillance.ts
index 46bb47e3f..415f2576e 100644
--- a/frontend/src/features/missions/MissionForm/Schemas/Surveillance.ts
+++ b/frontend/src/features/missions/MissionForm/Schemas/Surveillance.ts
@@ -1,3 +1,4 @@
+import _ from 'lodash'
import * as Yup from 'yup'
import { ThemeSchema } from './Theme'
@@ -6,6 +7,12 @@ import { REACT_APP_CYPRESS_TEST } from '../../../../env'
const shouldUseAlternateValidationInTestEnvironment = process.env.NODE_ENV === 'development' || REACT_APP_CYPRESS_TEST
+const SurveillanceZoneSchema = Yup.object().test({
+ message: 'Veuillez définir une zone de surveillance',
+ name: 'has-geom',
+ test: val => val && !_.isEmpty(val?.coordinates)
+})
+
export const getNewEnvActionSurveillanceSchema = (ctx: any): Yup.SchemaOf =>
Yup.object()
.shape({
@@ -92,7 +99,8 @@ export const getClosedEnvActionSurveillanceSchema = (ctx: any): Yup.SchemaOf
shouldUseAlternateValidationInTestEnvironment
? Yup.object().nullable()
- : Yup.array().ensure().min(1, 'Requis'),
+ : Yup.array().of(SurveillanceZoneSchema).ensure().min(1, 'Veuillez définir une zone de surveillance'),
+
then: () => Yup.object().nullable()
}),
diff --git a/frontend/src/features/missions/MissionForm/Schemas/Theme.ts b/frontend/src/features/missions/MissionForm/Schemas/Theme.ts
index 5c2f5be52..0468936a2 100644
--- a/frontend/src/features/missions/MissionForm/Schemas/Theme.ts
+++ b/frontend/src/features/missions/MissionForm/Schemas/Theme.ts
@@ -4,10 +4,6 @@ import type { EnvActionTheme } from '../../../../domain/entities/missions'
export const ThemeSchema: Yup.SchemaOf = Yup.object().shape({
protectedSpecies: Yup.array().of(Yup.string().optional()).nullable().optional(),
- subThemes: Yup.array()
- .of(Yup.string().required().default(''))
- .ensure()
- .required()
- .min(1, 'Sélectionnez au moins une sous thématique'),
- theme: Yup.string().required('Sélectionnez un thême')
+ subThemes: Yup.array().of(Yup.string().required()).ensure().required().min(1, 'Sous-thématique requise'),
+ theme: Yup.string().nullable().required('Thème requis')
})
diff --git a/frontend/src/features/missions/MissionForm/Schemas/index.ts b/frontend/src/features/missions/MissionForm/Schemas/index.ts
index bc2d14fd8..bea338d65 100644
--- a/frontend/src/features/missions/MissionForm/Schemas/index.ts
+++ b/frontend/src/features/missions/MissionForm/Schemas/index.ts
@@ -19,7 +19,7 @@ const shouldUseAlternateValidationInTestEnvironment = process.env.NODE_ENV === '
const MissionTypesSchema = Yup.array()
.of(Yup.mixed().oneOf(Object.values(MissionTypeEnum)).required())
.ensure()
- .min(1, 'Requis')
+ .min(1, 'Type de mission requis')
const ControlResourceSchema: Yup.SchemaOf = Yup.object()
.shape({
@@ -30,7 +30,7 @@ const ControlResourceSchema: Yup.SchemaOf = Yup
const ControlUnitSchema: Yup.SchemaOf = Yup.object()
.shape({
- administration: Yup.string().required(),
+ administration: Yup.string().required('Administration requise'),
contact: Yup.string()
.nullable()
.test({
@@ -45,7 +45,7 @@ const ControlUnitSchema: Yup.SchemaOf = Yup.object()
}
}),
id: Yup.number().required(),
- name: Yup.string().required(),
+ name: Yup.string().required('Unité requise'),
resources: Yup.array().ensure().of(ControlResourceSchema).required()
})
.defined()
@@ -110,14 +110,16 @@ const NewMissionSchema: Yup.SchemaOf = Yup.object()
envActions: Yup.array()
.of(NewEnvActionSchema as any)
.nullable(),
- geom: shouldUseAlternateValidationInTestEnvironment ? Yup.object().nullable() : MissionZoneSchema,
+ geom: shouldUseAlternateValidationInTestEnvironment
+ ? Yup.object().nullable()
+ : Yup.array().of(MissionZoneSchema).ensure().min(1, 'Veuillez définir une zone de mission'),
isClosed: Yup.boolean().oneOf([false]).required(),
missionTypes: MissionTypesSchema,
openBy: Yup.string()
.min(3, 'le Trigramme doit comporter 3 lettres')
.max(3, 'le Trigramme doit comporter 3 lettres')
.nullable()
- .required('Trigramme requis'),
+ .required("Trigramme d'ouverture requis"),
startDateTimeUtc: Yup.date().required('Date de début requise')
})
.required()
@@ -127,7 +129,7 @@ const ClosedMissionSchema = NewMissionSchema.shape({
.min(3, 'Minimum 3 lettres pour le Trigramme')
.max(3, 'Maximum 3 lettres pour le Trigramme')
.nullable()
- .required('Trigramme requis'),
+ .required('Trigramme de clôture requis'),
controlUnits: Yup.array().of(ClosedControlUnitSchema).ensure().defined().min(1),
envActions: Yup.array()
.of(ClosedEnvActionSchema as any)
diff --git a/frontend/src/features/missions/MissionForm/formikUseCases/updateActionThemes.ts b/frontend/src/features/missions/MissionForm/formikUseCases/updateActionThemes.ts
index fafd228ed..4dd6d0171 100644
--- a/frontend/src/features/missions/MissionForm/formikUseCases/updateActionThemes.ts
+++ b/frontend/src/features/missions/MissionForm/formikUseCases/updateActionThemes.ts
@@ -9,7 +9,7 @@ export const updateTheme =
const currentThemeValue = get(mission, themesPath) as EnvActionTheme[]
const newValue = [...currentThemeValue]
- newValue.splice(themeIndex, 1, { theme: value })
+ newValue.splice(themeIndex, 1, { protectedSpecies: [], subThemes: [], theme: value })
setFieldValue(themesPath, newValue)
}
diff --git a/frontend/src/features/missions/Missions.helpers.ts b/frontend/src/features/missions/Missions.helpers.ts
index ef912ceaa..7c499d7e2 100644
--- a/frontend/src/features/missions/Missions.helpers.ts
+++ b/frontend/src/features/missions/Missions.helpers.ts
@@ -37,7 +37,13 @@ export const actionFactory = ({
id: uuidv4(),
infractions: [],
observations: '',
- themes: [],
+ themes: [
+ {
+ protectedSpecies: undefined,
+ subThemes: [],
+ theme: ''
+ }
+ ],
...action
}
case ActionTypeEnum.NOTE:
@@ -56,7 +62,13 @@ export const actionFactory = ({
durationMatchesMission: true,
id: uuidv4(),
observations: '',
- themes: [],
+ themes: [
+ {
+ protectedSpecies: undefined,
+ subThemes: [],
+ theme: ''
+ }
+ ],
...action
}
}
diff --git a/frontend/src/features/missions/MultiPointPicker.tsx b/frontend/src/features/missions/MultiPointPicker.tsx
index 223e5393c..604eb7acc 100644
--- a/frontend/src/features/missions/MultiPointPicker.tsx
+++ b/frontend/src/features/missions/MultiPointPicker.tsx
@@ -90,7 +90,7 @@ export function MultiPointPicker({ addButtonLabel, label = undefined, name }: Mu
>
{addButtonLabel}
- {!!meta.error && Veuillez définir un point de contrôle}
+ {!!meta.error && {meta.error}}
<>
{points.map((coordinates, index) => (
diff --git a/frontend/src/features/missions/MultiZonePicker.tsx b/frontend/src/features/missions/MultiZonePicker.tsx
index 6e8011263..e2fe6a96f 100644
--- a/frontend/src/features/missions/MultiZonePicker.tsx
+++ b/frontend/src/features/missions/MultiZonePicker.tsx
@@ -98,7 +98,7 @@ export function MultiZonePicker({
{addButtonLabel}
- {!!meta.error && Veuillez définir une zone}
+ {!!meta.error && {meta.error}}
<>
{polygons.map((polygonCoordinates, index) => (