2018-05-23 16:03:26 +00:00
|
|
|
/* @flow */
|
2018-07-12 08:09:41 +00:00
|
|
|
import {
|
|
|
|
deletePreviousSimulation,
|
|
|
|
loadPreviousSimulation
|
|
|
|
} from 'Actions/actions'
|
2018-05-30 16:43:27 +00:00
|
|
|
import { compose } from 'ramda'
|
2018-05-23 16:03:26 +00:00
|
|
|
import React from 'react'
|
2019-02-08 11:45:14 +00:00
|
|
|
import { Trans, withTranslation } from 'react-i18next'
|
2018-05-23 16:03:26 +00:00
|
|
|
import { connect } from 'react-redux'
|
2018-09-04 14:23:05 +00:00
|
|
|
import { noUserInputSelector } from 'Selectors/analyseSelectors'
|
2018-07-12 08:09:41 +00:00
|
|
|
import { LinkButton } from 'Ui/Button'
|
2018-05-30 16:43:27 +00:00
|
|
|
import Banner from './Banner'
|
|
|
|
|
2018-07-12 08:09:41 +00:00
|
|
|
import type { SavedSimulation } from 'Types/State'
|
2018-05-23 16:03:26 +00:00
|
|
|
|
|
|
|
type ConnectedPropTypes = {
|
|
|
|
previousSimulation: SavedSimulation,
|
2018-06-18 16:03:52 +00:00
|
|
|
loadPreviousSimulation: () => void,
|
2018-07-12 08:09:41 +00:00
|
|
|
newSimulationStarted: boolean,
|
2018-06-18 16:03:52 +00:00
|
|
|
deletePreviousSimulation: () => void
|
2018-05-23 16:03:26 +00:00
|
|
|
}
|
|
|
|
const PreviousSimulationBanner = ({
|
|
|
|
previousSimulation,
|
2018-06-18 16:03:52 +00:00
|
|
|
deletePreviousSimulation,
|
2018-07-12 08:09:41 +00:00
|
|
|
newSimulationStarted,
|
2018-05-23 16:03:26 +00:00
|
|
|
loadPreviousSimulation
|
|
|
|
}: ConnectedPropTypes) => (
|
2018-07-12 08:09:41 +00:00
|
|
|
<Banner hidden={!previousSimulation || newSimulationStarted}>
|
2018-05-30 16:43:27 +00:00
|
|
|
<Trans i18nKey="previousSimulationBanner.info">
|
2018-06-19 15:15:58 +00:00
|
|
|
Votre précédente simulation a été sauvegardée.
|
2018-07-12 08:09:41 +00:00
|
|
|
</Trans>{' '}
|
2018-06-18 16:03:52 +00:00
|
|
|
<LinkButton onClick={loadPreviousSimulation}>
|
2018-05-30 16:43:27 +00:00
|
|
|
<Trans i18nKey="previousSimulationBanner.retrieveButton">
|
2018-06-19 15:15:58 +00:00
|
|
|
Retrouver ma simulation
|
2018-05-23 16:03:26 +00:00
|
|
|
</Trans>
|
2018-11-14 15:51:37 +00:00
|
|
|
</LinkButton>
|
|
|
|
.{' '}
|
2018-06-18 16:03:52 +00:00
|
|
|
<LinkButton onClick={deletePreviousSimulation}>
|
|
|
|
<Trans>Effacer</Trans>
|
|
|
|
</LinkButton>
|
2018-05-23 16:03:26 +00:00
|
|
|
</Banner>
|
|
|
|
)
|
|
|
|
|
2018-05-30 16:43:27 +00:00
|
|
|
export default compose(
|
2019-02-08 11:45:14 +00:00
|
|
|
withTranslation(),
|
2018-06-12 10:21:36 +00:00
|
|
|
connect(
|
2018-07-12 08:09:41 +00:00
|
|
|
state => ({
|
|
|
|
previousSimulation: state.previousSimulation,
|
|
|
|
newSimulationStarted: !noUserInputSelector(state)
|
|
|
|
}),
|
2018-06-12 10:21:36 +00:00
|
|
|
{
|
2018-06-18 16:03:52 +00:00
|
|
|
loadPreviousSimulation,
|
|
|
|
deletePreviousSimulation
|
2018-06-12 10:21:36 +00:00
|
|
|
}
|
|
|
|
)
|
2018-05-30 16:43:27 +00:00
|
|
|
)(PreviousSimulationBanner)
|