Skip to content

Commit

Permalink
Remove unused ref and fix update iin use-case
Browse files Browse the repository at this point in the history
  • Loading branch information
louptheron committed Mar 5, 2024
1 parent b4513a2 commit 71911b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 4 additions & 1 deletion frontend/src/domain/shared_slices/Vessel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ const vesselSlice = createSlice({
}
})

if (Vessel.getVesselFeatureId(state.selectedVesselIdentity) === action.payload.vesselFeatureId) {
if (
state.selectedVesselIdentity &&
Vessel.getVesselFeatureId(state.selectedVesselIdentity) === action.payload.vesselFeatureId
) {
let reportings: ReportingType[] = []

if (state.selectedVessel?.reportings?.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
} from '@features/Reporting/components/ReportingForm/utils'
import { useMainAppDispatch } from '@hooks/useMainAppDispatch'
import { useMainAppSelector } from '@hooks/useMainAppSelector'
import { Accent, Button, FormikSelect, FormikTextarea, FormikTextInput, Legend, Fieldset } from '@mtes-mct/monitor-ui'
import { Accent, Button, Fieldset, FormikSelect, FormikTextarea, FormikTextInput, Legend } from '@mtes-mct/monitor-ui'
import { Form, Formik } from 'formik'
import { useCallback, useMemo, useRef } from 'react'
import { useCallback, useMemo } from 'react'
import { Radio, RadioGroup } from 'rsuite'
import styled from 'styled-components'

Expand All @@ -25,7 +25,6 @@ import { mapControlUnitsToUniqueSortedIdsAsOptions } from '../VesselReportings/C
import type { VesselIdentity } from '../../../../domain/entities/vessel/types'
import type { EditableReporting, EditedReporting } from '../../../../domain/types/reporting'
import type { Option } from '@mtes-mct/monitor-ui'
import type { MutableRefObject } from 'react'

type ReportingFormProps = {
closeForm: () => void
Expand All @@ -44,7 +43,6 @@ export function ReportingForm({
const dispatch = useMainAppDispatch()
const infractions = useMainAppSelector(state => state.infraction.infractions)
const controlUnitsQuery = useGetLegacyControlUnitsQuery(undefined)
const previousReportingType = useRef() as MutableRefObject<ReportingType>

const infractionsAsOptions = useMemo(
() =>
Expand Down Expand Up @@ -75,7 +73,7 @@ export function ReportingForm({
getOnlyVesselIdentityProperties(editedReporting),
editedReporting.id,
nextReportingValue,
previousReportingType.current
editedReporting.type
)
).then(() => {
closeForm()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const updateReporting =
nextReporting.type === ReportingType.OBSERVATION &&
previousReportingType === ReportingType.INFRACTION_SUSPICION
) {
dispatch(removeCurrentReporting(updatedReporting.id))
dispatch(removeCurrentReporting(id))
}

// We update the reportings of the last positions vessels state
Expand Down

0 comments on commit 71911b0

Please sign in to comment.