Replace regex by index to get relative path

pull/2181/head
Jérémy Rialland 2022-07-07 11:04:28 +02:00 committed by Jérémy Rialland
parent 2c804328a6
commit eccbea537d
1 changed files with 6 additions and 6 deletions

View File

@ -12,14 +12,12 @@ import { StoreProvider } from './StoreContext'
import VotreSituation from './VotreSituation'
export default function ÉconomieCollaborative() {
const sitePaths = useContext(SitePathsContext)
const { économieCollaborative } = useContext(SitePathsContext).simulateurs
const iframePath =
useSimulatorsData()['économie-collaborative'].iframePath ?? ''
const indexPath = useIsEmbedded()
? '/iframes/' + iframePath
: sitePaths.simulateurs.économieCollaborative.index
const relative = (path: string) => path.replace(/.*\//, '/')
: économieCollaborative.index
return (
<TrackChapter chapter1="simulateurs" chapter2="economie_collaborative">
@ -35,8 +33,10 @@ export default function ÉconomieCollaborative() {
<Routes>
<Route path={'/'} element={<ActivitésSelection />} />
<Route
path={relative(
sitePaths.simulateurs.économieCollaborative.votreSituation
// TODO: react-router 6 use relative path now, we need to get relative path from sitepath instead of this replace
path={économieCollaborative.votreSituation.replace(
économieCollaborative.index,
''
)}
element={<VotreSituation />}
/>