mirror of
https://github.com/betagouv/mon-entreprise
synced 2025-02-09 05:15:02 +00:00
* eslint fixes batch * fix @typescript-eslint/camelcase (=> warn) * fix @typescript-eslint/consistent-type-assertions * fix no-prototype-builtins * @typescript-eslint/prefer-string-starts-ends-with => warn * fix @typescript-eslint/prefer-regexp-exec * fix prefer-const * fix no-case-declarations * fix @typescript-eslint/no-var-requires * fix react/jsx-key * fix react-hooks/rules-of-hooks * fix typescript errors following eslint fixes. Includes downgrading: ** @typescript-eslint/no-unnecessary-type-assertion ** @typescript-eslint/no-inferrable-types * apply prettier * use `object` type whenever possible
33 lines
960 B
TypeScript
33 lines
960 B
TypeScript
import { updateUnit } from 'Actions/actions'
|
|
import { parseUnit, serializeUnit } from 'Engine/units'
|
|
import React from 'react'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { useDispatch, useSelector } from 'react-redux'
|
|
import { targetUnitSelector } from 'Selectors/simulationSelectors'
|
|
import './PeriodSwitch.css'
|
|
|
|
export default function PeriodSwitch() {
|
|
const dispatch = useDispatch()
|
|
const language = useTranslation().i18n.language
|
|
const currentUnit = useSelector(targetUnitSelector)
|
|
|
|
const units = ['€/mois', '€/an']
|
|
return (
|
|
<span id="PeriodSwitch">
|
|
<span className="base ui__ small toggle">
|
|
{units.map(unit => (
|
|
<label key={unit}>
|
|
<input
|
|
name="defaultUnit"
|
|
type="radio"
|
|
value={unit}
|
|
onChange={() => dispatch(updateUnit(unit))}
|
|
checked={currentUnit === unit}
|
|
/>
|
|
<span>{serializeUnit(parseUnit(unit), 1, language)}</span>
|
|
</label>
|
|
))}
|
|
</span>
|
|
</span>
|
|
)
|
|
}
|