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 11, 2024
1 parent f146a58 commit 39009c2
Show file tree
Hide file tree
Showing 40 changed files with 818 additions and 655 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,12 @@
describe("Plan du site", () => {
it("je vois le plan du site", () => {
cy.visit("/");
cy.get("a").contains("Plan du site").click();
cy.contains("h1", "Plan du site");
cy.contains("a", "Page d'accueil");
cy.contains("a", "Boîte à outils");
cy.contains("a", "Vos fiches pratiques");
cy.contains("a", "Votre convention collective");
cy.contains("a", "Thèmes");
});
});
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 @@ -40,7 +40,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
11 changes: 4 additions & 7 deletions packages/code-du-travail-frontend/pages/integration/[slug].tsx
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 @@ -67,10 +67,7 @@ export const getServerSideProps = async ({ query, req }) => {
};
}
const { isModele } = integrationData[slug];
let selectOptions;
if (isModele) {
selectOptions = await getModelesList();
}
const selectOptions = isModele ? await getModelesList() : null;

const hostname: string = req.headers.host;
const [protocol] = req.headers["x-forwarded-proto"]
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
@@ -1,16 +1,7 @@
import { SOURCES } from "@socialgouv/cdtn-utils";

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

0 comments on commit 39009c2

Please sign in to comment.