mon-entreprise/source/components/PreviousSimulationBanner.js

57 lines
1.5 KiB
JavaScript
Raw Normal View History

/* @flow */
2018-07-12 08:09:41 +00:00
import {
deletePreviousSimulation,
loadPreviousSimulation
} from 'Actions/actions'
import { compose } from 'ramda'
import React from 'react'
import { Trans, withTranslation } from 'react-i18next'
import { connect } from 'react-redux'
import { noUserInputSelector } from 'Selectors/analyseSelectors'
2018-07-12 08:09:41 +00:00
import { LinkButton } from 'Ui/Button'
import Banner from './Banner'
2018-07-12 08:09:41 +00:00
import type { SavedSimulation } from 'Types/State'
type ConnectedPropTypes = {
previousSimulation: SavedSimulation,
loadPreviousSimulation: () => void,
2018-07-12 08:09:41 +00:00
newSimulationStarted: boolean,
deletePreviousSimulation: () => void
}
const PreviousSimulationBanner = ({
previousSimulation,
deletePreviousSimulation,
2018-07-12 08:09:41 +00:00
newSimulationStarted,
loadPreviousSimulation
}: ConnectedPropTypes) => (
2018-07-12 08:09:41 +00:00
<Banner hidden={!previousSimulation || newSimulationStarted}>
<Trans i18nKey="previousSimulationBanner.info">
Votre précédente simulation a été sauvegardée.
2018-07-12 08:09:41 +00:00
</Trans>{' '}
<LinkButton onClick={loadPreviousSimulation}>
<Trans i18nKey="previousSimulationBanner.retrieveButton">
Retrouver ma simulation
</Trans>
</LinkButton>
.{' '}
<LinkButton onClick={deletePreviousSimulation}>
<Trans>Effacer</Trans>
</LinkButton>
</Banner>
)
export default compose(
withTranslation(),
connect(
2018-07-12 08:09:41 +00:00
state => ({
previousSimulation: state.previousSimulation,
newSimulationStarted: !noUserInputSelector(state)
}),
{
loadPreviousSimulation,
deletePreviousSimulation
}
)
)(PreviousSimulationBanner)