-
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.
feat(dsfr): migration de la page modèle de document
- Loading branch information
1 parent
1f64d85
commit bb57eeb
Showing
20 changed files
with
459 additions
and
293 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
packages/code-du-travail-frontend/app/modeles-de-courriers/[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,49 @@ | ||
import React from "react"; | ||
import { DsfrLayout } from "../../../src/modules/layout"; | ||
import { generateDefaultMetadata } from "../../../src/modules/common/metas"; | ||
import { | ||
fetchModel, | ||
getTitle, | ||
LetterModel, | ||
} from "../../../src/modules/modeles-de-courriers"; | ||
import { notFound } from "next/navigation"; | ||
import { fetchRelatedItems } from "../../../src/modules/documents"; | ||
|
||
export async function generateMetadata({ params }) { | ||
const { title, type, metaDescription, meta_title } = await getModel( | ||
params.slug | ||
); | ||
const category = `Modèle ${type !== "fichier" ? `de ${type}` : "à télécharger"}`; | ||
|
||
return generateDefaultMetadata({ | ||
title: `${category} : ${meta_title ?? title}`, | ||
description: metaDescription, | ||
path: `/modeles-de-courriers/${params.slug}`, | ||
}); | ||
} | ||
|
||
async function ModeleCourrier({ params }) { | ||
const { title, ...model } = await getModel(params.slug); | ||
|
||
const relatedItems = await fetchRelatedItems({ _id: model._id }, params.slug); | ||
|
||
return ( | ||
<DsfrLayout> | ||
<LetterModel | ||
title={getTitle(params.slug, title)} | ||
{...model} | ||
relatedItems={relatedItems} | ||
/> | ||
</DsfrLayout> | ||
); | ||
} | ||
|
||
const getModel = async (slug: string) => { | ||
const model = await fetchModel(slug); | ||
|
||
if (!model) { | ||
return notFound(); | ||
} | ||
return model; | ||
}; | ||
export default ModeleCourrier; |
28 changes: 28 additions & 0 deletions
28
packages/code-du-travail-frontend/app/widgets/modeles-de-courriers/[id]/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,28 @@ | ||
import { | ||
fetchModelById, | ||
getTitle, | ||
} from "../../../../src/modules/modeles-de-courriers"; | ||
import { notFound } from "next/navigation"; | ||
import { LetterModelContent } from "../../../../src/modules/modeles-de-courriers/components/LetterModelContent"; | ||
import { WidgetWithIframeResizer } from "../../../../src/modules/widgets/WidgetWithIframeResizer"; // import { useIframeResizer } from "../../../../src/common/hooks"; | ||
|
||
async function WidgetModel({ params }) { | ||
const { title, ...model } = await getModel(params.id); | ||
|
||
return ( | ||
<WidgetWithIframeResizer> | ||
<LetterModelContent title={getTitle(params.slug, title)} {...model} /> | ||
</WidgetWithIframeResizer> | ||
); | ||
} | ||
|
||
export const getModel = async (id: string) => { | ||
const modele = await fetchModelById(id); | ||
|
||
if (!modele) { | ||
return notFound(); | ||
} | ||
return modele; | ||
}; | ||
|
||
export default WidgetModel; |
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
64 changes: 0 additions & 64 deletions
64
packages/code-du-travail-frontend/pages/modeles-de-courriers/[slug].tsx
This file was deleted.
Oops, something went wrong.
82 changes: 0 additions & 82 deletions
82
packages/code-du-travail-frontend/pages/widgets/modeles-de-courriers/[id].tsx
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...-du-travail-frontend/public/static/assets/img/modeles-de-courriers-download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
129 changes: 0 additions & 129 deletions
129
packages/code-du-travail-frontend/src/modeles/modeles.tsx
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.