Skip to content

Commit 9377021

Browse files
committed
fix(seo): retrait des h1 dupliqués
1 parent b3788f8 commit 9377021

File tree

17 files changed

+282
-423
lines changed

17 files changed

+282
-423
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { DsfrLayout } from "../../src/modules/layout";
2+
import { generateDefaultMetadata } from "../../src/modules/common/metas";
3+
import { BesoinPlusInformations } from "../../src/modules/besoin-plus-informations";
4+
5+
export const metadata = generateDefaultMetadata({
6+
title: "Besoin de plus d'informations",
7+
description:
8+
"Les services du ministère du Travail en région informent, conseillent et orientent les salariés et les employeurs du secteur privé sur leurs questions en droit du travail.",
9+
path: "/besoin-plus-informations",
10+
});
11+
12+
function Index() {
13+
return (
14+
<DsfrLayout>
15+
<BesoinPlusInformations />
16+
</DsfrLayout>
17+
);
18+
}
19+
20+
export default Index;

packages/code-du-travail-frontend/app/layout.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@ export default function RootLayout({
2424
}) {
2525
const headersData = headers();
2626
const nonce = headersData.get("x-nonce") ?? undefined;
27-
const pathname = headersData.get("x-url") ?? "";
2827

2928
return (
30-
<DefaultLayout
31-
nonce={nonce}
32-
defaultColorScheme={pathname.includes("/widgets") ? "light" : "system"}
33-
>
29+
<DefaultLayout nonce={nonce} defaultColorScheme={"light"}>
3430
{children}
3531
</DefaultLayout>
3632
);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
describe("Page Besoin de plus d'information", () => {
2+
it("Permet de rechercher le lien vers un service de renseignement", () => {
3+
cy.visit("/besoin-plus-informations");
4+
cy.findByRole("heading", { level: 1 })
5+
.should("have.text", "Besoin de plus d'informations")
6+
.click();
7+
8+
cy.contains("label", "Saisissez le numéro de votre département").as(
9+
"input-departement"
10+
);
11+
cy.get("@input-departement").type("75");
12+
cy.get("@input-departement").type("{enter}");
13+
14+
cy.get(
15+
'a[href="https://idf.drieets.gouv.fr/Adresse-et-horaires-d-ouverture-de-l-unite-departementale-75"]'
16+
).should("have.attr", "target", "_blank");
17+
});
18+
});

packages/code-du-travail-frontend/cypress/integration/light/home.spec.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,28 +92,4 @@ describe("Page d’accueil", () => {
9292
cy.get("button").contains("Plus de résultats").click();
9393
cy.get('div[role="region"]>ul li').should("have.length", 14);
9494
});
95-
96-
it("Affiche la popup de recherche Besoin de plus d'information", () => {
97-
cy.visit("/");
98-
cy.findByRole("heading", { level: 1 })
99-
.should("have.text", "Bienvenue sur le Code du travail numérique")
100-
.click();
101-
102-
cy.contains("Besoin de plus d'informations ?");
103-
104-
cy.contains("Trouver les services près de chez moi").click();
105-
cy.get("h1").should("contain", "Les services du ministère du Travail");
106-
107-
cy.get("#search-service").type("75");
108-
cy.get("#search-service").type("{enter}");
109-
110-
cy.get(
111-
'a[href="https://idf.drieets.gouv.fr/Adresse-et-horaires-d-ouverture-de-l-unite-departementale-75"]'
112-
).should("have.attr", "target", "_blank");
113-
114-
cy.get(".fr-btn--close.fr-btn[title='Fermer']").click({
115-
multiple: true,
116-
force: true,
117-
});
118-
});
11995
});

packages/code-du-travail-frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"clean:redirects": "yarn tsup && node dist/clean-redirects.js"
3636
},
3737
"dependencies": {
38-
"@codegouvfr/react-dsfr": "^1.13.9",
38+
"@codegouvfr/react-dsfr": "^1.16.0",
3939
"@elastic/elasticsearch": "^8.13.1",
4040
"@matejmazur/react-katex": "^3.1.3",
4141
"@opentelemetry/instrumentation-generic-pool": "^0.37.0",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import data from "./services-de-renseignement.json";
2+
3+
export type ServiceRenseignements = {
4+
[key: string]: ServiceRenseignement;
5+
};
6+
7+
export type ServiceRenseignement = {
8+
name: string;
9+
url: string;
10+
};
11+
12+
export const services: ServiceRenseignements = data;
13+
14+
export const serviceByDepartment = (
15+
code: string
16+
): ServiceRenseignement | undefined => {
17+
return services[code];
18+
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { render } from "@testing-library/react";
2+
import React from "react";
3+
import { BesoinPlusInformations } from "..";
4+
import { UserAction } from "../../../common";
5+
import { serviceByDepartment } from "../../../data/servicesDeRenseignement";
6+
7+
jest.mock("../../../data/servicesDeRenseignement");
8+
9+
describe("<BesoinPlusInformations />", () => {
10+
beforeAll(() => {
11+
(serviceByDepartment as jest.Mock).mockImplementation((data: string) => {
12+
if (data === "75") {
13+
return {
14+
name: "PARIS",
15+
url: "https://idf.drieets.gouv.fr/Adresse-et-horaires-d-ouverture-de-l-unite-departementale-75",
16+
};
17+
}
18+
return undefined;
19+
});
20+
});
21+
22+
it("doit trouver la DREETs à partir de son code postal", () => {
23+
const { getByTestId, getByLabelText } = render(<BesoinPlusInformations />);
24+
const userAction = new UserAction();
25+
userAction.setInput(
26+
getByLabelText("Saisissez le numéro de votre département"),
27+
"75"
28+
);
29+
userAction.click(getByTestId("button-search-service"));
30+
31+
expect(getByTestId("result-search-service").textContent).toBe(
32+
"https://idf.drieets.gouv.fr/Adresse-et-horaires-d-ouverture-de-l-unite-departementale-75"
33+
);
34+
});
35+
36+
it("doit trouver indiquer si le code postal n'existe pas", () => {
37+
const { getByTestId, getByLabelText } = render(<BesoinPlusInformations />);
38+
const userAction = new UserAction();
39+
userAction.setInput(
40+
getByLabelText("Saisissez le numéro de votre département"),
41+
"999"
42+
);
43+
userAction.click(getByTestId("button-search-service"));
44+
45+
expect(getByTestId("result-search-service-failed").textContent).toBe(
46+
"Aucun service de renseignement n'a été trouvé pour ce département."
47+
);
48+
});
49+
});
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
"use client";
2+
3+
import { fr } from "@codegouvfr/react-dsfr";
4+
import { Container } from "../layout/Container";
5+
import { useState } from "react";
6+
import { useNeedMoreInfoEvents } from "../layout/infos/tracking";
7+
import Image from "next/image";
8+
import { Input } from "@codegouvfr/react-dsfr/Input";
9+
import { Button } from "@codegouvfr/react-dsfr/Button";
10+
import { css } from "@styled-system/css";
11+
import { Alert } from "@codegouvfr/react-dsfr/Alert";
12+
import {
13+
serviceByDepartment,
14+
ServiceRenseignement,
15+
} from "../../data/servicesDeRenseignement";
16+
17+
export const BesoinPlusInformations = () => {
18+
const [department, setDepartment] = useState<string>("");
19+
const [hasSearched, setHasSearched] = useState<boolean>(false);
20+
const [result, setResult] = useState<undefined | ServiceRenseignement>(
21+
undefined
22+
);
23+
const { emitTrackNumber } = useNeedMoreInfoEvents();
24+
25+
const onSearchInput = () => {
26+
const departmentNum = (department.replace(/^0+/, "") || "").toLowerCase();
27+
const departmentData = serviceByDepartment(departmentNum);
28+
setResult(departmentData);
29+
setHasSearched(true);
30+
};
31+
32+
const onClickLinkPhoneNumber = () => {
33+
emitTrackNumber();
34+
};
35+
36+
return (
37+
<Container>
38+
<h1 id="mentions-legales" className={fr.cx("fr-mt-0")}>
39+
Besoin de plus d&apos;informations
40+
</h1>
41+
42+
<p className={fr.cx("fr-mt-6w", "fr-mb-6w", "fr-text--lg")}>
43+
Les services du ministère du Travail en région informent, conseillent et
44+
orientent les salariés et les employeurs du secteur privé sur leurs
45+
questions en droit du travail.
46+
</p>
47+
48+
<section className={fr.cx("fr-mb-6w")}>
49+
<h2 className={fr.cx("fr-h5", "fr-mb-2w")}>Contact téléphonique</h2>
50+
51+
<a href="tel:+33806000126" onClick={onClickLinkPhoneNumber}>
52+
<Image
53+
src="/static/assets/img/srdt.svg"
54+
alt="Contactez les services de renseignements au droit du travail au 0800 026 080"
55+
width={350}
56+
height={100}
57+
/>
58+
</a>
59+
</section>
60+
<section className={fr.cx("fr-mb-6w")}>
61+
<h2 className={fr.cx("fr-h5", "fr-mb-2w")}>
62+
Contact par email et prise de rendez-vous
63+
</h2>
64+
<Input
65+
id="search-service"
66+
label="Saisissez le numéro de votre département"
67+
nativeInputProps={{
68+
maxLength: 3,
69+
onChange: (e) => setDepartment(e.target.value),
70+
onKeyDown: (e) => {
71+
if (e.key === "Enter") {
72+
onSearchInput();
73+
}
74+
},
75+
}}
76+
addon={
77+
<Button
78+
iconId="fr-icon-search-line"
79+
data-testid="button-search-service"
80+
onClick={onSearchInput}
81+
title="Lancer la recherche par numéro de département"
82+
/>
83+
}
84+
classes={{
85+
nativeInputOrTextArea: inputCss,
86+
}}
87+
/>
88+
{result && (
89+
<a
90+
className={fr.cx("fr-link")}
91+
href={result.url}
92+
target="_blank"
93+
data-testid="result-search-service"
94+
>
95+
{result.url}
96+
</a>
97+
)}
98+
{hasSearched && !result && (
99+
<p
100+
className={fr.cx("fr-error-text", "fr-text--md")}
101+
data-testid="result-search-service-failed"
102+
>
103+
Aucun service de renseignement n&apos;a été trouvé pour ce
104+
département.
105+
</p>
106+
)}
107+
</section>
108+
<Alert
109+
severity={"info"}
110+
small
111+
description={
112+
<>
113+
<p className={fr.cx("fr-mb-2w", "fr-text--lg")}>
114+
Attention, ces services délivrent une information juridique, ils
115+
ne sont pas compétents pour :
116+
</p>
117+
<ul>
118+
<li className={fr.cx("fr-mb-0", "fr-text--lg")}>
119+
les demandes d&apos;intervention en entreprise
120+
</li>
121+
<li className={fr.cx("fr-mb-0", "fr-text--lg")}>
122+
la constitution des dossiers prud’homaux
123+
</li>
124+
<li className={fr.cx("fr-mb-0", "fr-text--lg")}>
125+
les calculs de droit au chômage
126+
</li>
127+
<li className={fr.cx("fr-mb-0", "fr-text--lg")}>
128+
vous renseigner sur les cotisations sociales
129+
</li>
130+
</ul>
131+
</>
132+
}
133+
></Alert>
134+
</Container>
135+
);
136+
};
137+
138+
const inputCss = css({
139+
maxWidth: "280px",
140+
});

packages/code-du-travail-frontend/src/modules/layout/Footer.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Footer as FooterDsfr } from "@codegouvfr/react-dsfr/Footer";
22
import { PACKAGE_VERSION } from "../../config";
3-
import { headerFooterDisplayItem } from "@codegouvfr/react-dsfr/Display";
43
import { BrandTop } from "./BrandTop";
54
import { homeLinksProps } from "./common";
65

@@ -173,7 +172,6 @@ export const Footer = () => {
173172
},
174173
text: "Plan du site",
175174
},
176-
headerFooterDisplayItem,
177175
]}
178176
/>
179177
);

packages/code-du-travail-frontend/src/modules/layout/__tests__/__snapshots__/Footer.test.tsx.snap

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -368,18 +368,6 @@ exports[`<Footer /> should match snapshot 1`] = `
368368
Plan du site
369369
</a>
370370
</li>
371-
<li
372-
class="fr-footer__bottom-item"
373-
>
374-
<button
375-
aria-controls="fr-theme-modal"
376-
class="fr-footer__bottom-link fr-icon-theme-fill fr-link--icon-left"
377-
data-fr-opened="false"
378-
id="fr-theme-modal-control-button"
379-
>
380-
Paramètres d'affichage
381-
</button>
382-
</li>
383371
</ul>
384372
<div
385373
class="fr-footer__bottom-copy"

0 commit comments

Comments
 (0)