-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rgcp): Ajout d'un bouton pour caisse de congés payés
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
site/source/pages/simulateurs/reduction-generale/components/CongésPayésSwitch.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { DottedName } from 'modele-social' | ||
import { useEffect, useState } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { useDispatch } from 'react-redux' | ||
import { styled } from 'styled-components' | ||
|
||
import { useEngine } from '@/components/utils/EngineContext' | ||
import { Radio, ToggleGroup } from '@/design-system' | ||
import { FlexCenter } from '@/design-system/global-style' | ||
import { Body } from '@/design-system/typography/paragraphs' | ||
import { enregistreLaRéponse } from '@/store/actions/actions' | ||
|
||
export default function CongésPayésSwitch() { | ||
const dispatch = useDispatch() | ||
const engine = useEngine() | ||
const dottedName = | ||
'salarié . cotisations . exonérations . réduction générale . caisse de congés payés' as DottedName | ||
const engineCongésPayés = engine.evaluate(dottedName).nodeValue as boolean | ||
const [currentCongésPayés, setCurrentCongésPayés] = useState( | ||
engineCongésPayés ? 'oui' : 'non' | ||
) | ||
const { t } = useTranslation() | ||
|
||
useEffect(() => { | ||
const congésPayés = engineCongésPayés ? 'oui' : 'non' | ||
setCurrentCongésPayés(congésPayés) | ||
}, [currentCongésPayés, engineCongésPayés]) | ||
|
||
return ( | ||
<Container> | ||
<StyledBody id="caisse-congés-payés-label"> | ||
{engine.getRule(dottedName).title} | ||
</StyledBody> | ||
<ToggleGroup | ||
value={currentCongésPayés} | ||
onChange={(value) => { | ||
setCurrentCongésPayés(value) | ||
dispatch(enregistreLaRéponse(dottedName, value)) | ||
}} | ||
aria-labelledby="caisse-congés-payés-label" | ||
> | ||
<Radio value="oui">{t('Oui')}</Radio> | ||
<Radio value="non">{t('Non')}</Radio> | ||
</ToggleGroup> | ||
</Container> | ||
) | ||
} | ||
|
||
const Container = styled.div` | ||
${FlexCenter} | ||
flex-wrap: wrap; | ||
justify-content: center; | ||
column-gap: ${({ theme }) => theme.spacings.sm}; | ||
` | ||
const StyledBody = styled(Body)` | ||
margin: ${({ theme }) => theme.spacings.xxs} 0; | ||
` |