-
+ (isActive ? { display: 'none' } : {})}
+ to={indexPath}
+ >
←{' '}
Retour à la selection d'activités
diff --git a/site/source/pages/Simulateurs/ExonerationCovid/ExonérationCovid.tsx b/site/source/pages/Simulateurs/ExonerationCovid/ExonérationCovid.tsx
index 2007ab024..75feb1bf5 100644
--- a/site/source/pages/Simulateurs/ExonerationCovid/ExonérationCovid.tsx
+++ b/site/source/pages/Simulateurs/ExonerationCovid/ExonérationCovid.tsx
@@ -12,7 +12,11 @@ import { DottedName as ExoCovidDottedNames } from 'exoneration-covid'
import { PublicodesExpression } from 'publicodes'
import { useCallback, useEffect } from 'react'
import { Trans } from 'react-i18next'
-import { useLocation } from 'react-router'
+import {
+ createSearchParams,
+ useLocation,
+ useSearchParams,
+} from 'react-router-dom'
import { useExoCovidEngine } from '.'
import { FormulaireS1S1Bis } from './FormulaireS1S1Bis'
import { FormulaireS2 } from './FormulaireS2'
@@ -25,7 +29,7 @@ const rootDottedNames = [
export const ExonérationCovid = () => {
const location = useLocation()
- const searchParams = new URLSearchParams(location.search)
+ const [searchParams] = useSearchParams()
const params = Object.fromEntries(searchParams.entries()) as {
[key in typeof rootDottedNames[number]]?: string
}
@@ -133,18 +137,18 @@ export const ExonérationCovid = () => {
isDisabled={!rootDottedNames.every((names) => situation[names])}
{...(rootDottedNames.every((names) => situation[names])
? {
- to: () => {
- rootDottedNames.forEach((key) =>
- searchParams.append(
- key,
- situation[key]?.toString() ?? ''
+ to: {
+ pathname: location.pathname,
+ search: createSearchParams(
+ Object.fromEntries(
+ rootDottedNames
+ .filter((key) => situation[key])
+ .map((key) => [
+ key,
+ situation[key]?.toString() ?? '',
+ ])
)
- )
-
- return {
- pathname: location.pathname,
- search: searchParams.toString(),
- }
+ ).toString(),
},
}
: null)}
diff --git a/site/source/pages/Simulateurs/Home.tsx b/site/source/pages/Simulateurs/Home.tsx
index e6ff35a26..33f5bbada 100644
--- a/site/source/pages/Simulateurs/Home.tsx
+++ b/site/source/pages/Simulateurs/Home.tsx
@@ -168,12 +168,8 @@ export function SimulateurCard({
}
- to={{
- state: fromGérer
- ? { fromGérer: true }
- : { fromSimulateurs: true },
- pathname: (isIframe && iframePath) || path,
- }}
+ to={{ pathname: (isIframe && iframePath) || path }}
+ state={fromGérer ? { fromGérer: true } : { fromSimulateurs: true }}
title={
{shortName} {tooltip && {tooltip}}
@@ -187,12 +183,8 @@ export function SimulateurCard({
title={shortName}
icon={}
ctaLabel={t('.cta', 'Lancer le simulateur')}
- to={{
- state: fromGérer
- ? { fromGérer: true }
- : { fromSimulateurs: true },
- pathname: (isIframe && iframePath) || path,
- }}
+ to={{ pathname: (isIframe && iframePath) || path }}
+ state={fromGérer ? { fromGérer: true } : { fromSimulateurs: true }}
>
{meta?.description}
diff --git a/site/source/pages/Simulateurs/cards/SimulatorRessourceCard.tsx b/site/source/pages/Simulateurs/cards/SimulatorRessourceCard.tsx
index e4e9d48f5..c578a1bf1 100644
--- a/site/source/pages/Simulateurs/cards/SimulatorRessourceCard.tsx
+++ b/site/source/pages/Simulateurs/cards/SimulatorRessourceCard.tsx
@@ -25,10 +25,8 @@ export function SimulatorRessourceCard({
Accéder au simulateur
}
- to={{
- pathname: simulator.path,
- state: { fromSimulateurs: true },
- }}
+ to={{ pathname: simulator.path }}
+ state={{ fromSimulateurs: true }}
>
{simulator.meta?.description}
diff --git a/site/source/pages/Simulateurs/index.tsx b/site/source/pages/Simulateurs/index.tsx
index 4100dc4e3..f399ce17e 100644
--- a/site/source/pages/Simulateurs/index.tsx
+++ b/site/source/pages/Simulateurs/index.tsx
@@ -5,10 +5,10 @@ import { SitePathsContext } from '@/components/utils/SitePathsContext'
import { Link } from '@/design-system/typography/link'
import { useContext, useEffect, useMemo } from 'react'
import { Trans } from 'react-i18next'
-import { Route, Routes, useLocation } from 'react-router-dom-v5-compat'
+import { Route, Routes, useLocation } from 'react-router-dom'
+import SimulateurPage from '../../components/PageData'
import Home from './Home'
import useSimulatorsData from './metadata'
-import SimulateurPage from '../../components/PageData'
export default function Simulateurs() {
const sitePaths = useContext(SitePathsContext)
@@ -20,7 +20,7 @@ export default function Simulateurs() {
}>('navigation::simulateurs::locationState::v2', {})
useEffect(() => {
if (state) {
- setLastState(state as any)
+ setLastState(state)
}
}, [setLastState, state])
const simulatorsData = useSimulatorsData()
@@ -32,7 +32,7 @@ export default function Simulateurs() {
.map((s) => (
}
/>
)),
@@ -60,7 +60,7 @@ export default function Simulateurs() {
)
) : null)}
- } />
+ } />
{simulatorRoutes}
>
diff --git a/site/source/pages/Simulateurs/metadata-src.ts b/site/source/pages/Simulateurs/metadata-src.ts
index 015355855..2c8455414 100644
--- a/site/source/pages/Simulateurs/metadata-src.ts
+++ b/site/source/pages/Simulateurs/metadata-src.ts
@@ -429,7 +429,7 @@ const metadataSrc = (t: TFunction<'translation', string>) => {
'Assistant à la déclaration de revenu pour les indépendants'
),
},
- pathId: 'gérer.déclarationIndépendant.beta',
+ pathId: 'gérer.déclarationIndépendant.beta.index',
shortName: t(
'pages.gérer.declaration_revenu_indépendant.shortname',
'Assistant déclaration de revenu [beta]'
diff --git a/site/source/pages/Simulateurs/metadata.tsx b/site/source/pages/Simulateurs/metadata.tsx
index a75c68171..6656b6551 100644
--- a/site/source/pages/Simulateurs/metadata.tsx
+++ b/site/source/pages/Simulateurs/metadata.tsx
@@ -12,8 +12,8 @@ import { createContext, useContext, useMemo } from 'react'
import { TFunction, Trans, useTranslation } from 'react-i18next'
import { constructLocalizedSitePath, SitePathsType } from '../../sitePaths'
import Créer from '../Creer/Home'
-import DéclarationRevenuIndépendant from '../gerer/declaration-revenu-independants'
import DéclarationChargeSocialeIndépendant from '../gerer/declaration-charges-sociales-independant'
+import DéclarationRevenuIndépendant from '../gerer/declaration-revenu-independants'
import FormulaireMobilitéIndépendant from '../gerer/demande-mobilité'
import ArtisteAuteur from './ArtisteAuteur'
import AutoEntrepreneur from './AutoEntrepreneur'
@@ -541,7 +541,7 @@ function getSimulatorsData({
'déclaration-revenu-indépendant-beta': {
...pureSimulatorsData['déclaration-revenu-indépendant-beta'],
component: DéclarationRevenuIndépendant,
- path: sitePaths.gérer.déclarationIndépendant.beta,
+ path: sitePaths.gérer.déclarationIndépendant.beta.index,
},
'demande-mobilité': {
...pureSimulatorsData['demande-mobilité'],
diff --git a/site/source/pages/Stats/Stats.tsx b/site/source/pages/Stats/Stats.tsx
index 13b9e9ba4..3e10f5db2 100644
--- a/site/source/pages/Stats/Stats.tsx
+++ b/site/source/pages/Stats/Stats.tsx
@@ -11,7 +11,7 @@ import { useFetchData } from '@/hooks/useFetchData'
import { formatValue } from 'publicodes'
import { useCallback, useEffect, useMemo, useState } from 'react'
import { Trans } from 'react-i18next'
-import { useSearchParams } from 'react-router-dom-v5-compat'
+import { useSearchParams } from 'react-router-dom'
import { BrushProps } from 'recharts'
import styled from 'styled-components'
import { toAtString } from '../../ATInternetTracking'
diff --git a/site/source/pages/gerer/_components/ImpotSociete.tsx b/site/source/pages/gerer/_components/ImpotSociete.tsx
index 92c022885..ff50ff988 100644
--- a/site/source/pages/gerer/_components/ImpotSociete.tsx
+++ b/site/source/pages/gerer/_components/ImpotSociete.tsx
@@ -16,12 +16,8 @@ export function ImpotSocieteCard() {
)}
icon={}
ctaLabel={t('gérer.choix.is.cta', 'Lancer le simulateur')}
- to={{
- pathname: sitePaths.simulateurs.is,
- state: {
- fromGérer: true,
- },
- }}
+ to={{ pathname: sitePaths.simulateurs.is }}
+ state={{ fromGérer: true }}
>
Calculez le montant de l'impôt sur les sociétés à partir de votre
diff --git a/site/source/pages/gerer/declaration-revenu-independants/_components/DéclarationRevenu.tsx b/site/source/pages/gerer/declaration-revenu-independants/_components/DéclarationRevenu.tsx
index c32734eb5..8d6089228 100644
--- a/site/source/pages/gerer/declaration-revenu-independants/_components/DéclarationRevenu.tsx
+++ b/site/source/pages/gerer/declaration-revenu-independants/_components/DéclarationRevenu.tsx
@@ -170,7 +170,7 @@ export function DéclarationRevenuSection({ progress }: { progress: number }) {
diff --git a/site/source/pages/gerer/declaration-revenu-independants/entreprise.tsx b/site/source/pages/gerer/declaration-revenu-independants/entreprise.tsx
index 71a67ac04..b2cdf8bd9 100644
--- a/site/source/pages/gerer/declaration-revenu-independants/entreprise.tsx
+++ b/site/source/pages/gerer/declaration-revenu-independants/entreprise.tsx
@@ -172,7 +172,7 @@ export default function Accueil() {
diff --git a/site/source/pages/gerer/declaration-revenu-independants/imposition.tsx b/site/source/pages/gerer/declaration-revenu-independants/imposition.tsx
index 84ce8913e..6372aa282 100644
--- a/site/source/pages/gerer/declaration-revenu-independants/imposition.tsx
+++ b/site/source/pages/gerer/declaration-revenu-independants/imposition.tsx
@@ -341,7 +341,7 @@ function ResultSection() {
`}
>
-
+
{steps.map(
(step) =>
- step.page &&
!step.isDisabled && (
-
+ } />
)
)}
- {defaultCurrentStep && }
-
+
+ }
+ />
+
>
@@ -84,7 +84,7 @@ export default function AideDéclarationIndépendant() {
}
function useSteps() {
- const sitePaths = useContext(SitePathsContext).gérer.déclarationIndépendant
+ const sitePaths = useRelativeSitePaths().gérer.déclarationIndépendant.beta
const { t } = useTranslation()
const step1Progress = useProgress(Step1Objectifs)
const step2Progress = useProgress(Step2Objectifs)
diff --git a/site/source/pages/gerer/index.tsx b/site/source/pages/gerer/index.tsx
index a47ca6816..9664db488 100644
--- a/site/source/pages/gerer/index.tsx
+++ b/site/source/pages/gerer/index.tsx
@@ -10,6 +10,7 @@ import {
WhenApplicable,
WhenNotApplicable,
} from '@/components/EngineValue'
+import PageData from '@/components/PageData'
import PageHeader from '@/components/PageHeader'
import { PlaceDesEntreprisesButton } from '@/components/PlaceDesEntreprises'
import { FromTop } from '@/components/ui/animate'
@@ -24,11 +25,11 @@ import { Container, Grid, Spacing } from '@/design-system/layout'
import { Strong } from '@/design-system/typography'
import { H2, H4 } from '@/design-system/typography/heading'
import { Link } from '@/design-system/typography/link'
-import { Li, Ul } from '@/design-system/typography/list'
import { Body, Intro } from '@/design-system/typography/paragraphs'
import { useQuestionList } from '@/hooks/useQuestionList'
import { useSetEntreprise } from '@/hooks/useSetEntreprise'
import { companySituationSelector } from '@/selectors/simulationSelectors'
+import { useRelativeSitePaths } from '@/sitePaths'
import { evaluateQuestion } from '@/utils'
import { useOverlayTriggerState } from '@react-stately/overlays'
import { DottedName } from 'modele-social'
@@ -39,16 +40,14 @@ import { Trans, useTranslation } from 'react-i18next'
import { useDispatch, useSelector } from 'react-redux'
import {
generatePath,
- Redirect,
+ Navigate,
Route,
- Switch,
+ Routes,
useLocation,
useParams,
- useRouteMatch,
-} from 'react-router'
+} from 'react-router-dom'
import styled from 'styled-components'
import { TrackChapter, TrackPage } from '../../ATInternetTracking'
-import PageData from '../../components/PageData'
import { SimulateurCard } from '../Simulateurs/Home'
import useSimulatorsData, { SimulatorData } from '../Simulateurs/metadata'
import Embaucher from './embaucher'
@@ -63,29 +62,42 @@ import { SecuriteSocialeCard } from './_components/SecuriteSocialeCard'
export default function Gérer() {
const sitePaths = useContext(SitePathsContext)
+ const relativeSitePaths = useRelativeSitePaths()
const location = useLocation()
const simulateurs = useSimulatorsData()
- const showLink = !useRouteMatch({
- path: [sitePaths.gérer.index, sitePaths.gérer.entreprise],
- exact: true,
- })
+
+ const back = (
+
+ ← Retour à mon activité
+
+ )
return (
<>
- {showLink && (
-
- ← Retour à mon activité
-
- )}
-
+
+ } />
+ } />
+ {back}
+
+ >
+ }
+ />
+
+ {back}
+
+ >
+ }
/>
-
{[
simulateurs['déclaration-charges-sociales-indépendant'],
simulateurs['déclaration-revenu-indépendant-beta'],
@@ -94,16 +106,16 @@ export default function Gérer() {
].map((p) => (
}
+ path={p.path.replace(sitePaths.gérer.index, '') + '/*'}
+ element={
+ <>
+ {back}
+
+ >
+ }
/>
))}
-
-
+
>
)
@@ -208,7 +220,7 @@ function Home() {
gérerPath &&
(param == null || (entreprise?.siren && entreprise.siren !== param))
) {
- return
+ return
}
if (
@@ -216,7 +228,7 @@ function Home() {
(param && entrepriseNotFound) ||
(entreprise && !overwrite && !engineSiren)
) {
- return
+ return
}
return (
diff --git a/site/source/pages/integration/Iframe.tsx b/site/source/pages/integration/Iframe.tsx
index f4092911d..a63d28e97 100644
--- a/site/source/pages/integration/Iframe.tsx
+++ b/site/source/pages/integration/Iframe.tsx
@@ -10,7 +10,7 @@ import urssafLogo from '@/images/Urssaf.svg'
import { useEffect, useRef, useState } from 'react'
import { HexColorPicker } from 'react-colorful'
import { Trans, useTranslation } from 'react-i18next'
-import { useHref, useSearchParams } from 'react-router-dom-v5-compat'
+import { useHref, useSearchParams } from 'react-router-dom'
import styled from 'styled-components'
import { TrackPage } from '../../ATInternetTracking'
import useSimulatorsData, { SimulatorData } from '../Simulateurs/metadata'
diff --git a/site/source/pages/integration/index.tsx b/site/source/pages/integration/index.tsx
index b7cc680a0..ea313cf63 100644
--- a/site/source/pages/integration/index.tsx
+++ b/site/source/pages/integration/index.tsx
@@ -4,9 +4,10 @@ import { SitePathsContext } from '@/components/utils/SitePathsContext'
import { Banner, InnerBanner } from '@/design-system/banner'
import { Link } from '@/design-system/typography/link'
import { useFetchData } from '@/hooks/useFetchData'
+import { useRelativeSitePaths } from '@/sitePaths'
import { useContext } from 'react'
import { Trans } from 'react-i18next'
-import { Route, Routes, useLocation } from 'react-router-dom-v5-compat'
+import { Route, Routes, useLocation } from 'react-router-dom'
import { TrackChapter } from '../../ATInternetTracking'
import API from './API'
import Iframe from './Iframe'
@@ -22,6 +23,7 @@ type JobOffer = {
export default function Integration() {
const sitePaths = useContext(SitePathsContext)
+ const relativeSitePaths = useRelativeSitePaths()
const { pathname } = useLocation()
const { data: jobOffers } = useFetchData('/data/job-offers.json')
const openJobOffer = jobOffers?.[0]
@@ -52,12 +54,18 @@ export default function Integration() {
)}
- } />
- } />
- } />
- } />
+ } />
+ } />
}
+ />
+ }
+ />
+ }
/>
diff --git a/site/source/sitePaths.ts b/site/source/sitePaths.ts
index c364c3244..9f798b8a9 100644
--- a/site/source/sitePaths.ts
+++ b/site/source/sitePaths.ts
@@ -1,5 +1,6 @@
import { MetadataSrc } from 'pages/Simulateurs/metadata-src'
import { LegalStatus } from '@/selectors/companyStatusSelectors'
+import { useTranslation } from 'react-i18next'
export const LANDING_LEGAL_STATUS_LIST: Array = [
'EI',
@@ -13,85 +14,89 @@ export const LANDING_LEGAL_STATUS_LIST: Array = [
'SA',
]
+const status = Object.fromEntries(
+ LANDING_LEGAL_STATUS_LIST.map((statut) => [statut, statut])
+) as { [statut in LegalStatus]: statut }
+
const rawSitePathsFr = {
index: '',
créer: {
- index: '/créer',
- ...(Object.fromEntries(
- LANDING_LEGAL_STATUS_LIST.map((statut) => [statut, `/${statut}`])
- ) as { [statut in LegalStatus]: string }),
- après: '/après-la-création',
+ index: 'créer',
+ ...status,
+ après: 'après-la-création',
guideStatut: {
- index: '/statut-juridique',
- liste: '/liste',
- soleProprietorship: '/responsabilité',
- directorStatus: '/dirigeant',
- autoEntrepreneur: '/auto-entrepreneur-ou-entreprise-individuelle',
- multipleAssociates: '/nombre-associés',
- minorityDirector: '/gérant-majoritaire-ou-minoritaire',
+ index: 'statut-juridique',
+ liste: 'liste',
+ soleProprietorship: 'responsabilité',
+ directorStatus: 'dirigeant',
+ autoEntrepreneur: 'auto-entrepreneur-ou-entreprise-individuelle',
+ multipleAssociates: 'nombre-associés',
+ minorityDirector: 'gérant-majoritaire-ou-minoritaire',
},
},
gérer: {
- index: '/gérer',
- entreprise: '/:entreprise',
- embaucher: '/embaucher',
- sécuritéSociale: '/sécurité-sociale',
+ index: 'gérer',
+ entreprise: ':entreprise',
+ embaucher: 'embaucher',
+ sécuritéSociale: 'sécurité-sociale',
'déclaration-charges-sociales-indépendant':
- '/declaration-charges-sociales-independant',
+ 'declaration-charges-sociales-independant',
déclarationIndépendant: {
- index: '/aide-declaration-independants',
- beta: '/beta',
- entreprise: '/beta/entreprise',
- imposition: '/beta/imposition',
- déclaration: '/beta/declaration',
- cotisations: '/beta/cotisations',
+ index: 'aide-declaration-independants',
+ beta: {
+ index: 'beta',
+ entreprise: 'entreprise',
+ imposition: 'imposition',
+ déclaration: 'declaration',
+ cotisations: 'cotisations',
+ },
},
- formulaireMobilité: '/demande-mobilité',
+ formulaireMobilité: 'demande-mobilité',
},
simulateurs: {
- index: '/simulateurs',
- 'auto-entrepreneur': '/auto-entrepreneur',
- 'entreprise-individuelle': '/entreprise-individuelle',
- eirl: '/eirl',
- sasu: '/sasu',
- eurl: '/eurl',
- indépendant: '/indépendant',
- comparaison: '/comparaison-régimes-sociaux',
- pamc: '/pamc',
- salarié: '/salaire-brut-net',
- 'artiste-auteur': '/artiste-auteur',
+ index: 'simulateurs',
+ 'auto-entrepreneur': 'auto-entrepreneur',
+ 'entreprise-individuelle': 'entreprise-individuelle',
+ eirl: 'eirl',
+ sasu: 'sasu',
+ eurl: 'eurl',
+ indépendant: 'indépendant',
+ comparaison: 'comparaison-régimes-sociaux',
+ pamc: 'pamc',
+ salarié: 'salaire-brut-net',
+ 'artiste-auteur': 'artiste-auteur',
'profession-libérale': {
- index: '/profession-liberale',
- médecin: '/medecin',
- pharmacien: '/pharmacien',
- auxiliaire: '/auxiliaire-medical',
- 'chirurgien-dentiste': '/chirurgien-dentiste',
- 'sage-femme': '/sage-femme',
- avocat: '/avocat',
- 'expert-comptable': '/expert-comptable',
+ index: 'profession-liberale',
+ médecin: 'medecin',
+ pharmacien: 'pharmacien',
+ auxiliaire: 'auxiliaire-medical',
+ 'chirurgien-dentiste': 'chirurgien-dentiste',
+ 'sage-femme': 'sage-femme',
+ avocat: 'avocat',
+ 'expert-comptable': 'expert-comptable',
},
- 'chômage-partiel': '/chômage-partiel',
+ 'chômage-partiel': 'chômage-partiel',
économieCollaborative: {
- index: '/économie-collaborative',
- votreSituation: '/votre-situation',
+ index: 'économie-collaborative',
+ votreSituation: 'votre-situation',
},
- is: '/impot-societe',
- dividendes: '/dividendes',
- 'exonération-covid': '/exonération-covid',
+ is: 'impot-societe',
+ dividendes: 'dividendes',
+ 'exonération-covid': 'exonération-covid',
},
- nouveautés: '/nouveautés',
- stats: '/stats',
- accessibilité: '/accessibilité',
- budget: '/budget',
+ nouveautés: 'nouveautés',
+ stats: 'stats',
+ accessibilité: 'accessibilité',
+ budget: 'budget',
développeur: {
- index: '/développeur',
- iframe: '/iframe',
- library: '/bibliothèque-de-calcul',
- api: '/api',
- spreadsheet: '/tableur',
+ index: 'développeur',
+ iframe: 'iframe',
+ library: 'bibliothèque-de-calcul',
+ api: 'api',
+ spreadsheet: 'tableur',
},
documentation: {
- index: '/documentation',
+ index: 'documentation',
},
} as const
@@ -99,80 +104,83 @@ const rawSitePathsEn = {
...rawSitePathsFr,
créer: {
...rawSitePathsFr.créer,
- index: '/create',
- après: '/after-registration',
+ index: 'create',
+ après: 'after-registration',
guideStatut: {
- index: '/legal-status',
- liste: '/list',
- soleProprietorship: '/liability',
- directorStatus: '/director',
- autoEntrepreneur: '/auto-entrepreneur',
- multipleAssociates: '/multiple-associates',
- minorityDirector: '/chairman-or-managing-director',
+ index: 'legal-status',
+ liste: 'list',
+ soleProprietorship: 'liability',
+ directorStatus: 'director',
+ autoEntrepreneur: 'auto-entrepreneur',
+ multipleAssociates: 'multiple-associates',
+ minorityDirector: 'chairman-or-managing-director',
},
},
gérer: {
- index: '/manage',
- entreprise: '/:entreprise',
- embaucher: '/hiring',
- sécuritéSociale: '/social-security',
+ index: 'manage',
+ entreprise: ':entreprise',
+ embaucher: 'hiring',
+ sécuritéSociale: 'social-security',
'déclaration-charges-sociales-indépendant':
- '/declaration-social-charges-independent',
+ 'declaration-social-charges-independent',
déclarationIndépendant: {
- index: '/declaration-aid-independent',
- beta: '/beta',
- imposition: '/beta/taxation',
- entreprise: '/beta/company',
- déclaration: '/beta/declaration',
- cotisations: '/beta/contributions',
+ index: 'declaration-aid-independent',
+ beta: {
+ index: 'beta',
+ imposition: 'taxation',
+ entreprise: 'company',
+ déclaration: 'declaration',
+ cotisations: 'contributions',
+ },
},
- formulaireMobilité: '/posting-demand',
+ formulaireMobilité: 'posting-demand',
},
simulateurs: {
- index: '/calculators',
- indépendant: '/independant',
- 'entreprise-individuelle': '/sole-proprietorship',
- 'auto-entrepreneur': '/auto-entrepreneur',
- eirl: '/eirl',
- sasu: '/sasu',
- eurl: '/eurl',
- pamc: '/pamc',
- comparaison: '/social-scheme-comparaison',
- salarié: '/salary',
- 'artiste-auteur': '/artist-author',
- 'chômage-partiel': '/partial-unemployement',
+ index: 'calculators',
+ indépendant: 'independant',
+ 'entreprise-individuelle': 'sole-proprietorship',
+ 'auto-entrepreneur': 'auto-entrepreneur',
+ eirl: 'eirl',
+ sasu: 'sasu',
+ eurl: 'eurl',
+ pamc: 'pamc',
+ comparaison: 'social-scheme-comparaison',
+ salarié: 'salary',
+ 'artiste-auteur': 'artist-author',
+ 'chômage-partiel': 'partial-unemployement',
'profession-libérale': {
- index: '/liberal-profession',
- médecin: '/doctor',
- pharmacien: '/pharmacist',
- auxiliaire: '/medical-auxiliary',
- 'chirurgien-dentiste': '/dental-surgeon',
- 'sage-femme': '/midwife',
- avocat: '/lawyer',
- 'expert-comptable': '/accountant',
+ index: 'liberal-profession',
+ médecin: 'doctor',
+ pharmacien: 'pharmacist',
+ auxiliaire: 'medical-auxiliary',
+ 'chirurgien-dentiste': 'dental-surgeon',
+ 'sage-femme': 'midwife',
+ avocat: 'lawyer',
+ 'expert-comptable': 'accountant',
},
économieCollaborative: {
- index: '/sharing-economy',
- votreSituation: '/your-situation',
+ index: 'sharing-economy',
+ votreSituation: 'your-situation',
},
- is: '/corporate-tax',
- dividendes: '/dividends',
- 'exonération-covid': '/exoneration-covid',
+ is: 'corporate-tax',
+ dividendes: 'dividends',
+ 'exonération-covid': 'exoneration-covid',
},
- nouveautés: '/news',
- accessibilité: '/accessibility',
+ nouveautés: 'news',
+ accessibilité: 'accessibility',
développeur: {
...rawSitePathsFr.développeur,
- index: '/developer',
- library: '/library',
- api: '/api',
- spreadsheet: '/spreadsheet',
+ index: 'developer',
+ library: 'library',
+ api: 'api',
+ spreadsheet: 'spreadsheet',
+ spreadsheetx: 'spreadsheet',
},
} as const
/**
* Le but des types suivants est d'obtenir un typage statique des chaînes de caractères
- * comme "simulateurs.auto-entrepreneur" utilisés comme identifiants des routes (via les pathId dans metadat-src.ts).
+ * comme "simulateurs.auto-entrepreneur" utilisés comme identifiants des routes (via les pathId dans metadata-src.ts).
* Cela permet de ne pas avoir de faute dans les clés comme 'aide-embauche' au lieu de 'aides-embauche'
*/
@@ -203,18 +211,47 @@ const checkedSitePathsEn: RequiredPath & typeof rawSitePathsEn = rawSitePathsEn
type SitePathsFr = typeof checkedSitePathsFr
type SitePathsEn = typeof checkedSitePathsEn
+type GenericSitePath = { [key: string]: string | GenericSitePath }
+
+const encodeRelativeSitePaths = (base: T): T => {
+ const sitepaths = Object.entries(base).reduce(
+ (obj, [key, val]) => ({
+ ...obj,
+ [key]:
+ typeof val === 'string' ? encodeURI(val) : encodeRelativeSitePaths(val),
+ }),
+ {} as T
+ )
+
+ return sitepaths
+}
+
+const encodedRelativeSitePaths = encodeRelativeSitePaths({
+ fr: rawSitePathsFr,
+ en: rawSitePathsEn,
+})
+
+export const useRelativeSitePaths = () => {
+ const { language } = useTranslation().i18n
+
+ return encodedRelativeSitePaths[language as 'fr' | 'en']
+}
+export type RelativeSitePath = ReturnType
+
type SitePath = { [key: string]: string | SitePath } & { index: string }
type SitePathBuilt = {
[K in keyof T]: T[K] extends string
? K extends 'index'
- ? `${Root}${T[K]}`
+ ? `${Root}${T[K]}` extends ''
+ ? '/'
+ : `${Root}${T[K]}`
: T extends { index: string }
- ? `${Root}${T['index']}${T[K]}`
+ ? `${Root}${T['index']}/${T[K]}`
: `${Root}${T[K]}`
: SitePathBuilt<
T[K] extends SitePath ? T[K] : never,
- T extends { index: string } ? `${Root}${T['index']}` : `${Root}`
+ T extends { index: string } ? `${Root}${T['index']}/` : `${Root}`
>
}
@@ -229,8 +266,8 @@ function constructSitePaths(
entries.map(([k, value]) => [
k,
typeof value === 'string'
- ? root + (k === 'index' ? value : index + value)
- : constructSitePaths(value, root + index),
+ ? encodeURI(root + (k === 'index' ? value : index + '/' + value)) || '/'
+ : constructSitePaths(value, root + index + '/'),
])
) as SitePathBuilt
}
diff --git a/yarn.lock b/yarn.lock
index 35f8d13c8..369820591 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2880,7 +2880,7 @@ __metadata:
languageName: node
linkType: hard
-"@babel/runtime@npm:^7.0.0, @babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.11.2, @babel/runtime@npm:^7.12.1, @babel/runtime@npm:^7.12.13, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.14.5, @babel/runtime@npm:^7.15.4, @babel/runtime@npm:^7.16.4, @babel/runtime@npm:^7.17.0, @babel/runtime@npm:^7.17.2, @babel/runtime@npm:^7.5.0, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.6.2, @babel/runtime@npm:^7.7.2, @babel/runtime@npm:^7.7.6, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.9.2":
+"@babel/runtime@npm:^7.0.0, @babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.11.2, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.14.5, @babel/runtime@npm:^7.15.4, @babel/runtime@npm:^7.16.4, @babel/runtime@npm:^7.17.0, @babel/runtime@npm:^7.17.2, @babel/runtime@npm:^7.5.0, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.6.2, @babel/runtime@npm:^7.7.2, @babel/runtime@npm:^7.7.6, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.9.2":
version: 7.17.8
resolution: "@babel/runtime@npm:7.17.8"
dependencies:
@@ -8210,13 +8210,6 @@ __metadata:
languageName: node
linkType: hard
-"@types/history@npm:^4.7.11":
- version: 4.7.11
- resolution: "@types/history@npm:4.7.11"
- checksum: c92e2ba407dcab0581a9afdf98f533aa41b61a71133420a6d92b1ca9839f741ab1f9395b17454ba5b88cb86020b70b22d74a1950ccfbdfd9beeaa5459fdc3464
- languageName: node
- linkType: hard
-
"@types/history@npm:^5.0.0":
version: 5.0.0
resolution: "@types/history@npm:5.0.0"
@@ -8614,27 +8607,6 @@ __metadata:
languageName: node
linkType: hard
-"@types/react-router-dom@npm:^5.3.3":
- version: 5.3.3
- resolution: "@types/react-router-dom@npm:5.3.3"
- dependencies:
- "@types/history": ^4.7.11
- "@types/react": "*"
- "@types/react-router": "*"
- checksum: 28c4ea48909803c414bf5a08502acbb8ba414669b4b43bb51297c05fe5addc4df0b8fd00e0a9d1e3535ec4073ef38aaafac2c4a2b95b787167d113bc059beff3
- languageName: node
- linkType: hard
-
-"@types/react-router@npm:*, @types/react-router@npm:^5.1.18":
- version: 5.1.18
- resolution: "@types/react-router@npm:5.1.18"
- dependencies:
- "@types/history": ^4.7.11
- "@types/react": "*"
- checksum: f08b37ee822f9f9ff904ffd0778fe2bb7c717ed3ee311610382ee024d02a35169bd3301ecde863cac21aae8fdee919501e8ea22bad0260c02c10cfbdba5c71be
- languageName: node
- linkType: hard
-
"@types/react@npm:*, @types/react@npm:^17.0.0":
version: 17.0.43
resolution: "@types/react@npm:17.0.43"
@@ -17216,7 +17188,7 @@ __metadata:
languageName: node
linkType: hard
-"history@npm:*, history@npm:^5.2.0, history@npm:^5.3.0":
+"history@npm:*, history@npm:^5.2.0":
version: 5.3.0
resolution: "history@npm:5.3.0"
dependencies:
@@ -17234,20 +17206,6 @@ __metadata:
languageName: node
linkType: hard
-"history@npm:^4.9.0":
- version: 4.10.1
- resolution: "history@npm:4.10.1"
- dependencies:
- "@babel/runtime": ^7.1.2
- loose-envify: ^1.2.0
- resolve-pathname: ^3.0.0
- tiny-invariant: ^1.0.2
- tiny-warning: ^1.0.0
- value-equal: ^1.0.1
- checksum: addd84bc4683929bae4400419b5af132ff4e4e9b311a0d4e224579ea8e184a6b80d7f72c55927e4fa117f69076a9e47ce082d8d0b422f1a9ddac7991490ca1d0
- languageName: node
- linkType: hard
-
"hmac-drbg@npm:^1.0.1":
version: 1.0.1
resolution: "hmac-drbg@npm:1.0.1"
@@ -17259,7 +17217,7 @@ __metadata:
languageName: node
linkType: hard
-"hoist-non-react-statics@npm:^3.0.0, hoist-non-react-statics@npm:^3.1.0, hoist-non-react-statics@npm:^3.3.0, hoist-non-react-statics@npm:^3.3.2":
+"hoist-non-react-statics@npm:^3.0.0, hoist-non-react-statics@npm:^3.3.0, hoist-non-react-statics@npm:^3.3.2":
version: 3.3.2
resolution: "hoist-non-react-statics@npm:3.3.2"
dependencies:
@@ -18732,13 +18690,6 @@ __metadata:
languageName: node
linkType: hard
-"isarray@npm:0.0.1":
- version: 0.0.1
- resolution: "isarray@npm:0.0.1"
- checksum: 49191f1425681df4a18c2f0f93db3adb85573bcdd6a4482539d98eac9e705d8961317b01175627e860516a2fc45f8f9302db26e5a380a97a520e272e2a40a8d4
- languageName: node
- linkType: hard
-
"isarray@npm:1.0.0, isarray@npm:^1.0.0, isarray@npm:~1.0.0":
version: 1.0.0
resolution: "isarray@npm:1.0.0"
@@ -20027,7 +19978,7 @@ __metadata:
languageName: node
linkType: hard
-"loose-envify@npm:^1.0.0, loose-envify@npm:^1.1.0, loose-envify@npm:^1.2.0, loose-envify@npm:^1.3.1, loose-envify@npm:^1.4.0":
+"loose-envify@npm:^1.0.0, loose-envify@npm:^1.1.0, loose-envify@npm:^1.4.0":
version: 1.4.0
resolution: "loose-envify@npm:1.4.0"
dependencies:
@@ -20659,19 +20610,6 @@ __metadata:
languageName: node
linkType: hard
-"mini-create-react-context@npm:^0.4.0":
- version: 0.4.1
- resolution: "mini-create-react-context@npm:0.4.1"
- dependencies:
- "@babel/runtime": ^7.12.1
- tiny-warning: ^1.0.3
- peerDependencies:
- prop-types: ^15.0.0
- react: ^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0
- checksum: f8cb2c7738aac355fe9ce7e8425f371b7fa90daddd5133edda4ccfdc18c49043b2ec04be6f3abf09b60a0f52549d54f158d5bfd81cdfb1a658531e5b9fe7bc6a
- languageName: node
- linkType: hard
-
"minimalistic-assert@npm:^1.0.0, minimalistic-assert@npm:^1.0.1":
version: 1.0.1
resolution: "minimalistic-assert@npm:1.0.1"
@@ -22572,15 +22510,6 @@ __metadata:
languageName: node
linkType: hard
-"path-to-regexp@npm:^1.7.0":
- version: 1.8.0
- resolution: "path-to-regexp@npm:1.8.0"
- dependencies:
- isarray: 0.0.1
- checksum: 709f6f083c0552514ef4780cb2e7e4cf49b0cc89a97439f2b7cc69a608982b7690fb5d1720a7473a59806508fc2dae0be751ba49f495ecf89fd8fbc62abccbcd
- languageName: node
- linkType: hard
-
"path-to-regexp@npm:^6.1.0":
version: 6.2.1
resolution: "path-to-regexp@npm:6.2.1"
@@ -23710,7 +23639,7 @@ __metadata:
languageName: node
linkType: hard
-"react-is@npm:^16.10.2, react-is@npm:^16.12.0, react-is@npm:^16.13.1, react-is@npm:^16.6.0, react-is@npm:^16.7.0":
+"react-is@npm:^16.10.2, react-is@npm:^16.12.0, react-is@npm:^16.13.1, react-is@npm:^16.7.0":
version: 16.13.1
resolution: "react-is@npm:16.13.1"
checksum: f7a19ac3496de32ca9ae12aa030f00f14a3d45374f1ceca0af707c831b2a6098ef0d6bdae51bd437b0a306d7f01d4677fcc8de7c0d331eb47ad0f46130e53c5f
@@ -23785,38 +23714,7 @@ __metadata:
languageName: node
linkType: hard
-"react-router-dom-v5-compat@npm:^6.3.0":
- version: 6.3.0
- resolution: "react-router-dom-v5-compat@npm:6.3.0"
- dependencies:
- history: ^5.3.0
- react-router: 6.3.0
- peerDependencies:
- react: ">=16.8"
- react-dom: ">=16.8"
- react-router-dom: 4 || 5
- checksum: ee82b48078bac91cea3b8c499954cbf13f9261daef87e5032695946652b594b2f0590d279448ac59dd26a1c0d208a7c53d3aef2e97dcd0335f4af82df228f197
- languageName: node
- linkType: hard
-
-"react-router-dom@npm:^5.3.3":
- version: 5.3.3
- resolution: "react-router-dom@npm:5.3.3"
- dependencies:
- "@babel/runtime": ^7.12.13
- history: ^4.9.0
- loose-envify: ^1.3.1
- prop-types: ^15.6.2
- react-router: 5.3.3
- tiny-invariant: ^1.0.2
- tiny-warning: ^1.0.0
- peerDependencies:
- react: ">=15"
- checksum: e1998918e391611f09b967bce0cb88bc9794aa3d8dc5f86453467a1226ae2ace648a1f401f5282f19c84a3a61fa6a3207e2a6fdfe8c8efae0b255244631febeb
- languageName: node
- linkType: hard
-
-"react-router-dom@npm:^6.0.0":
+"react-router-dom@npm:^6.0.0, react-router-dom@npm:^6.3.0":
version: 6.3.0
resolution: "react-router-dom@npm:6.3.0"
dependencies:
@@ -23829,26 +23727,6 @@ __metadata:
languageName: node
linkType: hard
-"react-router@npm:5.3.3, react-router@npm:^5.3.3":
- version: 5.3.3
- resolution: "react-router@npm:5.3.3"
- dependencies:
- "@babel/runtime": ^7.12.13
- history: ^4.9.0
- hoist-non-react-statics: ^3.1.0
- loose-envify: ^1.3.1
- mini-create-react-context: ^0.4.0
- path-to-regexp: ^1.7.0
- prop-types: ^15.6.2
- react-is: ^16.6.0
- tiny-invariant: ^1.0.2
- tiny-warning: ^1.0.0
- peerDependencies:
- react: ">=15"
- checksum: 52a9f28fa97577fda18a8ed2922b658704eafe873e444fe07202640d55d9e81e67c03efd2b2a5b80e3a80e8be8352df826a227ce5f42b33b91bef853c74d4841
- languageName: node
- linkType: hard
-
"react-router@npm:6.3.0, react-router@npm:^6.0.0":
version: 6.3.0
resolution: "react-router@npm:6.3.0"
@@ -24492,13 +24370,6 @@ __metadata:
languageName: node
linkType: hard
-"resolve-pathname@npm:^3.0.0":
- version: 3.0.0
- resolution: "resolve-pathname@npm:3.0.0"
- checksum: 6147241ba42c423dbe83cb067a2b4af4f60908c3af57e1ea567729cc71416c089737fe2a73e9e79e7a60f00f66c91e4b45ad0d37cd4be2d43fec44963ef14368
- languageName: node
- linkType: hard
-
"resolve-url@npm:^0.2.1":
version: 0.2.1
resolution: "resolve-url@npm:0.2.1"
@@ -25296,8 +25167,6 @@ __metadata:
"@types/react-dom": ^17.0.9
"@types/react-instantsearch-dom": ^6.10.1
"@types/react-redux": ^7.1.23
- "@types/react-router": ^5.1.18
- "@types/react-router-dom": ^5.3.3
"@types/recharts": ^1.8.16
"@types/serve-static": ^1.13.10
"@types/styled-components": ^5.1.24
@@ -25328,9 +25197,7 @@ __metadata:
react-instantsearch: ^6.11.2
react-instantsearch-dom: ^6.11.2
react-redux: ^7.2.8
- react-router: ^5.3.3
- react-router-dom: ^5.3.3
- react-router-dom-v5-compat: ^6.3.0
+ react-router-dom: ^6.3.0
react-signature-pad-wrapper: ^1.2.11
react-spring: ^9.3.1
react-use-measure: ^2.0.4
@@ -26708,20 +26575,6 @@ __metadata:
languageName: node
linkType: hard
-"tiny-invariant@npm:^1.0.2":
- version: 1.2.0
- resolution: "tiny-invariant@npm:1.2.0"
- checksum: e09a718a7c4a499ba592cdac61f015d87427a0867ca07f50c11fd9b623f90cdba18937b515d4a5e4f43dac92370498d7bdaee0d0e7a377a61095e02c4a92eade
- languageName: node
- linkType: hard
-
-"tiny-warning@npm:^1.0.0, tiny-warning@npm:^1.0.3":
- version: 1.0.3
- resolution: "tiny-warning@npm:1.0.3"
- checksum: da62c4acac565902f0624b123eed6dd3509bc9a8d30c06e017104bedcf5d35810da8ff72864400ad19c5c7806fc0a8323c68baf3e326af7cb7d969f846100d71
- languageName: node
- linkType: hard
-
"tinypool@npm:^0.1.2, tinypool@npm:^0.1.3":
version: 0.1.3
resolution: "tinypool@npm:0.1.3"
@@ -27862,13 +27715,6 @@ __metadata:
languageName: node
linkType: hard
-"value-equal@npm:^1.0.1":
- version: 1.0.1
- resolution: "value-equal@npm:1.0.1"
- checksum: bb7ae1facc76b5cf8071aeb6c13d284d023fdb370478d10a5d64508e0e6e53bb459c4bbe34258df29d82e6f561f874f0105eba38de0e61fe9edd0bdce07a77a2
- languageName: node
- linkType: hard
-
"value-or-function@npm:^3.0.0":
version: 3.0.0
resolution: "value-or-function@npm:3.0.0"