Skip to content

Commit

Permalink
fix: iframes transport
Browse files Browse the repository at this point in the history
  • Loading branch information
desoindx committed Nov 24, 2024
1 parent f0e29d8 commit efae06c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/components/outils/TransportSimulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import classNames from 'classnames'
import { useTranslations } from 'next-intl'
import { usePathname, useSearchParams } from 'next/navigation'
import React, { KeyboardEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { KeyboardEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import useParamContext from 'src/providers/ParamProvider'
import DistanceSimulator from './DistanceSimulator'
import ItineraireSimulator from './ItineraireSimulator'
Expand Down Expand Up @@ -36,8 +36,15 @@ const TransportSimulator = () => {
useEffect(() => {
if (pathName.includes(itineraire.value)) {
setSelected('itineraire')
} else {
const tabsParam = searchParams.get('tabs')
const values = tabsParam?.split(',')

if (values && values.includes(itineraire.value)) {
setSelected('itineraire')
}
}
}, [pathName, setSelected])
}, [pathName, setSelected, searchParams])

const tabs = useMemo(() => {
const tabsParam = searchParams.get('tabs')
Expand All @@ -53,10 +60,6 @@ const TransportSimulator = () => {
return true
}

if (values.includes(itineraire.value) && !pathName.includes(itineraire.value)) {
setSelected('itineraire')
}

return false
}, [pathName, searchParams])

Expand Down

0 comments on commit efae06c

Please sign in to comment.