From 206c61f84fc82159274e030894c72f24b17191c0 Mon Sep 17 00:00:00 2001 From: lhache Date: Sat, 7 Oct 2023 09:36:00 +0200 Subject: [PATCH] vessel type on new control --- .../mission/env/envActions/VesselTypeEnum.kt | 1 + frontend/src/pam/mission-types.ts | 33 ++++++++++--------- .../mission/controls/control-selection.tsx | 23 ++++++------- frontend/src/pam/mission/controls/utils.ts | 32 ++++++++++++++++++ frontend/src/pam/mission/mission.tsx | 10 +++--- .../pam/mission/timeline/timeline-item.tsx | 13 ++++++-- 6 files changed, 77 insertions(+), 35 deletions(-) diff --git a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/entities/mission/env/envActions/VesselTypeEnum.kt b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/entities/mission/env/envActions/VesselTypeEnum.kt index 9ed63d80..87c6eb54 100644 --- a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/entities/mission/env/envActions/VesselTypeEnum.kt +++ b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/entities/mission/env/envActions/VesselTypeEnum.kt @@ -5,6 +5,7 @@ enum class VesselTypeEnum { SAILING, MOTOR, COMMERCIAL, + SAILING_LEISURE, } fun mapStringToVesselType(value: String?): VesselTypeEnum? { diff --git a/frontend/src/pam/mission-types.ts b/frontend/src/pam/mission-types.ts index 007f28be..df7fbb1b 100644 --- a/frontend/src/pam/mission-types.ts +++ b/frontend/src/pam/mission-types.ts @@ -55,7 +55,8 @@ export enum VesselType { 'FISHING' = 'FISHING', 'SAILING' = 'SAILING', 'MOTOR' = 'MOTOR', - 'COMMERCIAL' = 'COMMERCIAL' + 'COMMERCIAL' = 'COMMERCIAL', + 'SAILING_LEISURE' = 'SAILING_LEISURE' } export enum VesselSize { @@ -180,18 +181,18 @@ export type Mission = { actions: Action[] } -export enum ControlTarget { - 'PECHE_PRO' = 'PECHE_PRO', - 'PLAISANCE_PRO' = 'PLAISANCE_PRO', - 'COMMERCE_PRO' = 'COMMERCE_PRO', - 'SERVICE_PRO' = 'SERVICE_PRO', - 'PLAISANCE_LOISIR' = 'PLAISANCE_LOISIR' -} - -export enum ControlTargetText { - 'PECHE_PRO' = 'pêche professionnelle', - 'PLAISANCE_PRO' = 'plaisance professionnelle', - 'COMMERCE_PRO' = 'commerce', - 'SERVICE_PRO' = 'service', - 'PLAISANCE_LOISIR' = 'plaisance de loisir' -} +// export enum ControlTarget { +// 'PECHE_PRO' = 'PECHE_PRO', +// 'PLAISANCE_PRO' = 'PLAISANCE_PRO', +// 'COMMERCE_PRO' = 'COMMERCE_PRO', +// 'SERVICE_PRO' = 'SERVICE_PRO', +// 'PLAISANCE_LOISIR' = 'PLAISANCE_LOISIR' +// } + +// export enum ControlTargetText { +// 'PECHE_PRO' = 'pêche professionnelle', +// 'PLAISANCE_PRO' = 'plaisance professionnelle', +// 'COMMERCE_PRO' = 'commerce', +// 'SERVICE_PRO' = 'service', +// 'PLAISANCE_LOISIR' = 'plaisance de loisir' +// } diff --git a/frontend/src/pam/mission/controls/control-selection.tsx b/frontend/src/pam/mission/controls/control-selection.tsx index ce347b84..84de0202 100644 --- a/frontend/src/pam/mission/controls/control-selection.tsx +++ b/frontend/src/pam/mission/controls/control-selection.tsx @@ -3,7 +3,8 @@ import { ActionTypeEnum, missionTypeEnum } from '../../env-mission-types' import { Stack } from 'rsuite' import Title from '../../../ui/title' import { useState } from 'react' -import { ControlTarget, ControlTargetText } from '../../mission-types' +import { ControlTarget, ControlTargetText, VesselType } from '../../mission-types' +import { vesselTypeToHumanString } from './utils' export const controlTypeRadio = { YES: { @@ -41,52 +42,52 @@ const ControlSelection: React.FC = ({ onSelect }) => { diff --git a/frontend/src/pam/mission/controls/utils.ts b/frontend/src/pam/mission/controls/utils.ts index 52e0f8d7..e11a87e2 100644 --- a/frontend/src/pam/mission/controls/utils.ts +++ b/frontend/src/pam/mission/controls/utils.ts @@ -1,3 +1,5 @@ +import { ControlMethod, VesselType } from '../../mission-types' + export const CONTROL_MULTIRADIO_OPTIONS = [ { label: 'Oui', @@ -12,3 +14,33 @@ export const CONTROL_MULTIRADIO_OPTIONS = [ value: null } ] + +export const controlMethodToHumanString = (controlMethod: ControlMethod): String => { + switch (controlMethod) { + case ControlMethod.AIR: + return 'aérien' + case ControlMethod.LAND: + return 'à Terre' + case ControlMethod.SEA: + return 'en Mer' + default: + return '' + } +} + +export const vesselTypeToHumanString = (vesselType: VesselType): String => { + switch (vesselType) { + case VesselType.FISHING: + return 'Navire de pêche professionnelle' + case VesselType.COMMERCIAL: + return 'Navire de commerce' + case VesselType.MOTOR: + return 'Navire de service' + case VesselType.SAILING: + return 'Navire de plaisance professionnelle' + case VesselType.SAILING: + return 'Navire de plaisance de loisir' + default: + return '' + } +} diff --git a/frontend/src/pam/mission/mission.tsx b/frontend/src/pam/mission/mission.tsx index 4988d45d..99d2a180 100644 --- a/frontend/src/pam/mission/mission.tsx +++ b/frontend/src/pam/mission/mission.tsx @@ -9,7 +9,7 @@ import MissionTimeline from './timeline/timeline' import { useState } from 'react' import { getComponentForAction } from './actions/action-mapping' import Title from '../../ui/title' -import { ControlTarget, Action, ActionStatusType } from '../mission-types' +import { ControlTarget, Action, ActionStatusType, VesselType } from '../mission-types' import ActionSelectionDropdown from './actions/action-selection-dropdown' import { ActionTypeEnum, MissionSourceEnum } from '../env-mission-types' import ControlSelection from './controls/control-selection' @@ -85,7 +85,7 @@ export default function Mission() { setSelectedAction(newAction as any) } - const addNewControl = (controlMethod: string, targetType: ControlTarget) => { + const addNewControl = (controlMethod: string, vesselType: VesselType) => { setShowControlTypesModal(false) debugger const uuid = uuidv4() @@ -94,8 +94,8 @@ export default function Mission() { id: uuid, missionId: parseInt(missionId!, 10), startDateTimeUtc: date, - controlMethod: controlMethod, - vesselType: null, + controlMethod, + vesselType, vesselIdentifier: null, vesselSize: null, identityControlledPerson: null, @@ -103,7 +103,7 @@ export default function Mission() { } const newAction = { id: uuid, - type: ActionTypeEnum.STATUS, + type: ActionTypeEnum.CONTROL, source: MissionSourceEnum.RAPPORTNAV, startDateTimeUtc: date, endDateTimeUtc: null, diff --git a/frontend/src/pam/mission/timeline/timeline-item.tsx b/frontend/src/pam/mission/timeline/timeline-item.tsx index 644804ae..a290d830 100644 --- a/frontend/src/pam/mission/timeline/timeline-item.tsx +++ b/frontend/src/pam/mission/timeline/timeline-item.tsx @@ -2,10 +2,11 @@ import React from 'react' import { THEME, Icon } from '@mtes-mct/monitor-ui' import { ActionTypeEnum, EnvAction, EnvActionControl, MissionSourceEnum } from '../../env-mission-types' import { FlexboxGrid, Stack } from 'rsuite' -import { ActionSource, Action, NavAction, ActionStatusType } from '../../mission-types' -import { FishAction, MissionActionType } from '../../fish-mission-types' +import { Action, NavAction } from '../../mission-types' +import { FishAction } from '../../fish-mission-types' import { StatusColorTag } from '../status/status-selection-dropdown' import { mapStatusToText } from '../status/utils' +import { controlMethodToHumanString, vesselTypeToHumanString } from '../controls/utils' interface MissionTimelineItemProps { action: Action @@ -93,7 +94,10 @@ const ActionNavControl: React.FC<{ action: NavAction; onClick: any }> = ({ actio - Contrôles Nav + + Contrôles {controlMethodToHumanString(action.controlMethod)} -{' '} + {vesselTypeToHumanString(action.vesselType)} + @@ -127,6 +131,9 @@ const ActionStatus: React.FC<{ action: NavAction; onClick: any }> = ({ action, o {`${mapStatusToText(action.status)} - ${action.isStart ? 'début' : 'fin'}`} + + + )