-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into 6295-modale-service-près-de-moi-formulaire-de…
…-recherche-non-accessible
- Loading branch information
Showing
101 changed files
with
16,532 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/code-du-travail-frontend/app/fiche-service-public/[slug]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from "react"; | ||
import { notFound } from "next/navigation"; | ||
import { DsfrLayout } from "../../../src/modules/layout"; | ||
import { fetchFicheSP } from "../../../src/modules/fiche-service-public/queries"; | ||
import { fetchRelatedItems } from "../../../src/modules/documents"; | ||
import { generateDefaultMetadata } from "../../../src/modules/common/metas"; | ||
import { getRouteBySource, SOURCES } from "@socialgouv/cdtn-utils"; | ||
import { FicheServicePublicContainer } from "../../../src/modules/fiche-service-public/FicheServicePublicContainer"; | ||
|
||
export async function generateMetadata({ params }) { | ||
const { title, description, url } = await getFiche(params.slug); | ||
|
||
return generateDefaultMetadata({ | ||
title: title, | ||
description: description, | ||
path: `/${getRouteBySource(SOURCES.SHEET_SP)}/${params.slug}`, | ||
overrideCanonical: url, | ||
}); | ||
} | ||
|
||
async function Fiche({ params }) { | ||
const { | ||
_id, | ||
breadcrumbs, | ||
date, | ||
description, | ||
raw, | ||
referencedTexts, | ||
title, | ||
url, | ||
} = await getFiche(params.slug); | ||
const relatedItems = await fetchRelatedItems({ _id }, params.slug); | ||
|
||
return ( | ||
<DsfrLayout> | ||
<FicheServicePublicContainer | ||
title={title} | ||
relatedItems={relatedItems} | ||
date={date} | ||
url={url} | ||
metaDescription={description} | ||
raw={raw} | ||
breadcrumbs={breadcrumbs} | ||
referencedTexts={referencedTexts} | ||
/> | ||
</DsfrLayout> | ||
); | ||
} | ||
|
||
const getFiche = async (slug: string) => { | ||
const fiche = await fetchFicheSP(slug); | ||
|
||
if (!fiche) { | ||
return notFound(); | ||
} | ||
return fiche; | ||
}; | ||
|
||
export default Fiche; |
29 changes: 29 additions & 0 deletions
29
packages/code-du-travail-frontend/cypress/integration/light/fiche-service-public.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
describe("Fiche Service public", () => { | ||
it("je vois une page fiche service public", () => { | ||
cy.visit("/fiche-service-public/salaire-primes-et-avantages"); | ||
cy.findAllByRole("heading", { level: 1 }).should( | ||
"have.text", | ||
"Salaire, primes et avantages" | ||
); | ||
cy.get("head > link[rel='canonical']") | ||
.should("have.prop", "href") | ||
.and( | ||
"equal", | ||
"https://www.service-public.fr/particuliers/vosdroits/F2301" | ||
); | ||
|
||
cy.contains("a", "Fiche service-public.fr") | ||
.should("have.attr", "href") | ||
.and( | ||
"contain", | ||
"https://www.service-public.fr/particuliers/vosdroits/F2301" | ||
); | ||
cy.get("body").should("contain", "01/11/2024"); | ||
cy.get("h2").first().should("contain", "Salaire"); | ||
}); | ||
|
||
it("je vois une fiche service public avec un accordéon ouvert", () => { | ||
cy.visit("/fiche-service-public/salaire-primes-et-avantages#salaire"); | ||
cy.get("h2").get('[aria-expanded="true"]').should("contain", "Salaire"); | ||
}); | ||
}); |
13 changes: 0 additions & 13 deletions
13
packages/code-du-travail-frontend/cypress/integration/light/landing-pages.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// / <reference types="next" /> | ||
// / <reference types="next/types/global" /> | ||
|
||
interface Dimensions { | ||
dimension1?: string; | ||
dimension2?: string; | ||
dimension3?: string; | ||
dimension4?: string; | ||
dimension5?: string; | ||
dimension6?: string; | ||
dimension7?: string; | ||
dimension8?: string; | ||
dimension9?: string; | ||
dimension10?: string; | ||
} | ||
|
||
interface Window { | ||
_paq?: | ||
| ( | ||
| Dimensions | ||
| number[] | ||
| string[] | ||
| number | ||
| string | ||
| null | ||
| undefined | ||
)[][] | ||
| null; | ||
} | ||
declare namespace NodeJS { | ||
interface Global { | ||
_paq?: | ||
| ( | ||
| Dimensions | ||
| number[] | ||
| string[] | ||
| number | ||
| string | ||
| null | ||
| undefined | ||
)[][] | ||
| null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 0 additions & 77 deletions
77
packages/code-du-travail-frontend/pages/fiche-service-public/[slug].tsx
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
packages/code-du-travail-frontend/src/modules/common/ReferencesList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from "react"; | ||
import { ServicePublicReference } from "@socialgouv/cdtn-types"; | ||
import { getRouteBySource, SOURCES } from "@socialgouv/cdtn-utils"; | ||
import { fr } from "@codegouvfr/react-dsfr"; | ||
|
||
export const ReferenceList = ({ | ||
references, | ||
}: { | ||
references: ServicePublicReference[]; | ||
}) => { | ||
const formattedRefs = references | ||
.map((ref) => { | ||
switch (ref.type) { | ||
case SOURCES.CDT: | ||
return ( | ||
<a | ||
key={ref.slug + ref.title} | ||
href={`/${getRouteBySource(SOURCES.CDT)}/${ref.slug}`} | ||
>{`Article ${ref.title} du Code du travail`}</a> | ||
); | ||
case SOURCES.CCN: | ||
return ( | ||
<a | ||
key={ref.slug + ref.title} | ||
href={`/${getRouteBySource(SOURCES.CCN)}/${ref.slug}`} | ||
>{`Convention collective: ${ref.title}`}</a> | ||
); | ||
case SOURCES.EXTERNALS: | ||
return ( | ||
<a | ||
key={ref.url + ref.title} | ||
href={ref.url} | ||
target="_blank" | ||
rel="noreferer noopener" | ||
>{`Convention collective: ${ref.title}`}</a> | ||
); | ||
} | ||
}) | ||
.filter((item) => item !== null); | ||
return ( | ||
<ul> | ||
{formattedRefs.map((item) => { | ||
return ( | ||
<li key={item.key}> | ||
<p className={fr.cx("fr-mb-0")}>{item}</p> | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
); | ||
}; |
Oops, something went wrong.