Skip to content

Commit

Permalink
[Alertes] Ajout de Mayotte dans la liste des alertes Océan Indien (#2775
Browse files Browse the repository at this point in the history
)

## Linked issues

- Resolve #2774 

----

- [ ] Tests E2E (Cypress)
  • Loading branch information
louptheron committed Dec 20, 2023
2 parents 0d0c300 + f11f618 commit a456de2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
18 changes: 9 additions & 9 deletions frontend/src/domain/entities/alerts/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// TODO This is a bit shady to mix up pending/silenced alerts with PNO ones here.

import { PendingAlertValueType } from './types'
import { SeaFrontGroup } from '../seaFront/constants'
import { SEA_FRONT_GROUP_SEA_FRONTS, SeaFront, SeaFrontGroup } from '../seaFront/constants'

import type { MenuItem } from '../../../types'

Expand Down Expand Up @@ -51,36 +51,36 @@ export const ALERTS_MENU_SEA_FRONT_TO_SEA_FRONTS: Record<
SeaFrontGroup,
{
menuSeaFront: SeaFrontGroup
seaFronts: string[]
seaFronts: SeaFront[]
}
> = {
ALL: {
menuSeaFront: SeaFrontGroup.ALL,
seaFronts: []
seaFronts: SEA_FRONT_GROUP_SEA_FRONTS[SeaFrontGroup.ALL]
},
MED: {
menuSeaFront: SeaFrontGroup.MED,
seaFronts: ['MED']
seaFronts: SEA_FRONT_GROUP_SEA_FRONTS[SeaFrontGroup.MED]
},
MEMN: {
menuSeaFront: SeaFrontGroup.MEMN,
seaFronts: ['MEMN']
seaFronts: SEA_FRONT_GROUP_SEA_FRONTS[SeaFrontGroup.MEMN]
},
NAMO: {
menuSeaFront: SeaFrontGroup.NAMO,
seaFronts: ['NAMO']
seaFronts: SEA_FRONT_GROUP_SEA_FRONTS[SeaFrontGroup.NAMO]
},
OUTREMEROA: {
menuSeaFront: SeaFrontGroup.OUTREMEROA,
seaFronts: ['Guadeloupe', 'Guyane', 'Martinique']
seaFronts: SEA_FRONT_GROUP_SEA_FRONTS[SeaFrontGroup.OUTREMEROA]
},
OUTREMEROI: {
menuSeaFront: SeaFrontGroup.OUTREMEROI,
seaFronts: ['Sud Océan Indien']
seaFronts: SEA_FRONT_GROUP_SEA_FRONTS[SeaFrontGroup.OUTREMEROI]
},
SA: {
menuSeaFront: SeaFrontGroup.SA,
seaFronts: [SeaFrontGroup.SA]
seaFronts: SEA_FRONT_GROUP_SEA_FRONTS[SeaFrontGroup.SA]
}
}

Expand Down
4 changes: 3 additions & 1 deletion frontend/src/domain/entities/alerts/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { SeaFront } from '../seaFront/constants'

import type { MissionAction } from '../../types/missionAction'
import type { VesselIdentifier, VesselIdentity } from '../vessel/types'
import type { Except } from 'type-fest'
Expand Down Expand Up @@ -28,7 +30,7 @@ export type PendingAlertValue = {
dml?: string
natinfCode?: string | null
riskFactor?: number
seaFront?: string
seaFront?: SeaFront | null
speed?: number
type: PendingAlertValueType
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/domain/types/reporting.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SeaFrontGroup } from '../entities/seaFront/constants'
import { SeaFront } from '../entities/seaFront/constants'

import type { Infraction } from './infraction'
import type { LegacyControlUnit } from './legacyControlUnit'
Expand Down Expand Up @@ -71,7 +71,7 @@ export type InfractionSuspicion = {
dml: string
natinfCode: number
reportingActor: string
seaFront: SeaFrontGroup
seaFront: SeaFront
title: string
type: string
}
Expand Down
15 changes: 13 additions & 2 deletions frontend/src/features/SideWindow/Alert/slice.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSlice } from '@reduxjs/toolkit'
import { propEq } from 'ramda'

import { SeaFrontGroup } from '../../../domain/entities/seaFront/constants'
import { SEA_FRONT_GROUP_SEA_FRONTS, SeaFrontGroup } from '../../../domain/entities/seaFront/constants'
import { deleteListItems } from '../../../utils/deleteListItems'

import type { AlertSubMenu } from './constants'
Expand Down Expand Up @@ -59,7 +59,18 @@ const slice = createSlice({
return
}

state.subMenu = (focusedPendingAlert.value.seaFront as SeaFrontGroup) || SeaFrontGroup.MEMN
const seaFrontGroup = (Object.keys(SEA_FRONT_GROUP_SEA_FRONTS) as SeaFrontGroup[]).find(group => {
if (
focusedPendingAlert.value.seaFront &&
SEA_FRONT_GROUP_SEA_FRONTS[group].includes(focusedPendingAlert.value.seaFront)
) {
return group
}

return undefined
})

state.subMenu = seaFrontGroup || SeaFrontGroup.MEMN
},

/**
Expand Down

0 comments on commit a456de2

Please sign in to comment.