diff --git a/frontend/src/features/ActivityReport/components/ExportActivityReportsDialog/index.tsx b/frontend/src/features/ActivityReport/components/ExportActivityReportsDialog/index.tsx index d1873291a4..4fe5fc0bb1 100644 --- a/frontend/src/features/ActivityReport/components/ExportActivityReportsDialog/index.tsx +++ b/frontend/src/features/ActivityReport/components/ExportActivityReportsDialog/index.tsx @@ -1,14 +1,5 @@ import { useMainAppDispatch } from '@hooks/useMainAppDispatch' -import { - Accent, - Button, - DatePicker, - Dialog, - FieldError, - getUtcizedDayjs, - Select, - useNewWindow -} from '@mtes-mct/monitor-ui' +import { Accent, Button, DatePicker, Dialog, FieldError, getUtcizedDayjs, Select } from '@mtes-mct/monitor-ui' import { useState } from 'react' import styled from 'styled-components' @@ -21,7 +12,6 @@ type ExportActivityReportsDialogProps = { onExit: () => Promisable } export function ExportActivityReportsDialog({ onExit }: ExportActivityReportsDialogProps) { - const { newWindowContainerRef } = useNewWindow() const dispatch = useMainAppDispatch() const [afterDateTimeUtc, setAfterDateTimeUtc] = useState() @@ -66,7 +56,6 @@ export function ExportActivityReportsDialog({ onExit }: ExportActivityReportsDia
Du au () @@ -20,7 +19,6 @@ export function DatePickerField() { return ( () const { updateFieldsControlledByVessel } = useGetMissionActionFormikUsecases() - const { newWindowContainerRef } = useNewWindow() - const { data: vessel, isFetching } = useGetVesselQuery(values.vesselId ?? skipToken) const defaultValue = useMemo(() => { @@ -100,7 +98,6 @@ export function VesselField() { () const error = errors.endDateTimeUtc ?? errors.startDateTimeUtc @@ -15,7 +14,6 @@ export function FormikDoubleDatePicker() {
export function FilterBar({ onQueryChange, searchQuery }: FilterBarProps) { - const { newWindowContainerRef } = useNewWindow() - const listFilterValues = useMainAppSelector(store => store.missionList.listFilterValues) const [isCustomDateRangeOpen, setIsCustomDateRangeOpen] = useState(false) @@ -198,11 +195,7 @@ export function FilterBar({ onQueryChange, searchQuery }: FilterBarProps) { ]} > {isCustomDateRangeOpen && ( - + )} diff --git a/frontend/src/features/PriorNotification/components/ManualPriorNotificationForm/fields/FormikVesselSelect.tsx b/frontend/src/features/PriorNotification/components/ManualPriorNotificationForm/fields/FormikVesselSelect.tsx index 1ed398a903..fc41769c2f 100644 --- a/frontend/src/features/PriorNotification/components/ManualPriorNotificationForm/fields/FormikVesselSelect.tsx +++ b/frontend/src/features/PriorNotification/components/ManualPriorNotificationForm/fields/FormikVesselSelect.tsx @@ -1,7 +1,7 @@ import { vesselApi } from '@features/Vessel/vesselApi' import { VesselSearch } from '@features/VesselSearch' import { useMainAppDispatch } from '@hooks/useMainAppDispatch' -import { Field, FieldError, logSoftError, useKey, useNewWindow } from '@mtes-mct/monitor-ui' +import { Field, FieldError, logSoftError, useKey } from '@mtes-mct/monitor-ui' import { useField } from 'formik' import { useCallback, useEffect, useRef, useState } from 'react' import styled from 'styled-components' @@ -17,7 +17,6 @@ export function FormikVesselSelect({ onChange, readOnly }: FormikVesselSelectPro const dispatch = useMainAppDispatch() const [input, meta, helper] = useField('vesselId') - const { newWindowContainerRef } = useNewWindow() const [isLoading, setIsLoading] = useState(true) @@ -92,7 +91,6 @@ export function FormikVesselSelect({ onChange, readOnly }: FormikVesselSelectPro store.priorNotification.listFilterValues) const dispatch = useMainAppDispatch() @@ -303,7 +301,6 @@ export function FilterBar() { {listFilterValues.expectedArrivalPeriod === ExpectedArrivalPeriod.CUSTOM && ( Promisable } export function AddSilencedAlertDialog({ onCancel, onConfirm }: DeletionConfirmationDialogProps) { - const { newWindowContainerRef } = useNewWindow() const [isValidatingOnChange, setIsValidatingOnChange] = useState(false) return ( @@ -37,12 +36,7 @@ export function AddSilencedAlertDialog({ onCancel, onConfirm }: DeletionConfirma <> - + diff --git a/frontend/src/features/SideWindow/Alert/SilencedAlerts/fields/VesselField.tsx b/frontend/src/features/SideWindow/Alert/SilencedAlerts/fields/VesselField.tsx index 6c612a29bf..5cf6e2bb3f 100644 --- a/frontend/src/features/SideWindow/Alert/SilencedAlerts/fields/VesselField.tsx +++ b/frontend/src/features/SideWindow/Alert/SilencedAlerts/fields/VesselField.tsx @@ -1,4 +1,4 @@ -import { Legend, useNewWindow } from '@mtes-mct/monitor-ui' +import { Legend } from '@mtes-mct/monitor-ui' import { useFormikContext } from 'formik' import { useMemo } from 'react' import styled from 'styled-components' @@ -12,7 +12,6 @@ import type { SilencedAlertFormValues } from '../types' export function VesselField() { const { errors, setValues, values } = useFormikContext() - const { newWindowContainerRef } = useNewWindow() const defaultValue: VesselIdentity = useMemo( () => ({ @@ -74,7 +73,6 @@ export function VesselField() { Navire , 'defaultValue' | 'onChange'> & { - baseRef?: MutableRefObject | undefined defaultValue?: VesselIdentity | undefined extendedWidth?: number | undefined hasError?: boolean | undefined @@ -33,7 +32,6 @@ type VesselSearchProps = Omit, 'defaultVal onInputClick?: () => Promisable } export function VesselSearch({ - baseRef, className, defaultValue, extendedWidth, @@ -60,7 +58,7 @@ export function VesselSearch({ const [showLastSearchedVessels, setShowLastSearchedVessels] = useState(false) const escapeFromKeyboard = useEscapeFromKeyboard() - const clickedOutsideComponent = useClickOutsideWhenOpenedWithinRef(wrapperRef, isExtended, baseRef) + const clickedOutsideComponent = useClickOutsideWhenOpened(wrapperRef, isExtended) useEffect(() => { setSelectedVessel(defaultValue) @@ -181,12 +179,10 @@ export function VesselSearch({ { - const [clicked, setClicked] = useState(null) - - useEffect(() => { - function handleClickOutside (event) { - if (ref.current && !ref.current.contains(event.target)) { - setClicked({}) - } else { - setClicked(null) - } - } - - // Bind the event listener - if (isOpened) { - if (baseRef) { - baseRef.current?.addEventListener('mousedown', handleClickOutside) - } else { - document.addEventListener('mousedown', handleClickOutside) - } - } - return () => { - // Unbind the event listener on clean up - if (baseRef) { - baseRef.current?.removeEventListener('mousedown', handleClickOutside) - } else { - document.addEventListener('mousedown', handleClickOutside) - } - } - }, [ref, isOpened]) - - return clicked -}