Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 5271 indemnité de licenciement créer un questionnaire spécifique #5287

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" && (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

peut être faire un array pour éviter d'avoir une url statique dans le code en mode MY_ARRAY.includes(router.asPath)

<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;
maxgfr marked this conversation as resolved.
Show resolved Hide resolved
};

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}
Comment on lines +45 to +47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On ne pourrait pas mettre des valeurs par défaut ici ?

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
Loading