diff --git a/modele-social/règles/declarations-indépendant/assistant-déclaration-revenu.yaml b/modele-social/règles/declarations-indépendant/assistant-déclaration-revenu.yaml index 4edefcc52..313f053d4 100644 --- a/modele-social/règles/declarations-indépendant/assistant-déclaration-revenu.yaml +++ b/modele-social/règles/declarations-indépendant/assistant-déclaration-revenu.yaml @@ -388,9 +388,9 @@ DRI . liasse . réel simplifié . c596: applicable si: entreprise . imposition . IR titre: '596' unité: € - résumé: Court terme meta: - requis: oui + facultatif: oui + résumé: Court terme DRI . liasse . réel normal: applicable si: entreprise . imposition . régime . réel normal @@ -549,6 +549,7 @@ DRI . déclaration revenus: possibilités: - déclarant 1 - déclarant 2 + par défaut: "'déclarant 1'" meta: affichage: toggle section: oui diff --git a/site/source/App.tsx b/site/source/App.tsx index fffae6630..2c9480278 100644 --- a/site/source/App.tsx +++ b/site/source/App.tsx @@ -38,7 +38,6 @@ import Simulateurs from './pages/Simulateurs' import Stats from './pages/Stats/LazyStats' import Provider, { ProviderProps } from './Provider' import redirects from './redirects' -import { RootState } from './reducers/rootReducer' import { constructLocalizedSitePath } from './sitePaths' type RootProps = { @@ -78,16 +77,14 @@ const Router = () => { const simulatorSituation = useSelector(situationSelector) const configSituation = useSelector(configSituationSelector) const companySituation = useSelector(companySituationSelector) - const DRISituation = useSelector((state: RootState) => state.DRISituation) const situation = useMemo( () => ({ - ...DRISituation, ...companySituation, ...configSituation, ...simulatorSituation, }), - [configSituation, simulatorSituation, companySituation, DRISituation] + [configSituation, simulatorSituation, companySituation] ) return ( diff --git a/site/source/components/PageData.tsx b/site/source/components/PageData.tsx index fa544985b..ea2bcd988 100644 --- a/site/source/components/PageData.tsx +++ b/site/source/components/PageData.tsx @@ -57,7 +57,7 @@ export default function PageData(props: PageDataProps) { typeof année === 'number' && année != 2022 ? ` - version ${année}` : '' const inIframe = useIsEmbedded() - useSimulationConfig(config) + useSimulationConfig(config, { path }) useSearchParamsSimulationSharing() // TODO : Move this logic elsewhere. diff --git a/site/source/components/PreviousSimulationBanner.tsx b/site/source/components/PreviousSimulationBanner.tsx index c127f0450..9e71da224 100644 --- a/site/source/components/PreviousSimulationBanner.tsx +++ b/site/source/components/PreviousSimulationBanner.tsx @@ -1,9 +1,9 @@ import { loadPreviousSimulation } from '@/actions/actions' import { Link } from '@/design-system/typography/link' -import { Trans } from 'react-i18next' -import { useDispatch, useSelector } from 'react-redux' import { RootState } from '@/reducers/rootReducer' import { firstStepCompletedSelector } from '@/selectors/simulationSelectors' +import { Trans } from 'react-i18next' +import { useDispatch, useSelector } from 'react-redux' import Banner from './Banner' export default function PreviousSimulationBanner() { diff --git a/site/source/components/SchemeComparaison.tsx b/site/source/components/SchemeComparaison.tsx index d2ca65228..622f3d1c9 100644 --- a/site/source/components/SchemeComparaison.tsx +++ b/site/source/components/SchemeComparaison.tsx @@ -5,26 +5,25 @@ import { } from '@/actions/companyStatusActions' import Value from '@/components/EngineValue' import Simulation from '@/components/Simulation' -import InfoBulle from '@/components/ui/InfoBulle' import AnswerGroup from '@/design-system/answer-group' import { Button } from '@/design-system/buttons' import { H2, H3 } from '@/design-system/typography/heading' import { SmallBody } from '@/design-system/typography/paragraphs' import revenusSVG from '@/images/revenus.svg' -import { useCallback, useMemo, useState } from 'react' +import { situationSelector } from '@/selectors/simulationSelectors' +import { Grid } from '@mui/material' +import { useCallback, useContext, useMemo, useState } from 'react' import { Trans } from 'react-i18next' import { useSelector } from 'react-redux' -import { situationSelector } from '@/selectors/simulationSelectors' import styled, { css } from 'styled-components' import dirigeantComparaison from '../pages/Simulateurs/configs/rémunération-dirigeant.yaml' import SeeAnswersButton from './conversation/SeeAnswersButton' import PeriodSwitch from './PeriodSwitch' -import { SimulationGoals, SimulationGoal } from './Simulation' - +import { SimulationGoal, SimulationGoals } from './Simulation' import Emoji from './utils/Emoji' import { useEngine } from './utils/EngineContext' +import { SitePathsContext } from './utils/SitePathsContext' import useSimulationConfig from './utils/useSimulationConfig' -import { Grid } from '@mui/material' type SchemeComparaisonProps = { hideAutoEntrepreneur?: boolean @@ -35,7 +34,10 @@ export default function SchemeComparaison({ hideAutoEntrepreneur = false, hideAssimiléSalarié = false, }: SchemeComparaisonProps) { - useSimulationConfig(dirigeantComparaison) + const sitePath = useContext(SitePathsContext) + useSimulationConfig(dirigeantComparaison, { + path: sitePath.simulateurs.comparaison, + }) const dispatch = useDispatchAndGoToNextQuestion() const engine = useEngine() diff --git a/site/source/components/ShareSimulationBanner/index.tsx b/site/source/components/ShareSimulationBanner/index.tsx index d587d7d9c..e7903e6ae 100644 --- a/site/source/components/ShareSimulationBanner/index.tsx +++ b/site/source/components/ShareSimulationBanner/index.tsx @@ -2,7 +2,6 @@ import Emoji from '@/components/utils/Emoji' import { PopoverWithTrigger } from '@/design-system' import { Button } from '@/design-system/buttons' import { Spacing } from '@/design-system/layout' -import { RootState } from '@/reducers/rootReducer' import { companySituationSelector, situationSelector, @@ -23,7 +22,6 @@ export function useUrl() { const situation = { ...useSelector(situationSelector), ...useSelector(companySituationSelector), - ...useSelector((state: RootState) => state.DRISituation), } const searchParams = useParamsFromSituation(situation) @@ -93,7 +91,6 @@ export default function ShareOrSaveSimulationBanner({ click_chapter1: 'feature:partage', click: 'démarré', }) - tracker.dispatch() startSharing().catch( // eslint-disable-next-line no-console (err) => console.error(err) diff --git a/site/source/components/utils/useSimulationConfig.ts b/site/source/components/utils/useSimulationConfig.ts index 7e9dc3184..2ef33dfe5 100644 --- a/site/source/components/utils/useSimulationConfig.ts +++ b/site/source/components/utils/useSimulationConfig.ts @@ -1,22 +1,25 @@ -import { setSimulationConfig } from '@/actions/actions' +import { loadPreviousSimulation, setSimulationConfig } from '@/actions/actions' import { SimulationConfig } from '@/reducers/rootReducer' import { configSelector } from '@/selectors/simulationSelectors' import { useEffect } from 'react' import { useDispatch, useSelector } from 'react-redux' -import { useHistory } from 'react-router' export default function useSimulationConfig( - config: SimulationConfig | undefined + config: SimulationConfig | undefined, + { + path, + autoloadLastSimulation = false, + }: { path: string; autoloadLastSimulation?: boolean } ) { const dispatch = useDispatch() - // TODO : Reading the URL here is buggy because when we do SPA navigation the - // "location" retrieved at this point is still the previous URL. What we - // actually need is to have a simulator identifier, which is currently not - // accessible from the situation config but is defined in the metadata file. - const url = useHistory().location.pathname.split('?')[0] const lastConfig = useSelector(configSelector) if (config && lastConfig !== config) { - dispatch(setSimulationConfig(config ?? {}, url)) + dispatch(setSimulationConfig(config ?? {}, path)) } + useEffect(() => { + if (autoloadLastSimulation) { + dispatch(loadPreviousSimulation()) + } + }, []) } diff --git a/site/source/pages/Simulateurs/AidesEmbauche/index.tsx b/site/source/pages/Simulateurs/AidesEmbauche/index.tsx index d91d1e89c..beacf8ea8 100644 --- a/site/source/pages/Simulateurs/AidesEmbauche/index.tsx +++ b/site/source/pages/Simulateurs/AidesEmbauche/index.tsx @@ -1,4 +1,3 @@ -import { Grid } from '@mui/material' import { HiddenOptionContext } from '@/components/conversation/ChoicesInput' import Conversation from '@/components/conversation/Conversation' import { FromTop } from '@/components/ui/animate' @@ -8,17 +7,17 @@ import { useEngine } from '@/components/utils/EngineContext' import { SitePathsContext } from '@/components/utils/SitePathsContext' import { useSimulationProgress } from '@/components/utils/useNextQuestion' import { useParamsFromSituation } from '@/components/utils/useSearchParamsSimulationSharing' -import useSimulationConfig from '@/components/utils/useSimulationConfig' import { Card } from '@/design-system/card' import { H2, H3 } from '@/design-system/typography/heading' import { Link } from '@/design-system/typography/link' import { Body } from '@/design-system/typography/paragraphs' +import { SimulationConfig, Situation } from '@/reducers/rootReducer' +import { Grid } from '@mui/material' import { DottedName } from 'modele-social' import Engine, { formatValue } from 'publicodes' import { partition } from 'ramda' import { useContext } from 'react' import { Trans, useTranslation } from 'react-i18next' -import { SimulationConfig, Situation } from '@/reducers/rootReducer' import { TrackPage } from '../../../ATInternetTracking' type AideDescriptor = { @@ -162,8 +161,6 @@ const config = { } as SimulationConfig export default function AidesEmbauche() { - useSimulationConfig(config) - return ( <> }> diff --git a/site/source/pages/Simulateurs/ImpôtSociété.tsx b/site/source/pages/Simulateurs/ImpôtSociété.tsx index b7885ad1f..e1d5a9482 100644 --- a/site/source/pages/Simulateurs/ImpôtSociété.tsx +++ b/site/source/pages/Simulateurs/ImpôtSociété.tsx @@ -5,12 +5,14 @@ import Notifications from '@/components/Notifications' import { SimulationGoal, SimulationGoals } from '@/components/Simulation' import { FromTop } from '@/components/ui/animate' import Warning from '@/components/ui/WarningBlock' +import { SitePathsContext } from '@/components/utils/SitePathsContext' import useSimulationConfig from '@/components/utils/useSimulationConfig' import { Body, Intro } from '@/design-system/typography/paragraphs' -import { Trans } from 'react-i18next' -import { useDispatch, useSelector } from 'react-redux' import { SimulationConfig } from '@/reducers/rootReducer' import { situationSelector } from '@/selectors/simulationSelectors' +import { useContext } from 'react' +import { Trans } from 'react-i18next' +import { useDispatch, useSelector } from 'react-redux' import styled from 'styled-components' import { TrackPage } from '../../ATInternetTracking' @@ -24,7 +26,9 @@ const ISConfig = { } as SimulationConfig export default function ISSimulation() { - useSimulationConfig(ISConfig) + const sitePaths = useContext(SitePathsContext) + + useSimulationConfig(ISConfig, { path: sitePaths.simulateurs.is }) return ( <> diff --git a/site/source/pages/gerer/declaration-charges-sociales-independant/index.tsx b/site/source/pages/gerer/declaration-charges-sociales-independant/index.tsx index 0b9d9ba6d..d68b585c8 100644 --- a/site/source/pages/gerer/declaration-charges-sociales-independant/index.tsx +++ b/site/source/pages/gerer/declaration-charges-sociales-independant/index.tsx @@ -6,6 +6,7 @@ import PreviousSimulationBanner from '@/components/PreviousSimulationBanner' import { FromTop } from '@/components/ui/animate' import Warning from '@/components/ui/WarningBlock' import { useEngine } from '@/components/utils/EngineContext' +import { SitePathsContext } from '@/components/utils/SitePathsContext' import useSimulationConfig from '@/components/utils/useSimulationConfig' import { Strong } from '@/design-system/typography' import { H2, H3 } from '@/design-system/typography/heading' @@ -13,7 +14,7 @@ import { Li, Ul } from '@/design-system/typography/list' import { Body, Intro, SmallBody } from '@/design-system/typography/paragraphs' import { situationSelector } from '@/selectors/simulationSelectors' import { Grid } from '@mui/material' -import { useCallback } from 'react' +import { useCallback, useContext } from 'react' import { Trans } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import styled from 'styled-components' @@ -25,7 +26,11 @@ import simulationConfig from './_config.yaml' import illustration from './_undraw_fill_in_mie5.svg' export default function AideDéclarationIndépendant() { - useSimulationConfig(simulationConfig) + const sitePaths = useContext(SitePathsContext) + useSimulationConfig(simulationConfig, { + path: sitePaths.gérer['déclaration-charges-sociales-indépendant'], + autoloadLastSimulation: true, + }) const situation = useSelector(situationSelector) return ( diff --git a/site/source/pages/gerer/declaration-revenu-independants/cotisations.tsx b/site/source/pages/gerer/declaration-revenu-independants/cotisations.tsx index dcef9ab79..f08af5c37 100644 --- a/site/source/pages/gerer/declaration-revenu-independants/cotisations.tsx +++ b/site/source/pages/gerer/declaration-revenu-independants/cotisations.tsx @@ -1,6 +1,6 @@ import Conversation from '@/components/conversation/Conversation' import Value, { WhenAlreadyDefined } from '@/components/EngineValue' -import { Appear, FromBottom, FromTop } from '@/components/ui/animate' +import { Appear, FromTop } from '@/components/ui/animate' import Progress from '@/components/ui/Progress' import { useEngine } from '@/components/utils/EngineContext' import { Markdown } from '@/components/utils/markdown' @@ -9,8 +9,7 @@ import { Message } from '@/design-system' import { Container, Spacing } from '@/design-system/layout' import { Strong } from '@/design-system/typography' import { H2 } from '@/design-system/typography/heading' -import { Link } from '@/design-system/typography/link' -import { Body, Intro } from '@/design-system/typography/paragraphs' +import { Intro } from '@/design-system/typography/paragraphs' import { Grid } from '@mui/material' export default function Cotisations() { diff --git a/site/source/pages/gerer/declaration-revenu-independants/declaration.tsx b/site/source/pages/gerer/declaration-revenu-independants/declaration.tsx index 0bbde1a5e..d85fc5a9b 100644 --- a/site/source/pages/gerer/declaration-revenu-independants/declaration.tsx +++ b/site/source/pages/gerer/declaration-revenu-independants/declaration.tsx @@ -1,6 +1,7 @@ -import { DottedName } from 'modele-social' +import { updateSituation } from '@/actions/actions' +import { ExplicableRule } from '@/components/conversation/Explicable' import RuleInput from '@/components/conversation/RuleInput' -import Value, { Condition, WhenApplicable } from '@/components/EngineValue' +import Value, { Condition } from '@/components/EngineValue' import ShareOrSaveSimulationBanner from '@/components/ShareSimulationBanner' import { FromTop } from '@/components/ui/animate' import { useEngine } from '@/components/utils/EngineContext' @@ -18,6 +19,7 @@ import { Body, Intro, SmallBody } from '@/design-system/typography/paragraphs' import { getMeta } from '@/utils' import { Grid } from '@mui/material' import { Item } from '@react-stately/collections' +import { DottedName } from 'modele-social' import { Rule, RuleNode } from 'publicodes' import { Fragment, @@ -28,12 +30,10 @@ import { useState, } from 'react' import { Trans, useTranslation } from 'react-i18next' +import { useDispatch } from 'react-redux' import styled, { css } from 'styled-components' import { SimpleField } from '../_components/Fields' import { useProgress } from './_components/hooks' -import { updateSituation } from '@/actions/actions' -import { useDispatch } from 'react-redux' -import { ExplicableRule } from '@/components/conversation/Explicable' interface Meta { requis?: 'oui' | 'non' @@ -97,15 +97,16 @@ export default function Déclaration() { -

Aide au remplissage de la déclaration de revenu

- Nous allons maintenant vous indiquer comment remplir votre - déclaration de revenu personnelle à partir de la déclaration de - résultat de votre entreprise. + Nous allons maintenant vous indiquer comment{' '} + remplir votre déclaration de revenu personnelle{' '} + à partir de la déclaration de résultat de votre entreprise. -

Où trouver la déclaration de résultat de l'entreprise ?

+

+ Où trouver la déclaration de résultat de l'entreprise ? +

C'est le comptable qui se charge de remplir la déclaration de @@ -221,10 +222,12 @@ export default function Déclaration() {
-

Renseignements complémentaires

+ +

Renseignements complémentaires

- - + + +
@@ -284,7 +287,9 @@ function LiasseFiscale() { ) : ( - + + + ) )} diff --git a/site/source/pages/gerer/declaration-revenu-independants/entreprise.tsx b/site/source/pages/gerer/declaration-revenu-independants/entreprise.tsx index 00bf24baf..be8114456 100644 --- a/site/source/pages/gerer/declaration-revenu-independants/entreprise.tsx +++ b/site/source/pages/gerer/declaration-revenu-independants/entreprise.tsx @@ -1,6 +1,5 @@ import { DottedName } from '@/../../modele-social' import { resetCompany } from '@/actions/companyActions' -import { useSetEntreprise } from '@/hooks/useSetEntreprise' import { CompanyDetails } from '@/components/company/Details' import { CompanySearchField } from '@/components/company/SearchField' import { @@ -8,7 +7,8 @@ import { WhenApplicable, WhenNotAlreadyDefined, } from '@/components/EngineValue' -import { FromBottom, FromTop } from '@/components/ui/animate' +import PageHeader from '@/components/PageHeader' +import { FromTop } from '@/components/ui/animate' import { useEngine } from '@/components/utils/EngineContext' import { Markdown } from '@/components/utils/markdown' import { SitePathsContext } from '@/components/utils/SitePathsContext' @@ -18,17 +18,17 @@ import { Spacing } from '@/design-system/layout' import { Strong } from '@/design-system/typography' import { H3 } from '@/design-system/typography/heading' import { Link } from '@/design-system/typography/link' +import { Li, Ul } from '@/design-system/typography/list' import { Body, Intro, SmallBody } from '@/design-system/typography/paragraphs' +import { useSetEntreprise } from '@/hooks/useSetEntreprise' import { Grid } from '@mui/material' import { useContext } from 'react' import { Trans } from 'react-i18next' import { useDispatch } from 'react-redux' import { SimpleField } from '../_components/Fields' -import illustration from './_components/undraw_fill_in_mie5.svg' import { useProgress } from './_components/hooks' import notHandled from './_components/undraw_access_denied_re_awnf.svg' -import PageHeader from '@/components/PageHeader' -import { Li, Ul } from '@/design-system/typography/list' +import illustration from './_components/undraw_fill_in_mie5.svg' export const OBJECTIFS: DottedName[] = [ 'entreprise . SIREN', @@ -70,7 +70,7 @@ export default function Accueil() { - + Vous pouvez rechercher votre entreprise avec{' '} votre nom, le{' '} @@ -80,9 +80,7 @@ export default function Accueil() { - - - +