Skip to content

Commit

Permalink
fix(preavis-retraite): correction de petits bugs sur le resultat (#6098)
Browse files Browse the repository at this point in the history
* fix: retours preavis

* Update packages/code-du-travail-frontend/src/outils/PreavisRetraite/steps/Result/components/DecryptedResult.tsx

Co-authored-by: Caroline <[email protected]>

---------

Co-authored-by: Caroline <[email protected]>
  • Loading branch information
maxgfr and carolineBda authored Sep 10, 2024
1 parent fe44cbd commit d6eee29
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test(`Départ à la retraite sans sélection de CC avec handicap
expect(ui.result.noticeHandicap2.get()).toBeInTheDocument();
expect(ui.result.resultatLegal.get()).toHaveTextContent("3 mois");
expect(ui.result.resultatAgreement.get()).toHaveTextContent(
"convention collective non traitée"
"convention collective non renseignée"
);
expect(ui.result.decryptedDescription.get()).toHaveTextContent(
"La convention collective n’ayant pas été renseignée, la durée de préavis affichée correspond à la durée légale."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test(`Départ à la retraite sans sélection de CC
expect(ui.result.travailleurHandicape.get()).toHaveTextContent("Non");
expect(ui.result.resultatLegal.get()).toHaveTextContent("2 mois");
expect(ui.result.resultatAgreement.get()).toHaveTextContent(
"convention collective non traitée"
"convention collective non renseignée"
);
expect(ui.result.decryptedDescription.get()).toHaveTextContent(
"La convention collective n’ayant pas été renseignée, la durée de préavis affichée correspond à la durée légale."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test(`Mise à la retraite sans sélection de CC avec handicap
expect(ui.result.noticeHandicap2.get()).toBeInTheDocument();
expect(ui.result.resultatLegal.get()).toHaveTextContent("3 mois");
expect(ui.result.resultatAgreement.get()).toHaveTextContent(
"convention collective non traitée"
"convention collective non renseignée"
);
expect(ui.result.decryptedDescription.get()).toHaveTextContent(
"La convention collective n’ayant pas été renseignée, la durée de préavis affichée correspond à la durée légale."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test(`Mise à la retraite sans sélection de CC
expect(ui.result.travailleurHandicape.get()).toHaveTextContent("Non");
expect(ui.result.resultatLegal.get()).toHaveTextContent("2 mois");
expect(ui.result.resultatAgreement.get()).toHaveTextContent(
"convention collective non traitée"
"convention collective non renseignée"
);
expect(ui.result.decryptedDescription.get()).toHaveTextContent(
"La convention collective n’ayant pas été renseignée, la durée de préavis affichée correspond à la durée légale."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { SectionTitle } from "../../../../common/stepStyles";
import { getDescription } from "../utils/getDescription";
import { DepartOuMiseRetraite } from "../../OriginStep/store";
import { NoticeUsed } from "../utils/types";
import { AgreementRoute } from "../../../../common/type/WizardType";

type Props = {
legalResult?: PublicodesPreavisRetraiteResult;
Expand All @@ -16,6 +17,7 @@ type Props = {
isSeniorityLessThan6Months: boolean;
hasAgreement: boolean;
isAgreementSupported: boolean;
agreementRoute?: AgreementRoute;
};

const DecryptedResult: React.FC<Props> = ({
Expand All @@ -28,6 +30,7 @@ const DecryptedResult: React.FC<Props> = ({
hasAgreement,
isAgreementSupported,
agreementResult,
agreementRoute,
}) => {
const description = getDescription(
typeDeDepart,
Expand All @@ -54,6 +57,7 @@ const DecryptedResult: React.FC<Props> = ({
result={agreementResult}
isAgreementSupported={isAgreementSupported}
agreementMaximumResult={agreementMaximumResult}
agreementRoute={agreementRoute}
/>
</Paragraph>
{description && (
Expand Down Expand Up @@ -102,17 +106,19 @@ const ShowResult: React.FC<ShowResultProps> = ({

type ShowResultAgreementProps = ShowResultProps & {
isAgreementSupported?: boolean;
agreementRoute?: AgreementRoute;
};

const ShowResultAgreement: React.FC<ShowResultAgreementProps> = ({
result,
isAgreementSupported,
agreementMaximumResult,
agreementRoute,
}) => {
if (!result) {
if (agreementRoute === "not-selected") {
return <strong>convention collective non renseignée</strong>;
}
if (result?.value > 0 && agreementMaximumResult) {
if (result && result.value > 0 && agreementMaximumResult) {
return (
<ShowResult
result={result}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,26 @@ const ShowResult: React.FC<Props> = ({
{result.unit}&nbsp;et&nbsp;
{agreementMaximumResult?.value}&nbsp;
{agreementMaximumResult?.unit}
<NoticeNote
numberOfElements={1 + notifications.length}
currentElement={1}
isList
/>
</>
) : result.value > 0 ? (
<>
{result.value}
&nbsp;
{result.unit}
<NoticeNote
numberOfElements={1 + notifications.length}
currentElement={1}
isList
/>
</>
) : (
<>il n’y a pas de préavis à effectuer</>
)}
<NoticeNote
numberOfElements={1 + notifications.length}
currentElement={1}
isList
/>
</HighlightResult>
</p>
{result.value !== 0 && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const StepResult = (): JSX.Element => {
moreThanXYears,
errorPublicodes,
result,
agreementRoute,
} = usePreavisRetraiteStore(store, (state) => ({
originDepart: state.originDepartData.input.originDepart,
agreement: state.agreementData.input.agreement,
Expand All @@ -50,6 +51,7 @@ const StepResult = (): JSX.Element => {
moreThanXYears: state.seniorityData.input.moreThanXYears,
errorPublicodes: state.resultData.error.errorPublicodes,
result: state.resultData.input.result,
agreementRoute: state.agreementData.input.route,
}));

useEffect(() => {
Expand Down Expand Up @@ -89,6 +91,7 @@ const StepResult = (): JSX.Element => {
noticeUsed={noticeUsed!}
typeDeDepart={originDepart!}
isSeniorityLessThan6Months={!!isSeniorityLessThan6Months}
agreementRoute={agreementRoute}
/>
<PubliReferences references={resultReferences ?? []} />
</ShowDetails>
Expand Down

0 comments on commit d6eee29

Please sign in to comment.