diff --git a/README.md b/README.md index 0840522573..e7df52ff86 100644 --- a/README.md +++ b/README.md @@ -53,3 +53,4 @@ yarn test:e2e:ui # To run e2e test with Cypress UI ## License [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FSocialGouv%2Fcode-du-travail-numerique.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FSocialGouv%2Fcode-du-travail-numerique?ref=badge_large) + diff --git a/packages/code-du-travail-frontend/jest.config.js b/packages/code-du-travail-frontend/jest.config.js index cf4f60c2af..74a14eaf1c 100644 --- a/packages/code-du-travail-frontend/jest.config.js +++ b/packages/code-du-travail-frontend/jest.config.js @@ -12,7 +12,8 @@ const customJestConfig = { "/node_modules/", "/cypress/", ], - testTimeout: 20000 + testTimeout: 20000, + maxWorkers: "80%", }; module.exports = createJestConfig(customJestConfig); diff --git a/packages/code-du-travail-frontend/package.json b/packages/code-du-travail-frontend/package.json index 1af166a746..b66951412d 100644 --- a/packages/code-du-travail-frontend/package.json +++ b/packages/code-du-travail-frontend/package.json @@ -89,7 +89,7 @@ "@testing-library/user-event": "^13.5.0", "@types/cors": "^2.8.13", "@types/debounce-promise": "^3.1.4", - "@types/jest": "^29.5.0", + "@types/jest": "^29.5.12", "@types/react-autosuggest": "^10.1.6", "cypress": "12.17.4", "cypress-iframe": "^1.0.1", @@ -97,8 +97,8 @@ "eslint-config-next": "14.1.0", "eslint-plugin-cypress": "^2.12.1", "eslint-plugin-storybook": "^0.8.0", - "jest": "^29.5.0", - "jest-environment-jsdom": "^29.5.0", + "jest": "^29.7.0", + "jest-environment-jsdom": "^29.7.0", "lint-staged": "^13.0.0", "mockdate": "^3.0.5", "nextjs-http-supertest": "^1.0.6", diff --git a/packages/code-du-travail-frontend/pages/outils/[slug].tsx b/packages/code-du-travail-frontend/pages/outils/[slug].tsx index acdfbef908..712bf0445a 100644 --- a/packages/code-du-travail-frontend/pages/outils/[slug].tsx +++ b/packages/code-du-travail-frontend/pages/outils/[slug].tsx @@ -1,6 +1,6 @@ import * as Sentry from "@sentry/nextjs"; import { SOURCES } from "@socialgouv/cdtn-utils"; -import { Container, Section, theme } from "@socialgouv/cdtn-ui"; +import { Container, theme } from "@socialgouv/cdtn-ui"; import { push as matopush } from "@socialgouv/matomo-next"; import { GetServerSideProps } from "next"; import { useRouter } from "next/router"; @@ -15,7 +15,8 @@ import { SITE_URL } from "../../src/config"; import { Layout } from "../../src/layout/Layout"; import { AgreementSearch, - CalculateurIndemnite, + CalculateurIndemniteLicenciement, + CalculateurRuptureConventionnelle, DismissalProcess, DureePreavisDemission, DureePreavisLicenciement, @@ -29,13 +30,14 @@ import { const toolsBySlug = { "convention-collective": AgreementSearch, "heures-recherche-emploi": HeuresRechercheEmploi, - "indemnite-licenciement": CalculateurIndemnite, + "indemnite-licenciement": CalculateurIndemniteLicenciement, "indemnite-precarite": SimulateurIndemnitePrecarite, "preavis-demission": DureePreavisDemission, "preavis-licenciement": DureePreavisLicenciement, "preavis-retraite": DureePreavisRetraite, "simulateur-embauche": SimulateurEmbauche, "procedure-licenciement": DismissalProcess, + "indemnite-rupture-conventionnelle": CalculateurRuptureConventionnelle, }; export interface Props { diff --git a/packages/code-du-travail-frontend/pages/outils/index.tsx b/packages/code-du-travail-frontend/pages/outils/index.tsx index ba028930ad..4521e34088 100644 --- a/packages/code-du-travail-frontend/pages/outils/index.tsx +++ b/packages/code-du-travail-frontend/pages/outils/index.tsx @@ -89,9 +89,10 @@ export async function getStaticProps() { } else { result = await getToolsByIdsAndSlugs(); } + const isProd = process.env.NEXT_PUBLIC_IS_PRODUCTION_DEPLOYMENT === "production" const tools = result .map(({ _id, _source }) => ({ ..._source, _id })) - .filter((tool) => tool.displayTool); + .filter((tool) => isProd ? tool.displayTool : true); return { props: { diff --git a/packages/code-du-travail-frontend/pages/widgets/[slug].tsx b/packages/code-du-travail-frontend/pages/widgets/[slug].tsx index 113bb349e1..dc41fbeb63 100644 --- a/packages/code-du-travail-frontend/pages/widgets/[slug].tsx +++ b/packages/code-du-travail-frontend/pages/widgets/[slug].tsx @@ -7,7 +7,7 @@ import { Footer } from "../../src/widgets"; import { AgreementSearch, - CalculateurIndemnite, + CalculateurIndemniteLicenciement, DismissalProcess, DureePreavisDemission, DureePreavisLicenciement, @@ -22,7 +22,7 @@ const toolsBySlug = { "preavis-licenciement": DureePreavisLicenciement, "preavis-retraite": DureePreavisRetraite, "procedure-licenciement": DismissalProcess, - "indemnite-licenciement": CalculateurIndemnite, + "indemnite-licenciement": CalculateurIndemniteLicenciement, "indemnite-precarite": SimulateurIndemnitePrecarite, "convention-collective": AgreementSearch, "preavis-demission": DureePreavisDemission, diff --git a/packages/code-du-travail-frontend/src/common/tiles/CallToAction.tsx b/packages/code-du-travail-frontend/src/common/tiles/CallToAction.tsx index 5bc77710bc..821fa43648 100644 --- a/packages/code-du-travail-frontend/src/common/tiles/CallToAction.tsx +++ b/packages/code-du-travail-frontend/src/common/tiles/CallToAction.tsx @@ -2,7 +2,9 @@ import { Paragraph, theme } from "@socialgouv/cdtn-ui"; import React, { ForwardedRef } from "react"; import styled from "styled-components"; import { LinkedTile, Props } from "./LinkedTile"; -import { DirectionRight } from "@socialgouv/cdtn-ui/lib/icons"; +import { icons } from "@socialgouv/cdtn-ui"; + +const { DirectionRight } = icons; type CallToActionTileProps = Props & { action?: string }; @@ -20,7 +22,7 @@ export const CallToActionTile = React.forwardRef< {action && ( - {action} + {action} )} diff --git a/packages/code-du-travail-frontend/src/contributions/ContributionContent.tsx b/packages/code-du-travail-frontend/src/contributions/ContributionContent.tsx index 551a1eeb57..d206f59c57 100644 --- a/packages/code-du-travail-frontend/src/contributions/ContributionContent.tsx +++ b/packages/code-du-travail-frontend/src/contributions/ContributionContent.tsx @@ -11,7 +11,7 @@ import { A11yLink } from "../common/A11yLink"; import DisplayContentContribution, { ContentSP, } from "./DisplayContentContribution"; -import { Section } from "@socialgouv/cdtn-ui/lib"; +import { Section } from "@socialgouv/cdtn-ui"; type Props = { contribution: diff --git a/packages/code-du-travail-frontend/src/lib/matomo/types.ts b/packages/code-du-travail-frontend/src/lib/matomo/types.ts index 669e3504c5..fe6e40b8e6 100644 --- a/packages/code-du-travail-frontend/src/lib/matomo/types.ts +++ b/packages/code-du-travail-frontend/src/lib/matomo/types.ts @@ -88,6 +88,7 @@ export enum MatomoActionEvent { PREAVIS_DEMISSION = "view_step_Préavis de démission", PREAVIS_LICENCIEMENT = "view_step_Préavis de licenciement", INDEMNITE_LICENCIEMENT = "view_step_Indemnité de licenciement", + RUPTURE_CONVENTIONNELLE = "view_step_Rupture conventionnelle", VIEW_STEP = "view_step", CLICK_PREVIOUS = "click_previous", } diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/__tests__/ui.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/__tests__/ui.ts similarity index 85% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/__tests__/ui.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/__tests__/ui.ts index 231d90136b..0ab55bdcb7 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/__tests__/ui.ts +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/__tests__/ui.ts @@ -1,4 +1,9 @@ -import { byTestId, byText, byTitle } from "testing-library-selector"; +import { + byLabelText, + byTestId, + byText, + byTitle, +} from "testing-library-selector"; export const ui = { introduction: { @@ -98,6 +103,9 @@ export const ui = { engineerAge: byTestId( "infos.contrat salarié - convention collective - transports routiers - indemnité de licenciement - catégorie professionnelle - Ingénieurs et cadres - age" ), + ruptureEngineerAge: byTestId( + "infos.contrat salarié - convention collective - transports routiers - rupture conventionnelle - cadre age" + ), employeeAge: byTestId( "infos.contrat salarié - convention collective - transports routiers - indemnité de licenciement - age" ), @@ -149,16 +157,11 @@ export const ui = { proCategory: byTestId( "infos.contrat salarié - convention collective - industries chimiques - indemnité de licenciement - catégorie professionnelle" ), - economicFire: { - oui: byTestId( - "infos.contrat salarié - convention collective - industries chimiques - indemnité de licenciement - catégorie professionnelle - licenciement économique - Oui" - ), - non: byTestId( - "infos.contrat salarié - convention collective - industries chimiques - indemnité de licenciement - catégorie professionnelle - licenciement économique - Non" - ), - }, age: byTestId( - "infos.contrat salarié - convention collective - industries chimiques - indemnité de licenciement - catégorie professionnelle - licenciement économique - age" + "infos.contrat salarié - convention collective - industries chimiques - indemnité de licenciement - catégorie professionnelle - age" + ), + ruptureAge: byTestId( + "infos.contrat salarié - convention collective - industries chimiques - rupture conventionnelle - age" ), }, agreement2609: { @@ -237,6 +240,9 @@ export const ui = { age: byTestId( "infos.contrat salarié - convention collective - commerces de gros - catégorie professionnelle - agents - licenciement économique - age" ), + ageRupture: byTestId( + "infos.contrat salarié - convention collective - commerces de gros - rupture conventionnelle - licenciement économique agents age" + ), }, agreement2120: { proCategory: byTestId( @@ -279,6 +285,9 @@ export const ui = { age: byTestId( "infos.contrat salarié - convention collective - ouvriers travaux public - indemnité de licenciement - age" ), + ruptureAge: byTestId( + "infos.contrat salarié - convention collective - ouvriers travaux public - rupture conventionnelle - age" + ), }, agreement3248: { proCategory: byTestId( @@ -336,6 +345,36 @@ export const ui = { "infos.contrat salarié - convention collective - hospitalisation privée à but non lucratif - indemnité de licenciement - catégorie professionnelle" ), }, + agreement1501: { + proCategory: byTestId( + "infos.contrat salarié - convention collective - restauration rapide - indemnité de licenciement - catégorie professionnelle" + ), + age: byTestId( + "infos.contrat salarié - convention collective - restauration rapide - indemnité de licenciement - licenciement économique - age" + ), + ruptureAge: byTestId( + "infos.contrat salarié - convention collective - restauration rapide - rupture conventionnelle - age" + ), + }, + agreement2098: { + proCategory: byTestId( + "infos.contrat salarié - convention collective - personnel presta service tertiaire - autre licenciement - catégorie professionnelle" + ), + age: byTestId( + "infos.contrat salarié - convention collective - personnel presta service tertiaire - rupture conventionnelle - cadre age" + ), + }, + agreement2216: { + proCategory: byTestId( + "infos.contrat salarié - convention collective - commerce gros et detail alimentation - indemnité de licenciement - catégorie professionnelle" + ), + age: byTestId( + "infos.contrat salarié - convention collective - commerce gros et detail alimentation - indemnité de licenciement - catégorie professionnelle - licenciement économique - age" + ), + ruptureAge: byTestId( + "infos.contrat salarié - convention collective - commerce gros et detail alimentation - rupture conventionnelle - licenciement économique age" + ), + }, }, seniority: { startDate: byTestId("date-entree"), @@ -404,12 +443,21 @@ export const ui = { resultat: byText(/À partir des éléments que vous avez saisis/), resultatLegal: byText(/Montant prévu par le code du travail/), resultatAgreement: byText(/Montant prévu par la convention collective/), + data: byText(/Éléments saisis/), formula: byTestId("formula"), legalError: { title: byText( "Il n'y a pas d'indemnité de licenciement dans cette situation" ), - cdd: byText(/L’indemnité de licenciement n’est pas due pour les CDD/), + ruptureTitle: byText( + "Il n'y a pas d'indemnité de rupture conventionnelle dans cette situation" + ), + cddLicenciement: byText( + /L’indemnité de licenciement ne concerne pas les salariés en CDD et en contrat de travail temporaire/ + ), + cddRupture: byText( + /La rupture conventionnelle ne concerne pas les salariés en CDD ou en contrat de travail temporaire/ + ), fauteGrave: byText( /L’indemnité de licenciement n’est pas due en cas de faute grave/ ), @@ -459,6 +507,20 @@ export const ui = { agreement3239: { result: byText(/À partir des éléments que vous avez saisis/), }, + dismissalType: { + economic: byText(/Licenciement pour motif économique/), + mobility: byText( + /Le licenciement fait suite au refus d'une clause de mobilité/ + ), + inaptitude: byText( + /Licenciement pour inaptitude totale et définitive non consécutive à un accident du travail/ + ), + discipline: byText(/Licenciement pour motif disciplinaire/), + }, + sources: byTestId("source-", { exact: false }), + source: (index: number) => byTestId(`source-${index}`), + notifications: byTestId("notification-", { exact: false }), + notification: (index: number) => byTestId(`notification-${index}`), }, next: byText("Suivant"), previous: byText("Précédent"), diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1483-habillement-textiles-commerce-de-detail/Component.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1483-habillement-textiles-commerce-de-detail/Component.tsx similarity index 94% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1483-habillement-textiles-commerce-de-detail/Component.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1483-habillement-textiles-commerce-de-detail/Component.tsx index 38b6518cec..60f9f429c1 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1483-habillement-textiles-commerce-de-detail/Component.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1483-habillement-textiles-commerce-de-detail/Component.tsx @@ -2,12 +2,12 @@ import React, { useContext } from "react"; import { RadioQuestion } from "../../../Components"; import { SalaireTempsPlein } from "../../steps/Salaires/components"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement1483() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { noticeSalaryPeriods, onSalariesChange, @@ -17,7 +17,7 @@ export default function Agreement1483() { errorHasReceivedSalaries, noticePeriodsMoreThan3Months, init, - } = useIndemniteLicenciementStore(store, (state) => ({ + } = useIndemniteDepartStore(store, (state) => ({ noticeSalaryPeriods: state.agreement1483Data.input.noticeSalaryPeriods ?? [], onSalariesChange: state.agreement1483Function.onSalariesChange, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1483-habillement-textiles-commerce-de-detail/Informations.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1483-habillement-textiles-commerce-de-detail/Informations.tsx similarity index 92% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1483-habillement-textiles-commerce-de-detail/Informations.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1483-habillement-textiles-commerce-de-detail/Informations.tsx index 299326b2f6..dd079f7a21 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1483-habillement-textiles-commerce-de-detail/Informations.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1483-habillement-textiles-commerce-de-detail/Informations.tsx @@ -6,14 +6,14 @@ import { StyledFilledElementTable, } from "../../steps/Resultat/components/FilledElements"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement1483Informations() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { noticeSalaryPeriods, hasReceivedSalaries } = - useIndemniteLicenciementStore(store, (state) => ({ + useIndemniteDepartStore(store, (state) => ({ noticeSalaryPeriods: state.agreement1483Data.input.noticeSalaryPeriods ?? [], hasReceivedSalaries: state.agreement1483Data.input.hasReceivedSalaries, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1483-habillement-textiles-commerce-de-detail/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1483-habillement-textiles-commerce-de-detail/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1483-habillement-textiles-commerce-de-detail/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1483-habillement-textiles-commerce-de-detail/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1483-habillement-textiles-commerce-de-detail/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1483-habillement-textiles-commerce-de-detail/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1483-habillement-textiles-commerce-de-detail/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1483-habillement-textiles-commerce-de-detail/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1483-habillement-textiles-commerce-de-detail/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1483-habillement-textiles-commerce-de-detail/store/store.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1483-habillement-textiles-commerce-de-detail/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1483-habillement-textiles-commerce-de-detail/store/store.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1483-habillement-textiles-commerce-de-detail/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1483-habillement-textiles-commerce-de-detail/store/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1483-habillement-textiles-commerce-de-detail/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1483-habillement-textiles-commerce-de-detail/store/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1483-habillement-textiles-commerce-de-detail/store/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1483-habillement-textiles-commerce-de-detail/store/validator.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1483-habillement-textiles-commerce-de-detail/store/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1483-habillement-textiles-commerce-de-detail/store/validator.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1516-organismes-formation/Component.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1516-organismes-formation/Component.tsx similarity index 95% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1516-organismes-formation/Component.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1516-organismes-formation/Component.tsx index b1cddfeb2c..3e1c7f5e3c 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1516-organismes-formation/Component.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1516-organismes-formation/Component.tsx @@ -2,12 +2,12 @@ import React, { useContext } from "react"; import { RadioQuestion } from "../../../Components"; import { SalaireTempsPlein } from "../../steps/Salaires/components"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement1516() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { noticeSalaryPeriods, onSalariesChange, @@ -17,7 +17,7 @@ export default function Agreement1516() { errorHasReceivedSalaries, noticePeriodsMoreThan3Months, init, - } = useIndemniteLicenciementStore(store, (state) => ({ + } = useIndemniteDepartStore(store, (state) => ({ noticeSalaryPeriods: state.agreement1516Data.input.noticeSalaryPeriods ?? [], onSalariesChange: state.agreement1516Function.onSalariesChange, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1516-organismes-formation/Informations.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1516-organismes-formation/Informations.tsx similarity index 92% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1516-organismes-formation/Informations.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1516-organismes-formation/Informations.tsx index 3b26beb161..d27c290f2f 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1516-organismes-formation/Informations.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1516-organismes-formation/Informations.tsx @@ -6,14 +6,14 @@ import { StyledFilledElementTable, } from "../../steps/Resultat/components/FilledElements"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement1516Informations() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { noticeSalaryPeriods, hasReceivedSalaries } = - useIndemniteLicenciementStore(store, (state) => ({ + useIndemniteDepartStore(store, (state) => ({ noticeSalaryPeriods: state.agreement1516Data.input.noticeSalaryPeriods ?? [], hasReceivedSalaries: state.agreement1516Data.input.hasReceivedSalaries, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1516-organismes-formation/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1516-organismes-formation/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1516-organismes-formation/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1516-organismes-formation/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1516-organismes-formation/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1516-organismes-formation/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1516-organismes-formation/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1516-organismes-formation/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1516-organismes-formation/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1516-organismes-formation/store/store.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1516-organismes-formation/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1516-organismes-formation/store/store.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1516-organismes-formation/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1516-organismes-formation/store/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1516-organismes-formation/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1516-organismes-formation/store/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1516-organismes-formation/store/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1516-organismes-formation/store/validator.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1516-organismes-formation/store/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1516-organismes-formation/store/validator.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1517-commerces-de-detail-non-alimentaires/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1517-commerces-de-detail-non-alimentaires/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1517-commerces-de-detail-non-alimentaires/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1517-commerces-de-detail-non-alimentaires/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1517-commerces-de-detail-non-alimentaires/validator/dateSortie.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1517-commerces-de-detail-non-alimentaires/validator/dateSortie.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1517-commerces-de-detail-non-alimentaires/validator/dateSortie.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1517-commerces-de-detail-non-alimentaires/validator/dateSortie.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1517-commerces-de-detail-non-alimentaires/validator/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1517-commerces-de-detail-non-alimentaires/validator/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1517-commerces-de-detail-non-alimentaires/validator/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1517-commerces-de-detail-non-alimentaires/validator/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1527-immobilier/Component.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1527-immobilier/Component.tsx similarity index 85% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1527-immobilier/Component.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1527-immobilier/Component.tsx index dba59b9bd4..192b5a245c 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1527-immobilier/Component.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1527-immobilier/Component.tsx @@ -1,14 +1,14 @@ import React, { useContext } from "react"; import { RadioQuestion } from "../../../Components"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement1527() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { hasCommission, onChangeHasCommission, errorHasCommission } = - useIndemniteLicenciementStore(store, (state) => ({ + useIndemniteDepartStore(store, (state) => ({ hasCommission: state.agreement1527Data.input.hasCommission, onChangeHasCommission: state.agreement1527Function.onChangeHasCommission, errorHasCommission: state.agreement1527Data.error.errorHasCommission, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1527-immobilier/Informations.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1527-immobilier/Informations.tsx similarity index 65% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1527-immobilier/Informations.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1527-immobilier/Informations.tsx index 0af04dccdb..da1df1579d 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1527-immobilier/Informations.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1527-immobilier/Informations.tsx @@ -1,12 +1,12 @@ import { useContext } from "react"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement1527Informations() { - const store = useContext(IndemniteLicenciementContext); - const { hasCommission } = useIndemniteLicenciementStore(store, (state) => ({ + const store = useContext(IndemniteDepartContext); + const { hasCommission } = useIndemniteDepartStore(store, (state) => ({ hasCommission: state.agreement1527Data.input.hasCommission, })); diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1527-immobilier/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1527-immobilier/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1527-immobilier/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1527-immobilier/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1527-immobilier/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1527-immobilier/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1527-immobilier/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1527-immobilier/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1527-immobilier/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1527-immobilier/store/store.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1527-immobilier/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1527-immobilier/store/store.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1527-immobilier/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1527-immobilier/store/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1527-immobilier/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1527-immobilier/store/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1527-immobilier/store/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1527-immobilier/store/validator.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1527-immobilier/store/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1527-immobilier/store/validator.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/16-transports-routiers/Component.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/16-transports-routiers/Component.tsx similarity index 88% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/16-transports-routiers/Component.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/16-transports-routiers/Component.tsx index d8944a8be4..19ddc1796c 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/16-transports-routiers/Component.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/16-transports-routiers/Component.tsx @@ -1,12 +1,12 @@ import React, { useContext, useEffect } from "react"; import { RadioQuestion } from "../../../Components"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement16() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { init, showVariablePay, @@ -14,7 +14,7 @@ export default function Agreement16() { hasVariablePay, onChangeHasVariablePay, errorHasVariablePay, - } = useIndemniteLicenciementStore(store, (state) => ({ + } = useIndemniteDepartStore(store, (state) => ({ init: state.agreement16Function.onInit, showVariablePay: state.agreement16Data.input.showVariablePay, hasSameSalary: state.salairesData.input.hasSameSalary, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/16-transports-routiers/Informations.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/16-transports-routiers/Informations.tsx similarity index 72% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/16-transports-routiers/Informations.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/16-transports-routiers/Informations.tsx index 3e9772f9b4..12293dc5eb 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/16-transports-routiers/Informations.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/16-transports-routiers/Informations.tsx @@ -1,12 +1,12 @@ import { useContext } from "react"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement16Informations() { - const store = useContext(IndemniteLicenciementContext); - const { showVariablePay, hasVariablePay } = useIndemniteLicenciementStore( + const store = useContext(IndemniteDepartContext); + const { showVariablePay, hasVariablePay } = useIndemniteDepartStore( store, (state) => ({ showVariablePay: state.agreement16Data.input.showVariablePay, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/16-transports-routiers/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/16-transports-routiers/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/16-transports-routiers/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/16-transports-routiers/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/16-transports-routiers/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/16-transports-routiers/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/16-transports-routiers/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/16-transports-routiers/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/16-transports-routiers/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/16-transports-routiers/store/store.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/16-transports-routiers/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/16-transports-routiers/store/store.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/16-transports-routiers/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/16-transports-routiers/store/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/16-transports-routiers/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/16-transports-routiers/store/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/16-transports-routiers/store/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/16-transports-routiers/store/validator.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/16-transports-routiers/store/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/16-transports-routiers/store/validator.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1672-societes-assurances/Component.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1672-societes-assurances/Component.tsx similarity index 94% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1672-societes-assurances/Component.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1672-societes-assurances/Component.tsx index 78a5bb19dd..4da876a7f9 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1672-societes-assurances/Component.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1672-societes-assurances/Component.tsx @@ -3,12 +3,12 @@ import React, { useContext } from "react"; import { RadioQuestion } from "../../../Components"; import { SalaireTempsPlein } from "../../steps/Salaires/components"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement1672() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { noticeSalaryPeriods, onSalariesChange, @@ -17,7 +17,7 @@ export default function Agreement1672() { onChangeHasReceivedSalaries, errorHasReceivedSalaries, init, - } = useIndemniteLicenciementStore(store, (state) => ({ + } = useIndemniteDepartStore(store, (state) => ({ noticeSalaryPeriods: state.agreement1672Data.input.noticeSalaryPeriods ?? [], onSalariesChange: state.agreement1672Function.onSalariesChange, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1672-societes-assurances/Informations.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1672-societes-assurances/Informations.tsx similarity index 91% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1672-societes-assurances/Informations.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1672-societes-assurances/Informations.tsx index d101696f5f..b708bb0b96 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1672-societes-assurances/Informations.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1672-societes-assurances/Informations.tsx @@ -5,14 +5,14 @@ import { StyledFilledElementTable, } from "../../steps/Resultat/components/FilledElements"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement1672Informations() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { noticeSalaryPeriods, hasReceivedSalaries } = - useIndemniteLicenciementStore(store, (state) => ({ + useIndemniteDepartStore(store, (state) => ({ noticeSalaryPeriods: state.agreement1672Data.input.noticeSalaryPeriods ?? [], hasReceivedSalaries: state.agreement1672Data.input.hasReceivedSalaries, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1672-societes-assurances/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1672-societes-assurances/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1672-societes-assurances/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1672-societes-assurances/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1672-societes-assurances/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1672-societes-assurances/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1672-societes-assurances/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1672-societes-assurances/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1672-societes-assurances/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1672-societes-assurances/store/store.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1672-societes-assurances/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1672-societes-assurances/store/store.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1672-societes-assurances/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1672-societes-assurances/store/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1672-societes-assurances/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1672-societes-assurances/store/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1672-societes-assurances/store/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1672-societes-assurances/store/validator.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1672-societes-assurances/store/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1672-societes-assurances/store/validator.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1702-ouvriers-travaux-public/Component.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1702-ouvriers-travaux-public/Component.tsx similarity index 94% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1702-ouvriers-travaux-public/Component.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1702-ouvriers-travaux-public/Component.tsx index 5625463dd8..7e66a7a959 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1702-ouvriers-travaux-public/Component.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1702-ouvriers-travaux-public/Component.tsx @@ -3,12 +3,12 @@ import React, { useContext } from "react"; import { RadioQuestion } from "../../../Components"; import { SalaireTempsPlein } from "../../steps/Salaires/components"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement1702() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { noticeSalaryPeriods, onSalariesChange, @@ -17,7 +17,7 @@ export default function Agreement1702() { onChangeHasReceivedSalaries, errorHasReceivedSalaries, init, - } = useIndemniteLicenciementStore(store, (state) => ({ + } = useIndemniteDepartStore(store, (state) => ({ noticeSalaryPeriods: state.agreement1702Data.input.noticeSalaryPeriods ?? [], onSalariesChange: state.agreement1702Function.onSalariesChange, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1702-ouvriers-travaux-public/Informations.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1702-ouvriers-travaux-public/Informations.tsx similarity index 91% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1702-ouvriers-travaux-public/Informations.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1702-ouvriers-travaux-public/Informations.tsx index 1664ab8d3b..9a32ed8345 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1702-ouvriers-travaux-public/Informations.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1702-ouvriers-travaux-public/Informations.tsx @@ -5,14 +5,14 @@ import { StyledFilledElementTable, } from "../../steps/Resultat/components/FilledElements"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement1702Informations() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { noticeSalaryPeriods, hasReceivedSalaries } = - useIndemniteLicenciementStore(store, (state) => ({ + useIndemniteDepartStore(store, (state) => ({ noticeSalaryPeriods: state.agreement1702Data.input.noticeSalaryPeriods ?? [], hasReceivedSalaries: state.agreement1702Data.input.hasReceivedSalaries, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1702-ouvriers-travaux-public/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1702-ouvriers-travaux-public/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1702-ouvriers-travaux-public/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1702-ouvriers-travaux-public/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1702-ouvriers-travaux-public/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1702-ouvriers-travaux-public/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1702-ouvriers-travaux-public/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1702-ouvriers-travaux-public/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1702-ouvriers-travaux-public/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1702-ouvriers-travaux-public/store/store.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1702-ouvriers-travaux-public/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1702-ouvriers-travaux-public/store/store.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1702-ouvriers-travaux-public/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1702-ouvriers-travaux-public/store/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1702-ouvriers-travaux-public/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1702-ouvriers-travaux-public/store/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1702-ouvriers-travaux-public/store/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1702-ouvriers-travaux-public/store/validator.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1702-ouvriers-travaux-public/store/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1702-ouvriers-travaux-public/store/validator.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1740-batiment-region-parisienne/Component.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1740-batiment-region-parisienne/Component.tsx similarity index 94% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1740-batiment-region-parisienne/Component.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1740-batiment-region-parisienne/Component.tsx index a05cfc8a3d..5534997cfd 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1740-batiment-region-parisienne/Component.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1740-batiment-region-parisienne/Component.tsx @@ -2,12 +2,12 @@ import React, { useContext } from "react"; import { RadioQuestion } from "../../../Components"; import { SalaireTempsPlein } from "../../steps/Salaires/components"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement1740() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { noticeSalaryPeriods, onSalariesChange, @@ -16,7 +16,7 @@ export default function Agreement1740() { onChangeHasReceivedSalaries, errorHasReceivedSalaries, init, - } = useIndemniteLicenciementStore(store, (state) => ({ + } = useIndemniteDepartStore(store, (state) => ({ noticeSalaryPeriods: state.agreement1740Data.input.noticeSalaryPeriods ?? [], onSalariesChange: state.agreement1740Function.onSalariesChange, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1740-batiment-region-parisienne/Informations.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1740-batiment-region-parisienne/Informations.tsx similarity index 92% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1740-batiment-region-parisienne/Informations.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1740-batiment-region-parisienne/Informations.tsx index b668bdabac..37f50387e7 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1740-batiment-region-parisienne/Informations.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1740-batiment-region-parisienne/Informations.tsx @@ -6,14 +6,14 @@ import { StyledFilledElementTable, } from "../../steps/Resultat/components/FilledElements"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement1740Informations() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { noticeSalaryPeriods, hasReceivedSalaries } = - useIndemniteLicenciementStore(store, (state) => ({ + useIndemniteDepartStore(store, (state) => ({ noticeSalaryPeriods: state.agreement1740Data.input.noticeSalaryPeriods ?? [], hasReceivedSalaries: state.agreement1740Data.input.hasReceivedSalaries, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1740-batiment-region-parisienne/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1740-batiment-region-parisienne/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1740-batiment-region-parisienne/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1740-batiment-region-parisienne/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1740-batiment-region-parisienne/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1740-batiment-region-parisienne/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1740-batiment-region-parisienne/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1740-batiment-region-parisienne/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1740-batiment-region-parisienne/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1740-batiment-region-parisienne/store/store.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1740-batiment-region-parisienne/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1740-batiment-region-parisienne/store/store.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1740-batiment-region-parisienne/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1740-batiment-region-parisienne/store/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1740-batiment-region-parisienne/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1740-batiment-region-parisienne/store/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1740-batiment-region-parisienne/store/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1740-batiment-region-parisienne/store/validator.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/1740-batiment-region-parisienne/store/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/1740-batiment-region-parisienne/store/validator.ts diff --git a/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2120-banques/Component.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2120-banques/Component.tsx new file mode 100644 index 0000000000..a225ad8c25 --- /dev/null +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2120-banques/Component.tsx @@ -0,0 +1,101 @@ +import React, { useContext } from "react"; + +import { TextQuestion } from "../../../Components"; +import { IndemniteDepartContext, useIndemniteDepartStore } from "../../store"; +import { IndemniteDepartType } from "../../../types"; + +type Props = { + type: IndemniteDepartType; +}; + +export default function Agreement2120({ type }: Props) { + const store = useContext(IndemniteDepartContext); + const label = + type === IndemniteDepartType.LICENCIEMENT + ? "Montant total des éléments variables perçus au cours des 12 derniers mois précédant la notification du licenciement" + : "Montant total des éléments variables perçus au cours des 12 derniers mois précédant la rupture du contrat (obligatoire)"; + const subLabel = + type === IndemniteDepartType.LICENCIEMENT + ? "Indiquez le montant total des éléments variables, primes (à l’exception du 13ème mois) et avantages en nature perçus au cours des 12 derniers mois précédant la notification du licenciement" + : "Indiquez le montant total des éléments variables, primes (à l’exception du 13ème mois) et avantages en nature perçus au cours des 12 derniers mois précédant la rupture du contrat"; + const content = + type === IndemniteDepartType.LICENCIEMENT ? ( + <> +

+ Vous pouvez trouver ces éléments sur votre bulletin de paie. + Renseignez dans ce champ la somme des primes (fixes ou + exceptionnelles, sauf prime ou gratification librement versée par + l’employeur), éléments variables (ex : commissions) et avantages en + nature (ex : mise à disposition d’un logement ou d’un véhicule) perçus + au cours des 12 mois précédant la notification du licenciement. +

+

+ Le montant renseigné nous permettra de calculer l’indemnité de + licenciement prévue par la convention collective de la banque qui est + calculée sur la base des salaires sans ces éléments de rémunération. + Il sera donc déduit du/des salaires renseigné(s) à la question + précédente. A l’inverse, l’indemnité prévue par le code du travail est + calculée sur la base des salaires avec ces éléments de rémunération. +

+ + ) : ( + <> +

+ Vous pouvez trouver ces éléments sur votre bulletin de paie. + Renseignez dans ce champ la somme des primes (fixes ou + exceptionnelles, sauf prime ou gratification librement versée par + l’employeur), éléments variables (ex : commissions) et avantages en + nature (ex : mise à disposition d’un logement ou d’un véhicule) perçus + au cours des 12 mois précédant la rupture du contrat. +

+

+ Le montant renseigné nous permettra de calculer l’indemnité de rupture + conventionnelle prévue par la convention collective de la banque qui + est calculée sur la base des salaires sans ces éléments de + rémunération. Il sera donc déduit du/des salaires renseigné(s) à la + question précédente. A l’inverse, l’indemnité prévue par le code du + travail est calculée sur la base des salaires avec ces éléments de + rémunération. +

+ + ); + const { + salariesVariablePart, + onChangeSalariesVariablePart, + errorSalariesVariablePart, + isLicenciementDisciplinaire, + init, + } = useIndemniteDepartStore(store, (state) => ({ + salariesVariablePart: state.agreement2120Data.input.salariesVariablePart, + onChangeSalariesVariablePart: + state.agreement2120Function.onChangeSalariesVariablePart, + errorSalariesVariablePart: + state.agreement2120Data.error.errorSalariesVariablePart, + isLicenciementDisciplinaire: + state.agreement2120Data.input.isLicenciementDisciplinaire, + init: state.agreement2120Function.init, + })); + + React.useEffect(() => { + init(); + }, []); + + if (isLicenciementDisciplinaire) return <>; + return ( + + ); +} diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2120-banques/Informations.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2120-banques/Informations.tsx similarity index 72% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2120-banques/Informations.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2120-banques/Informations.tsx index 4a3ba8da3b..1d6613f4bf 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2120-banques/Informations.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2120-banques/Informations.tsx @@ -1,12 +1,12 @@ import { useContext } from "react"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement2120Informations() { - const store = useContext(IndemniteLicenciementContext); - const { salariesVariablePart } = useIndemniteLicenciementStore( + const store = useContext(IndemniteDepartContext); + const { salariesVariablePart } = useIndemniteDepartStore( store, (state) => ({ salariesVariablePart: state.agreement2120Data.input.salariesVariablePart, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2120-banques/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2120-banques/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2120-banques/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2120-banques/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2120-banques/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2120-banques/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2120-banques/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2120-banques/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2120-banques/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2120-banques/store/store.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2120-banques/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2120-banques/store/store.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2120-banques/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2120-banques/store/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2120-banques/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2120-banques/store/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2120-banques/store/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2120-banques/store/validator.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2120-banques/store/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2120-banques/store/validator.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2148-telecommunications/Component.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2148-telecommunications/Component.tsx similarity index 94% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2148-telecommunications/Component.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2148-telecommunications/Component.tsx index 56a56e26b5..df6ea593d6 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2148-telecommunications/Component.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2148-telecommunications/Component.tsx @@ -3,12 +3,12 @@ import React, { useContext } from "react"; import { RadioQuestion } from "../../../Components"; import { SalaireTempsPlein } from "../../steps/Salaires/components"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement2148() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { noticeSalaryPeriods, onSalariesChange, @@ -17,7 +17,7 @@ export default function Agreement2148() { onChangeHasReceivedSalaries, errorHasReceivedSalaries, init, - } = useIndemniteLicenciementStore(store, (state) => ({ + } = useIndemniteDepartStore(store, (state) => ({ noticeSalaryPeriods: state.agreement2148Data.input.noticeSalaryPeriods ?? [], onSalariesChange: state.agreement2148Function.onSalariesChange, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2148-telecommunications/Informations.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2148-telecommunications/Informations.tsx similarity index 91% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2148-telecommunications/Informations.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2148-telecommunications/Informations.tsx index 7a126a0a06..7e5c0c4cfb 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2148-telecommunications/Informations.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2148-telecommunications/Informations.tsx @@ -5,14 +5,14 @@ import { StyledFilledElementTable, } from "../../steps/Resultat/components/FilledElements"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement2148Informations() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { noticeSalaryPeriods, hasReceivedSalaries } = - useIndemniteLicenciementStore(store, (state) => ({ + useIndemniteDepartStore(store, (state) => ({ noticeSalaryPeriods: state.agreement2148Data.input.noticeSalaryPeriods ?? [], hasReceivedSalaries: state.agreement2148Data.input.hasReceivedSalaries, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2148-telecommunications/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2148-telecommunications/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2148-telecommunications/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2148-telecommunications/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2148-telecommunications/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2148-telecommunications/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2148-telecommunications/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2148-telecommunications/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2148-telecommunications/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2148-telecommunications/store/store.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2148-telecommunications/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2148-telecommunications/store/store.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2148-telecommunications/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2148-telecommunications/store/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2148-telecommunications/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2148-telecommunications/store/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2148-telecommunications/store/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2148-telecommunications/store/validator.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2148-telecommunications/store/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2148-telecommunications/store/validator.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2596-coiffure/Component.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2596-coiffure/Component.tsx similarity index 94% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2596-coiffure/Component.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2596-coiffure/Component.tsx index accb26b9de..bb02c1ecd9 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2596-coiffure/Component.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2596-coiffure/Component.tsx @@ -3,12 +3,12 @@ import React, { useContext } from "react"; import { RadioQuestion } from "../../../Components"; import { SalaireTempsPlein } from "../../steps/Salaires/components"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement2596() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { noticeSalaryPeriods, onSalariesChange, @@ -17,7 +17,7 @@ export default function Agreement2596() { onChangeHasReceivedSalaries, errorHasReceivedSalaries, init, - } = useIndemniteLicenciementStore(store, (state) => ({ + } = useIndemniteDepartStore(store, (state) => ({ noticeSalaryPeriods: state.agreement2596Data.input.noticeSalaryPeriods ?? [], onSalariesChange: state.agreement2596Function.onSalariesChange, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2596-coiffure/Informations.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2596-coiffure/Informations.tsx similarity index 91% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2596-coiffure/Informations.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2596-coiffure/Informations.tsx index 189a4c302b..592a28f4cf 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2596-coiffure/Informations.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2596-coiffure/Informations.tsx @@ -5,14 +5,14 @@ import { StyledFilledElementTable, } from "../../steps/Resultat/components/FilledElements"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement2596Informations() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { noticeSalaryPeriods, hasReceivedSalaries } = - useIndemniteLicenciementStore(store, (state) => ({ + useIndemniteDepartStore(store, (state) => ({ noticeSalaryPeriods: state.agreement2596Data.input.noticeSalaryPeriods ?? [], hasReceivedSalaries: state.agreement2596Data.input.hasReceivedSalaries, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2596-coiffure/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2596-coiffure/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2596-coiffure/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2596-coiffure/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2596-coiffure/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2596-coiffure/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2596-coiffure/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2596-coiffure/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2596-coiffure/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2596-coiffure/store/store.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2596-coiffure/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2596-coiffure/store/store.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2596-coiffure/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2596-coiffure/store/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2596-coiffure/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2596-coiffure/store/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2596-coiffure/store/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2596-coiffure/store/validator.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2596-coiffure/store/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2596-coiffure/store/validator.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2609-batiment-etam/Component.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2609-batiment-etam/Component.tsx similarity index 86% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2609-batiment-etam/Component.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2609-batiment-etam/Component.tsx index 9431aab539..8bc0e066de 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2609-batiment-etam/Component.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2609-batiment-etam/Component.tsx @@ -1,18 +1,18 @@ import React, { useContext } from "react"; import { RadioQuestion } from "../../../Components"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement2609() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { hasSameSalary, hasVariablePay, onChangeHasVariablePay, errorHasVariablePay, - } = useIndemniteLicenciementStore(store, (state) => ({ + } = useIndemniteDepartStore(store, (state) => ({ hasSameSalary: state.salairesData.input.hasSameSalary, hasVariablePay: state.agreement2609Data.input.hasVariablePay, onChangeHasVariablePay: state.agreement2609Function.onChangeHasVariablePay, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2609-batiment-etam/Informations.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2609-batiment-etam/Informations.tsx similarity index 72% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2609-batiment-etam/Informations.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2609-batiment-etam/Informations.tsx index fbc8b5353e..006edb3102 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2609-batiment-etam/Informations.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2609-batiment-etam/Informations.tsx @@ -1,12 +1,12 @@ import { useContext } from "react"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement2609Informations() { - const store = useContext(IndemniteLicenciementContext); - const { hasSameSalary, hasVariablePay } = useIndemniteLicenciementStore( + const store = useContext(IndemniteDepartContext); + const { hasSameSalary, hasVariablePay } = useIndemniteDepartStore( store, (state) => ({ hasSameSalary: state.salairesData.input.hasSameSalary, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2609-batiment-etam/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2609-batiment-etam/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2609-batiment-etam/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2609-batiment-etam/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2609-batiment-etam/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2609-batiment-etam/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2609-batiment-etam/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2609-batiment-etam/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2609-batiment-etam/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2609-batiment-etam/store/store.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2609-batiment-etam/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2609-batiment-etam/store/store.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2609-batiment-etam/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2609-batiment-etam/store/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2609-batiment-etam/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2609-batiment-etam/store/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2609-batiment-etam/store/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2609-batiment-etam/store/validator.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2609-batiment-etam/store/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2609-batiment-etam/store/validator.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2614-travaux-public/Component.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2614-travaux-public/Component.tsx similarity index 86% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2614-travaux-public/Component.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2614-travaux-public/Component.tsx index c8acce94c9..eabb59842d 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2614-travaux-public/Component.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2614-travaux-public/Component.tsx @@ -1,18 +1,18 @@ import React, { useContext } from "react"; import { RadioQuestion } from "../../../Components"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement2614() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { hasSameSalary, hasVariablePay, onChangeHasVariablePay, errorHasVariablePay, - } = useIndemniteLicenciementStore(store, (state) => ({ + } = useIndemniteDepartStore(store, (state) => ({ hasSameSalary: state.salairesData.input.hasSameSalary, hasVariablePay: state.agreement2614Data.input.hasVariablePay, onChangeHasVariablePay: state.agreement2614Function.onChangeHasVariablePay, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2614-travaux-public/Informations.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2614-travaux-public/Informations.tsx similarity index 72% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2614-travaux-public/Informations.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2614-travaux-public/Informations.tsx index df063aa610..1c51b33473 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2614-travaux-public/Informations.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2614-travaux-public/Informations.tsx @@ -1,12 +1,12 @@ import { useContext } from "react"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement2614Informations() { - const store = useContext(IndemniteLicenciementContext); - const { hasSameSalary, hasVariablePay } = useIndemniteLicenciementStore( + const store = useContext(IndemniteDepartContext); + const { hasSameSalary, hasVariablePay } = useIndemniteDepartStore( store, (state) => ({ hasSameSalary: state.salairesData.input.hasSameSalary, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2614-travaux-public/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2614-travaux-public/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2614-travaux-public/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2614-travaux-public/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2614-travaux-public/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2614-travaux-public/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2614-travaux-public/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2614-travaux-public/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2614-travaux-public/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2614-travaux-public/store/store.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2614-travaux-public/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2614-travaux-public/store/store.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2614-travaux-public/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2614-travaux-public/store/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2614-travaux-public/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2614-travaux-public/store/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2614-travaux-public/store/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2614-travaux-public/store/validator.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/2614-travaux-public/store/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/2614-travaux-public/store/validator.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/29-hospitalisation-privee-but-non-lucratif/Component.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/29-hospitalisation-privee-but-non-lucratif/Component.tsx similarity index 85% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/29-hospitalisation-privee-but-non-lucratif/Component.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/29-hospitalisation-privee-but-non-lucratif/Component.tsx index 9252aa4f46..70bcdd5dd8 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/29-hospitalisation-privee-but-non-lucratif/Component.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/29-hospitalisation-privee-but-non-lucratif/Component.tsx @@ -1,12 +1,9 @@ import React, { useContext, useEffect } from "react"; import { RadioQuestion, TextQuestion } from "../../../Components"; -import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, -} from "../../store"; +import { IndemniteDepartContext, useIndemniteDepartStore } from "../../store"; export default function Agreement29() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { hasSixBestSalaries, onChangeHasSixBestSalaries, @@ -17,7 +14,7 @@ export default function Agreement29() { init, shouldAskSixBestSalaries, hasSameSalary, - } = useIndemniteLicenciementStore(store, (state) => ({ + } = useIndemniteDepartStore(store, (state) => ({ hasSixBestSalaries: state.agreement29Data.input.hasSixBestSalaries, onChangeHasSixBestSalaries: state.agreement29Function.onChangeHasSixBestSalaries, @@ -74,10 +71,9 @@ export default function Agreement29() { )} {hasSixBestSalaries === "non" && (

- Le calcul de l’indemnité de licenciement nécessite le total des 6 - meilleurs salaires perçus consécutivement durant le contrat de - travail. Pour réaliser cette simulation, nous calculerons ce total sur - la base + Le calcul de l’indemnité nécessite le total des 6 meilleurs salaires + perçus consécutivement durant le contrat de travail. Pour réaliser + cette simulation, nous calculerons ce total sur la base {hasSameSalary == "oui" ? " du salaire renseigné " : " des salaires renseignés "} diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/29-hospitalisation-privee-but-non-lucratif/Informations.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/29-hospitalisation-privee-but-non-lucratif/Informations.tsx similarity index 85% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/29-hospitalisation-privee-but-non-lucratif/Informations.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/29-hospitalisation-privee-but-non-lucratif/Informations.tsx index 06eaf21e74..889743e98b 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/29-hospitalisation-privee-but-non-lucratif/Informations.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/29-hospitalisation-privee-but-non-lucratif/Informations.tsx @@ -1,17 +1,17 @@ import { useContext, useEffect } from "react"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement29Informations() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { hasSixBestSalaries, sixBestSalariesTotal, init, shouldAskSixBestSalaries, - } = useIndemniteLicenciementStore(store, (state) => ({ + } = useIndemniteDepartStore(store, (state) => ({ hasSixBestSalaries: state.agreement29Data.input.hasSixBestSalaries, sixBestSalariesTotal: state.agreement29Data.input.sixBestSalariesTotal, init: state.agreement29Function.init, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/29-hospitalisation-privee-but-non-lucratif/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/29-hospitalisation-privee-but-non-lucratif/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/29-hospitalisation-privee-but-non-lucratif/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/29-hospitalisation-privee-but-non-lucratif/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/29-hospitalisation-privee-but-non-lucratif/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/29-hospitalisation-privee-but-non-lucratif/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/29-hospitalisation-privee-but-non-lucratif/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/29-hospitalisation-privee-but-non-lucratif/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/29-hospitalisation-privee-but-non-lucratif/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/29-hospitalisation-privee-but-non-lucratif/store/store.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/29-hospitalisation-privee-but-non-lucratif/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/29-hospitalisation-privee-but-non-lucratif/store/store.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/29-hospitalisation-privee-but-non-lucratif/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/29-hospitalisation-privee-but-non-lucratif/store/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/29-hospitalisation-privee-but-non-lucratif/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/29-hospitalisation-privee-but-non-lucratif/store/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/29-hospitalisation-privee-but-non-lucratif/store/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/29-hospitalisation-privee-but-non-lucratif/store/validator.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/29-hospitalisation-privee-but-non-lucratif/store/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/29-hospitalisation-privee-but-non-lucratif/store/validator.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/44-industries-chimiques/Component.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/44-industries-chimiques/Component.tsx similarity index 95% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/44-industries-chimiques/Component.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/44-industries-chimiques/Component.tsx index 0bfd0e6d47..88b35b30a2 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/44-industries-chimiques/Component.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/44-industries-chimiques/Component.tsx @@ -2,12 +2,12 @@ import React, { useContext, useEffect } from "react"; import { RadioQuestion } from "../../../Components"; import { SalaireTempsPlein } from "../../steps/Salaires/components"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement44() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { init, showVariablePay, @@ -23,7 +23,7 @@ export default function Agreement44() { errorLastMonthSalary, lastMonthSalary, onChangeLastMonthSalary, - } = useIndemniteLicenciementStore(store, (state) => ({ + } = useIndemniteDepartStore(store, (state) => ({ init: state.agreement44Function.onInit, showVariablePay: state.agreement44Data.input.showVariablePay, hasSameSalary: state.salairesData.input.hasSameSalary, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/44-industries-chimiques/Informations.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/44-industries-chimiques/Informations.tsx similarity index 88% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/44-industries-chimiques/Informations.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/44-industries-chimiques/Informations.tsx index e93f957a10..bbdfce3b56 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/44-industries-chimiques/Informations.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/44-industries-chimiques/Informations.tsx @@ -1,13 +1,13 @@ import { useContext } from "react"; import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; export default function Agreement44Informations() { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { hasVariablePay, knowingLastSalary, lastMonthSalary, showKnowingLastSalary, showLastMonthSalary } = - useIndemniteLicenciementStore(store, (state) => ({ + useIndemniteDepartStore(store, (state) => ({ hasVariablePay: state.agreement44Data.input.hasVariablePay, lastMonthSalary: state.agreement44Data.input.lastMonthSalary, knowingLastSalary: state.agreement44Data.input.knowingLastSalary, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/44-industries-chimiques/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/44-industries-chimiques/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/44-industries-chimiques/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/44-industries-chimiques/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/44-industries-chimiques/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/44-industries-chimiques/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/44-industries-chimiques/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/44-industries-chimiques/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/44-industries-chimiques/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/44-industries-chimiques/store/store.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/44-industries-chimiques/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/44-industries-chimiques/store/store.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/44-industries-chimiques/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/44-industries-chimiques/store/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/44-industries-chimiques/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/44-industries-chimiques/store/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/44-industries-chimiques/store/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/44-industries-chimiques/store/validator.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/44-industries-chimiques/store/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/44-industries-chimiques/store/validator.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/AgreementsInjector.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/AgreementsInjector.tsx similarity index 67% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/AgreementsInjector.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/AgreementsInjector.tsx index eadf2b2a2b..8341b7b15e 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/AgreementsInjector.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/AgreementsInjector.tsx @@ -1,6 +1,6 @@ -import { SupportedCc } from "@socialgouv/modeles-social"; +import { PublicodesSimulator, SupportedCc } from "@socialgouv/modeles-social"; import React from "react"; -import { IndemniteLicenciementStepName } from ".."; +import { IndemniteDepartStepName } from ".."; import { Agreement1516, Agreement1516Informations, @@ -37,94 +37,96 @@ import { Agreement1740Informations, } from "./1740-batiment-region-parisienne"; import { Agreement2120, Agreement2120Informations } from "./2120-banques"; +import { IndemniteDepartType } from "../../types"; type Props = { idcc: SupportedCc | null | undefined; - step: IndemniteLicenciementStepName; + step: IndemniteDepartStepName; + type: IndemniteDepartType; }; export default function AgreementsInjector(props: Props) { switch (true) { case SupportedCc.IDCC0016 === props.idcc && - props.step === IndemniteLicenciementStepName.Salaires: + props.step === IndemniteDepartStepName.Salaires: return ; case SupportedCc.IDCC0016 === props.idcc && - props.step === IndemniteLicenciementStepName.Resultat: + props.step === IndemniteDepartStepName.Resultat: return ; case SupportedCc.IDCC0029 === props.idcc && - props.step === IndemniteLicenciementStepName.Salaires: + props.step === IndemniteDepartStepName.Salaires: return ; case SupportedCc.IDCC0029 === props.idcc && - props.step === IndemniteLicenciementStepName.Resultat: + props.step === IndemniteDepartStepName.Resultat: return ; case SupportedCc.IDCC0044 === props.idcc && - props.step === IndemniteLicenciementStepName.Salaires: + props.step === IndemniteDepartStepName.Salaires: return ; case SupportedCc.IDCC0044 === props.idcc && - props.step === IndemniteLicenciementStepName.Resultat: + props.step === IndemniteDepartStepName.Resultat: return ; case SupportedCc.IDCC1516 === props.idcc && - props.step === IndemniteLicenciementStepName.Salaires: + props.step === IndemniteDepartStepName.Salaires: return ; case SupportedCc.IDCC1516 === props.idcc && - props.step === IndemniteLicenciementStepName.Resultat: + props.step === IndemniteDepartStepName.Resultat: return ; case SupportedCc.IDCC1527 === props.idcc && - props.step === IndemniteLicenciementStepName.Salaires: + props.step === IndemniteDepartStepName.Salaires: return ; case SupportedCc.IDCC1527 === props.idcc && - props.step === IndemniteLicenciementStepName.Resultat: + props.step === IndemniteDepartStepName.Resultat: return ; case SupportedCc.IDCC2596 === props.idcc && - props.step === IndemniteLicenciementStepName.Salaires: + props.step === IndemniteDepartStepName.Salaires: return ; case SupportedCc.IDCC2596 === props.idcc && - props.step === IndemniteLicenciementStepName.Resultat: + props.step === IndemniteDepartStepName.Resultat: return ; case SupportedCc.IDCC2609 === props.idcc && - props.step === IndemniteLicenciementStepName.Salaires: + props.step === IndemniteDepartStepName.Salaires: return ; case SupportedCc.IDCC2614 === props.idcc && - props.step === IndemniteLicenciementStepName.Salaires: + props.step === IndemniteDepartStepName.Salaires: return ; case SupportedCc.IDCC2609 === props.idcc && - props.step === IndemniteLicenciementStepName.Resultat: + props.step === IndemniteDepartStepName.Resultat: return ; case SupportedCc.IDCC2120 === props.idcc && - props.step === IndemniteLicenciementStepName.Salaires: - return ; + props.step === IndemniteDepartStepName.Salaires: + return ; case SupportedCc.IDCC2120 === props.idcc && - props.step === IndemniteLicenciementStepName.Resultat: + props.step === IndemniteDepartStepName.Resultat: return ; case SupportedCc.IDCC2148 === props.idcc && - props.step === IndemniteLicenciementStepName.Salaires: + props.step === IndemniteDepartStepName.Salaires: return ; case SupportedCc.IDCC2148 === props.idcc && - props.step === IndemniteLicenciementStepName.Resultat: + props.step === IndemniteDepartStepName.Resultat: return ; case SupportedCc.IDCC1672 === props.idcc && - props.step === IndemniteLicenciementStepName.Salaires: + props.step === IndemniteDepartStepName.Salaires: return ; case SupportedCc.IDCC1672 === props.idcc && - props.step === IndemniteLicenciementStepName.Resultat: + props.step === IndemniteDepartStepName.Resultat: return ; case SupportedCc.IDCC1483 === props.idcc && - props.step === IndemniteLicenciementStepName.Salaires: + props.step === IndemniteDepartStepName.Salaires: return ; case SupportedCc.IDCC1483 === props.idcc && - props.step === IndemniteLicenciementStepName.Resultat: + props.step === IndemniteDepartStepName.Resultat: return ; case SupportedCc.IDCC1702 === props.idcc && - props.step === IndemniteLicenciementStepName.Salaires: + props.step === IndemniteDepartStepName.Salaires: return ; case SupportedCc.IDCC1702 === props.idcc && - props.step === IndemniteLicenciementStepName.Resultat: + props.step === IndemniteDepartStepName.Resultat: return ; case SupportedCc.IDCC1740 === props.idcc && - props.step === IndemniteLicenciementStepName.Salaires: + props.step === IndemniteDepartStepName.Salaires: return ; case SupportedCc.IDCC1740 === props.idcc && - props.step === IndemniteLicenciementStepName.Resultat: + props.step === IndemniteDepartStepName.Resultat: return ; default: return <>; diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/__tests__/messageMotifExample.test.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/__tests__/messageMotifExample.test.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/__tests__/messageMotifExample.test.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/__tests__/messageMotifExample.test.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/seniority/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/seniority/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/seniority/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/seniority/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/seniority/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/seniority/validator.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/seniority/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/seniority/validator.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/ui-customizations/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/ui-customizations/index.ts new file mode 100644 index 0000000000..8c5cc96591 --- /dev/null +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/ui-customizations/index.ts @@ -0,0 +1,2 @@ +export * from "./messages"; +export * from "./tooltip"; diff --git a/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/ui-customizations/messages.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/ui-customizations/messages.ts new file mode 100644 index 0000000000..277b2f7187 --- /dev/null +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/ui-customizations/messages.ts @@ -0,0 +1,47 @@ +import { CatPro3239 } from "@socialgouv/modeles-social"; + +export const getMessageMotifExample = ( + informations?: Record +): string => { + let isAssMat = false; + let isSalariePartEmployeur = false; + if (informations) { + const categoryPro3239 = + informations[ + "contrat salarié . convention collective . particuliers employeurs et emploi à domicile . indemnité de licenciement . catégorie professionnelle" + ]; + isAssMat = categoryPro3239 === CatPro3239.assistantMaternel; + isSalariePartEmployeur = + categoryPro3239 === CatPro3239.salarieParticulierEmployeur; + } + if (isAssMat || isSalariePartEmployeur) + return "Les jours fériés à l’exception des jours fériés tombant sur une semaine non travaillée prévue au contrat de travail, les congés payés, le congé maternité, paternité, d’accueil de l’enfant et d’adoption, les congés pour évènements familiaux, le congé de présence parentale, l'arrêt de travail lié à un accident du travail ou une maladie professionnelle ou un accident de trajet, le congé lié à la formation professionnelle (CIF, projet de transition professionnelle), le congé pour la journée de la défense et de la citoyenneté, le congé pour assister à la cérémonie d’accueil dans la citoyenneté française, les absences pour la participation aux commissions paritaires de la branche, les absences pour la participation à la vie statutaire d’un syndicat ou à une formation syndicale sont déjà pris en compte dans l'ancienneté et ne sont pas des périodes à renseigner ci-après :"; + return "Les congés payés, le congé de maternité, paternité ou d'adoption, le congé de présence parentale, le congé parental d'éducation à temps partiel, l'arrêt de travail lié à un accident du travail ou une maladie professionnelle, le congé lié à la formation professionnelle (CIF, projet de transition professionnelle), le congé de solidarité internationale, le congé de solidarité familiale et le stage de fin d'étude de plus de 2 mois sont déjà pris en compte dans l'ancienneté et ne sont pas des périodes à renseigner ci-après :"; +}; + +export const getSalairesTempsPleinSubtitle = ( + agreementNumber?: number +): string | undefined => { + switch (agreementNumber) { + case 3239: + return undefined; + case 1702: + return "Indiquez le montant des salaires (en incluant l’indemnité de congés payés, les primes, dont la prime de vacances, et les avantages en nature) dans le premier champ et le montant des primes dans le second champ (uniquement pour les 3 derniers mois)"; + default: + return "Indiquez le montant des salaires (en incluant les primes et avantages en nature) dans le premier champ et le montant des primes dans le second champ (uniquement pour les 3 derniers mois)"; + } +}; + +export const isParentalNoticeHiddenForAgreement = ( + isAgreementBetter: boolean, + agreementNumber: number +): boolean => { + if (agreementNumber === 3239) return true; + return ( + isAgreementBetter && + (agreementNumber === 1404 || + agreementNumber === 2120 || + agreementNumber === 292 || + agreementNumber === 176) + ); +}; diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/ui-customizations/tooltip.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/ui-customizations/tooltip.tsx similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/ui-customizations/tooltip.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/ui-customizations/tooltip.tsx diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/validator.ts similarity index 74% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/validator.ts index 5a6307cba5..868ea05c3e 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/agreements/validator.ts +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/agreements/validator.ts @@ -1,6 +1,6 @@ import { SupportedCc } from "@socialgouv/modeles-social"; import { StoreApi } from "zustand"; -import { IndemniteLicenciementStepName } from ".."; +import { IndemniteDepartStepName } from ".."; import { MainStore } from "../store"; import { validateAgreement1516 } from "./1516-organismes-formation"; import { validateAgreement1527 } from "./1527-immobilier"; @@ -19,52 +19,52 @@ import { validateAgreement1740 } from "./1740-batiment-region-parisienne"; const validatorAgreement = ( idcc: SupportedCc | null | undefined, - step: IndemniteLicenciementStepName, + step: IndemniteDepartStepName, get: StoreApi["getState"], set: StoreApi["setState"] ): boolean => { switch (true) { case SupportedCc.IDCC1516 === idcc && - step === IndemniteLicenciementStepName.Salaires: + step === IndemniteDepartStepName.Salaires: return validateAgreement1516(get, set); case SupportedCc.IDCC1527 === idcc && - step === IndemniteLicenciementStepName.Salaires: + step === IndemniteDepartStepName.Salaires: return validateAgreement1527(get, set); case SupportedCc.IDCC0029 === idcc && - step === IndemniteLicenciementStepName.Salaires: + step === IndemniteDepartStepName.Salaires: return validateAgreement29(get, set); case SupportedCc.IDCC0016 === idcc && - step === IndemniteLicenciementStepName.Salaires: + step === IndemniteDepartStepName.Salaires: return validateAgreement16(get, set); case SupportedCc.IDCC0044 === idcc && - step === IndemniteLicenciementStepName.Salaires: + step === IndemniteDepartStepName.Salaires: return validateAgreement44(get, set); case SupportedCc.IDCC2596 === idcc && - step === IndemniteLicenciementStepName.Salaires: + step === IndemniteDepartStepName.Salaires: return validateAgreement2596(get, set); case SupportedCc.IDCC2609 === idcc && - step === IndemniteLicenciementStepName.Salaires: + step === IndemniteDepartStepName.Salaires: return validateAgreement2609(get, set); case SupportedCc.IDCC2120 === idcc && - step === IndemniteLicenciementStepName.Salaires: + step === IndemniteDepartStepName.Salaires: return validateAgreement2120(get, set); case SupportedCc.IDCC2148 === idcc && - step === IndemniteLicenciementStepName.Salaires: + step === IndemniteDepartStepName.Salaires: return validateAgreement2148(get, set); case SupportedCc.IDCC2614 === idcc && - step === IndemniteLicenciementStepName.Salaires: + step === IndemniteDepartStepName.Salaires: return validateAgreement2614(get, set); case SupportedCc.IDCC1672 === idcc && - step === IndemniteLicenciementStepName.Salaires: + step === IndemniteDepartStepName.Salaires: return validateAgreement1672(get, set); case SupportedCc.IDCC1483 === idcc && - step === IndemniteLicenciementStepName.Salaires: + step === IndemniteDepartStepName.Salaires: return validateAgreement1483(get, set); case SupportedCc.IDCC1702 === idcc && - step === IndemniteLicenciementStepName.Salaires: + step === IndemniteDepartStepName.Salaires: return validateAgreement1702(get, set); case SupportedCc.IDCC1740 === idcc && - step === IndemniteLicenciementStepName.Salaires: + step === IndemniteDepartStepName.Salaires: return validateAgreement1740(get, set); default: return true; diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/usecase/__tests__/computeSalaryPeriods.test.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/usecase/__tests__/computeSalaryPeriods.test.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/usecase/__tests__/computeSalaryPeriods.test.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/usecase/__tests__/computeSalaryPeriods.test.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/usecase/__tests__/getSupportedCc.test.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/usecase/__tests__/getSupportedCc.test.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/usecase/__tests__/getSupportedCc.test.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/usecase/__tests__/getSupportedCc.test.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/usecase/computeSalaryPeriods.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/usecase/computeSalaryPeriods.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/usecase/computeSalaryPeriods.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/usecase/computeSalaryPeriods.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/usecase/getSupportedCc.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/usecase/getSupportedCc.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/usecase/getSupportedCc.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/usecase/getSupportedCc.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/usecase/hasNoBetterAllowance.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/usecase/hasNoBetterAllowance.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/usecase/hasNoBetterAllowance.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/usecase/hasNoBetterAllowance.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/usecase/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/usecase/index.ts similarity index 80% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/usecase/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/usecase/index.ts index 529ffea50f..16dd9f1ea6 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/usecase/index.ts +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/usecase/index.ts @@ -1,5 +1,4 @@ export { default as computeSalaryPeriods } from "./computeSalaryPeriods"; export { default as getSupportedCc } from "./getSupportedCc"; -export { default as hasNoLegalIndemnity } from "./hasNoLegalIndemnity"; export { default as isCcFullySupportedIndemniteLicenciement } from "./isCcFullySupported"; export { default as hasNoBetterAllowance } from "./hasNoBetterAllowance"; diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/usecase/isCcFullySupported.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/usecase/isCcFullySupported.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/common/usecase/isCcFullySupported.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/common/usecase/isCcFullySupported.ts diff --git a/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/events/emitter.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/events/emitter.ts new file mode 100644 index 0000000000..1de8310c38 --- /dev/null +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/events/emitter.ts @@ -0,0 +1,42 @@ +import { CallbackEventType, EventType } from "./events"; + +export const eventEmitter: { + readonly events: Record; + dispatch( + eventType: T, + ...values: Parameters + ): void; + subscribe( + eventType: T, + callback: CallbackEventType[T] + ): void; + unsubscribe(eventType: T): void; + unsubscribeAll(): void; +} = { + events: {}, + + dispatch( + event: T, + ...values: Parameters + ) { + if (!this.events[event]) return; + this.events[event].forEach((callback: any) => + callback(...(values as Parameters)) + ); + }, + + subscribe(event, callback) { + if (!this.events[event]) this.events[event] = []; + if (!this.events[event]?.includes(this.events[event][0])) + this.events[event]?.push(callback); + }, + + unsubscribe(event) { + if (!this.events[event]) return; + delete this.events[event]; + }, + + unsubscribeAll() { + this.events = {}; + }, +}; diff --git a/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/events/events.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/events/events.ts new file mode 100644 index 0000000000..0b296e5fac --- /dev/null +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/events/events.ts @@ -0,0 +1,9 @@ +export enum EventType { + SEND_RESULT_EVENT = "sendResultEvent", + TRACK_QUESTION = "trackQuestion", +} + +export type CallbackEventType = { + [EventType.SEND_RESULT_EVENT]: (isEligible: boolean) => void; + [EventType.TRACK_QUESTION]: (title: string) => void; +}; diff --git a/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/index.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/index.tsx new file mode 100644 index 0000000000..e9a4e78f32 --- /dev/null +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/index.tsx @@ -0,0 +1,158 @@ +import React, { useContext } from "react"; +import { SimulatorLayout } from "../Components"; +import { Step } from "../Simulator"; +import { + createIndemniteDepartStore, + IndemniteDepartContext, + IndemniteDepartProvider, + useIndemniteDepartStore, +} from "./store"; +import { IndemniteDepartType } from "../types"; +import { PublicodesSimulator } from "@socialgouv/modeles-social"; +import { Feedback } from "../common/Feedback"; +import styled from "styled-components"; + +type Props = { + icon: string; + title: string; + displayTitle: string; + tool: IndemniteDepartType; + steps: Step[]; + hasFeedbackPopup: boolean; +}; + +type SimulateurProps = Props & { + icon: string; + title: string; + displayTitle: string; + tool: IndemniteDepartType; +}; + +export enum IndemniteDepartStepName { + Introduction = "start", + ContratTravail = "contrat_travail", + Agreement = "info_cc", + Anciennete = "anciennete", + Salaires = "salaires", + Resultat = "results", + Informations = "infos", +} + +const IndemniteDepartSimulator = ({ + title, + icon, + displayTitle, + hasFeedbackPopup, + steps, +}: SimulateurProps): JSX.Element => { + const store = useContext(IndemniteDepartContext); + const { + onNextStepContratTravail, + isStepContratTravailValid, + onNextStepAnciennete, + isStepAncienneteValid, + onNextStepSalaires, + isStepSalairesValid, + onNextStepAgreement, + isStepAgreementValid, + onNextStepInformations, + isStepInformationsValid, + isStepInformationsHidden, + isStepSalaryHidden, + } = useIndemniteDepartStore(store, (state) => ({ + onNextStepContratTravail: state.contratTravailFunction.onNextStep, + isStepContratTravailValid: state.contratTravailData.isStepValid, + onNextStepAnciennete: state.ancienneteFunction.onNextStep, + isStepAncienneteValid: state.ancienneteData.isStepValid, + onNextStepSalaires: state.salairesFunction.onNextStep, + isStepSalairesValid: state.salairesData.isStepValid, + onNextStepAgreement: state.agreementFunction.onNextStep, + isStepAgreementValid: state.agreementData.isStepValid, + onNextStepInformations: state.informationsFunction.onNextStep, + isStepInformationsValid: state.informationsData.isStepValid, + isStepInformationsHidden: state.informationsData.input.isStepHidden, + isStepSalaryHidden: state.informationsData.input.isStepSalaryHidden, + })); + + const getHiddenSteps = (): IndemniteDepartStepName[] => { + const hiddenSteps: IndemniteDepartStepName[] = []; + if (isStepInformationsHidden) { + hiddenSteps.push(IndemniteDepartStepName.Informations); + } + if (isStepSalaryHidden) { + hiddenSteps.push(IndemniteDepartStepName.Salaires); + } + return hiddenSteps; + }; + + return ( + + + simulator={PublicodesSimulator.INDEMNITE_LICENCIEMENT} + title={title} + displayTitle={displayTitle} + icon={icon} + duration="5 à 10 min" + steps={steps} + onStepChange={[ + { + stepName: IndemniteDepartStepName.ContratTravail, + isStepValid: isStepContratTravailValid, + onNextStep: onNextStepContratTravail, + }, + { + stepName: IndemniteDepartStepName.Agreement, + isStepValid: isStepAgreementValid, + onNextStep: onNextStepAgreement, + }, + { + stepName: IndemniteDepartStepName.Anciennete, + isStepValid: isStepAncienneteValid, + onNextStep: onNextStepAnciennete, + }, + { + stepName: IndemniteDepartStepName.Salaires, + isStepValid: isStepSalairesValid, + onNextStep: onNextStepSalaires, + }, + { + stepName: IndemniteDepartStepName.Informations, + isStepValid: isStepInformationsValid, + onNextStep: onNextStepInformations, + }, + ]} + hiddenStep={getHiddenSteps()} + /> + {hasFeedbackPopup && } + + ); +}; + +export const CalculateurIndemnite = ({ + icon, + title, + displayTitle, + tool, + steps, + hasFeedbackPopup, +}: Props): JSX.Element => { + const store = React.useRef(createIndemniteDepartStore(tool)).current; + + return ( + + + + ); +}; + +const Flex = styled.div` + display: flex; + flex-direction: column; +`; diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Agreement/index.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Agreement/index.tsx similarity index 94% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Agreement/index.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Agreement/index.tsx index dabb0534a9..1034ed975f 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Agreement/index.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Agreement/index.tsx @@ -1,6 +1,6 @@ import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; import CommonAgreementStep from "../../../CommonSteps/Agreement"; import { getSupportedCc } from "../../common"; @@ -9,7 +9,7 @@ import { useContext } from "react"; import { Agreement } from "@socialgouv/cdtn-utils"; const AgreementStep = (): JSX.Element => { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { error, onRouteChange, @@ -22,7 +22,7 @@ const AgreementStep = (): JSX.Element => { onInitAgreementPage, hasNoEnterpriseSelected, setHasNoEnterpriseSelected, - } = useIndemniteLicenciementStore(store, (state) => ({ + } = useIndemniteDepartStore(store, (state) => ({ error: state.agreementData.error, onRouteChange: state.agreementFunction.onRouteChange, route: state.agreementData.input.route, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/components/AbsencePeriod.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/components/AbsencePeriod.tsx similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/components/AbsencePeriod.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/components/AbsencePeriod.tsx diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/components/AbsencePeriods.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/components/AbsencePeriods.tsx similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/components/AbsencePeriods.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/components/AbsencePeriods.tsx diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/components/SectionTitleWithTooltip.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/components/SectionTitleWithTooltip.tsx similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/components/SectionTitleWithTooltip.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/components/SectionTitleWithTooltip.tsx diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/components/__tests__/AbscencePeriod.data.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/components/__tests__/AbscencePeriod.data.tsx similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/components/__tests__/AbscencePeriod.data.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/components/__tests__/AbscencePeriod.data.tsx diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/components/__tests__/AbscencePeriod.test.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/components/__tests__/AbscencePeriod.test.tsx similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/components/__tests__/AbscencePeriod.test.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/components/__tests__/AbscencePeriod.test.tsx diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/components/__tests__/AbscencePeriods.test.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/components/__tests__/AbscencePeriods.test.tsx similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/components/__tests__/AbscencePeriods.test.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/components/__tests__/AbscencePeriods.test.tsx diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/components/__tests__/SectionTitleWithTooltip.test.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/components/__tests__/SectionTitleWithTooltip.test.tsx similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/components/__tests__/SectionTitleWithTooltip.test.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/components/__tests__/SectionTitleWithTooltip.test.tsx diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/components/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/components/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/components/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/components/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/index.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/index.tsx new file mode 100644 index 0000000000..f7b16a558a --- /dev/null +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/index.tsx @@ -0,0 +1,2 @@ +export * from "./components"; +export * from "./store"; diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/__tests__/validator.test.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/__tests__/validator.test.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/__tests__/validator.test.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/__tests__/validator.test.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/store.ts similarity index 97% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/store.ts index a2cc06c469..b38facd1d8 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/store.ts +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/store.ts @@ -147,9 +147,9 @@ const createAncienneteStore: StoreSlice< ? JSON.stringify(absencePeriods) : undefined, }; - const { result, ineligibility } = publicodes.calculate(situation); - if (result.value === 0 && ineligibility) { - errorEligibility = ineligibility; + const result = publicodes.calculate(situation); + if (result.type === "ineligibility") { + errorEligibility = result.ineligibility; } } catch (e) { console.error(e); diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/validator/absencePeriods.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/validator/absencePeriods.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/validator/absencePeriods.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/validator/absencePeriods.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/validator/absenceProlonge.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/validator/absenceProlonge.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/validator/absenceProlonge.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/validator/absenceProlonge.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/validator/dateArretTravail.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/validator/dateArretTravail.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/validator/dateArretTravail.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/validator/dateArretTravail.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/validator/dateEntree.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/validator/dateEntree.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/validator/dateEntree.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/validator/dateEntree.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/validator/dateNotification.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/validator/dateNotification.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/validator/dateNotification.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/validator/dateNotification.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/validator/dateSortie.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/validator/dateSortie.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/validator/dateSortie.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/validator/dateSortie.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/validator/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/validator/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Anciennete/store/validator/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Anciennete/store/validator/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/ContratTravail/index.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/ContratTravail/index.tsx new file mode 100644 index 0000000000..f5990c259b --- /dev/null +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/ContratTravail/index.tsx @@ -0,0 +1 @@ +export * from "./store"; diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/ContratTravail/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/ContratTravail/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/ContratTravail/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/ContratTravail/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/ContratTravail/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/ContratTravail/store/store.ts similarity index 84% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/ContratTravail/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/ContratTravail/store/store.ts index a2987e6a9e..b9ce0b51db 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/ContratTravail/store/store.ts +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/ContratTravail/store/store.ts @@ -5,9 +5,9 @@ import { ContratTravailStoreSlice, } from "./types"; import produce from "immer"; -import { StoreSlice } from "../../../../types"; +import { IndemniteDepartType, StoreSlice } from "../../../../types"; import { validateStep } from "./validator"; -import { AncienneteStoreSlice } from "../../Anciennete/store"; +import { AncienneteStoreSlice } from "../../Anciennete"; import { ValidationResponse } from "../../../../Components/SimulatorLayout"; import { CommonInformationsStoreSlice } from "../../../../CommonSteps/Informations/store"; import { loadPublicodes } from "../../../../api"; @@ -30,7 +30,10 @@ const createContratTravailStore: StoreSlice< AncienneteStoreSlice & CommonInformationsStoreSlice & CommonSituationStoreSlice -> = (set, get) => ({ +> = (set, get, { type }) => ({ + contratTravailConfig: { + showFauteGrave: type === IndemniteDepartType.LICENCIEMENT, + }, contratTravailData: { ...initialState }, contratTravailFunction: { onChangeTypeContratTravail: (value) => { @@ -64,16 +67,15 @@ const createContratTravailStore: StoreSlice< if (isValid) { try { - const publicodes = - loadPublicodes( - PublicodesSimulator.INDEMNITE_LICENCIEMENT - ); - const { result, ineligibility } = publicodes.calculate( - get().situationData.situation - ); + const simulator = + type === IndemniteDepartType.LICENCIEMENT + ? PublicodesSimulator.INDEMNITE_LICENCIEMENT + : PublicodesSimulator.RUPTURE_CONVENTIONNELLE; + const publicodes = loadPublicodes(simulator); + const result = publicodes.calculate(get().situationData.situation); - if (result.value === 0 && ineligibility) { - errorEligibility = ineligibility; + if (result.type === "ineligibility") { + errorEligibility = result.ineligibility; } } catch (e) { console.error(e); diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/ContratTravail/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/ContratTravail/store/types.ts similarity index 96% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/ContratTravail/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/ContratTravail/store/types.ts index 4838cfd2ac..7fa3209db7 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/ContratTravail/store/types.ts +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/ContratTravail/store/types.ts @@ -1,5 +1,5 @@ import { StepData } from "../../../store"; -import { OuiNon } from "../../../common/types"; +import { OuiNon } from "../../../common"; import { ValidationResponse } from "../../../../Components/SimulatorLayout"; export type CdiCdd = "cdi" | "cdd"; diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/ContratTravail/store/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/ContratTravail/store/validator.ts similarity index 95% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/ContratTravail/store/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/ContratTravail/store/validator.ts index 5a33a73747..d1ed55ea35 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/ContratTravail/store/validator.ts +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/ContratTravail/store/validator.ts @@ -1,5 +1,5 @@ import { deepEqualObject, isValidDate } from "../../../../../lib"; -import { ContratTravailStoreInput, ContratTravailStoreError } from "./types"; +import { ContratTravailStoreError, ContratTravailStoreInput } from "./types"; export const validateStep = (state: ContratTravailStoreInput) => { const errorState: ContratTravailStoreError = { diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Informations/index.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Informations/index.tsx similarity index 77% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Informations/index.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Informations/index.tsx index 981fa4255c..d54520162b 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Informations/index.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Informations/index.tsx @@ -1,14 +1,14 @@ import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, + IndemniteDepartContext, + useIndemniteDepartStore, } from "../../store"; import CommonInformationStep from "../../../CommonSteps/Informations"; import { useContext } from "react"; const InformationsStep = (): JSX.Element => { - const store = useContext(IndemniteLicenciementContext); + const store = useContext(IndemniteDepartContext); const { errors, onInformationsChange, informations } = - useIndemniteLicenciementStore(store, (state) => ({ + useIndemniteDepartStore(store, (state) => ({ errors: state.informationsData.error, onInformationsChange: state.informationsFunction.onInformationsChange, informations: state.informationsData.input.publicodesInformations, diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/AbsenceTable.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/AbsenceTable.tsx similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/AbsenceTable.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/AbsenceTable.tsx diff --git a/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/DecryptResult.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/DecryptResult.tsx new file mode 100644 index 0000000000..3a45c75f57 --- /dev/null +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/DecryptResult.tsx @@ -0,0 +1,44 @@ +import { Paragraph } from "@socialgouv/cdtn-ui"; +import { SectionTitle } from "../../../../common/stepStyles"; +import { + getDecryptedValue, + getDecryptedValueAgreement, +} from "../utils/getDecryptedValue"; +import { + ExplanationAgreementResult, + ExplanationMainResult, +} from "@socialgouv/modeles-social"; + +type Props = { + label: string; + agreementResult?: string; + agreementExplanation?: ExplanationAgreementResult; + legalResult: string; + resultExplanation?: ExplanationMainResult; +}; + +export default function DecryptResult(props: Props) { + return ( + <> + Résultat décrypté + + Montant prévu par le code du travail :  + {props.legalResult} € + + + Montant prévu par la convention collective :  + + {getDecryptedValueAgreement( + props.agreementExplanation, + props.agreementResult + )} + + + {props.resultExplanation && ( + + {getDecryptedValue(props.label, props.resultExplanation)} + + )} + + ); +} diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/ErrorPublicodes.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/ErrorPublicodes.tsx similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/ErrorPublicodes.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/ErrorPublicodes.tsx diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/FilledElements.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/FilledElements.tsx similarity index 80% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/FilledElements.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/FilledElements.tsx index 6a83f76e51..fef30d2219 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/FilledElements.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/FilledElements.tsx @@ -9,19 +9,23 @@ import { generateResultSalaireTempsPlein, generateResultSameSalary, } from "../../../utils/question"; +import { IndemniteDepartType } from "../../../../types"; + +type SituationItem = { + text: string; + value: string; + detail?: string; +}; type Props = { - typeContrat: string; - isLicenciementFauteGrave: boolean; + contractTravail: SituationItem[]; agreementName?: string; - isLicenciementInaptitude: boolean; isArretTravail: boolean; - dateArretTravail?: string; agreementInformations?: AgreementInformation[]; agreementRefSalaryInfo: React.ReactNode; dateEntree: string; dateSortie: string; - dateNotification: string; + dateNotification?: string; absencesPeriods: Absence[]; salaryPeriods: SalaryPeriods[]; hasTempsPartiel: boolean; @@ -31,6 +35,7 @@ type Props = { isStepSalaryHidden: boolean; showHasTempsPartiel: boolean; disableParentalNotice?: boolean; + type: IndemniteDepartType; }; export default function FilledElements(props: Props) { @@ -41,39 +46,19 @@ export default function FilledElements(props: Props) {

  • Contrat de travail
      -
    • - Type de contrat : {props.typeContrat.toUpperCase()} -
    • -
    • - Licenciement dû à une faute grave (ou lourde) :  - {props.isLicenciementFauteGrave ? "Oui" : "Non"} -
    • -
    • - Licenciement dû à une inaptitude d’origine - professionnelle :  - {props.isLicenciementInaptitude ? "Oui" : "Non"} - {props.isLicenciementInaptitude && - !props.isAgreementBetter && - "*"} - {props.isLicenciementInaptitude && !props.isAgreementBetter && ( - - * Le salarié ayant été licencié pour inaptitude suite à un - accident du travail ou une maladie professionnelle reconnue, - le montant de l'indemnité de licenciement légale est - doublé - - )} -
    • - Arrêt de travail au moment du licenciement :  - {props.isArretTravail ? "Oui" : "Non"} -
    • - {props.dateArretTravail && ( -
    • - Date de début de l'arrêt de travail  :  - {props.dateArretTravail} + {props.contractTravail.map((item) => { + return ( +
    • + {item.text} : {item.value} + {item.detail && "*"} + {item.detail && ( + + * {item.detail} + + )}
    • - )} - + ); + })}
  • @@ -106,10 +91,12 @@ export default function FilledElements(props: Props) { Date de début du contrat de travail :  {props.dateEntree}
  • -
  • - Date de notification du licenciement :  - {props.dateNotification} -
  • + {props.dateNotification && ( +
  • + Date de notification du licenciement :  + {props.dateNotification} +
  • + )}
  • Date de fin du contrat de travail :  {props.dateSortie} @@ -144,6 +131,7 @@ export default function FilledElements(props: Props) { )}
  • {generateResultSameSalary( + props.type, props.isArretTravail ? "oui" : "non", props.salaryPeriods )} @@ -160,6 +148,7 @@ export default function FilledElements(props: Props) { {props.salaryPeriods.length > 0 && !props.hasSameSalary && (
  • {generateResultSalaireTempsPlein( + props.type, props.isArretTravail ? "oui" : "non", props.salaryPeriods )} diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/FormulaInterpreter.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/FormulaInterpreter.tsx similarity index 93% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/FormulaInterpreter.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/FormulaInterpreter.tsx index 976f7378b3..93fe97cddb 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/FormulaInterpreter.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/FormulaInterpreter.tsx @@ -4,10 +4,11 @@ import { SectionTitle } from "../../../../common/stepStyles"; import { Paragraph } from "@socialgouv/cdtn-ui"; type Props = { - formula: Formula; + formula?: Formula; }; export default function FormulaInterpreter(props: Props) { + if (!props.formula) return <>; return ( <> {props.formula.explanations.length > 0 && ( diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/Result.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/Result.tsx similarity index 62% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/Result.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/Result.tsx index 9fd42884be..b93b4290a4 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/Result.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/Result.tsx @@ -17,23 +17,6 @@ export default function Result({ resultMessage, maxResult, }: Props) { - const notifs = [ - { - dottedName: "congé paternité", - description: ( - - Ce montant est exonéré d’impôt sur le revenu et de cotisations - sociales sous certaines conditions,{" "} - - en savoir plus - - - ), - } as Notification, - ].concat(notifications); return (
    Indemnité @@ -41,15 +24,20 @@ export default function Result({ {resultMessage}{" "} {maxResult.replace(".", ",")} €. - {notifs.map((notification, index) => ( - + {notifications.map((notification, index) => ( + {notification.description} diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/__tests__/FilledElements.test.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/__tests__/FilledElements.test.tsx similarity index 84% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/__tests__/FilledElements.test.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/__tests__/FilledElements.test.tsx index 9c65ae9718..6ab65f4434 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/__tests__/FilledElements.test.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/__tests__/FilledElements.test.tsx @@ -2,19 +2,23 @@ import { render } from "@testing-library/react"; import React from "react"; import FilledElement from "../FilledElements"; import { MotifKeys } from "@socialgouv/modeles-social"; +import { IndemniteDepartType } from "../../../../../types"; describe("", () => { it("should render", () => { expect( render( ", () => { + it("should render", () => { + const { queryByText } = render( + + Ce montant est exonéré d’impôt sur le revenu et de cotisations + sociales sous certaines conditions. + + ), + show: "légal et conventionnel", + }, + ]} + /> + ); + expect(queryByText(/2000/i)).toBeInTheDocument(); + expect( + queryByText(/Ce montant est exonéré d’impôt sur le revenu/) + ).toBeInTheDocument(); + }); +}); diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/index.ts similarity index 84% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/index.ts index 87eb5fcebe..5c27f5772d 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/components/index.ts +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/components/index.ts @@ -1,4 +1,3 @@ -export { default as ForMoreInfo } from "./ForMoreInfo"; export { default as DecryptResult } from "./DecryptResult"; export { default as FormulaInterpreter } from "./FormulaInterpreter"; export { default as FilledElements } from "./FilledElements"; diff --git a/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/index.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/index.tsx new file mode 100644 index 0000000000..3a6b173e83 --- /dev/null +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/index.tsx @@ -0,0 +1,35 @@ +import React, { useContext, useEffect } from "react"; +import { IndemniteDepartContext, useIndemniteDepartStore } from "../../store"; + +import { ErrorPublicodes } from "./components"; + +type Props = { + eligibleComponent?: JSX.Element; + ineligibleComponent?: JSX.Element; +}; + +const StepResult = ({ eligibleComponent, ineligibleComponent }: Props) => { + const store = useContext(IndemniteDepartContext); + const { isEligible, init, errorPublicodes, getPublicodesResult } = + useIndemniteDepartStore(store, (state) => ({ + isEligible: state.resultData.input.isEligible, + init: state.resultFunction.init, + errorPublicodes: state.resultData.error.errorPublicodes, + getPublicodesResult: state.resultFunction.getPublicodesResult, + })); + + useEffect(() => { + const { isEligible } = init(); + if (isEligible) { + getPublicodesResult(); + } + }, []); + + if (errorPublicodes) { + return ; + } + + return <>{isEligible ? eligibleComponent : ineligibleComponent}; +}; + +export default StepResult; diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/store/service.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/store/service.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/store/service.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/store/service.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/store/store.ts similarity index 52% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/store/store.ts index 7d37e351ce..533e2a78e5 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/store/store.ts +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/store/store.ts @@ -1,19 +1,14 @@ import { Formula, - getSupportedAgreement, Notification, PublicodesIndemniteLicenciementResult, PublicodesSimulator, References, - SeniorityResult, } from "@socialgouv/modeles-social"; import { StoreSlice } from "../../../../types"; -import { - mapToPublicodesSituationForCalculation, - mapToPublicodesSituationForIndemniteLicenciementConventionnelWithValues, -} from "../../../../publicodes"; -import { AncienneteStoreSlice } from "../../Anciennete/store"; -import { ContratTravailStoreSlice } from "../../ContratTravail/store"; +import { mapToPublicodesSituationForIndemniteLicenciementConventionnelWithValues } from "../../../../publicodes"; +import { AncienneteStoreSlice } from "../../Anciennete"; +import { ContratTravailStoreSlice } from "../../ContratTravail"; import { SalairesStoreSlice } from "../../Salaires/store"; import produce from "immer"; @@ -21,29 +16,22 @@ import { ResultStoreData, ResultStoreSlice } from "./types"; import { CommonAgreementStoreSlice } from "../../../../CommonSteps/Agreement/store"; import { CommonInformationsStoreSlice } from "../../../../CommonSteps/Informations/store"; import { isParentalNoticeHiddenForAgreement } from "../../../agreements/ui-customizations/messages"; -import { - AgreementInformation, - hasNoLegalIndemnity, - hasNoBetterAllowance, -} from "../../../common"; +import { AgreementInformation, hasNoBetterAllowance } from "../../../common"; import { informationToSituation } from "../../../../CommonSteps/Informations/utils"; import { getInfoWarning } from "./service"; -import { IndemniteLicenciementStepName } from "../../.."; -import { - MatomoBaseEvent, - MatomoActionEvent, - MatomoSimulatorEvent, -} from "../../../../../lib"; -import { push as matopush } from "@socialgouv/matomo-next"; import getSupportedCc from "../../../common/usecase/getSupportedCc"; import * as Sentry from "@sentry/nextjs"; import { CommonSituationStoreSlice } from "../../../../common/situationStore"; +import { eventEmitter } from "../../../events/emitter"; +import { EventType } from "../../../events/events"; +import { PublicodesResult } from "@socialgouv/modeles-social/bin"; const initialState: ResultStoreData = { input: { - legalFormula: { formula: "", explanations: [] }, + formula: { formula: "", explanations: [] }, legalReferences: [], - publicodesLegalResult: { value: "" }, + result: { value: undefined }, + publicodesLegalResult: { value: undefined }, isAgreementBetter: false, isEligible: false, isParentalNoticeHidden: false, @@ -55,26 +43,6 @@ const initialState: ResultStoreData = { isStepValid: true, }; -const isAgreementBetterDetection = ( - publicodesSituationLegal: PublicodesIndemniteLicenciementResult, - publicodesSituationConventionnel: PublicodesIndemniteLicenciementResult -) => - publicodesSituationLegal.value !== undefined && - publicodesSituationLegal.value !== null && - publicodesSituationConventionnel.value !== undefined && - publicodesSituationConventionnel.value !== null && - publicodesSituationConventionnel.value > publicodesSituationLegal.value; - -const isAgreementSameDetection = ( - publicodesSituationLegal: PublicodesIndemniteLicenciementResult, - publicodesSituationConventionnel: PublicodesIndemniteLicenciementResult -) => - publicodesSituationLegal.value !== undefined && - publicodesSituationLegal.value !== null && - publicodesSituationConventionnel.value !== undefined && - publicodesSituationConventionnel.value !== null && - publicodesSituationConventionnel.value === publicodesSituationLegal.value; - const createResultStore: StoreSlice< ResultStoreSlice, AncienneteStoreSlice & @@ -116,14 +84,7 @@ const createResultStore: StoreSlice< ancienneteEligibility && informationEligibility; - matopush([ - MatomoBaseEvent.TRACK_EVENT, - MatomoBaseEvent.OUTIL, - MatomoActionEvent.INDEMNITE_LICENCIEMENT, - isEligible - ? IndemniteLicenciementStepName.Resultat - : MatomoSimulatorEvent.STEP_RESULT_INELIGIBLE, - ]); + eventEmitter.dispatch(EventType.SEND_RESULT_EVENT, isEligible); set( produce((state: ResultStoreSlice) => { @@ -131,6 +92,7 @@ const createResultStore: StoreSlice< state.resultData.input.infoWarning = infoWarning; }) ); + return { isEligible }; }, getEligibilityError: () => { const contratTravailEligibility = @@ -145,159 +107,106 @@ const createResultStore: StoreSlice< ); }, getPublicodesResult: () => { - const salaryPeriods = get().salairesData.input.salaryPeriods; const agreement = get().agreementData.input.agreement; - const isLicenciementInaptitude = - get().contratTravailData.input.licenciementInaptitude === "oui"; - const longTermDisability = - get().contratTravailData.input.arretTravail === "oui"; const publicodes = get().agreementData.publicodes; - const dateEntree = get().ancienneteData.input.dateEntree!; - const dateNotification = get().ancienneteData.input.dateNotification!; - const dateSortie = get().ancienneteData.input.dateSortie!; - const isAgreementSupported = - get().agreementData.input.isAgreementSupportedIndemniteLicenciement; - if (!publicodes) { throw new Error("Publicodes is not defined"); } - let publicodesSituationLegal: PublicodesIndemniteLicenciementResult = { - value: null, - }; - let errorPublicodes = false; + let errorPublicodes: boolean; const absencePeriods = get().ancienneteData.input.absencePeriods; - console.log( - `Les informations de l'ancienneté sont ${JSON.stringify( - get().ancienneteData.input - )}` + const legalReferences = publicodes.getReferences(); + let publicodesSituation: + | PublicodesResult + | undefined = undefined; + + let agreementReferences: References[]; + let formula: Formula; + let isAgreementBetter = false; + let isAgreementEqualToLegal = false; + let agreementInformations: AgreementInformation[]; + let agreementNotifications: Notification[] = []; + let notifications: Notification[]; + let agreementHasNoLegalIndemnity: boolean; + let agreementHasNoBetterAllowance: boolean; + let isParentalNoticeHidden = false; + + const infos = informationToSituation( + get().informationsData.input.publicodesInformations ); + try { - const situationLegal = { - ...mapToPublicodesSituationForCalculation( - dateEntree, - dateNotification, - dateSortie, - salaryPeriods, - isLicenciementInaptitude, - longTermDisability + console.log( + `Les informations de l'ancienneté sont ${JSON.stringify( + get().ancienneteData.input + )}` + ); + const situation = { + ...mapToPublicodesSituationForIndemniteLicenciementConventionnelWithValues( + agreement?.num, + get().salairesData.input.salaryPeriods, + get().ancienneteData.input.dateNotification!, + get().ancienneteData.input.dateEntree!, + get().ancienneteData.input.dateSortie!, + get().contratTravailData.input.licenciementInaptitude === "oui", + get().contratTravailData.input.arretTravail === "oui", + { ...infos } ), absencePeriods: absencePeriods && absencePeriods.length ? JSON.stringify(absencePeriods) : undefined, + ...get().situationData.situation, }; - publicodesSituationLegal = publicodes.calculate(situationLegal).result; + const result = publicodes.calculate(situation); + if (result.type !== "result") { + throw new Error( + `Le calcul sur l'écran de résultat retourne un ${ + result.type + } (detail: ${JSON.stringify(result)})` + ); + } + publicodesSituation = result; + isAgreementBetter = + publicodesSituation.detail.chosenResult === "AGREEMENT" || + publicodesSituation.detail.chosenResult === "HAS_NO_LEGAL"; + isAgreementEqualToLegal = + publicodesSituation.detail.chosenResult === "SAME"; + agreementHasNoLegalIndemnity = + publicodesSituation.detail.chosenResult === "HAS_NO_LEGAL"; + if (publicodesSituation.formula) { + formula = publicodesSituation.formula; + } } catch (e) { errorPublicodes = true; Sentry.captureException(e); console.error(e); } - const legalFormula = publicodes.getFormule(); - const legalReferences = publicodes.getReferences(); - - let publicodesSituationConventionnel: PublicodesIndemniteLicenciementResult = - { - value: null, - }; - let agreementReferences: References[]; - let agreementFormula: Formula; - let isAgreementBetter = false; - let isAgreementEqualToLegal = false; - let agreementInformations: AgreementInformation[]; - let agreementNotifications: Notification[] = []; - let notifications: Notification[]; - let agreementHasNoLegalIndemnity: boolean; - let agreementHasNoBetterAllowance: boolean; - let isParentalNoticeHidden = false; - if ( agreement && getSupportedCc().some( (item) => item.idcc === agreement.num && item.fullySupported ) ) { - const infos = informationToSituation( - get().informationsData.input.publicodesInformations - ); + agreementReferences = publicodesSituation?.references ?? []; + + agreementNotifications = publicodesSituation?.notifications ?? []; agreementInformations = get() - .informationsData.input.publicodesInformations.map( - (v) => - v.question.rule.titre && - v.info && { + .informationsData.input.publicodesInformations.map((v) => { + if (v.question.rule.titre && v.info) { + return { label: v.question.rule.titre, value: v.info, unit: v.question.rule.unité, - } - ) - .filter((v) => v !== "") as AgreementInformation[]; - - try { - const situation = { - ...mapToPublicodesSituationForIndemniteLicenciementConventionnelWithValues( - agreement.num, - salaryPeriods, - get().ancienneteData.input.dateNotification!, - get().ancienneteData.input.dateEntree!, - get().ancienneteData.input.dateSortie!, - isLicenciementInaptitude, - longTermDisability, - { ...infos } - ), - absencePeriods: - absencePeriods && absencePeriods.length - ? JSON.stringify(absencePeriods) - : undefined, - ...get().situationData.situation, - }; - publicodesSituationConventionnel = publicodes.calculate( - situation, - "contrat salarié . indemnité de licenciement . résultat conventionnel" - ).result; - } catch (e) { - errorPublicodes = true; - Sentry.captureException(e); - console.error(e); - } - - agreementReferences = publicodes.getReferences( - "résultat conventionnel" - ); - - agreementFormula = publicodes.getFormule(); - - agreementNotifications = publicodes.getNotifications(); - - agreementHasNoLegalIndemnity = hasNoLegalIndemnity( - agreement.num, - agreementInformations - ); + }; + } + }) + .filter((v) => v !== undefined) as AgreementInformation[]; agreementHasNoBetterAllowance = hasNoBetterAllowance(agreement.num); - if ( - agreementHasNoLegalIndemnity || - (isAgreementBetterDetection( - publicodesSituationLegal, - publicodesSituationConventionnel - ) && - isAgreementSupported) - ) { - isAgreementBetter = true; - } - - if ( - isAgreementSameDetection( - publicodesSituationLegal, - publicodesSituationConventionnel - ) && - isAgreementSupported - ) { - isAgreementEqualToLegal = true; - } - isParentalNoticeHidden = isParentalNoticeHiddenForAgreement( isAgreementBetter, agreement.num @@ -326,14 +235,21 @@ const createResultStore: StoreSlice< set( produce((state: ResultStoreSlice) => { state.resultData.error.errorPublicodes = errorPublicodes; - state.resultData.input.legalFormula = legalFormula; + state.resultData.input.result = publicodesSituation?.result ?? { + value: undefined, + }; + state.resultData.input.formula = formula; state.resultData.input.legalReferences = legalReferences; - state.resultData.input.publicodesLegalResult = - publicodesSituationLegal; + state.resultData.input.publicodesLegalResult = publicodesSituation + ?.detail?.legalResult ?? { value: 0 }; state.resultData.input.publicodesAgreementResult = - publicodesSituationConventionnel; + publicodesSituation?.detail?.agreementResult; + state.resultData.input.agreementExplanation = + publicodesSituation?.detail?.agreementExplanation; + state.resultData.input.resultExplanation = + publicodesSituation?.explanation; + publicodesSituation?.detail?.agreementResult; state.resultData.input.agreementReferences = agreementReferences; - state.resultData.input.agreementFormula = agreementFormula; state.resultData.input.isAgreementBetter = isAgreementBetter; state.resultData.input.agreementInformations = agreementInformations; state.resultData.input.notifications = notifications; diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/store/types.ts similarity index 83% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/store/types.ts index 3f71e762e0..8afe89c845 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Resultat/store/types.ts +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/store/types.ts @@ -4,17 +4,21 @@ import { Notification, PublicodesIndemniteLicenciementResult, References, + ExplanationMainResult, + ExplanationAgreementResult, SeniorityResult, } from "@socialgouv/modeles-social"; import { AgreementInformation } from "../../../common"; import { StepData } from "../../../store"; export type ResultStoreInput = { + result: PublicodesIndemniteLicenciementResult; publicodesLegalResult: PublicodesIndemniteLicenciementResult; publicodesAgreementResult?: PublicodesIndemniteLicenciementResult; + resultExplanation?: ExplanationMainResult; + agreementExplanation?: ExplanationAgreementResult; agreementSeniority?: SeniorityResult; - legalFormula: Formula; - agreementFormula?: Formula; + formula: Formula; legalReferences: References[]; agreementReferences?: References[]; isAgreementBetter: boolean; @@ -35,7 +39,7 @@ export type ResultStoreData = StepData; export type ResultStoreFn = { getPublicodesResult: () => void; - init: () => void; + init: () => { isEligible: boolean }; getEligibilityError: () => string | undefined; }; diff --git a/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/utils/getDecryptedValue.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/utils/getDecryptedValue.ts new file mode 100644 index 0000000000..77d52b4c2e --- /dev/null +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Resultat/utils/getDecryptedValue.ts @@ -0,0 +1,50 @@ +import { + ExplanationAgreementResult, + ExplanationMainResult, +} from "@socialgouv/modeles-social"; + +export const getDecryptedValueAgreement = ( + value?: ExplanationAgreementResult, + agreementResult?: string +): string => { + const defaultResult = `${agreementResult} €`; + if (!value) return defaultResult; + switch (value) { + case "IS_HORS_ANI": + return "Non applicable dans votre situation"; + case "NO_AGREEMENT_SELECTED": + return "Convention collective non renseignée"; + case "AGREEMENT_NOT_SUPPORTED": + return "Convention collective non traitée"; + case "AGREEMENT_RESULT_ZERO": + return "La convention collective ne prévoit pas d'indemnité dans ce cas"; + case "NO_EXPLANATION": + default: + return defaultResult; + } +}; + +export const getDecryptedValue = ( + label: string, + value: ExplanationMainResult +): string => { + switch (value) { + case "HAS_NOT_SELECTED_AGREEMENT": + return `La convention collective n’ayant pas été renseignée, le montant de l’indemnité de ${label} affiché correspond au montant prévu par le code du travail.`; + case "AGREEMENT_NOT_SUPPORTED": + return `La convention collective n’ayant pas été traitée par nos services, le montant de l’indemnité de ${label} affiché correspond au montant prévu par le code du travail.`; + case "AGREEMENT_RESULT_ZERO": + return `En l’absence de montant prévu par la convention collective, le montant de l’indemnité de ${label} à appliquer pour le salarié est donc le montant prévu par le code du travail.`; + case "LEGAL_RESULT_ZERO_BUT_AGREEMENT": + return `En l’absence de montant prévu par le code du travail, le montant de l’indemnité de ${label} à appliquer pour le salarié est donc le montant prévu par la convention collective.`; + case "SAME_AMOUNT": + return "Le montant prévu par le code du travail est le même que celui prévu par la convention collective."; + case "AGREEMENT_AMOUNT_MORE": + return "Le montant à retenir pour le salarié est celui prévu par la convention collective, celui-ci étant plus favorable que le montant prévu par le code du travail."; + case "LEGAL_AMOUNT_MORE": + return "Le montant à retenir pour le salarié est celui prévu par le code du travail, celui-ci étant plus favorable que le montant prévu par la convention collective."; + case "NO_EXPLANATION": + default: + throw new Error("No explanation provided"); + } +}; diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/components/SalaireTempsPlein.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/components/SalaireTempsPlein.tsx similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/components/SalaireTempsPlein.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/components/SalaireTempsPlein.tsx diff --git a/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/components/TempsPartiel.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/components/TempsPartiel.tsx new file mode 100644 index 0000000000..9bd7d3d959 --- /dev/null +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/components/TempsPartiel.tsx @@ -0,0 +1,35 @@ +import { Alert, Paragraph, Text } from "@socialgouv/cdtn-ui"; +import React from "react"; +import { IndemniteDepartType } from "../../../../types"; + +type Props = { + type: IndemniteDepartType; +}; + +const TempsPartiel = ({ type }: Props): JSX.Element => { + return ( + + + À noter + + + + Le calcul de l’indemnité de{" "} + {type === IndemniteDepartType.LICENCIEMENT + ? "licenciement" + : "rupture conventionnelle"}{" "} + dans le cas d’une alternance de temps plein et de temps partiel est + actuellement en cours de développement. + + + Les périodes à temps partiel ne sont actuellement pas prises en compte + dans le calcul. + + + Cela pourrait conduire à un résultat différent de l’indemnité. + + + ); +}; + +export default TempsPartiel; diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/components/TooltipSalary.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/components/TooltipSalary.tsx similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/components/TooltipSalary.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/components/TooltipSalary.tsx diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/components/__tests__/SalaireTempsPlein.test.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/components/__tests__/SalaireTempsPlein.test.tsx similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/components/__tests__/SalaireTempsPlein.test.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/components/__tests__/SalaireTempsPlein.test.tsx diff --git a/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/components/__tests__/TempsPartiel.test.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/components/__tests__/TempsPartiel.test.tsx new file mode 100644 index 0000000000..f0aa55d8b6 --- /dev/null +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/components/__tests__/TempsPartiel.test.tsx @@ -0,0 +1,22 @@ +import { render } from "@testing-library/react"; +import React from "react"; +import TempsPartiel from "../TempsPartiel"; +import { IndemniteDepartType } from "../../../../../types"; + +describe("", () => { + it("doit contenir le texte pour l'indemnité de licenciement", () => { + expect( + render().asFragment() + ).toHaveTextContent( + /Le calcul de l’indemnité de licenciement dans le cas d’une alternance de temps plein et de temps partiel est actuellement en cours de développement/ + ); + }); + + it("doit contenir le texte pour l'indemnité de rupture conventionnelle", () => { + expect( + render().asFragment() + ).toHaveTextContent( + /Le calcul de l’indemnité de rupture conventionnelle dans le cas d’une alternance de temps plein et de temps partiel est actuellement en cours de développement/ + ); + }); +}); diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/components/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/components/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/components/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/components/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/index.tsx b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/index.tsx similarity index 88% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/index.tsx rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/index.tsx index c1d46d65e1..053a8050c9 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/index.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/index.tsx @@ -1,12 +1,9 @@ import React, { useContext } from "react"; -import { - IndemniteLicenciementContext, - useIndemniteLicenciementStore, -} from "../../store"; +import { IndemniteDepartContext, useIndemniteDepartStore } from "../../store"; import { RadioQuestion, TextQuestion } from "../../../Components"; import { SalaireTempsPlein, TempsPartiel } from "./components"; import { getSupportedAgreement } from "@socialgouv/modeles-social"; -import { IndemniteLicenciementStepName } from "../.."; +import { IndemniteDepartStepName } from "../.."; import { AgreementsInjector } from "../../agreements"; import { getSalairesTempsPleinSubtitle, @@ -17,9 +14,14 @@ import { generateSameSalaryQuestion, generateSmallText, } from "../../utils/question"; +import { IndemniteDepartType } from "../../../types"; + +type Props = { + type: IndemniteDepartType; +}; -const StepSalaires = () => { - const store = useContext(IndemniteLicenciementContext); +const StepSalaires = ({ type }: Props) => { + const store = useContext(IndemniteDepartContext); const { hasTempsPartiel, onChangeHasTempsPartiel, @@ -39,7 +41,7 @@ const StepSalaires = () => { showHasTempsPartiel, initShowHasTempsPartiel, isAgreementSupported, - } = useIndemniteLicenciementStore(store, (state) => ({ + } = useIndemniteDepartStore(store, (state) => ({ hasTempsPartiel: state.salairesData.input.hasTempsPartiel, onChangeHasTempsPartiel: state.salairesFunction.onChangeHasTempsPartiel, errorHasTempsPartiel: state.salairesData.error.errorHasTempsPartiel, @@ -92,7 +94,7 @@ const StepSalaires = () => { /> )} - {hasTempsPartiel === "oui" && } + {hasTempsPartiel === "oui" && } {hasTempsPartiel === "non" && ( <> { }, ]} name="hasSameSalary" - label={generateSameSalaryQuestion(arretTravail, salaryPeriods)} + label={generateSameSalaryQuestion( + type, + arretTravail, + salaryPeriods + )} selectedOption={hasSameSalary} onChangeSelectedOption={onChangeHasSameSalary} error={errorHasSameSalary} @@ -135,6 +141,7 @@ const StepSalaires = () => { {hasSameSalary === "non" && ( { isAgreementSupported && ( )} diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/store/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/store/index.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/store/index.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/store/index.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/store/store.ts similarity index 97% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/store/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/store/store.ts index c0ff0de3d6..97b511410b 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/store/store.ts +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/store/store.ts @@ -15,7 +15,7 @@ import { PublicodesSimulator, SalaryPeriods, } from "@socialgouv/modeles-social"; -import { IndemniteLicenciementStepName } from "../../.."; +import { IndemniteDepartStepName } from "../../.."; import { deepMergeArray } from "../../../../../lib"; import { computeSalaryPeriods } from "../../../common"; import { CommonAgreementStoreSlice } from "../../../../CommonSteps/Agreement/store"; @@ -130,7 +130,7 @@ const createSalairesStore: StoreSlice< if (agreement && isAgreementSupportedIndemniteLicenciement) { isAgreementValid = validatorAgreement( getSupportedAgreement(agreement.num), - IndemniteLicenciementStepName.Salaires, + IndemniteDepartStepName.Salaires, get, set ); @@ -177,7 +177,7 @@ const applyGenericValidation = ( if (agreement && isAgreementSupportedIndemniteLicenciement) { isAgreementValid = validatorAgreement( getSupportedAgreement(agreement.num), - IndemniteLicenciementStepName.Salaires, + IndemniteDepartStepName.Salaires, get, set ); diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/store/types.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/store/types.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/store/types.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/store/types.ts diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/store/validator.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/store/validator.ts similarity index 100% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/steps/Salaires/store/validator.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/Salaires/store/validator.ts diff --git a/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/index.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/index.ts new file mode 100644 index 0000000000..54a2fb2413 --- /dev/null +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/steps/index.ts @@ -0,0 +1,6 @@ +export * from "./ContratTravail"; +export * from "./Anciennete"; +export { default as StepSalaires } from "./Salaires"; +export { default as StepResultat } from "./Resultat"; +export { default as StepInformations } from "./Informations"; +export { default as StepAgreement } from "./Agreement"; diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/store.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/store.ts similarity index 65% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/store.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/store.ts index 50724d208f..e927cd465e 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/store.ts +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/store.ts @@ -1,4 +1,4 @@ -import { StoreApi, createStore as create, useStore } from "zustand"; +import { createStore as create, StoreApi, useStore } from "zustand"; import { AgreementStoreError, AgreementStoreInput, @@ -6,28 +6,28 @@ import { createRootAgreementsStore, } from "./agreements"; import { - AncienneteStoreSlice, - AncienneteStoreInput, AncienneteStoreError, + AncienneteStoreInput, + AncienneteStoreSlice, createAncienneteStore, } from "./steps/Anciennete/store"; import { - ContratTravailStoreSlice, - ContratTravailStoreInput, ContratTravailStoreError, + ContratTravailStoreInput, + ContratTravailStoreSlice, createContratTravailStore, } from "./steps/ContratTravail/store"; import { - ResultStoreSlice, createResultStore, ResultStoreError, ResultStoreInput, + ResultStoreSlice, } from "./steps/Resultat/store"; import { - SalairesStoreSlice, - SalairesStoreInput, - SalairesStoreError, createSalairesStore, + SalairesStoreError, + SalairesStoreInput, + SalairesStoreSlice, } from "./steps/Salaires/store"; import { CommonAgreementStoreError, @@ -43,12 +43,12 @@ import { } from "../CommonSteps/Informations/store"; import { - createCommonSituationStore, CommonSituationStoreSlice, + createCommonSituationStore, } from "../common/situationStore"; -import { ToolName } from "../types"; -import { createContext, useContext } from "react"; +import { IndemniteDepartType } from "../types"; +import { createContext } from "react"; import { PublicodesSimulator } from "@socialgouv/modeles-social"; export type MainStore = ContratTravailStoreSlice & @@ -86,7 +86,7 @@ export type StepData< export type StoreOptions = { publicodesRules?: string; - toolName: ToolName; + type: IndemniteDepartType; }; const createRootSlice = ( @@ -94,33 +94,39 @@ const createRootSlice = ( get: StoreApi["getState"], { simulatorName, toolName } ) => ({ - ...createContratTravailStore(set, get, { toolName }), - ...createAncienneteStore(set, get, { toolName }), - ...createSalairesStore(set, get, { toolName }), - ...createResultStore(set, get, { toolName }), - ...createRootAgreementsStore(set, get, { toolName }), - ...createCommonAgreementStore(set, get, { toolName, simulatorName }), - ...createCommonInformationsStore(set, get, { toolName }), - ...createCommonSituationStore(set, get, { toolName }), + ...createContratTravailStore(set, get, { type: toolName }), + ...createAncienneteStore(set, get, { type: toolName }), + ...createSalairesStore(set, get, { type: toolName }), + ...createResultStore(set, get, { type: toolName }), + ...createRootAgreementsStore(set, get, { type: toolName }), + ...createCommonAgreementStore(set, get, { type: toolName, simulator: simulatorName }), + ...createCommonInformationsStore(set, get, { type: toolName }), + ...createCommonSituationStore(set, get, { type: toolName }), }); -const createStore = (simulatorName: PublicodesSimulator, toolName: ToolName) => +const createStore = (type: IndemniteDepartType) => create( ( set: StoreApi["setState"], get: StoreApi["getState"] - ) => createRootSlice(set, get, { simulatorName, toolName }) + ) => + createRootSlice(set, get, { + toolName: type, + simulatorName: type === IndemniteDepartType.RUPTURE_CONVENTIONNELLE + ? PublicodesSimulator.RUPTURE_CONVENTIONNELLE + : PublicodesSimulator.INDEMNITE_LICENCIEMENT, + }) ); -const IndemniteLicenciementContext = createContext>( +const IndemniteDepartContext = createContext>( {} as StoreApi ); -const { Provider } = IndemniteLicenciementContext; +const { Provider } = IndemniteDepartContext; export { - Provider as IndemniteLicenciementProvider, - createStore as createIndemniteLicenciementStore, - IndemniteLicenciementContext, - useStore as useIndemniteLicenciementStore, + Provider as IndemniteDepartProvider, + createStore as createIndemniteDepartStore, + IndemniteDepartContext, + useStore as useIndemniteDepartStore, }; diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/utils/__tests__/question.test.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/utils/__tests__/question.test.ts similarity index 70% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/utils/__tests__/question.test.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/utils/__tests__/question.test.ts index d811bae60a..84f26d72cb 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/utils/__tests__/question.test.ts +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/utils/__tests__/question.test.ts @@ -5,36 +5,41 @@ import { generateSalaireTempsPleinQuestion, generateSameSalaryQuestion, } from "../question"; +import { IndemniteDepartType } from "../../../types"; describe("question.ts", () => { describe("generateSameSalaryQuestion", () => { it.each([ [ + IndemniteDepartType.LICENCIEMENT, "non" as OuiNon, [{ month: "janvier" }], "Le salaire mensuel brut a-t-il été le même pour le mois précédant la notification du licenciement ?", ], [ + IndemniteDepartType.LICENCIEMENT, "oui" as OuiNon, [{ month: "janvier" }], "Le salaire mensuel brut a-t-il été le même pour le mois précédant l'arrêt de travail ?", ], [ + IndemniteDepartType.RUPTURE_CONVENTIONNELLE, "non" as OuiNon, [{ month: "janvier" }, { month: "février" }], - "Le salaire mensuel brut a-t-il été le même durant les 2 derniers mois précédant la notification du licenciement ?", + "Le salaire mensuel brut a-t-il été le même durant les 2 derniers mois précédant la fin du contrat ?", ], [ + IndemniteDepartType.LICENCIEMENT, "oui" as OuiNon, [{ month: "janvier" }, { month: "février" }, { month: "mars" }], "Le salaire mensuel brut a-t-il été le même durant les 3 derniers mois précédant l'arrêt de travail ?", ], ])( "should return the correct question", - (arretTravail, salaryPeriods, expected) => { - expect(generateSameSalaryQuestion(arretTravail, salaryPeriods)).toBe( - expected - ); + (type, arretTravail, salaryPeriods, expected) => { + expect( + generateSameSalaryQuestion(type, arretTravail, salaryPeriods) + ).toBe(expected); } ); }); @@ -42,30 +47,34 @@ describe("question.ts", () => { describe("generateSalaireTempsPleinQuestion", () => { it.each([ [ + IndemniteDepartType.LICENCIEMENT, "non" as OuiNon, [{ month: "janvier" }], "Salaire mensuel brut du dernier mois et primes du dernier mois précédant la notification du licenciement", ], [ + IndemniteDepartType.LICENCIEMENT, "oui" as OuiNon, [{ month: "janvier" }], "Salaire mensuel brut du dernier mois et primes du dernier mois précédant l'arrêt de travail", ], [ + IndemniteDepartType.RUPTURE_CONVENTIONNELLE, "non" as OuiNon, [{ month: "janvier" }, { month: "février" }], - "Salaires mensuels bruts des 2 derniers mois et primes des 2 derniers mois précédant la notification du licenciement", + "Salaires mensuels bruts des 2 derniers mois et primes des 2 derniers mois précédant la fin du contrat", ], [ + IndemniteDepartType.LICENCIEMENT, "oui" as OuiNon, [{ month: "janvier" }, { month: "février" }, { month: "mars" }], "Salaires mensuels bruts des 3 derniers mois et primes des 3 derniers mois précédant l'arrêt de travail", ], ])( "should return the correct question", - (arretTravail, salaryPeriods, expected) => { + (type, arretTravail, salaryPeriods, expected) => { expect( - generateSalaireTempsPleinQuestion(arretTravail, salaryPeriods) + generateSalaireTempsPleinQuestion(type, arretTravail, salaryPeriods) ).toBe(expected); } ); @@ -74,31 +83,35 @@ describe("question.ts", () => { describe("generateResultSameSalary", () => { it.each([ [ + IndemniteDepartType.LICENCIEMENT, "non" as OuiNon, [{ month: "janvier" }], "Salaire mensuel brut identique précédant la notification du licenciement", ], [ + IndemniteDepartType.LICENCIEMENT, "oui" as OuiNon, [{ month: "janvier" }], "Salaire mensuel brut identique précédant l'arrêt de travail", ], [ + IndemniteDepartType.RUPTURE_CONVENTIONNELLE, "non" as OuiNon, [{ month: "janvier" }, { month: "février" }], - "Salaire mensuel brut identique durant les 2 derniers mois précédant la notification du licenciement", + "Salaire mensuel brut identique durant les 2 derniers mois précédant la fin du contrat", ], [ + IndemniteDepartType.LICENCIEMENT, "oui" as OuiNon, [{ month: "janvier" }, { month: "février" }, { month: "mars" }], "Salaire mensuel brut identique durant les 3 derniers mois précédant l'arrêt de travail", ], ])( "should return the correct result", - (arretTravail, salaryPeriods, expected) => { - expect(generateResultSameSalary(arretTravail, salaryPeriods)).toBe( - expected - ); + (type, arretTravail, salaryPeriods, expected) => { + expect( + generateResultSameSalary(type, arretTravail, salaryPeriods) + ).toBe(expected); } ); }); @@ -106,30 +119,34 @@ describe("question.ts", () => { describe("generateResultSalaireTempsPlein", () => { it.each([ [ + IndemniteDepartType.LICENCIEMENT, "non" as OuiNon, [{ month: "janvier" }], "Salaire mensuel brut perçu le dernier mois précédant la notification du licenciement", ], [ + IndemniteDepartType.LICENCIEMENT, "oui" as OuiNon, [{ month: "janvier" }], "Salaire mensuel brut perçu le dernier mois précédant l'arrêt de travail", ], [ + IndemniteDepartType.RUPTURE_CONVENTIONNELLE, "non" as OuiNon, [{ month: "janvier" }, { month: "février" }], - "Salaires mensuels bruts perçus au cours des 2 derniers mois précédant la notification du licenciement", + "Salaires mensuels bruts perçus au cours des 2 derniers mois précédant la fin du contrat", ], [ + IndemniteDepartType.LICENCIEMENT, "oui" as OuiNon, [{ month: "janvier" }, { month: "février" }, { month: "mars" }], "Salaires mensuels bruts perçus au cours des 3 derniers mois précédant l'arrêt de travail", ], ])( "should return the correct result", - (arretTravail, salaryPeriods, expected) => { + (type, arretTravail, salaryPeriods, expected) => { expect( - generateResultSalaireTempsPlein(arretTravail, salaryPeriods) + generateResultSalaireTempsPlein(type, arretTravail, salaryPeriods) ).toBe(expected); } ); diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/utils/question.ts b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/utils/question.ts similarity index 76% rename from packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/utils/question.ts rename to packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/utils/question.ts index 6ca45f1971..7cb09e8efe 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/utils/question.ts +++ b/packages/code-du-travail-frontend/src/outils/CommonIndemniteDepart/utils/question.ts @@ -1,8 +1,10 @@ import { SalaryPeriods } from "@socialgouv/modeles-social"; import { Agreement } from "@socialgouv/cdtn-utils"; import { OuiNon } from "../common"; +import { IndemniteDepartType } from "../../types"; export const generateSameSalaryQuestion = ( + type: IndemniteDepartType, arretTravail: OuiNon | undefined, salaryPeriods: SalaryPeriods[] ): string => { @@ -13,11 +15,14 @@ export const generateSameSalaryQuestion = ( } précédant ${ arretTravail === "oui" ? `l'arrêt de travail` - : `la notification du licenciement` + : type === IndemniteDepartType.LICENCIEMENT + ? "la notification du licenciement" + : "la fin du contrat" } ?`; }; export const generateSalaireTempsPleinQuestion = ( + type: IndemniteDepartType, arretTravail: OuiNon | undefined, salaryPeriods: SalaryPeriods[] ): string => { @@ -32,11 +37,14 @@ export const generateSalaireTempsPleinQuestion = ( } précédant ${ arretTravail === "oui" ? "l'arrêt de travail" - : "la notification du licenciement" + : type === IndemniteDepartType.LICENCIEMENT + ? "la notification du licenciement" + : "la fin du contrat" }`; }; export const generateResultSameSalary = ( + type: IndemniteDepartType, arretTravail: OuiNon | undefined, salaryPeriods: SalaryPeriods[] ): string => { @@ -47,11 +55,14 @@ export const generateResultSameSalary = ( }précédant ${ arretTravail === "oui" ? `l'arrêt de travail` - : `la notification du licenciement` + : type === IndemniteDepartType.LICENCIEMENT + ? "la notification du licenciement" + : "la fin du contrat" }`; }; export const generateResultSalaireTempsPlein = ( + type: IndemniteDepartType, arretTravail: OuiNon | undefined, salaryPeriods: SalaryPeriods[] ): string => { @@ -62,7 +73,9 @@ export const generateResultSalaireTempsPlein = ( } précédant ${ arretTravail === "oui" ? "l'arrêt de travail" - : "la notification du licenciement" + : type === IndemniteDepartType.LICENCIEMENT + ? "la notification du licenciement" + : "la fin du contrat" }`; }; diff --git a/packages/code-du-travail-frontend/src/outils/CommonSteps/Agreement/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonSteps/Agreement/store/store.ts index 8e51eb050d..f024d714bd 100644 --- a/packages/code-du-travail-frontend/src/outils/CommonSteps/Agreement/store/store.ts +++ b/packages/code-du-travail-frontend/src/outils/CommonSteps/Agreement/store/store.ts @@ -15,8 +15,8 @@ import { } from "../../../../lib"; import { pushAgreementEvents } from "../../../common/Agreement"; import { AgreementRoute } from "../../../common/type/WizardType"; +import { isCcFullySupportedIndemniteLicenciement } from "../../../CommonIndemniteDepart/common"; import { Agreement } from "@socialgouv/cdtn-utils"; -import { isCcFullySupportedIndemniteLicenciement } from "../../../IndemniteLicenciement/common"; const initialState: Omit< CommonAgreementStoreData, @@ -35,8 +35,8 @@ const initialState: Omit< const createCommonAgreementStore: StoreSlicePublicode< CommonAgreementStoreSlice, CommonInformationsStoreSlice -> = (set, get, { simulatorName, toolName }) => ({ - agreementData: { ...initialState, publicodes: loadPublicodes(simulatorName) }, +> = (set, get, { simulator, type }) => ({ + agreementData: { ...initialState, publicodes: loadPublicodes(simulator) }, agreementFunction: { onInitAgreementPage: () => { try { @@ -55,13 +55,11 @@ const createCommonAgreementStore: StoreSlicePublicode< ); const idcc = parsedData?.num?.toString(); if (idcc) { + const publicodes = loadPublicodes(simulator, idcc); set( produce( (state: CommonAgreementStoreSlice) => { - state.agreementData.publicodes = loadPublicodes( - simulatorName, - idcc - ); + state.agreementData.publicodes = publicodes; state.agreementData.input.isAgreementSupportedIndemniteLicenciement = isCcFullySupportedIndemniteLicenciement(parseInt(idcc)); } @@ -86,8 +84,15 @@ const createCommonAgreementStore: StoreSlicePublicode< } }, onRouteChange: (value) => { - if (value === "not-selected" && window.localStorage) { - window.localStorage.removeItem(STORAGE_KEY_AGREEMENT); + if (value === "not-selected") { + if (window.localStorage) { + window.localStorage.removeItem(STORAGE_KEY_AGREEMENT); + } + set( + produce((state: CommonAgreementStoreSlice) => { + state.agreementData.publicodes = loadPublicodes(simulator); + }) + ); } set( produce((state: CommonAgreementStoreSlice) => { @@ -115,10 +120,7 @@ const createCommonAgreementStore: StoreSlicePublicode< if (idcc) { set( produce((state: CommonAgreementStoreSlice) => { - state.agreementData.publicodes = loadPublicodes( - simulatorName, - idcc - ); + state.agreementData.publicodes = loadPublicodes(simulator, idcc); state.agreementData.input.isAgreementSupportedIndemniteLicenciement = isCcFullySupportedIndemniteLicenciement(parseInt(idcc)); }) @@ -149,7 +151,7 @@ const createCommonAgreementStore: StoreSlicePublicode< indemniteLicenciement && idcc === agreement?.num ); pushAgreementEvents( - toolName, + type, { route, selected: agreement, @@ -172,7 +174,7 @@ const createCommonAgreementStore: StoreSlicePublicode< matopush([ MatomoBaseEvent.TRACK_EVENT, MatomoSearchAgreementCategory.AGREEMENT_SEARCH, - toolName, + type, JSON.stringify(data), ]); }, @@ -180,7 +182,7 @@ const createCommonAgreementStore: StoreSlicePublicode< matopush([ MatomoBaseEvent.TRACK_EVENT, MatomoSearchAgreementCategory.ENTERPRISE_SEARCH, - toolName, + type, JSON.stringify(data), ]); }, diff --git a/packages/code-du-travail-frontend/src/outils/CommonSteps/Informations/components/PubliQuestion.tsx b/packages/code-du-travail-frontend/src/outils/CommonSteps/Informations/components/PubliQuestion.tsx index 3990df5cd8..07b62c8d92 100644 --- a/packages/code-du-travail-frontend/src/outils/CommonSteps/Informations/components/PubliQuestion.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonSteps/Informations/components/PubliQuestion.tsx @@ -8,13 +8,12 @@ import { TextQuestion, } from "../../../Components"; import { reverseValues } from "../../../publicodes"; -import { MatomoActionEvent, trackQuestion } from "../../../../lib"; -import { icons } from "@socialgouv/cdtn-ui"; +import { eventEmitter } from "../../../CommonIndemniteDepart/events/emitter"; +import { EventType } from "../../../CommonIndemniteDepart/events/events"; interface Props { name: string; rule: Rule; - trackQuestionEvent: MatomoActionEvent; value: string | undefined; onChange: (value: unknown) => void; error?: string; @@ -25,7 +24,6 @@ interface Props { const PubliQuestion: React.FC = ({ name, rule, - trackQuestionEvent, value, onChange, error, @@ -40,8 +38,8 @@ const PubliQuestion: React.FC = ({ ? { content: {rule.description}, trackableFn: (visibility: boolean) => { - if (visibility && titre && trackQuestionEvent) { - trackQuestion(titre, trackQuestionEvent); + if (visibility && titre) { + eventEmitter.dispatch(EventType.TRACK_QUESTION, titre); } }, } diff --git a/packages/code-du-travail-frontend/src/outils/CommonSteps/Informations/components/__tests__/PubliQuestion.test.tsx b/packages/code-du-travail-frontend/src/outils/CommonSteps/Informations/components/__tests__/PubliQuestion.test.tsx index 8af018c6a4..65bb6e63b1 100644 --- a/packages/code-du-travail-frontend/src/outils/CommonSteps/Informations/components/__tests__/PubliQuestion.test.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonSteps/Informations/components/__tests__/PubliQuestion.test.tsx @@ -26,7 +26,6 @@ describe("", () => { titre: "Catégorie professionnelle", }} value="v" - trackQuestionEvent={MatomoActionEvent.INDEMNITE_LICENCIEMENT} /> ) ).toBeTruthy(); @@ -52,7 +51,6 @@ describe("", () => { titre: "Catégorie professionnelle", }} value="v" - trackQuestionEvent={MatomoActionEvent.INDEMNITE_LICENCIEMENT} /> ); expect(getByRole("combobox")).toBeTruthy(); @@ -78,7 +76,6 @@ describe("", () => { titre: "Catégorie professionnelle", }} value="v" - trackQuestionEvent={MatomoActionEvent.INDEMNITE_LICENCIEMENT} /> ); expect(getAllByRole("radio")).toBeTruthy(); diff --git a/packages/code-du-travail-frontend/src/outils/CommonSteps/Informations/index.tsx b/packages/code-du-travail-frontend/src/outils/CommonSteps/Informations/index.tsx index 6b2cf14f08..09f19d0caf 100644 --- a/packages/code-du-travail-frontend/src/outils/CommonSteps/Informations/index.tsx +++ b/packages/code-du-travail-frontend/src/outils/CommonSteps/Informations/index.tsx @@ -24,7 +24,6 @@ const CommonInformationStep = ({ key={info.id} name={"infos." + info.question.name} rule={info.question.rule} - trackQuestionEvent={MatomoActionEvent.INDEMNITE_LICENCIEMENT} value={info.info} onChange={(v) => onChange(info.question.rule.nom, v, info.question.rule.cdtn?.type) diff --git a/packages/code-du-travail-frontend/src/outils/CommonSteps/Informations/store/store.ts b/packages/code-du-travail-frontend/src/outils/CommonSteps/Informations/store/store.ts index 2d71e880f3..3bd21dfa38 100644 --- a/packages/code-du-travail-frontend/src/outils/CommonSteps/Informations/store/store.ts +++ b/packages/code-du-travail-frontend/src/outils/CommonSteps/Informations/store/store.ts @@ -18,8 +18,9 @@ import { CommonAgreementStoreSlice } from "../../Agreement/store"; import { removeDuplicateObject } from "../../../../lib"; import { informationToSituation } from "../utils"; import { ValidationResponse } from "../../../Components/SimulatorLayout"; -import { ContratTravailStoreSlice } from "../../../IndemniteLicenciement/steps/ContratTravail/store"; +import { ContratTravailStoreSlice } from "../../../CommonIndemniteDepart/steps/ContratTravail/store"; import * as Sentry from "@sentry/nextjs"; +import { CommonSituationStoreSlice } from "../../../common/situationStore"; const initialState: CommonInformationsStoreData = { input: { @@ -38,7 +39,9 @@ const initialState: CommonInformationsStoreData = { const createCommonInformationsStore: StoreSlice< CommonInformationsStoreSlice, - CommonAgreementStoreSlice & ContratTravailStoreSlice + CommonAgreementStoreSlice & + ContratTravailStoreSlice & + CommonSituationStoreSlice > = (set, get) => ({ informationsData: { ...initialState, @@ -58,10 +61,13 @@ const createCommonInformationsStore: StoreSlice< agreement.num, isLicenciementInaptitude, false - ), - "contrat salarié . indemnité de licenciement . résultat conventionnel" + ) ); - const missingArgs = result.missingArgs.filter( + let resultMissingArgs: MissingArgs[] = []; + if (result.type === "missing-args") { + resultMissingArgs = result.missingArgs; + } + const missingArgs = resultMissingArgs.filter( (item) => item.rawNode.cdtn ); if (missingArgs.length > 0) { @@ -111,9 +117,6 @@ const createCommonInformationsStore: StoreSlice< get().informationsData.input.publicodesInformations; const isLicenciementInaptitude = get().contratTravailData.input.licenciementInaptitude === "oui"; - const contractType = get().contratTravailData.input.typeContratTravail; - const isDismissalSeriousMisconduct = - get().contratTravailData.input.licenciementFauteGrave; const questionAnswered = publicodesInformations.find( (question) => question.question.rule.nom === key ); @@ -145,10 +148,13 @@ const createCommonInformationsStore: StoreSlice< isLicenciementInaptitude, false, rules - ), - "contrat salarié . indemnité de licenciement . résultat conventionnel" + ) ); - missingArgs = result.missingArgs.filter((item) => item.rawNode.cdtn); + let resultMissingArgs: MissingArgs[] = []; + if (result.type === "missing-args") { + resultMissingArgs = result.missingArgs; + } + missingArgs = resultMissingArgs.filter((item) => item.rawNode.cdtn); const notifBloquante = publicodes.getNotificationsBloquantes(); if (notifBloquante.length > 0) { blockingNotification = notifBloquante[0].description; @@ -240,12 +246,22 @@ const createCommonInformationsStore: StoreSlice< }, onNextStep: () => { const state = get().informationsData.input; - const currentError = get().informationsData.error; const { isValid, errorState } = validateStep(state); let errorEligibility; if (isValid) { - errorEligibility = state.blockingNotification; + const publicodes = get().agreementData.publicodes; + const situation = { + ...get().situationData.situation, + ...informationToSituation( + get().informationsData.input.publicodesInformations + ), + }; + const result = publicodes.calculate(situation); + errorEligibility = + result.type === "ineligibility" + ? result.ineligibility + : state.blockingNotification; } set( diff --git a/packages/code-du-travail-frontend/src/outils/Components/SimulatorLayout.tsx b/packages/code-du-travail-frontend/src/outils/Components/SimulatorLayout.tsx index 9a6bf85922..a4dae2bcec 100644 --- a/packages/code-du-travail-frontend/src/outils/Components/SimulatorLayout.tsx +++ b/packages/code-du-travail-frontend/src/outils/Components/SimulatorLayout.tsx @@ -12,7 +12,7 @@ import { import SimulatorNavigation from "./SimulatorNavigation"; import { push as matopush } from "@socialgouv/matomo-next"; import { MatomoActionEvent, MatomoBaseEvent } from "../../lib"; -import { IndemniteLicenciementStepName } from "../IndemniteLicenciement"; +import { IndemniteDepartStepName } from "../CommonIndemniteDepart"; import { PublicodesSimulator } from "@socialgouv/modeles-social"; import scrollToTop from "../common/utils/scrollToTop"; @@ -22,7 +22,7 @@ export enum ValidationResponse { Valid = "valid", } -type StepChange = { +export type StepChange = { onNextStep?: () => ValidationResponse; onPrevStep?: () => void; stepName: StepName; @@ -104,7 +104,7 @@ const SimulatorContent = ({ const doNotTriggerMatomo = (stepName: string) => navigationAction === "none" || - (stepName === IndemniteLicenciementStepName.Resultat && + (stepName === IndemniteDepartStepName.Resultat && simulator === PublicodesSimulator.INDEMNITE_LICENCIEMENT); const onNextStep = () => { diff --git a/packages/code-du-travail-frontend/src/outils/DureePreavisDemission/steps/__tests__/__snapshots__/Result.test.tsx.snap b/packages/code-du-travail-frontend/src/outils/DureePreavisDemission/steps/__tests__/__snapshots__/Result.test.tsx.snap index 8d3f1661c4..1f44369275 100644 --- a/packages/code-du-travail-frontend/src/outils/DureePreavisDemission/steps/__tests__/__snapshots__/Result.test.tsx.snap +++ b/packages/code-du-travail-frontend/src/outils/DureePreavisDemission/steps/__tests__/__snapshots__/Result.test.tsx.snap @@ -122,8 +122,12 @@ exports[` should render CC answer 1`] = ` > Sources -