Skip to content

Commit

Permalink
vessel type on new control
Browse files Browse the repository at this point in the history
  • Loading branch information
lwih committed Oct 7, 2023
1 parent d213f66 commit 206c61f
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ enum class VesselTypeEnum {
SAILING,
MOTOR,
COMMERCIAL,
SAILING_LEISURE,
}

fun mapStringToVesselType(value: String?): VesselTypeEnum? {
Expand Down
33 changes: 17 additions & 16 deletions frontend/src/pam/mission-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export enum VesselType {
'FISHING' = 'FISHING',
'SAILING' = 'SAILING',
'MOTOR' = 'MOTOR',
'COMMERCIAL' = 'COMMERCIAL'
'COMMERCIAL' = 'COMMERCIAL',
'SAILING_LEISURE' = 'SAILING_LEISURE'
}

export enum VesselSize {
Expand Down Expand Up @@ -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'
// }
23 changes: 12 additions & 11 deletions frontend/src/pam/mission/controls/control-selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -41,52 +42,52 @@ const ControlSelection: React.FC<ControlSelectionProps> = ({ onSelect }) => {
</Stack.Item>
<Stack.Item style={{ width: '100%' }}>
<Button
onClick={() => onSelect(selectedControlType, ControlTarget.PECHE_PRO)}
onClick={() => onSelect(selectedControlType, VesselType.FISHING)}
Icon={Icon.Plus}
accent={Accent.SECONDARY}
isFullWidth
>
Contrôles de navires de <b>{ControlTargetText.PECHE_PRO}</b>
Contrôles de <b>{vesselTypeToHumanString(VesselType.FISHING)}</b>
</Button>
</Stack.Item>
<Stack.Item style={{ width: '100%' }}>
<Button
onClick={() => onSelect(selectedControlType, ControlTarget.PLAISANCE_PRO)}
onClick={() => onSelect(selectedControlType, VesselType.SAILING)}
Icon={Icon.Plus}
accent={Accent.SECONDARY}
isFullWidth
>
Contrôles de navires de <b>{ControlTargetText.PLAISANCE_PRO}</b>
Contrôles de <b>{vesselTypeToHumanString(VesselType.SAILING)}</b>
</Button>
</Stack.Item>
<Stack.Item style={{ width: '100%' }}>
<Button
onClick={() => onSelect(selectedControlType, ControlTarget.COMMERCE_PRO)}
onClick={() => onSelect(selectedControlType, VesselType.COMMERCIAL)}
Icon={Icon.Plus}
accent={Accent.SECONDARY}
isFullWidth
>
Contrôles de navires de <b>{ControlTargetText.COMMERCE_PRO}</b>
Contrôles de <b>{vesselTypeToHumanString(VesselType.COMMERCIAL)}</b>
</Button>
</Stack.Item>
<Stack.Item style={{ width: '100%' }}>
<Button
onClick={() => onSelect(selectedControlType, ControlTarget.SERVICE_PRO)}
onClick={() => onSelect(selectedControlType, VesselType.MOTOR)}
Icon={Icon.Plus}
accent={Accent.SECONDARY}
isFullWidth
>
Contrôles de navires de <b>{ControlTargetText.SERVICE_PRO} (travaux...)</b>
Contrôles de <b>{vesselTypeToHumanString(VesselType.MOTOR)} (travaux...)</b>
</Button>
</Stack.Item>
<Stack.Item style={{ width: '100%' }}>
<Button
onClick={() => onSelect(selectedControlType, ControlTarget.PLAISANCE_LOISIR)}
onClick={() => onSelect(selectedControlType, VesselType.SAILING_LEISURE)}
Icon={Icon.Plus}
accent={Accent.SECONDARY}
isFullWidth
>
Contrôles de navires de <b>{ControlTargetText.PLAISANCE_LOISIR}</b>
Contrôles de <b>{vesselTypeToHumanString(VesselType.SAILING_LEISURE)}</b>
</Button>
</Stack.Item>
</Stack>
Expand Down
32 changes: 32 additions & 0 deletions frontend/src/pam/mission/controls/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ControlMethod, VesselType } from '../../mission-types'

export const CONTROL_MULTIRADIO_OPTIONS = [
{
label: 'Oui',
Expand All @@ -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 ''
}
}
10 changes: 5 additions & 5 deletions frontend/src/pam/mission/mission.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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()
Expand All @@ -94,16 +94,16 @@ export default function Mission() {
id: uuid,
missionId: parseInt(missionId!, 10),
startDateTimeUtc: date,
controlMethod: controlMethod,
vesselType: null,
controlMethod,
vesselType,
vesselIdentifier: null,
vesselSize: null,
identityControlledPerson: null,
observations: null
}
const newAction = {
id: uuid,
type: ActionTypeEnum.STATUS,
type: ActionTypeEnum.CONTROL,
source: MissionSourceEnum.RAPPORTNAV,
startDateTimeUtc: date,
endDateTimeUtc: null,
Expand Down
13 changes: 10 additions & 3 deletions frontend/src/pam/mission/timeline/timeline-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -93,7 +94,10 @@ const ActionNavControl: React.FC<{ action: NavAction; onClick: any }> = ({ actio
</Stack.Item>
<Stack.Item alignSelf="flex-start">
<Stack direction="column" alignItems="flex-start">
<Stack.Item>Contrôles Nav</Stack.Item>
<Stack.Item>
Contrôles <b>{controlMethodToHumanString(action.controlMethod)}</b> -{' '}
<b>{vesselTypeToHumanString(action.vesselType)}</b>
</Stack.Item>
</Stack>
</Stack.Item>
</Stack>
Expand Down Expand Up @@ -127,6 +131,9 @@ const ActionStatus: React.FC<{ action: NavAction; onClick: any }> = ({ action, o
<Stack.Item>
<b>{`${mapStatusToText(action.status)} - ${action.isStart ? 'début' : 'fin'}`}</b>
</Stack.Item>
<Stack.Item>
<Icon.EditUnbordered size={20} />
</Stack.Item>
</Stack>
</Wrapper>
)
Expand Down

0 comments on commit 206c61f

Please sign in to comment.