Skip to content

Commit 7f238a0

Browse files
authored
Equipement VMS - Correction de l'erreur quand l'equipement n'est pas trouvé (#3330)
## Linked issues - Resolve #3223 (comment) ---- - [ ] Tests E2E (Cypress)
2 parents 2c40eb2 + 6be4445 commit 7f238a0

File tree

4 files changed

+38
-13
lines changed

4 files changed

+38
-13
lines changed

frontend/cypress/e2e/vessel_sidebar/ers_vms.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ context('Vessel sidebar ers/vms tab', () => {
3131
cy.get('*[data-cy="vessel-equipments"]').contains('Non')
3232
})
3333

34+
it('ERS/VMS tab Should not throw When a beacon is missing', () => {
35+
// Given
36+
cy.get('input[placeholder="Rechercher un navire..."]').type('MERLU')
37+
cy.contains('mark', 'MERLU').click()
38+
cy.wait(50)
39+
cy.get('*[data-cy="vessel-sidebar"]', { timeout: 10000 }).should('be.visible')
40+
cy.intercept('GET', '/bff/v1/vessels/beacon_malfunctions*').as('vesselBeaconMalfunctions')
41+
42+
// When
43+
cy.get('*[data-cy="vessel-menu-ers-vms"]').click({ timeout: 10000 })
44+
45+
// Then, it does not throw
46+
})
47+
3448
it('ERS/VMS tab Should contain history of beacon malfunctions and show a malfunction detail in history', () => {
3549
// Given
3650
cy.get('.VESSELS_POINTS').click(460, 460, { force: true, timeout: 10000 })

frontend/src/features/Vessel/Vessel.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export namespace Vessel {
4242
}
4343

4444
export interface EnrichedVessel extends Vessel {
45-
beacon: Beacon
45+
beacon: Beacon | undefined
4646
hasLogbookEsacapt: boolean
4747
hasVisioCaptures: boolean | undefined
4848
logbookEquipmentStatus: string | undefined

frontend/src/features/VesselSidebar/Equipment/resume/EquipmentResume.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ export function EquipmentResume({ setIsCurrentBeaconMalfunctionDetails }: Beacon
5252
dispatch(setVesselBeaconMalfunctionsFromDate(nextDate))
5353
}
5454

55+
const beaconType = useMemo(() => {
56+
if (selectedVessel?.beacon?.isCoastal === undefined) {
57+
return undefined
58+
}
59+
60+
return selectedVessel.beacon.isCoastal ? 'Côtier' : 'Satellitaire'
61+
}, [selectedVessel?.beacon?.isCoastal])
62+
5563
return (
5664
<>
5765
{!loadingVesselBeaconMalfunctions ? (
@@ -61,16 +69,17 @@ export function EquipmentResume({ setIsCurrentBeaconMalfunctionDetails }: Beacon
6169
column={[
6270
{
6371
key: 'N° balise VMS',
64-
value: selectedVessel?.beacon.beaconNumber
72+
value: selectedVessel?.beacon?.beaconNumber
6573
},
6674
{
6775
key: 'Type de balise',
68-
value: selectedVessel?.beacon.isCoastal ? 'Côtier' : 'Satellitaire'
76+
value: beaconType
6977
},
7078
{
7179
key: 'Date de loggage',
7280
value:
73-
!!selectedVessel?.beacon.loggingDatetimeUtc && getDateTime(selectedVessel.beacon.loggingDatetimeUtc)
81+
!!selectedVessel?.beacon?.loggingDatetimeUtc &&
82+
getDateTime(selectedVessel.beacon.loggingDatetimeUtc)
7483
}
7584
]}
7685
valueEllipsisedForWidth={100}

frontend/src/features/VesselSidebar/Identity/index.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import { FlatTwoColumnKeyValue } from '@features/VesselSidebar/common/FlatTwoColumnKeyValue'
2+
import { useMainAppDispatch } from '@hooks/useMainAppDispatch'
3+
import { useMainAppSelector } from '@hooks/useMainAppSelector'
4+
import { THEME } from '@mtes-mct/monitor-ui'
25
import countries from 'i18n-iso-countries'
36
import { useEffect, useMemo } from 'react'
47
import { FingerprintSpinner } from 'react-epic-spinners'
58
import styled from 'styled-components'
69

7-
import { COLORS } from '../../../constants/constants'
810
import { showVessel } from '../../../domain/use_cases/vessel/showVessel'
9-
import { useMainAppDispatch } from '../../../hooks/useMainAppDispatch'
10-
import { useMainAppSelector } from '../../../hooks/useMainAppSelector'
1111
import { getDate } from '../../../utils'
1212

1313
export function Identity() {
1414
const dispatch = useMainAppDispatch()
15-
const { loadingVessel, selectedVessel, selectedVesselIdentity, selectedVesselPositions } = useMainAppSelector(
16-
state => state.vessel
17-
)
15+
const loadingVessel = useMainAppSelector(state => state.vessel.loadingVessel)
16+
const selectedVessel = useMainAppSelector(state => state.vessel.selectedVessel)
17+
const selectedVesselIdentity = useMainAppSelector(state => state.vessel.selectedVesselIdentity)
18+
const selectedVesselPositions = useMainAppSelector(state => state.vessel.selectedVesselPositions)
1819
const gears = useMainAppSelector(state => state.gear.gears)
1920

2021
const lastPosition = useMemo(() => {
@@ -52,11 +53,12 @@ export function Identity() {
5253
if (selectedVessel && selectedVessel[propertyName]) {
5354
return selectedVessel[propertyName]
5455
}
56+
5557
if (lastPosition && lastPosition[propertyName]) {
5658
return lastPosition[propertyName]
5759
}
5860

59-
return <NoValue>-</NoValue>
61+
return undefined
6062
}
6163

6264
return !loadingVessel ? (
@@ -73,7 +75,7 @@ export function Identity() {
7375
},
7476
{
7577
key: 'Balise n°',
76-
value: getVesselOrLastPositionProperty('beaconNumber')
78+
value: selectedVessel?.beacon?.beaconNumber
7779
}
7880
]}
7981
secondColumn={[
@@ -272,7 +274,7 @@ export function Identity() {
272274
</Zone>
273275
</Body>
274276
) : (
275-
<FingerprintSpinner className="radar" color={COLORS.charcoal} size={100} />
277+
<FingerprintSpinner className="radar" color={THEME.color.charcoal} size={100} />
276278
)
277279
}
278280

0 commit comments

Comments
 (0)