Skip to content

Commit

Permalink
feat: 5271 indemnité de licenciement créer un questionnaire spécifique (
Browse files Browse the repository at this point in the history
#5287)

Co-authored-by: Martial Maillot <[email protected]>
Co-authored-by: Victor Zeinstra <[email protected]>
Co-authored-by: Maxime Golfier <[email protected]>
  • Loading branch information
4 people authored Aug 3, 2023
1 parent 399b2e7 commit 969c330
Show file tree
Hide file tree
Showing 22 changed files with 959 additions and 42 deletions.
12 changes: 7 additions & 5 deletions packages/code-du-travail-frontend/pages/outils/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,20 @@ function Outils({
<div>
<Container>
<Flex>
<ShareContainer>
<Share title={title} metaDescription={description} />
</ShareContainer>
<Tool
icon={icon}
title={title}
displayTitle={displayTitle}
slug={slug}
/>
<ShareContainer>
<Share title={title} metaDescription={description} />
</ShareContainer>
</Flex>
<RelatedItems items={relatedItems} />
<Feedback url={router.asPath} />
{router.asPath !== "/outils/indemnite-licenciement" && (
<Feedback url={router.asPath} />
)}
</Container>
</div>
</Layout>
Expand Down Expand Up @@ -149,5 +151,5 @@ export const ShareContainer = styled.div`

export const Flex = styled.div`
display: flex;
flex-direction: column-reverse;
flex-direction: column;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from "./store";
import { ToolName } from "../types";
import { PublicodesSimulator } from "@socialgouv/modeles-social";
import { Feedback } from "../common/Feedback";

type Props = {
icon: string;
Expand Down Expand Up @@ -119,42 +120,45 @@ const IndemniteLicenciementSimulator = ({
};

return (
<SimulatorLayout<IndemniteLicenciementStepName>
simulator={PublicodesSimulator.INDEMNITE_LICENCIEMENT}
title={title}
displayTitle={displayTitle}
icon={icon}
duration="5 à 10 min"
steps={steps}
onStepChange={[
{
stepName: IndemniteLicenciementStepName.ContratTravail,
isStepValid: isStepContratTravailValid,
onNextStep: onNextStepContratTravail,
},
{
stepName: IndemniteLicenciementStepName.Agreement,
isStepValid: isStepAgreementValid,
onNextStep: onNextStepAgreement,
},
{
stepName: IndemniteLicenciementStepName.Anciennete,
isStepValid: isStepAncienneteValid,
onNextStep: onNextStepAnciennete,
},
{
stepName: IndemniteLicenciementStepName.Salaires,
isStepValid: isStepSalairesValid,
onNextStep: onNextStepSalaires,
},
{
stepName: IndemniteLicenciementStepName.Informations,
isStepValid: isStepInformationsValid,
onNextStep: onNextStepInformations,
},
]}
hiddenStep={getHiddenSteps()}
/>
<>
<SimulatorLayout<IndemniteLicenciementStepName>
simulator={PublicodesSimulator.INDEMNITE_LICENCIEMENT}
title={title}
displayTitle={displayTitle}
icon={icon}
duration="5 à 10 min"
steps={steps}
onStepChange={[
{
stepName: IndemniteLicenciementStepName.ContratTravail,
isStepValid: isStepContratTravailValid,
onNextStep: onNextStepContratTravail,
},
{
stepName: IndemniteLicenciementStepName.Agreement,
isStepValid: isStepAgreementValid,
onNextStep: onNextStepAgreement,
},
{
stepName: IndemniteLicenciementStepName.Anciennete,
isStepValid: isStepAncienneteValid,
onNextStep: onNextStepAnciennete,
},
{
stepName: IndemniteLicenciementStepName.Salaires,
isStepValid: isStepSalairesValid,
onNextStep: onNextStepSalaires,
},
{
stepName: IndemniteLicenciementStepName.Informations,
isStepValid: isStepInformationsValid,
onNextStep: onNextStepInformations,
},
]}
hiddenStep={getHiddenSteps()}
/>
<Feedback />
</>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import styled from "styled-components";
import { Button, Heading } from "@socialgouv/cdtn-ui";

import { QuestionnaireItem, Status } from "./QuestionnaireItem";
import { trackFeedback, EVENT_ACTION, FEEDBACK_RESULT } from "./tracking";
import { useState } from "react";

type QuestionnaireProps = {
onClick: () => void;
};

export const Questionnaire = ({ onClick }: QuestionnaireProps): JSX.Element => {
const [status, setStatus] = useState<FEEDBACK_RESULT>();
const [displayError, setDisplayError] = useState(false);
return (
<>
<StyledHeading variant="primary" stripe="left">
Comment s&apos;est passée cette simulation pour vous ?
</StyledHeading>
<StyledQuestionnaireItem
badEventValue={FEEDBACK_RESULT.NOT_GOOD}
averageEventValue={FEEDBACK_RESULT.AVERAGE}
goodEventValue={FEEDBACK_RESULT.GOOD}
badText="Pas bien"
onChange={(status: FEEDBACK_RESULT) => {
setStatus(status);
setDisplayError(false);
}}
displayError={displayError}
/>
<StyledButton
onClick={() => {
if (!status) {
setDisplayError(true);
} else {
trackFeedback(EVENT_ACTION.GLOBAL, status);
onClick();
}
}}
variant="primary"
>
Envoyer
</StyledButton>
</>
);
};

const StyledHeading = styled(Heading)`
margin-left: 0;
margin-bottom: 0;
padding-top: 6px;
`;

const StyledButton = styled(Button)`
margin: 12px auto 24px 24px;
`;

const StyledQuestionnaireItem = styled(QuestionnaireItem)`
padding: 24px;
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import { Button, Heading } from "@socialgouv/cdtn-ui";
import { QuestionnaireItem } from "./QuestionnaireItem";
import { QuestionnaireText } from "./QuestionnaireText";
import styled from "styled-components";
import { useState } from "react";
import {
trackFeedback,
trackFeedbackText,
FEEDBACK_RESULT,
EVENT_ACTION,
} from "./tracking";
import { useRouter } from "next/router";

type QuestionnaireAdvancedProps = {
onClick: () => void;
};

export const QuestionnaireAdvanced = ({
onClick,
}: QuestionnaireAdvancedProps): React.ReactElement => {
const router = useRouter();
const [statusSimulator, setStatusSimulator] = useState<FEEDBACK_RESULT>();
const [statusQuestion, setStatusQuestion] = useState<FEEDBACK_RESULT>();
const [statusExplanation, setStatusExplanation] = useState<FEEDBACK_RESULT>();
const [feedbackText, setFeedbackText] = useState<string>();
return (
<>
<StyledHeading variant="primary" stripe="left">
Merci pour votre aide ! Pouvez-vous nous en dire plus ?
</StyledHeading>
<FormContainer>
<StyledQuestionnaireItem
badEventValue={FEEDBACK_RESULT.NOT_AT_ALL}
averageEventValue={FEEDBACK_RESULT.AVERAGE}
goodEventValue={FEEDBACK_RESULT.EASY}
title="Le simulateur était-il facile à utiliser ?"
badText="Pas du tout"
goodText="Facile"
onChange={(status) => {
setStatusSimulator(status);
}}
dataTestId="simulator"
/>
<StyledQuestionnaireItem
badEventValue={FEEDBACK_RESULT.NOT_AT_ALL}
averageEventValue={FEEDBACK_RESULT.AVERAGE}
goodEventValue={FEEDBACK_RESULT.YES}
title="Les questions étaient-elles claires et compréhensibles ?"
badText="Pas du tout"
goodText="Oui"
onChange={(status) => {
setStatusQuestion(status);
}}
dataTestId="questionClarity"
/>
<StyledQuestionnaireItem
badEventValue={FEEDBACK_RESULT.NOT_AT_ALL}
averageEventValue={FEEDBACK_RESULT.AVERAGE}
goodEventValue={FEEDBACK_RESULT.YES}
title="Les explications du résultat obtenu étaient-elles claires et compréhensibles ?"
badText="Pas du tout"
goodText="Oui"
onChange={(status) => {
setStatusExplanation(status);
}}
dataTestId="resultClarity"
/>
<QuestionnaireText
title="Vous souhaitez nous en dire davantage ?"
placeholder="ex: la question sur la date de début du contrat n'est pas claire"
onChange={setFeedbackText}
dataTestId="more-input"
/>
</FormContainer>
<StyledButton
variant="primary"
onClick={() => {
if (statusSimulator) {
trackFeedback(EVENT_ACTION.EASINESS, statusSimulator);
}
if (statusQuestion) {
trackFeedback(EVENT_ACTION.QUESTION_CLARITY, statusQuestion);
}
if (statusExplanation) {
trackFeedback(EVENT_ACTION.RESULT_CLARITY, statusExplanation);
}
if (feedbackText) {
trackFeedbackText(feedbackText, router.asPath);
}
onClick();
}}
>
Envoyer
</StyledButton>
</>
);
};

const StyledHeading = styled(Heading)`
margin-left: 0;
margin-bottom: 0;
padding-top: 6px;
`;

const StyledButton = styled(Button)`
margin: 12px auto 24px 24px;
`;

const FormContainer = styled.div`
padding: 0 24px;
`;

const StyledQuestionnaireItem = styled(QuestionnaireItem)`
margin: 24px 0;
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Heading } from "@socialgouv/cdtn-ui";
import styled from "styled-components";

export const QuestionnaireEnd = (): JSX.Element => {
return (
<>
<StyledHeading variant="primary" stripe="left">
Merci pour votre aide !
</StyledHeading>
<StyledText>
Votre évaluation sera étudiée au plus vite par nos équipes
</StyledText>
</>
);
};

const StyledHeading = styled(Heading)`
margin-left: 0;
padding-top: 6px;
`;

const StyledText = styled.span`
margin: 12px auto 24px 24px;
`;
Loading

0 comments on commit 969c330

Please sign in to comment.