-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ajoute un avertissement lorsque la catégorie juridique de l'ent…
…reprise sélectionnée ne correspond pas au simulateur
- Loading branch information
Showing
3 changed files
with
60 additions
and
38 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
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
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,42 @@ | ||
import { Trans } from 'react-i18next' | ||
import { useSelector } from 'react-redux' | ||
|
||
import { Message } from '@/design-system' | ||
import { Strong } from '@/design-system/typography' | ||
import { SmallBody } from '@/design-system/typography/paragraphs' | ||
import { useCurrentSimulatorData } from '@/hooks/useCurrentSimulatorData' | ||
import { PageConfig } from '@/pages/simulateurs/_configs/types' | ||
import { companySituationSelector } from '@/store/selectors/simulationSelectors' | ||
|
||
export default function WrongSimulateurWarning() { | ||
const company = useSelector(companySituationSelector) | ||
|
||
const simulatorData = useCurrentSimulatorData().currentSimulatorData as | ||
| PageConfig | ||
| undefined | ||
const isWrongSimulateur = | ||
simulatorData && | ||
simulatorData.codesCatégorieJuridique?.length && | ||
simulatorData.codesCatégorieJuridique.indexOf( | ||
company['entreprise . code catégorie juridique'] as string | ||
) < 0 | ||
|
||
if (!Object.keys(company).length || !isWrongSimulateur) { | ||
return null | ||
} | ||
|
||
return ( | ||
<Message type="error"> | ||
<SmallBody> | ||
<Trans i18nKey="simulationPréremplieBanner.warning.1"> | ||
Votre catégorie juridique est | ||
</Trans>{' '} | ||
<Strong>{company['entreprise . catégorie juridique'] as string}</Strong>{' '} | ||
<Trans i18nKey="simulationPréremplieBanner.warning.2"> | ||
mais vous êtes sur le simulateur pour{' '} | ||
</Trans> | ||
<Strong>{simulatorData.shortName}</Strong>. | ||
</SmallBody> | ||
</Message> | ||
) | ||
} |