Corrige les liens vers la doc depuis le comparateur
parent
0cc4038665
commit
052d69d003
|
@ -3,15 +3,15 @@ import { Route, Routes, useNavigate } from 'react-router-dom'
|
|||
import Popover from '@/design-system/popover/Popover'
|
||||
import Documentation from '@/pages/Documentation'
|
||||
import { EngineComparison } from '@/pages/simulateurs/comparaison-statuts/components/Comparateur'
|
||||
import { useSitePaths } from '@/sitePaths'
|
||||
|
||||
export function EngineDocumentationRoutes({
|
||||
namedEngines,
|
||||
basePath,
|
||||
}: {
|
||||
namedEngines: EngineComparison
|
||||
basePath: string
|
||||
}) {
|
||||
const navigate = useNavigate()
|
||||
const { absoluteSitePaths } = useSitePaths()
|
||||
|
||||
return (
|
||||
<Routes>
|
||||
|
@ -25,14 +25,14 @@ export function EngineDocumentationRoutes({
|
|||
isOpen
|
||||
isDismissable
|
||||
onClose={() => {
|
||||
navigate(absoluteSitePaths.simulateurs.comparaison, {
|
||||
navigate(basePath, {
|
||||
replace: true,
|
||||
})
|
||||
}}
|
||||
>
|
||||
<Documentation
|
||||
engine={engine}
|
||||
documentationPath={`/simulateurs/comparaison-régimes-sociaux/${name}`}
|
||||
documentationPath={`${basePath}/${name}`}
|
||||
/>
|
||||
</Popover>
|
||||
</div>
|
||||
|
|
|
@ -13,7 +13,7 @@ const stepOrder: readonly Step[] = [
|
|||
'association',
|
||||
'associé',
|
||||
'rémunération',
|
||||
'statuts',
|
||||
'comparateur',
|
||||
] as const
|
||||
|
||||
export function useCurrentStep() {
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
import { useMemo } from 'react'
|
||||
|
||||
import { EngineDocumentationRoutes } from '@/components/EngineDocumentationRoutes'
|
||||
import { Statut } from '@/components/StatutTag'
|
||||
import { useEngine, useRawSituation } from '@/components/utils/EngineContext'
|
||||
import { EngineComparison } from '@/pages/simulateurs/comparaison-statuts/components/Comparateur'
|
||||
import Détails from '@/pages/simulateurs/comparaison-statuts/components/Détails'
|
||||
import Résultats from '@/pages/simulateurs/comparaison-statuts/components/Résultats'
|
||||
import { useCasParticuliers } from '@/pages/simulateurs/comparaison-statuts/contexts/CasParticuliers'
|
||||
import { useSitePaths } from '@/sitePaths'
|
||||
import { Situation } from '@/store/reducers/rootReducer'
|
||||
|
||||
export default function Comparateur() {
|
||||
const namedEngines = useStatutComparaison()
|
||||
const { absoluteSitePaths } = useSitePaths()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Résultats namedEngines={namedEngines} />
|
||||
<Détails namedEngines={namedEngines} />
|
||||
<EngineDocumentationRoutes
|
||||
namedEngines={namedEngines}
|
||||
basePath={absoluteSitePaths.assistants['choix-du-statut'].comparateur}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the situation for computing the results with the given statut
|
||||
* @param statut
|
||||
*/
|
||||
function useStatutComparaison(): EngineComparison {
|
||||
const { isAutoEntrepreneurACREEnabled } = useCasParticuliers()
|
||||
const possibleStatuts = usePossibleStatuts()
|
||||
console.log(possibleStatuts)
|
||||
const situation = useRawSituation()
|
||||
const engine = useEngine()
|
||||
|
||||
return useMemo(
|
||||
() =>
|
||||
possibleStatuts.map((statut) => ({
|
||||
name: statut,
|
||||
engine: engine.shallowCopy().setSituation({
|
||||
...situation,
|
||||
...getSituationFromStatut(statut, isAutoEntrepreneurACREEnabled),
|
||||
}),
|
||||
})) as EngineComparison,
|
||||
[possibleStatuts, isAutoEntrepreneurACREEnabled]
|
||||
)
|
||||
}
|
||||
|
||||
function usePossibleStatuts(): Array<Statut> {
|
||||
const engine = useEngine()
|
||||
// We could do this logic by filtering the applicable status in publicodes,
|
||||
// but for now, there is only two options, so we hardcode it
|
||||
if (
|
||||
engine.evaluate('entreprise . catégorie juridique . EI = non').nodeValue ===
|
||||
true
|
||||
) {
|
||||
return ['SASU', 'SARL']
|
||||
} else {
|
||||
return ['SASU', 'EI', 'AE']
|
||||
}
|
||||
}
|
||||
|
||||
function getSituationFromStatut(statut: Statut, AEAcre: boolean): Situation {
|
||||
return {
|
||||
'entreprise . catégorie juridique . remplacements': 'oui',
|
||||
'entreprise . catégorie juridique':
|
||||
statut === 'SASU'
|
||||
? "'SAS'"
|
||||
: statut === 'EURL'
|
||||
? "'EURL'"
|
||||
: statut === 'AE'
|
||||
? "'EI'"
|
||||
: statut === 'SELARLU'
|
||||
? "'SELARL'"
|
||||
: statut === 'SELASU'
|
||||
? "'SELAS'"
|
||||
: `'${statut}'`,
|
||||
'entreprise . catégorie juridique . EI . auto-entrepreneur':
|
||||
statut === 'AE' ? 'oui' : 'non',
|
||||
'entreprise . imposition': "'IS'",
|
||||
'entreprise . associés': ['SARL', 'SAS', 'SELAS', 'SELARL'].includes(statut)
|
||||
? "'multiple'"
|
||||
: "'unique'",
|
||||
...(AEAcre ? { 'dirigeant . exonérations . ACRE': 'oui' } : {}),
|
||||
}
|
||||
}
|
|
@ -32,6 +32,7 @@ export function choixStatutJuridiqueConfig({
|
|||
simulation: {
|
||||
situation: {
|
||||
'entreprise . catégorie juridique . remplacements': 'non',
|
||||
salarié: 'non',
|
||||
},
|
||||
},
|
||||
autoloadLastSimulation: true,
|
||||
|
|
|
@ -7,12 +7,12 @@ import { useCurrentStep } from './_components/useSteps'
|
|||
import Association from './association'
|
||||
import Associé from './associé'
|
||||
import Commune from './commune'
|
||||
import Comparateur from './comparateur'
|
||||
import DétailsActivité from './détails-activité'
|
||||
import AccueilChoixStatut from './home'
|
||||
import RechercheActivité from './recherche-activité'
|
||||
import Rémunération from './rémunération'
|
||||
import Résultat from './résultat'
|
||||
import Statuts from './statuts'
|
||||
|
||||
export default function ChoixDuStatut() {
|
||||
const { relativeSitePaths } = useSitePaths()
|
||||
|
@ -32,12 +32,21 @@ export default function ChoixDuStatut() {
|
|||
path={childrenPaths['détails-activité']}
|
||||
element={<DétailsActivité />}
|
||||
/>
|
||||
<Route path={childrenPaths.commune} element={<Commune />} />
|
||||
<Route path={childrenPaths.associé} element={<Associé />} />
|
||||
<Route path={childrenPaths.association} element={<Association />} />
|
||||
<Route path={childrenPaths.rémunération} element={<Rémunération />} />
|
||||
<Route path={childrenPaths.résultat} element={<Résultat />} />
|
||||
<Route path={childrenPaths.statuts} element={<Statuts />} />
|
||||
<Route path={`${childrenPaths.commune}/*`} element={<Commune />} />
|
||||
<Route path={`${childrenPaths.associé}/*`} element={<Associé />} />
|
||||
<Route
|
||||
path={`${childrenPaths.association}/*`}
|
||||
element={<Association />}
|
||||
/>
|
||||
<Route
|
||||
path={`${childrenPaths.rémunération}/*`}
|
||||
element={<Rémunération />}
|
||||
/>
|
||||
<Route path={`${childrenPaths.résultat}/*`} element={<Résultat />} />
|
||||
<Route
|
||||
path={`${childrenPaths.comparateur}/*`}
|
||||
element={<Comparateur />}
|
||||
/>
|
||||
</Routes>
|
||||
</>
|
||||
)
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
import ComparateurStatuts from '@/pages/simulateurs/comparaison-statuts'
|
||||
|
||||
export default function Statuts() {
|
||||
return <ComparateurStatuts />
|
||||
}
|
|
@ -10,6 +10,7 @@ import Simulation, {
|
|||
} from '@/components/Simulation'
|
||||
import { Statut } from '@/components/StatutTag'
|
||||
import { Spacing } from '@/design-system/layout'
|
||||
import { useSitePaths } from '@/sitePaths'
|
||||
|
||||
import Détails from './Détails'
|
||||
import Résultats from './Résultats'
|
||||
|
@ -19,7 +20,9 @@ type NamedEngine = {
|
|||
name: Statut
|
||||
}
|
||||
|
||||
export type EngineComparison = [NamedEngine, NamedEngine, NamedEngine]
|
||||
export type EngineComparison =
|
||||
| [NamedEngine, NamedEngine, NamedEngine]
|
||||
| [NamedEngine, NamedEngine]
|
||||
|
||||
function Comparateur({ namedEngines }: { namedEngines: EngineComparison }) {
|
||||
const { t } = useTranslation()
|
||||
|
@ -30,6 +33,8 @@ function Comparateur({ namedEngines }: { namedEngines: EngineComparison }) {
|
|||
Engine<DottedName>
|
||||
]
|
||||
|
||||
const { absoluteSitePaths } = useSitePaths()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Simulation
|
||||
|
@ -54,7 +59,10 @@ function Comparateur({ namedEngines }: { namedEngines: EngineComparison }) {
|
|||
<Spacing md />
|
||||
<Résultats namedEngines={namedEngines} />
|
||||
<Détails namedEngines={namedEngines} />
|
||||
<EngineDocumentationRoutes namedEngines={namedEngines} />
|
||||
<EngineDocumentationRoutes
|
||||
basePath={absoluteSitePaths.simulateurs.comparaison}
|
||||
namedEngines={namedEngines}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ const DetailsRowCards = ({
|
|||
warning?: (engine: Engine<DottedName>) => ReactNode
|
||||
footer?: (engine: Engine<DottedName>) => ReactNode
|
||||
}) => {
|
||||
console.log(namedEngines)
|
||||
const options = namedEngines.map(({ engine, name }) => ({
|
||||
engine,
|
||||
name,
|
||||
|
@ -104,7 +103,7 @@ const DetailsRowCards = ({
|
|||
>
|
||||
<DisabledLabel>Ne s'applique pas</DisabledLabel>
|
||||
<StyledRuleLink
|
||||
documentationPath={`/simulateurs/comparaison-régimes-sociaux/${statusObject.name}`}
|
||||
documentationPath={`${statusObject.name}`}
|
||||
dottedName={dottedName}
|
||||
engine={statusObject.engine}
|
||||
>
|
||||
|
@ -128,7 +127,7 @@ const DetailsRowCards = ({
|
|||
{label && label}
|
||||
</span>
|
||||
<StyledRuleLink
|
||||
documentationPath={`/simulateurs/comparaison-régimes-sociaux/${statusObject.name}`}
|
||||
documentationPath={`${statusObject.name}`}
|
||||
dottedName={dottedName}
|
||||
engine={statusObject.engine}
|
||||
>
|
||||
|
|
|
@ -34,7 +34,7 @@ const rawSitePathsFr = {
|
|||
association: 'association',
|
||||
associé: 'associe',
|
||||
rémunération: 'remuneration',
|
||||
statuts: 'statuts',
|
||||
comparateur: 'comparateur',
|
||||
résultat: 'resultat',
|
||||
},
|
||||
},
|
||||
|
@ -120,7 +120,7 @@ const rawSitePathsEn = {
|
|||
association: 'association',
|
||||
associé: 'partnership',
|
||||
rémunération: 'remuneration',
|
||||
statuts: 'statuts',
|
||||
comparateur: 'comparator',
|
||||
résultat: 'result',
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue