Skip to content

Commit

Permalink
feat(dsfr): migration de la page plan du site
Browse files Browse the repository at this point in the history
  • Loading branch information
m-maillot committed Sep 5, 2024
1 parent 4422345 commit 83418bb
Show file tree
Hide file tree
Showing 39 changed files with 517 additions and 646 deletions.
25 changes: 25 additions & 0 deletions packages/code-du-travail-frontend/app/plan-du-site/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Metadata } from "next";
import { DsfrLayout } from "../../src/modules/layout";
import { getSitemapData } from "../../src/api";
import { SiteMap } from "../../src/modules/plan-du-site";

export const metadata: Metadata = {
title: "Plan du site - Code du travail numérique",
description: "Plan du site du Code du travail numérique",
};

const getSiteMap = async () => {
return getSitemapData();
};

async function Index() {
const data = await getSiteMap();

return (
<DsfrLayout>
<SiteMap {...data} />
</DsfrLayout>
);
}

export default Index;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
describe("Plan du site", () => {
it("je vois le plan du site", () => {
cy.visit("/");
cy.get("a").contains("Plan du site").click();
cy.get("h1").should("have.text", "Plan du site");
cy.get("a").contains("Page d'accueil").should("have.href", "/");
cy.get("a").contains("Boîte à outils").should("have.href", "/tools");
cy.get("a")
.contains("Vos fiches pratiques")
.should("have.href", "/contributions");
cy.get("a")
.contains("Votre convention collective")
.should("have.href", "/convention-collective");
cy.get("a").contains("Thèmes").should("have.href", "/themes");
});
});
4 changes: 2 additions & 2 deletions packages/code-du-travail-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@sentry/nextjs": "^8.24.0",
"@socialgouv/cdtn-elasticsearch": "^2.44.2",
"@socialgouv/cdtn-logger": "^2.0.0",
"@socialgouv/cdtn-types": "^2.48.1",
"@socialgouv/cdtn-types": "^2.49.1",
"@socialgouv/cdtn-ui": "workspace:^",
"@socialgouv/cdtn-utils": "workspace:^",
"@socialgouv/fiches-travail-data": "^4.241.0",
Expand Down Expand Up @@ -114,7 +114,7 @@
"stylelint-processor-styled-components": "^1.10.0",
"supertest": "^6.3.3",
"testing-library-selector": "0.3.1",
"typescript": "^5.0.4",
"typescript": "^5.5.4",
"xml2js": "^0.6.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,15 @@ export default Page;

export async function getStaticProps() {
try {
let data = await getAllAgreements();
let data = await getAllAgreements([
"title",
"shortTitle",
"description",
"url",
"slug",
"source",
"num",
]);
return { props: { ccs: data }, revalidate: REVALIDATE_TIME };
} catch (error) {
console.error(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ const IntegrationPage = (props): JSX.Element => {
const keys = Object.keys(integrationData);

const getModelesList = async () => {
const modeles = await getAllModeles();
const modeles = await getAllModeles(["title", "cdtnId"]);
return modeles
.map((item) => {
return {
label: item?.title ?? "",
value: item?.cdtnId ?? "",
label: item.title,
value: item.cdtnId,
};
})
?.sort((a, b) => a.label.localeCompare(b.label));
Expand All @@ -70,6 +70,8 @@ export const getServerSideProps = async ({ query, req }) => {
let selectOptions;
if (isModele) {
selectOptions = await getModelesList();
} else {
selectOptions = null;
}

const hostname: string = req.headers.host;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,14 @@ function Modeles(props) {

export async function getStaticProps() {
try {
const data = await getAllModeles();
const data = await getAllModeles([
"title",
"slug",
"description",
"source",
"breadcrumbs",
"cdtnId",
]);
return { props: { data }, revalidate: REVALIDATE_TIME };
} catch (error) {
console.error(error);
Expand Down
220 changes: 0 additions & 220 deletions packages/code-du-travail-frontend/pages/plan-du-site.tsx

This file was deleted.

12 changes: 9 additions & 3 deletions packages/code-du-travail-frontend/pages/themes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Metas from "../../src/common/Metas";
import { REVALIDATE_TIME } from "../../src/config";
import { Layout } from "../../src/layout/Layout";
import { LinkedTile } from "../../src/common/tiles/LinkedTile";
import { getAllThemes } from "../../src/api";
import { getRootThemes } from "../../src/api";

const SubThemes = ({ children = [] }) => {
return (
Expand Down Expand Up @@ -73,8 +73,14 @@ const ThemesPage = ({ children = [] }) => (

export async function getStaticProps() {
try {
const data = await getAllThemes();
return { props: { children: data.children }, revalidate: REVALIDATE_TIME };
const data = await getRootThemes([
"icon",
"children",
"title",
"slug",
"position",
]);
return { props: { children: data }, revalidate: REVALIDATE_TIME };
} catch (error) {
console.error(error);
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import {

describe("Agreements", () => {
it("getAllAgreements", async () => {
const result = await getAllAgreements();
const result = await getAllAgreements(
["title", "shortTitle", "description", "url", "slug", "source", "num"],
"shortTitle"
);
expect(result).toMatchSnapshot();
});
it("getBySlugsAgreements", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ import { SOURCES } from "@socialgouv/cdtn-utils";

export const getAllAgreementsWithContributions = () => {
return {
_source: [
"title",
"shortTitle",
"description",
"url",
"slug",
"source",
"num",
],
query: {
bool: {
filter: [
Expand Down
Loading

0 comments on commit 83418bb

Please sign in to comment.