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: 6197 migration du simulateur brutnet #6205

Merged
merged 89 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 85 commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
5d0bee3
fix: dsfr
maxgfr Aug 22, 2024
26c096b
fix: dsfr
maxgfr Aug 22, 2024
26fda93
fix: dsfr
maxgfr Aug 22, 2024
3de62c3
fix: tests
maxgfr Aug 23, 2024
519c2b8
fix: build
maxgfr Aug 23, 2024
584430c
fix: build
maxgfr Aug 23, 2024
e72900e
fix: build
maxgfr Aug 23, 2024
e7e9d9d
feat(dsfr): ajout du footer (#6079)
maxgfr Aug 27, 2024
9b5940d
fix: tests
maxgfr Aug 28, 2024
6b8bbc3
fix: tests
maxgfr Aug 29, 2024
39725b4
fix: tests
maxgfr Aug 29, 2024
fa27e26
fix: dernier titi
maxgfr Aug 29, 2024
730c547
fix: autoclick
maxgfr Aug 29, 2024
8959e95
fix: bug
maxgfr Aug 29, 2024
5e70276
feat(css): ajout de la lib `panda-css` (zero-runtime) (#6085)
maxgfr Sep 2, 2024
84fd66c
feat(dsfr): ajout de la page stats (#6090)
maxgfr Sep 2, 2024
a1bc36f
fix: tests
maxgfr Sep 2, 2024
205f24d
fix: tests
maxgfr Sep 2, 2024
9fa7db2
Update packages/code-du-travail-frontend/src/modules/mentions-legales…
carolineBda Sep 3, 2024
34ad3a4
fix(recherche): remonter les pré-qualifiés dans la recherche (#6082)
m-maillot Aug 30, 2024
811d51c
chore(release): version 4.151.1
SocialGroovyBot Aug 30, 2024
3a18228
fix(csp): remove reporting on sentry (#6092)
maxgfr Sep 3, 2024
632ad2d
fix: config
maxgfr Sep 3, 2024
dc60c8a
fix: config
maxgfr Sep 3, 2024
3c964c6
fix: config
maxgfr Sep 3, 2024
49e3218
empty
maxgfr Sep 3, 2024
66af4ac
fix: config
maxgfr Sep 3, 2024
b89df9e
empty
maxgfr Sep 3, 2024
7d74e34
Update packages/code-du-travail-frontend/src/modules/mentions-legales…
maxgfr Sep 3, 2024
50029c0
Update packages/code-du-travail-frontend/src/modules/mentions-legales…
maxgfr Sep 3, 2024
4cf46ee
fix: config
maxgfr Sep 3, 2024
4422345
Merge branch 'dev' into maxgfr/dsfr-header
maxgfr Sep 3, 2024
56bde01
chore(dsfr): mise à jour de la version DSFR
m-maillot Sep 5, 2024
0dcdb11
fix(dsfr): ignore les exceptions d'hydratation
m-maillot Sep 10, 2024
eb9af7a
Merge branch 'dev' into maxgfr/dsfr-header
m-maillot Sep 10, 2024
f7ccd02
feat(tests): ajout du module de testing (#6096)
maxgfr Sep 10, 2024
f146a58
fix(dsfr): ignore les exceptions d'hydratation
m-maillot Sep 10, 2024
1ab139e
empty
maxgfr Sep 10, 2024
b9ae448
Merge branch 'dev' into maxgfr/dsfr-header
maxgfr Sep 10, 2024
e43a732
fix: readme
maxgfr Sep 10, 2024
222395d
feat(DSFR): migration de la page article du code du travail (#6099)
carolineBda Sep 16, 2024
e1b2b85
feat: 6093 dsfr page politique de confidentialit (#6094)
Viczei Sep 16, 2024
c4033af
Merge branch 'dev' into maxgfr/dsfr-header
m-maillot Sep 16, 2024
9c7536b
feat(dsfr): ajout des liens d'évitement (#6120)
m-maillot Sep 16, 2024
75b9216
feat(dsfr): migration de la page plan du site (#6097)
m-maillot Sep 16, 2024
13ba1aa
feat(dsfr): mise à jour des snapshots
m-maillot Sep 16, 2024
aee0955
feat(dsfr): mise à jour des snapshots
m-maillot Sep 16, 2024
abecbd2
chore(dsfr): mise à jour de la lib DSFR
m-maillot Sep 17, 2024
a5c5bdc
feat(dsfr): ajout du composant "Avez-vous trouvé une réponse à votre …
maxgfr Sep 18, 2024
6709c1e
fix: tests
maxgfr Sep 18, 2024
919318a
fix: retours
maxgfr Sep 19, 2024
1f81741
fix: tests
maxgfr Sep 19, 2024
75cddcf
feat: nouvelle API pour les articles du code du travail (#6132)
m-maillot Sep 19, 2024
e830c52
fix: merge date
maxgfr Sep 20, 2024
1935bcf
fix(spec) : fix de la spec article-code-du-travail.spec.ts
carolineBda Sep 23, 2024
b250d45
fix(dsfr): ajout de la config pour supprimer le `insafe-inline` des `…
maxgfr Sep 26, 2024
3d0967c
feat(dsfr): ajout de matomo pour tracker les events (#6157)
maxgfr Sep 26, 2024
177b731
Merge branch 'dev' into maxgfr/dsfr-header
m-maillot Sep 26, 2024
f87c8ad
fix(feedback): ajout d'une logique de caractères restants (#6156)
maxgfr Sep 26, 2024
c4c92cb
feat(dsfr): ajout du nouveau logo (#6159)
carolineBda Sep 30, 2024
29ec0d6
feat(dsfr): ajout des pages d'erreurs (404 + 500) (#6146)
maxgfr Oct 3, 2024
70c41a0
feat: séparation des anciennes API et des nouvelles (#6183)
m-maillot Oct 3, 2024
16ed3e8
fix(article code du travail): retrait du tag Code du travail (#6182)
carolineBda Oct 3, 2024
7f329e0
feat(config): correction de `husky`, ajout de `prettier` pour le form…
maxgfr Oct 9, 2024
68ea2cf
Merge branch 'dev' into maxgfr/dsfr-header
maxgfr Oct 9, 2024
0ebc402
fix: branch
maxgfr Oct 9, 2024
6cefcfb
merge dev
carolineBda Oct 10, 2024
36697b3
merge dev
carolineBda Oct 10, 2024
fb4a99a
feat: implémentation simulateur brut net
Oct 11, 2024
0a35960
chore: fix ts
Oct 11, 2024
6eb422c
chore: snap
Oct 11, 2024
26bad05
chore: clean
Oct 11, 2024
8afa8bc
chore: clean
Oct 11, 2024
5839013
chore: clean
Oct 11, 2024
1520482
chore: review
Oct 14, 2024
cd15bc7
feat: update responsive
Oct 15, 2024
0748928
Merge branch 'dev' into simulateur-brut-net-dsfr
Oct 15, 2024
fe39518
Revert "Merge branch 'dev' into simulateur-brut-net-dsfr"
Oct 15, 2024
0731fc3
chore: clean
Oct 15, 2024
002ae75
feat: chore clean
Oct 15, 2024
66875a5
chore: clean
Oct 15, 2024
282063a
Merge branch 'dev' into simulateur-brut-net-dsfr
Oct 15, 2024
bb5da2f
chore: remove undesired files
Oct 15, 2024
cab0a48
chore: remove undesired files
Oct 15, 2024
ef094cf
chore: clean
Oct 15, 2024
6e7f2c0
fix: meta description share
Oct 17, 2024
4965bae
feat: switch simu brut net couleur par defaut
Oct 17, 2024
5c7f10f
fix: ts
Oct 21, 2024
5270d52
fix: bug load
Oct 21, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { DsfrLayout } from "../../../src/modules/layout";
import { HiringSimulator } from "../../../src/modules/outils/simulateur-embauche";
import { fetchRelatedItems } from "../../../src/modules/documents";
import { fetchTool } from "../../../src/modules/outils";
import { notFound } from "next/navigation";
import { generateDefaultMetadata } from "../../../src/modules/common/metas";

export async function generateMetadata() {
const { title, description } = await getTool();

return generateDefaultMetadata({
title: `Simulateur - ${title}`,
description: description,
path: `/outils/simulateur-embauche`,
});
}

async function HiringSimulatorPage() {
const tool = await getTool();
const relatedItems = await fetchRelatedItems(
{ _id: tool._id },
"simulateur-embauche"
);
return (
<DsfrLayout>
<HiringSimulator relatedItems={relatedItems} />
</DsfrLayout>
);
}

const getTool = async () => {
const tool = await fetchTool("simulateur-embauche");

if (!tool) {
return notFound();
}
return tool;
};

export default HiringSimulatorPage;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import "cypress-iframe";
describe("Outil - Salaire brut/net", () => {
it("Valider que le simulateur s'affiche correctement dans l'iframe", () => {
cy.visit("/outils/simulateur-embauche");
cy.get("h1").should("have.text", "Calculer le salaire brut/net");
cy.findByRole("heading", { level: 1 }).should(
"have.text",
"Calculer le salaire brut/net"
);
cy.iframe("#simulateurEmbauche")
.contains("Coût total employeur")
.should("be.visible");
Expand Down
2 changes: 0 additions & 2 deletions packages/code-du-travail-frontend/pages/outils/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
DureePreavisDemission,
DureePreavisLicenciement,
HeuresRechercheEmploi,
SimulateurEmbauche,
SimulateurIndemnitePrecarite,
CalculateurPreavisRetraite,
} from "../../src/outils";
Expand All @@ -38,7 +37,6 @@ const toolsBySlug = {
"preavis-demission": DureePreavisDemission,
"preavis-licenciement": DureePreavisLicenciement,
"preavis-retraite": CalculateurPreavisRetraite,
"simulateur-embauche": SimulateurEmbauche,
"procedure-licenciement": DismissalProcess,
"indemnite-rupture-conventionnelle": CalculateurRuptureConventionnelle,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { fr } from "@codegouvfr/react-dsfr";
import { Breadcrumb, BreadcrumbProps } from "@codegouvfr/react-dsfr/Breadcrumb";

import { RelatedItems } from "../common/RelatedItems";
import { Share } from "../common/Share";
import { RelatedItem } from "../documents";
import { Feedback } from "../layout/feedback";

type Props = {
relatedItems: { items: RelatedItem[]; title: string }[];
title: string;
description: string;
children: React.ReactNode;
} & Pick<BreadcrumbProps, "segments">;

export const ContainerSimulator = ({
children,
relatedItems,
title,
description,
segments = [],
}: Props) => {
return (
<div className={fr.cx("fr-grid-row")}>
<Breadcrumb
currentPageLabel={title}
homeLinkProps={{
href: "/",
}}
segments={segments}
className={fr.cx("fr-mb-2v")}
/>
<div>
{children}
<div className={fr.cx("fr-col-12", "fr-col-md-7", "fr-my-12v")}>
<Feedback />
</div>
</div>
<div className={fr.cx("fr-col-12", "fr-col-md-8")}>
<RelatedItems relatedItems={relatedItems} />
</div>
<div className={fr.cx("fr-col-12", "fr-col-md-4", "fr-mb-12v")}>
<Share title={title} metaDescription={description} />
</div>
</div>
);
};
22 changes: 22 additions & 0 deletions packages/code-du-travail-frontend/src/modules/outils/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
} from "../../api/utils";
import { Tool } from "@socialgouv/cdtn-types";
import { SOURCES } from "@socialgouv/cdtn-utils";
import { DocumentElasticResult, fetchDocument } from "../documents";
import { ElasticTool } from "./type";

export const fetchAllTools = async <K extends keyof Tool>(
fields: K[]
Expand Down Expand Up @@ -53,3 +55,23 @@ export const fetchAllTools = async <K extends keyof Tool>(
.map(({ _source }) => _source)
.filter((source) => source !== undefined);
};

export const fetchTool = async (
slug: string
): Promise<DocumentElasticResult<ElasticTool> | undefined> => {
return await fetchDocument<
ElasticTool,
keyof DocumentElasticResult<ElasticTool>
>(["description", "title"], {
query: {
bool: {
filter: [
{ term: { source: SOURCES.TOOLS } },
{ term: { slug } },
{ term: { isPublished: true } },
],
},
},
size: 1,
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
"use client";
import { Highlight } from "@codegouvfr/react-dsfr/Highlight";
import { fr } from "@codegouvfr/react-dsfr";
import { useEffect, createRef, useState } from "react";
import { ContainerSimulator } from "../../layout/ContainerSimulator";
import { RelatedItem } from "../../documents";

type Props = {
relatedItems: {
items: RelatedItem[];
title: string;
}[];
};

export const HiringSimulator = ({ relatedItems }: Props) => {
const simRef = createRef<HTMLDivElement>();
const [state, setState] = useState({
error: "",
simulator: "loading",
});
const onError = (error) => {
setState({ error, simulator: "error" });
};

const onLoad = () => {
setState({ simulator: "success", error: "" });
if (
!simRef.current ||
!simRef.current.querySelector("#simulateurEmbauche")
) {
setState({ error: "empty child", simulator: "error" });
}
};
useEffect(() => {
const script = document.createElement("script");

script.src =
"https://mon-entreprise.urssaf.fr/simulateur-iframe-integration.js";
script.async = true;
script.dataset.couleur = "#2975D1";
script.id = "script-simulateur-embauche";
script.onload = onLoad;
script.onerror = onError;

if (simRef.current) {
simRef.current.appendChild(script);
}

return () => {
if (simRef.current) {
simRef.current.removeChild(script);
}
};
}, []);
const { simulator } = state;
return (
<ContainerSimulator
relatedItems={relatedItems}
title="Calculer le salaire brut/net"
description="description"
Viczei marked this conversation as resolved.
Show resolved Hide resolved
segments={[{ label: "Simulateurs", linkProps: { href: "/outils" } }]}
>
<h1 id="simulateur-embauche">Calculer le salaire brut/net</h1>
<Highlight size="lg" className={fr.cx("fr-mb-12v")}>
Pour information, l&apos;estimation du salaire net après impôt est basée
sur la situation d&apos;une personne célibataire sans enfants ni
patrimoine.
</Highlight>
{simulator === "loading" && <p>Chargement de l’outil</p>}
{simulator === "error" ? (
<p>
Le simulateur d’embauche n’est pas disponible actuellement.
<br />
Retrouvez les autres simulateurs autour du thème de l’entreprise, sur
le site:{" "}
<a
title="Voir les simulateurs"
href="https://mon-entreprise.urssaf.fr/"
>
https://mon-entreprise.urssaf.fr/
</a>
</p>
) : (
<div ref={simRef} className={fr.cx("fr-col-12")} />
)}
</ContainerSimulator>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./HiringSimulator";
3 changes: 3 additions & 0 deletions packages/code-du-travail-frontend/src/modules/outils/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { DocumentElasticWithSource, Tool } from "@socialgouv/cdtn-types";

export type ElasticTool = DocumentElasticWithSource<Tool>;
80 changes: 0 additions & 80 deletions packages/code-du-travail-frontend/src/outils/SimulateurEmbauche.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/code-du-travail-frontend/src/outils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export * from "./DureePreavisLicenciement";
export * from "./IndemniteLicenciement";
export * from "./HeuresRechercheEmploi";
export * from "./IndemnitePrecarite";
export * from "./SimulateurEmbauche";
export * from "./DismissalProcess";
export * from "./RuptureCoventionnelle";
export * from "./api";
Expand Down
Loading