Transform and refacto créer to assistants/choix-du-statut

pull/2529/head
Jérémy Rialland 2023-03-02 15:29:29 +01:00 committed by Johan Girod
parent 9996d69b95
commit 2c8afdbb93
29 changed files with 233 additions and 172 deletions

View File

@ -17,7 +17,7 @@ export const pagesToPrerender: {
} = {
'mon-entreprise': [
sitePathFr.index,
sitePathFr.créer.index,
sitePathFr.assistants['choix-du-statut'].index,
sitePathFr.simulateurs.index,
sitePathFr.simulateurs.salarié,
sitePathFr.simulateurs['chômage-partiel'],

View File

@ -23,7 +23,6 @@ import { useIsEmbedded } from '@/hooks/useIsEmbedded'
import { useSaveAndRestoreScrollPosition } from '@/hooks/useSaveAndRestoreScrollPosition'
import Accessibilité from '@/pages/Accessibilité'
import Budget from '@/pages/Budget/Budget'
import Créer from '@/pages/Creer'
import IntegrationTest from '@/pages/Dev/IntegrationTest'
import Documentation from '@/pages/Documentation'
import Iframes from '@/pages/Iframes'
@ -166,10 +165,6 @@ const App = () => {
<Container>
<ErrorBoundary fallback={CatchOffline}>
<Routes>
<Route
path={relativeSitePaths.créer.index + '/*'}
element={<Créer />}
/>
<Route
path={relativeSitePaths.assistants.index + '/*'}
element={<Assistants />}

View File

@ -30,7 +30,7 @@ export const useFeedback = () => {
![
absoluteSitePaths.documentation.index,
absoluteSitePaths.assistants.index,
absoluteSitePaths.créer.index,
absoluteSitePaths.assistants['choix-du-statut'].index,
absoluteSitePaths.nouveautés,
absoluteSitePaths.stats,
absoluteSitePaths.développeur.index,

View File

@ -1,41 +0,0 @@
import { Route, Routes, useLocation } from 'react-router-dom'
import { TrackChapter } from '@/components/ATInternetTracking'
import { ScrollToTop } from '@/components/utils/Scroll'
import { LANDING_LEGAL_STATUS_LIST, useSitePaths } from '../../sitePaths'
import AfterRegistration from './AfterRegistration'
import CreationChecklist from './CreationChecklist'
import GuideStatut from './GuideStatut'
import Home from './choix-statut/Home'
export default function CreateMyCompany() {
const { relativeSitePaths } = useSitePaths()
const location = useLocation()
return (
<>
<ScrollToTop key={location.pathname} />
<TrackChapter chapter1="creer">
<Routes>
<Route index element={<Home />} />
{LANDING_LEGAL_STATUS_LIST.map((statut) => (
<Route
key={statut}
path={relativeSitePaths.créer[statut]}
element={<CreationChecklist statut={statut} />}
/>
))}
<Route
path={relativeSitePaths.créer.après}
element={<AfterRegistration />}
/>
<Route
path={relativeSitePaths.créer.guideStatut.index + '/*'}
element={<GuideStatut />}
/>
</Routes>
</TrackChapter>
</>
)
}

View File

@ -99,8 +99,10 @@ export default function SearchOrCreate() {
role="link"
to={
statutChoisi
? absoluteSitePaths.créer[statutChoisi]
: absoluteSitePaths.créer.index
? absoluteSitePaths.assistants['choix-du-statut'][
statutChoisi
]
: absoluteSitePaths.assistants['choix-du-statut'].index
}
aria-label={t(
'landing.choice.create.aria-label',

View File

@ -40,7 +40,9 @@ export default function Plan() {
</Li>
<Li>
<H3 as="h2">
<HeaderLink to={absoluteSitePaths.créer.index}>
<HeaderLink
to={absoluteSitePaths.assistants['choix-du-statut'].index}
>
<Trans>Créer une entreprise</Trans>
</HeaderLink>
</H3>
@ -48,14 +50,21 @@ export default function Plan() {
<Ul>
<Li>
<H3 as="h2">
<Link to={absoluteSitePaths.créer.après}>
<Link
to={absoluteSitePaths.assistants['choix-du-statut'].après}
>
<Trans>Après la création</Trans>
</Link>
</H3>
</Li>
<Li>
<H3 as="h2">
<Link to={absoluteSitePaths.créer.guideStatut.index}>
<Link
to={
absoluteSitePaths.assistants['choix-du-statut'].guideStatut
.index
}
>
<Trans>Choix du statut juridique</Trans>
</Link>
</H3>

View File

@ -5,12 +5,13 @@ import { useEngine } from '@/components/utils/EngineContext'
import { Grid } from '@/design-system/layout'
import { H2 } from '@/design-system/typography/heading'
import { MergedSimulatorDataValues } from '@/hooks/useCurrentSimulatorData'
import { FAQAutoEntrepreneurArticle } from '@/pages/Creer/CreationChecklist'
import { GuideURSSAFCard } from '@/pages/Simulateurs/cards/GuideURSSAFCard'
import { IframeIntegrationCard } from '@/pages/Simulateurs/cards/IframeIntegrationCard'
import { SimulatorRessourceCard } from '@/pages/Simulateurs/cards/SimulatorRessourceCard'
import { useSitePaths } from '@/sitePaths'
import { FAQAutoEntrepreneurArticle } from '../assistants/choix-du-statut/CreationChecklist'
interface NextStepsProps {
iframePath?: MergedSimulatorDataValues['iframePath']
nextSteps: MergedSimulatorDataValues['nextSteps']

View File

@ -60,7 +60,10 @@ export default function Simulateurs() {
<span aria-hidden></span> <Trans>Retour à mon activité</Trans>
</Link>
) : lastState?.fromCréer ? (
<Link to={absoluteSitePaths.créer.index} noUnderline>
<Link
to={absoluteSitePaths.assistants['choix-du-statut'].index}
noUnderline
>
<span aria-hidden></span> <Trans>Retour à la création</Trans>
</Link>
) : !isEmbedded ? (

View File

@ -1,6 +1,6 @@
import { ImmutableType } from '@/types/utils'
import { choixStatutConfig } from '../Creer/choix-statut/config'
import { choixStatutJuridiqueConfig } from '../assistants/choix-du-statut/choix-statut-juridique/config'
import { déclarationChargesSocialesIndépendantConfig } from '../assistants/declaration-charges-sociales-independant/config'
import { déclarationRevenuIndépendantBetaConfig } from '../assistants/declaration-revenu-independants/config'
import { demandeMobilitéConfig } from '../assistants/demande-mobilité/config'
@ -51,7 +51,6 @@ const getMetadataSrc = (params: SimulatorsDataParams) => {
...chômagePartielConfig(params),
...comparaisonStatutsConfig(params),
...économieCollaborativeConfig(params),
...choixStatutConfig(params),
...pharmacienConfig(params),
...médecinConfig(params),
...chirurgienDentisteConfig(params),
@ -67,11 +66,12 @@ const getMetadataSrc = (params: SimulatorsDataParams) => {
...cipavConfig(params),
// assistants:
...choixStatutJuridiqueConfig(params),
...déclarationChargesSocialesIndépendantConfig(params),
...déclarationRevenuIndépendantBetaConfig(params),
...demandeMobilitéConfig(params),
...rechercheCodeApeConfig(params),
...pourMonEntrepriseConfig(params),
...rechercheCodeApeConfig(params),
} as const
return data satisfies ImmutableType<Record<string, PageConfig>>

View File

@ -82,7 +82,10 @@ export default function VotreSituation() {
concernées (et le changer si besoin). Sinon, vous aurez à créer
une nouvelle entreprise.
</Body>
<Button to={absoluteSitePaths.créer.index} light>
<Button
to={absoluteSitePaths.assistants['choix-du-statut'].index}
light
>
Créer une entreprise
</Button>
</Trans>

View File

@ -28,7 +28,10 @@ export default function AfterRegistration() {
</DefaultHelmet>
<ScrollToTop />
<TrackPage name="apres_la_creation" />
<Link noUnderline to={absoluteSitePaths.créer.index}>
<Link
noUnderline
to={absoluteSitePaths.assistants['choix-du-statut'].index}
>
<span aria-hidden></span> <Trans>Retour à la création</Trans>
</Link>
<H1>

View File

@ -76,7 +76,7 @@ export default function CreateCompany({ statut }: CreateCompanyProps) {
</DefaultHelmet>
<Scroll.toTop />
<Link
to={absoluteSitePaths.créer.index}
to={absoluteSitePaths.assistants['choix-du-statut'].index}
onPress={() => {
dispatch(resetCompanyStatusChoice())
}}
@ -547,7 +547,7 @@ export default function CreateCompany({ statut }: CreateCompanyProps) {
</Trans>
</h3>
}
to={absoluteSitePaths.créer.après}
to={absoluteSitePaths.assistants['choix-du-statut'].après}
ctaLabel={t('entreprise.ressources.après.cta', 'Voir le glossaire')}
>
<Trans i18nKey="entreprise.ressources.après.body">

View File

@ -24,7 +24,11 @@ const StatutButton = ({ statut }: StatutButtonProps) => {
const { t } = useTranslation()
return (
<Button to={absoluteSitePaths.créer[statut]} light size="XS">
<Button
to={absoluteSitePaths.assistants['choix-du-statut'][statut]}
light
size="XS"
>
<>
{statut.includes('auto-entrepreneur') ? (
<Trans>Devenir</Trans>

View File

@ -94,7 +94,7 @@ export default function PreviousAnswers() {
<PreviousAnswersItem key={key}>
<Link
to={
absoluteSitePaths.créer.guideStatut[
absoluteSitePaths.assistants['choix-du-statut'].guideStatut[
key as keyof typeof legalStatus
]
}

View File

@ -31,7 +31,7 @@ const useResetFollowingAnswers = () => {
)
useEffect(() => {
const companyStatusCurrentQuestionName = (Object.entries(
absoluteSitePaths.créer.guideStatut
absoluteSitePaths.assistants['choix-du-statut'].guideStatut
).find(([, pathname]) => location.pathname === pathname) || [])[0]
if (!companyStatusCurrentQuestionName) {
return
@ -48,7 +48,7 @@ const useResetFollowingAnswers = () => {
)
)
}
}, [location.pathname, dispatch, absoluteSitePaths.créer.guideStatut])
}, [location.pathname, dispatch, absoluteSitePaths.assistants])
}
export default function Créer() {
@ -58,7 +58,7 @@ export default function Créer() {
return (
<>
<Link to={absoluteSitePaths.créer.index}>
<Link to={absoluteSitePaths.assistants['choix-du-statut'].index}>
<span aria-hidden></span> <Trans>Retour</Trans>
</Link>
<TrackChapter chapter2="guide">
@ -71,34 +71,55 @@ export default function Créer() {
<FromBottom key={location.pathname}>
<Routes>
<Route
path={relativeSitePaths.créer.guideStatut.soleProprietorship}
path={
relativeSitePaths.assistants['choix-du-statut'].guideStatut
.soleProprietorship
}
element={<SoleProprietorship />}
/>
<Route
path={relativeSitePaths.créer.guideStatut.directorStatus}
path={
relativeSitePaths.assistants['choix-du-statut'].guideStatut
.directorStatus
}
element={<DirectorStatus />}
/>
<Route
path={relativeSitePaths.créer.guideStatut.autoEntrepreneur}
path={
relativeSitePaths.assistants['choix-du-statut'].guideStatut
.autoEntrepreneur
}
element={<AutoEntrepreneur />}
/>
<Route
path={relativeSitePaths.créer.guideStatut.multipleAssociates}
path={
relativeSitePaths.assistants['choix-du-statut'].guideStatut
.multipleAssociates
}
element={<NumberOfAssociate />}
/>
<Route
path={relativeSitePaths.créer.guideStatut.minorityDirector}
path={
relativeSitePaths.assistants['choix-du-statut'].guideStatut
.minorityDirector
}
element={<MinorityDirector />}
/>
<Route
path={relativeSitePaths.créer.guideStatut.liste}
path={
relativeSitePaths.assistants['choix-du-statut'].guideStatut
.liste
}
element={<PickLegalStatus />}
/>
<Route
index
element={
<Navigate
to={absoluteSitePaths.créer.guideStatut.liste}
to={
absoluteSitePaths.assistants['choix-du-statut'].guideStatut
.liste
}
replace
/>
}

View File

@ -1,11 +1,21 @@
import { config } from '../../Simulateurs/configs/config'
import { SimulatorsDataParams } from '../../Simulateurs/configs/types'
import Créer from './Home'
// import {NavigateToChoixStatutJuridique} from '.'
export function choixStatutConfig({ t, sitePaths }: SimulatorsDataParams) {
import { NavigateToChoixStatutJuridique } from '.'
import ChoixDuStatut from '..'
import { config } from '../../../Simulateurs/configs/config'
import { SimulatorsDataParams } from '../../../Simulateurs/configs/types'
import GuideStatut from '../GuideStatut'
export function choixStatutJuridiqueConfig({
t,
sitePaths,
}: SimulatorsDataParams) {
return config({
id: 'choix-statut',
path: sitePaths.créer.guideStatut.index,
pathId: 'assistants.choix-du-statut.guideStatut.index',
path: sitePaths.assistants['choix-du-statut'].index,
iframePath: 'choix-statut-juridique',
icône: '📚',
tracking: {
chapter1: 'creer',
chapter2: 'guide',
@ -20,14 +30,11 @@ export function choixStatutConfig({ t, sitePaths }: SimulatorsDataParams) {
'SASU, EURL, auto-entrepreneur, EIRL : choisissez le statut qui vous convient le mieux grâce à cet assistant'
),
},
icône: '📚',
pathId: 'créer.guideStatut.index',
title: t(
'pages.choix-statut.title',
'Assistant au choix du statut juridique'
),
iframePath: 'choix-statut-juridique',
shortName: t('pages.choix-statut.shortname', 'Assistant statut juridique'),
component: Créer,
component: ChoixDuStatut,
} as const)
}

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -15,10 +15,10 @@ import { useSitePaths } from '@/sitePaths'
import { RootState } from '@/store/reducers/rootReducer'
import { useNextQuestionUrl } from '@/store/selectors/companyStatusSelectors'
import { SimulateurCard } from '../../Simulateurs/Home'
import { SimulateurCard } from '../../../Simulateurs/Home'
import créerSvg from './créer.svg'
export default function Créer() {
export default function ChoixStatutJuridique() {
const { t } = useTranslation()
const { absoluteSitePaths } = useSitePaths()
const nextQuestionUrl = useNextQuestionUrl()
@ -54,7 +54,8 @@ export default function Créer() {
to={
guideAlreadyStarted && nextQuestionUrl
? nextQuestionUrl
: absoluteSitePaths.créer.guideStatut.multipleAssociates
: absoluteSitePaths.assistants['choix-du-statut'].guideStatut
.multipleAssociates
}
>
{!guideAlreadyStarted
@ -90,7 +91,11 @@ export default function Créer() {
'créer.ressources.autoEntrepreneur.title',
'Démarche auto-entrepreneur'
)}
to={absoluteSitePaths.créer['auto-entrepreneur']}
to={
absoluteSitePaths.assistants['choix-du-statut'][
'auto-entrepreneur'
]
}
ctaLabel={t(
'créer.ressources.autoEntrepreneur.cta',
'Consulter les démarches'

View File

@ -0,0 +1,41 @@
import { Route, Routes, useLocation } from 'react-router-dom'
import { ScrollToTop } from '@/components/utils/Scroll'
import { LANDING_LEGAL_STATUS_LIST, useSitePaths } from '@/sitePaths'
import AfterRegistration from './AfterRegistration'
import CreationChecklist from './CreationChecklist'
import GuideStatut from './GuideStatut'
import ChoixStatutJuridique from './choix-statut-juridique'
export default function ChoixDuStatut() {
const { relativeSitePaths } = useSitePaths()
const location = useLocation()
return (
<>
<ScrollToTop key={location.pathname} />
<Routes>
<Route index element={<ChoixStatutJuridique />} />
{LANDING_LEGAL_STATUS_LIST.map((statut) => (
<Route
key={statut}
path={relativeSitePaths.assistants['choix-du-statut'][statut]}
element={<CreationChecklist statut={statut} />}
/>
))}
<Route
path={relativeSitePaths.assistants['choix-du-statut'].après}
element={<AfterRegistration />}
/>
<Route
path={
relativeSitePaths.assistants['choix-du-statut'].guideStatut.index +
'/*'
}
element={<GuideStatut />}
/>
</Routes>
</>
)
}

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -9,6 +9,7 @@ import { Link } from '@/design-system/typography/link'
import useSimulatorsData from '@/hooks/useSimulatorsData'
import { useSitePaths } from '@/sitePaths'
import ChoixDuStatut from './choix-du-statut'
import Embaucher from './embaucher'
import SocialSecurity from './sécurité-sociale'
@ -27,47 +28,52 @@ export default function Gérer() {
<>
<ScrollToTop key={location.pathname} />
<TrackChapter chapter1="gerer">
<Routes>
{/* <Route index element={<Home />} /> Navigate to /simu-et-assist */}
<Route
path={relativeSitePaths.assistants.sécuritéSociale}
element={
<>
{back}
<SocialSecurity />
</>
}
/>
<Route
path={relativeSitePaths.assistants.embaucher}
element={
<>
{back}
<Embaucher />
</>
}
/>
{Object.entries(simulateurs)
.filter(([, simu]) => simu.pathId.startsWith('assistants.'))
.map(([, simu]) => (
<Route
key={simu.path}
path={
simu.path.replace(absoluteSitePaths.assistants.index, '') +
'/*'
}
element={
<>
{back}
<PageData />
</>
}
/>
))}
<Route path="*" element={<Route404 />} />
</Routes>
</TrackChapter>
<Routes>
{/* <Route index element={<Home />} /> Navigate to /simu-et-assist */}
<Route
path={relativeSitePaths.assistants.sécuritéSociale}
element={
<TrackChapter chapter1="gerer">
{back}
<SocialSecurity />
</TrackChapter>
}
/>
<Route
path={relativeSitePaths.assistants.embaucher}
element={
<TrackChapter chapter1="gerer">
{back}
<Embaucher />
</TrackChapter>
}
/>
<Route
path={relativeSitePaths.assistants['choix-du-statut'].index + '/*'}
element={
<TrackChapter chapter1="creer">
<ChoixDuStatut />
</TrackChapter>
}
/>
{Object.entries(simulateurs)
.filter(([, simu]) => simu.pathId.startsWith('assistants.'))
.map(([, simu]) => (
<Route
key={simu.path}
path={
simu.path.replace(absoluteSitePaths.assistants.index, '') + '/*'
}
element={
<>
{back}
<PageData />
</>
}
/>
))}
<Route path="*" element={<Route404 />} />
</Routes>
</>
)
}

View File

@ -21,30 +21,18 @@ const status = Object.fromEntries(
const rawSitePathsFr = {
index: '',
créer: {
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',
},
},
assistants: {
index: 'assistants',
embaucher: 'embaucher',
sécuritéSociale: 'sécurité-sociale',
formulaireMobilité: 'demande-mobilité',
'recherche-code-ape': 'recherche-code-ape',
'déclaration-charges-sociales-indépendant':
'declaration-charges-sociales-independant',
'pour-mon-entreprise': {
index: 'pour-mon-entreprise',
entreprise: ':entreprise',
},
embaucher: 'embaucher',
sécuritéSociale: 'sécurité-sociale',
'déclaration-charges-sociales-indépendant':
'declaration-charges-sociales-independant',
déclarationIndépendant: {
index: 'aide-declaration-independants-v2',
entreprise: 'entreprise',
@ -52,8 +40,20 @@ const rawSitePathsFr = {
déclaration: 'declaration',
cotisations: 'cotisations',
},
formulaireMobilité: 'demande-mobilité',
'recherche-code-ape': 'recherche-code-ape',
'choix-du-statut': {
index: 'choix-du-statut',
...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',
},
},
},
simulateurs: {
index: 'simulateurs',
@ -106,30 +106,18 @@ const rawSitePathsFr = {
const rawSitePathsEn = {
...rawSitePathsFr,
créer: {
...rawSitePathsFr.créer,
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',
},
},
assistants: {
index: 'assistants',
embaucher: 'hiring',
sécuritéSociale: 'social-security',
formulaireMobilité: 'posting-demand',
'recherche-code-ape': 'search-code-ape',
'déclaration-charges-sociales-indépendant':
'declaration-social-charges-independent',
'pour-mon-entreprise': {
index: 'for-my-business',
entreprise: ':entreprise',
},
embaucher: 'hiring',
sécuritéSociale: 'social-security',
'déclaration-charges-sociales-indépendant':
'declaration-social-charges-independent',
déclarationIndépendant: {
index: 'declaration-aid-independent-v2',
imposition: 'taxation',
@ -137,8 +125,20 @@ const rawSitePathsEn = {
déclaration: 'declaration',
cotisations: 'contributions',
},
formulaireMobilité: 'posting-demand',
'recherche-code-ape': 'search-code-ape',
'choix-du-statut': {
...rawSitePathsFr.assistants['choix-du-statut'],
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',
},
},
},
simulateurs: {
index: 'calculators',
@ -210,10 +210,10 @@ type PathIds = MetadataSrc[keyof MetadataSrc]['pathId']
type RequiredPath = Required<UnionToIntersection<PathToType<PathIds, string>>>
// If there is a type error here, check rawSitePathsFr object matches the metadata-src.ts pathId
const checkedSitePathsFr: RequiredPath & typeof rawSitePathsFr = rawSitePathsFr
const checkedSitePathsFr = rawSitePathsFr satisfies RequiredPath
// If there is a type error here, check rawSitePathsEn object matches the metadata-src.ts pathId
const checkedSitePathsEn: RequiredPath & typeof rawSitePathsEn = rawSitePathsEn
const checkedSitePathsEn = rawSitePathsEn satisfies RequiredPath
type SitePathsFr = typeof checkedSitePathsFr
type SitePathsEn = typeof checkedSitePathsEn

View File

@ -184,8 +184,10 @@ export const useNextQuestionUrl = () => {
const nextQuestion = useSelector(nextQuestionSelector)
const { absoluteSitePaths } = useSitePaths()
if (!nextQuestion) {
return absoluteSitePaths.créer.guideStatut.liste
return absoluteSitePaths.assistants['choix-du-statut'].guideStatut.liste
}
return absoluteSitePaths.créer.guideStatut[nextQuestion]
return absoluteSitePaths.assistants['choix-du-statut'].guideStatut[
nextQuestion
]
}