Améliore l'autosave de l'assistant à la déclaration de revenu

pull/2092/head
Johan Girod 2022-04-07 18:30:13 +02:00
parent 29030c3eb8
commit 2e6cddf5c3
21 changed files with 92 additions and 157 deletions

View File

@ -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

View File

@ -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 (

View File

@ -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.

View File

@ -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() {

View File

@ -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()

View File

@ -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)

View File

@ -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())
}
}, [])
}

View File

@ -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 (
<>
<Warning

View File

@ -8,15 +8,11 @@ import Simulation, {
} from '@/components/Simulation'
import { InstitutionsPartenairesArtisteAuteur } from '@/components/simulationExplanation/InstitutionsPartenaires'
import { EngineContext } from '@/components/utils/EngineContext'
import useSimulationConfig from '@/components/utils/useSimulationConfig'
import { H2 } from '@/design-system/typography/heading'
import { useContext } from 'react'
import { Trans } from 'react-i18next'
import config from './configs/artiste-auteur.yaml'
export default function ArtisteAuteur() {
useSimulationConfig(config)
return (
<>
<Simulation explanations={<CotisationsResult />}>

View File

@ -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 (
<>

View File

@ -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 (

View File

@ -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() {

View File

@ -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() {
<Grid container>
<Grid item lg={10} xl={8}>
<FromTop>
<H2>Aide au remplissage de la déclaration de revenu</H2>
<Trans i18nKey="assistant-DRI.declaration.intro">
<Intro>
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{' '}
<Strong>remplir votre déclaration de revenu personnelle</Strong>{' '}
à partir de la déclaration de résultat de votre entreprise.
</Intro>
</Trans>
<H3>Où trouver la déclaration de résultat de l'entreprise ?</H3>
<H3 as="h2">
Où trouver la déclaration de résultat de l'entreprise ?
</H3>
<Body>
C'est le comptable qui se charge de remplir la déclaration de
@ -221,10 +222,12 @@ export default function Déclaration() {
</Grid>
<LiasseFiscale />
<H2>Renseignements complémentaires</H2>
<Grid item xs={12}>
<H2>Renseignements complémentaires</H2>
<SimpleField dottedName="DRI . liasse . OGA" />
<SimpleField dottedName="DRI . liasse . rémunération dirigeant" />
<SimpleField dottedName="DRI . liasse . OGA" />
<SimpleField dottedName="DRI . liasse . rémunération dirigeant" />
</Grid>
</Grid>
<Spacing xxl />
@ -284,7 +287,9 @@ function LiasseFiscale() {
</Grid>
) : (
<Grid item md={4} sm={6} xs={12} key={dottedName}>
<SimpleField dottedName={dottedName} />
<FromTop>
<SimpleField dottedName={dottedName} />
</FromTop>
</Grid>
)
)}

View File

@ -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() {
<Grid container>
<Grid item lg={10} xl={8}>
<WhenNotAlreadyDefined dottedName="entreprise . SIREN">
<Message border={false}>
<Message border={false} icon>
<Body>
Vous pouvez rechercher votre entreprise avec{' '}
<Strong>votre nom</Strong>, le{' '}
@ -80,9 +80,7 @@ export default function Accueil() {
<CompanySearchField onSubmit={setEntreprise} />
</WhenNotAlreadyDefined>
<WhenAlreadyDefined dottedName="entreprise . SIREN">
<FromBottom>
<CompanyDetails />
</FromBottom>
<CompanyDetails />
<Button size="XS" light onPress={() => dispatch(resetCompany())}>
<Trans>Modifier l'entreprise</Trans>

View File

@ -1,29 +1,27 @@
import { Condition } from '@/components/EngineValue'
import PageHeader from '@/components/PageHeader'
import { useEngine } from '@/components/utils/EngineContext'
import { SitePathsContext } from '@/components/utils/SitePathsContext'
import { useSimulationProgress } from '@/components/utils/useNextQuestion'
import useSimulationConfig from '@/components/utils/useSimulationConfig'
import { Step, Stepper } from '@/design-system'
import { Spacing } from '@/design-system/layout'
import { Strong } from '@/design-system/typography'
import { Link } from '@/design-system/typography/link'
import { Li, Ul } from '@/design-system/typography/list'
import { Body, Intro } from '@/design-system/typography/paragraphs'
import { omit } from '@/utils'
import { useContext } from 'react'
import { Trans, useTranslation } from 'react-i18next'
import { useTranslation } from 'react-i18next'
import { Redirect, Route, Switch } from 'react-router'
import Cotisations from './cotisations'
import Déclaration, { useObjectifs as useStep3Objectifs } from './declaration'
import Entreprise, { OBJECTIFS as Step1Objectifs } from './entreprise'
import Imposition, { OBJECTIFS as Step2Objectifs } from './imposition'
import { useProgress } from './_components/hooks'
import illustration from './_components/undraw_fill_in_mie5.svg'
import config from './_config.yaml'
export default function AideDéclarationIndépendant() {
useSimulationConfig(config)
const sitePaths = useContext(SitePathsContext)
useSimulationConfig(config, {
path: sitePaths.gérer.déclarationIndépendant.index,
autoloadLastSimulation: true,
})
const steps = useSteps()
const defaultCurrentStep =
steps

View File

@ -11,12 +11,14 @@ import { PlacesDesEntreprisesButton } from '@/components/PlaceDesEntreprises'
import { FromTop } from '@/components/ui/animate'
import { useEngine } from '@/components/utils/EngineContext'
import { Markdown } from '@/components/utils/markdown'
import { ScrollToTop } from '@/components/utils/Scroll'
import { SitePathsContext } from '@/components/utils/SitePathsContext'
import useSimulationConfig from '@/components/utils/useSimulationConfig'
import { Message } from '@/design-system'
import { Container, 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'
@ -35,21 +37,18 @@ import {
} from 'react-router'
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'
import SocialSecurity from './sécurité-sociale'
import { AutoEntrepreneurCard } from './_components/AutoEntrepeneurCard'
import { DemarcheEmbaucheCard } from './_components/DemarcheEmbauche'
import { KbisCard } from './_components/KBISCard'
import { MobiliteCard } from './_components/MobiliteCard'
import SocialSecurity from './sécurité-sociale'
import { SecuriteSocialeCard } from './_components/SecuriteSocialeCard'
import forms from './_components/forms.svg'
import growth from './_components/growth.svg'
import { ScrollToTop } from '@/components/utils/Scroll'
import { Link } from '@/design-system/typography/link'
import Embaucher from './embaucher'
import PageData from '../../components/PageData'
import { KbisCard } from './_components/KBISCard'
import { MobiliteCard } from './_components/MobiliteCard'
import { SecuriteSocialeCard } from './_components/SecuriteSocialeCard'
export default function Gérer() {
const sitePaths = useContext(SitePathsContext)
@ -358,7 +357,8 @@ const companyDetailsConfig = {
}
export const AskCompanyMissingDetails = () => {
useSimulationConfig(companyDetailsConfig)
const sitePaths = useContext(SitePathsContext)
useSimulationConfig(companyDetailsConfig, { path: sitePaths.gérer.index })
const [questions, onQuestionAnswered] = useQuestionList()
const engine = useEngine()

View File

@ -1,32 +0,0 @@
import { DottedName } from '@/../../modele-social'
import { Action } from '@/actions/actions'
import { omit } from '@/utils'
import { Situation } from './rootReducer'
const SAVED_NAMESPACES = ['DRI'] as Array<DottedName>
export function DRISituation(state: Situation = {}, action: Action) {
switch (action.type) {
case 'UPDATE_SITUATION':
if (
SAVED_NAMESPACES.some((namespace) =>
action.fieldName.startsWith(namespace)
)
) {
return {
...state,
[action.fieldName]: action.value,
}
}
break
case 'DELETE_FROM_SITUATION': {
const newState = omit({ ...state }, action.fieldName)
return newState
}
case 'COMPANY::RESET':
return {}
}
return state
}

View File

@ -9,7 +9,6 @@ import { objectifsSelector } from '../selectors/simulationSelectors'
import { omit } from '../utils'
import choixStatutJuridique from './choixStatutJuridiqueReducer'
import { companySituation } from './companySituationReducer'
import { DRISituation } from './DRISituationReducer'
import previousSimulationRootReducer from './previousSimulationRootReducer'
function explainedVariable(
@ -198,7 +197,6 @@ const mainReducer = combineReducers({
explainedVariable,
simulation,
companySituation,
DRISituation,
previousSimulation: defaultTo(null) as Reducer<PreviousSimulation | null>,
activeTargetInput,
choixStatutJuridique,

View File

@ -1,29 +0,0 @@
import { Action } from '@/actions/actions'
import { RootState, Situation } from '@/reducers/rootReducer'
import { Store } from 'redux'
import { debounce } from '../utils'
import * as safeLocalStorage from './safeLocalStorage'
const VERSION = 1
const LOCAL_STORAGE_KEY = `mon-entreprise::DRISituation::v${VERSION}`
export function setupDRISituationPersistence(store: Store<RootState, Action>) {
const listener = () => {
const state = store.getState()
safeLocalStorage.setItem(
LOCAL_STORAGE_KEY,
JSON.stringify(state.DRISituation)
)
}
store.subscribe(debounce(1000, listener))
}
export function retrievePersistedDRISituation(): Situation | undefined {
const serializedState = safeLocalStorage.getItem(LOCAL_STORAGE_KEY)
return serializedState && serializedState !== 'undefined'
? (JSON.parse(serializedState) as Situation)
: undefined
}

View File

@ -1,7 +1,8 @@
import { Action } from '@/actions/actions'
import { RootState } from '@/reducers/rootReducer'
import { Store } from 'redux'
import { PreviousSimulation } from '@/selectors/previousSimulationSelectors'
import { isEmpty } from 'ramda'
import { Store } from 'redux'
import { debounce } from '../utils'
import * as safeLocalStorage from './safeLocalStorage'
import { deserialize, serialize } from './serializeSimulation'
@ -20,7 +21,7 @@ export function setupSimulationPersistence(
if (!state.simulation?.url) {
return
}
if (!state.simulation?.foldedSteps.length) {
if (isEmpty(state.simulation?.situation)) {
return
}
safeLocalStorage.setItem(

View File

@ -10,16 +10,12 @@ import {
retrievePersistedCompanySituation,
setupCompanySituationPersistence,
} from './storage/persistCompanySituation'
import {
retrievePersistedDRISituation,
setupDRISituationPersistence,
} from './storage/persistDRISituation'
import { setupSimulationPersistence } from './storage/persistSimulation'
const initialStore = {
choixStatutJuridique: retrievePersistedChoixStatutJuridique(),
companySituation: retrievePersistedCompanySituation(),
DRISituation: retrievePersistedDRISituation(),
}
const composeEnhancers = composeWithDevToolsDevelopmentOnly(
@ -34,5 +30,4 @@ export const store = createStore(reducers, initialStore, storeEnhancer)
setupChoixStatutJuridiquePersistence(store)
setupCompanySituationPersistence(store)
setupDRISituationPersistence(store)
setupSimulationPersistence(store)