Skip to content

Commit

Permalink
Mémoire de la viz en sélectionnée des persona dans l'URL
Browse files Browse the repository at this point in the history
  • Loading branch information
laem committed Aug 24, 2022
1 parent 0ce3e71 commit 108bf8b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions source/sites/publicodes/Personas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { resetSimulation } from 'Actions/actions'
import { useEffect, useState } from 'react'
import emoji from 'react-easy-emoji'
import { useDispatch, useSelector } from 'react-redux'
import { useSearchParams } from 'react-router-dom'
import { setDifferentSituation } from '../../actions/actions'
import IllustratedMessage from '../../components/ui/IllustratedMessage'
import useBranchData from '../../components/useBranchData'
Expand All @@ -27,9 +28,11 @@ const visualisationChoices = {

export default ({}) => {
const persona = useSelector((state) => state.simulation?.persona)
const [selectedVisualisation, selectVisualisation] = useState('aucun')
const [searchParams, setSearchParams] = useSearchParams({
visualisation: 'aucun',
})

const Visualisation = visualisationChoices[selectedVisualisation]
const Visualisation = visualisationChoices[searchParams.get('visualisation')]
const engine = useEngine()

const slideProps = {
Expand All @@ -50,10 +53,10 @@ export default ({}) => {
{Object.keys(visualisationChoices).map((name) => (
<label>
<input
onClick={() => selectVisualisation(name)}
onClick={() => setSearchParams({ visualisation: name })}
type="radio"
value={name}
checked={selectedVisualisation === name}
checked={searchParams.get('visualisation') === name}
/>
{name}
</label>
Expand Down

0 comments on commit 108bf8b

Please sign in to comment.