mon-entreprise/source/components/PreviousSimulationBanner.tsx

30 lines
1019 B
TypeScript

import { loadPreviousSimulation } from 'Actions/actions'
import React from 'react'
import { Trans } from 'react-i18next'
import { useDispatch, useSelector } from 'react-redux'
import { RootState } from 'Reducers/rootReducer'
import { noUserInputSelector } from 'Selectors/analyseSelectors'
import { LinkButton } from 'Ui/Button'
import Banner from './Banner'
export default function PreviousSimulationBanner() {
const previousSimulation = useSelector(
(state: RootState) => state.previousSimulation
)
const newSimulationStarted = !useSelector(noUserInputSelector)
const dispatch = useDispatch()
return (
<Banner hidden={!previousSimulation || newSimulationStarted} icon="💾">
<Trans i18nKey="previousSimulationBanner.info">
Votre précédente simulation a été sauvegardée :
</Trans>{' '}
<LinkButton onClick={() => dispatch(loadPreviousSimulation())}>
<Trans i18nKey="previousSimulationBanner.retrieveButton">
Retrouver ma simulation
</Trans>
</LinkButton>
</Banner>
)
}