diff --git a/site/source/components/ShareSimulationBanner/index.tsx b/site/source/components/ShareSimulationBanner/index.tsx
index 1c6176361..d587d7d9c 100644
--- a/site/source/components/ShareSimulationBanner/index.tsx
+++ b/site/source/components/ShareSimulationBanner/index.tsx
@@ -1,29 +1,31 @@
-import { Grid } from '@mui/material'
import Emoji from '@/components/utils/Emoji'
+import { PopoverWithTrigger } from '@/design-system'
import { Button } from '@/design-system/buttons'
import { Spacing } from '@/design-system/layout'
-import { PopoverWithTrigger } from '@/design-system'
-import { CurrentSimulatorDataContext } from '../../pages/Simulateurs/metadata'
-import { useContext } from 'react'
-import { Trans, useTranslation } from 'react-i18next'
-import { useSelector } from 'react-redux'
+import { RootState } from '@/reducers/rootReducer'
import {
companySituationSelector,
situationSelector,
} from '@/selectors/simulationSelectors'
+import { Grid } from '@mui/material'
+import { useContext } from 'react'
+import { Trans, useTranslation } from 'react-i18next'
+import { useSelector } from 'react-redux'
import styled from 'styled-components'
import { TrackingContext } from '../../ATInternetTracking'
+import { CurrentSimulatorDataContext } from '../../pages/Simulateurs/metadata'
+import { PlacesDesEntreprisesButton } from '../PlaceDesEntreprises'
import { useParamsFromSituation } from '../utils/useSearchParamsSimulationSharing'
import { ShareSimulationPopup } from './ShareSimulationPopup'
-import { PlacesDesEntreprisesButton } from '../PlaceDesEntreprises'
export function useUrl() {
const language = useTranslation().i18n.language
const situation = {
...useSelector(situationSelector),
...useSelector(companySituationSelector),
+ ...useSelector((state: RootState) => state.DRISituation),
}
- delete situation['entreprise . SIREN']
+
const searchParams = useParamsFromSituation(situation)
const currentSimulatorData = useContext(CurrentSimulatorDataContext)
@@ -42,7 +44,15 @@ const ButtonLabel = styled.span`
margin-left: 1rem;
`
-export default function ShareOrSaveSimulationBanner() {
+export default function ShareOrSaveSimulationBanner({
+ share,
+ print,
+ placeDesEntreprises,
+}: {
+ share?: boolean
+ print?: boolean
+ placeDesEntreprises?: boolean
+}) {
const { t } = useTranslation()
const tracker = useContext(TrackingContext)
const shareAPIAvailable = !!window?.navigator?.share
@@ -69,42 +79,45 @@ export default function ShareOrSaveSimulationBanner() {
spacing={4}
justifyContent="center"
>
-
- (
-
+ )}
+ small
+ >
+
+
+
+ )}
- {typeof window.print === 'function' && (
+ {print && typeof window.print === 'function' && (
window.print()}>
@@ -117,9 +130,11 @@ export default function ShareOrSaveSimulationBanner() {
)}
-
-
-
+ {placeDesEntreprises && (
+
+
+
+ )}
>
)
diff --git a/site/source/components/Simulation/index.tsx b/site/source/components/Simulation/index.tsx
index f6026e046..970c67b2c 100644
--- a/site/source/components/Simulation/index.tsx
+++ b/site/source/components/Simulation/index.tsx
@@ -97,7 +97,7 @@ export default function Simulation({
)}
{firstStepCompleted && !hideDetails && (
<>
-
+
>
)}
diff --git a/site/source/components/utils/useSearchParamsSimulationSharing.ts b/site/source/components/utils/useSearchParamsSimulationSharing.ts
index 33e0b51cf..fcbac657c 100644
--- a/site/source/components/utils/useSearchParamsSimulationSharing.ts
+++ b/site/source/components/utils/useSearchParamsSimulationSharing.ts
@@ -7,11 +7,7 @@ import { useEngine } from '@/components/utils/EngineContext'
import { configSelector } from '@/selectors/simulationSelectors'
import Engine, { ParsedRules, serializeEvaluation } from 'publicodes'
import { DottedName } from 'modele-social'
-import {
- updateSituation,
- setActiveTarget,
- batchUpdateSituation,
-} from '@/actions/actions'
+import { setActiveTarget, batchUpdateSituation } from '@/actions/actions'
import { isEmpty } from 'ramda'
type Objectifs = (string | { objectifs: string[] })[]
@@ -139,15 +135,17 @@ export function getSearchParamsFromSituation(
): URLSearchParams {
const searchParams = new URLSearchParams()
const dottedNameParamNameMapping = Object.fromEntries(dottedNameParamName)
- ;(Object.entries(situation) as [DottedName, any][]).forEach(
- ([dottedName, value]) => {
- const paramName = dottedNameParamNameMapping[dottedName]
- const serializedValue = serializeEvaluation(engine.evaluate(value))
- if (typeof serializedValue !== 'undefined') {
- searchParams.set(paramName, serializedValue)
- }
+
+ Object.entries(situation).forEach(([dottedName, value]) => {
+ const paramName = dottedNameParamNameMapping[dottedName]
+ const serializedValue = serializeEvaluation(engine.evaluate(value))
+
+ if (typeof serializedValue !== 'undefined') {
+ searchParams.set(paramName, serializedValue)
+ } else if (typeof value === 'object') {
+ searchParams.set(paramName, JSON.stringify(value))
}
- )
+ })
searchParams.sort()
return searchParams
@@ -157,7 +155,8 @@ export function getSituationFromSearchParams(
searchParams: URLSearchParams,
dottedNameParamName: [DottedName, ParamName][]
) {
- const situation: { [key in DottedName]?: string } = {}
+ const situation: { [key in DottedName]?: string | Record } =
+ {}
const paramNameDottedName = dottedNameParamName.reduce(
(dottedNameBySearchParamName, [dottedName, paramName]) => ({
@@ -170,6 +169,17 @@ export function getSituationFromSearchParams(
searchParams.forEach((value, paramName) => {
if (Object.prototype.hasOwnProperty.call(paramNameDottedName, paramName)) {
situation[paramNameDottedName[paramName]] = value
+
+ if (value.startsWith('{') && value.endsWith('}')) {
+ try {
+ const parsed = JSON.parse(value) as Record
+
+ situation[paramNameDottedName[paramName]] = parsed
+ } catch (error) {
+ // eslint-disable-next-line no-console
+ console.error(error)
+ }
+ }
}
})
diff --git a/site/source/pages/gerer/declaration-revenu-independants/declaration.tsx b/site/source/pages/gerer/declaration-revenu-independants/declaration.tsx
index 4159b8846..d93ac8f83 100644
--- a/site/source/pages/gerer/declaration-revenu-independants/declaration.tsx
+++ b/site/source/pages/gerer/declaration-revenu-independants/declaration.tsx
@@ -1,12 +1,12 @@
import { DottedName } from '@/../../modele-social'
import Value, { Condition } from '@/components/EngineValue'
+import ShareOrSaveSimulationBanner from '@/components/ShareSimulationBanner'
import { FromTop } from '@/components/ui/animate'
import { useEngine } from '@/components/utils/EngineContext'
import { Markdown } from '@/components/utils/markdown'
import { SitePathsContext } from '@/components/utils/SitePathsContext'
import { Message } from '@/design-system'
import Accordion from '@/design-system/accordion'
-import AnswerGroup from '@/design-system/answer-group'
import { Button } from '@/design-system/buttons'
import { Container, Spacing } from '@/design-system/layout'
import { Strong } from '@/design-system/typography'
@@ -312,6 +312,7 @@ function ResultSection() {
spacing={3}
alignItems="stretch"
flexWrap={'wrap-reverse'}
+ justifyContent="center"
>
@@ -354,16 +355,9 @@ function ResultSection() {
)
)}
-
-
-
- Imprimer ou sauvegarder en PDF
-
-
- Obtenir un lien de partage
-
-
+
+