mirror of
https://github.com/betagouv/mon-entreprise
synced 2025-02-09 05:15:02 +00:00
0663c97204
Suppression de notre composant withLanguage qui rajoutait une abstraction inutile. Note: de nombreux appels à withTranslation et withLanguage était inutile car le composant augmenté n'utilisait pas les paramètres fournis (language, t, i18n). L'utilisation des hooks nous permet de mieux gérer le code mort, car il s'agit de simples variables dont le non-usage est détecté par l'analyse statique.
55 lines
1.4 KiB
JavaScript
55 lines
1.4 KiB
JavaScript
/* @flow */
|
|
import {
|
|
deletePreviousSimulation,
|
|
loadPreviousSimulation
|
|
} from 'Actions/actions'
|
|
import { compose } from 'ramda'
|
|
import React from 'react'
|
|
import { Trans } from 'react-i18next'
|
|
import { connect } from 'react-redux'
|
|
import { noUserInputSelector } from 'Selectors/analyseSelectors'
|
|
import { LinkButton } from 'Ui/Button'
|
|
import Banner from './Banner'
|
|
|
|
import type { SavedSimulation } from 'Types/State'
|
|
|
|
type ConnectedPropTypes = {
|
|
previousSimulation: SavedSimulation,
|
|
loadPreviousSimulation: () => void,
|
|
newSimulationStarted: boolean,
|
|
deletePreviousSimulation: () => void
|
|
}
|
|
const PreviousSimulationBanner = ({
|
|
previousSimulation,
|
|
deletePreviousSimulation,
|
|
newSimulationStarted,
|
|
loadPreviousSimulation
|
|
}: ConnectedPropTypes) => (
|
|
<Banner hidden={!previousSimulation || newSimulationStarted} icon="💾">
|
|
<Trans i18nKey="previousSimulationBanner.info">
|
|
Votre précédente simulation a été sauvegardée.
|
|
</Trans>{' '}
|
|
<LinkButton onClick={loadPreviousSimulation}>
|
|
<Trans i18nKey="previousSimulationBanner.retrieveButton">
|
|
Retrouver ma simulation
|
|
</Trans>
|
|
</LinkButton>
|
|
.{' '}
|
|
<LinkButton onClick={deletePreviousSimulation}>
|
|
<Trans>Effacer</Trans>
|
|
</LinkButton>
|
|
</Banner>
|
|
)
|
|
|
|
export default compose(
|
|
connect(
|
|
state => ({
|
|
previousSimulation: state.previousSimulation,
|
|
newSimulationStarted: !noUserInputSelector(state)
|
|
}),
|
|
{
|
|
loadPreviousSimulation,
|
|
deletePreviousSimulation
|
|
}
|
|
)
|
|
)(PreviousSimulationBanner)
|