Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
desoindx committed Nov 22, 2024
2 parents ff9f631 + f0e29d8 commit 00ff7a2
Show file tree
Hide file tree
Showing 142 changed files with 1,294 additions and 1,909 deletions.
8 changes: 2 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,11 @@
}
]
},
"plugins": [
"@typescript-eslint",
"prettier",
"jest"
],
"plugins": ["@typescript-eslint", "prettier", "jest"],
"env": {
"browser": true,
"es2022": true,
"node": true,
"jest/globals": true
}
}
}
14 changes: 3 additions & 11 deletions .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,7 @@
"bracketSameLine": true,
"arrowParens": "always",
"endOfLine": "lf",
"importOrder": [
"data/(.*)$",
"utils/(.*)$",
"hooks/(.*)$",
"components/(.*)$",
"^[./]"
],
"plugins": [
"@trivago/prettier-plugin-sort-imports"
],
"importOrder": ["data/(.*)$", "utils/(.*)$", "hooks/(.*)$", "components/(.*)$", "^[./]"],
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"importOrderSortSpecifiers": true
}
}
5 changes: 3 additions & 2 deletions app/(iframes)/iframes/[tool]/[equivalent]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ export async function generateStaticParams() {
}

type Props = {
params: { tool: string; equivalent: string }
params: Promise<{ tool: string; equivalent: string }>
}

const page = ({ params }: Props) => {
const page = async (props: Props) => {
const params = await props.params
const category = categories.find((category) => category.slug === params.tool)
if (!category || !category.equivalents) {
return notFound()
Expand Down
5 changes: 3 additions & 2 deletions app/(iframes)/iframes/[tool]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import Category from 'components/outils/Category'
import { simulators } from 'components/outils/simulators'
import { getCategory } from 'utils/category'

type Props = { params: { tool: string } }
type Props = { params: Promise<{ tool: string }> }

export async function generateStaticParams() {
return categories.map((category) => ({ tool: category.slug }))
}

const page = ({ params }: Props) => {
const page = async (props: Props) => {
const params = await props.params
const category = getCategory(params.tool)
if (category) {
return <Category category={category} simulator={simulators[params.tool]} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Metadata } from 'next'
import React from 'react'
import Notion from 'components/Notion/Notion'
import { getNotionContentProps, getNotionRevalidate } from 'components/Notion/utils'
import { getNotionContentProps } from 'components/Notion/utils'
import Suggestion from 'components/layout/Suggestion'

export const revalidate = getNotionRevalidate()
export const revalidate = 900

const title = 'Comment sensibiliser vos visiteurs à l’empreinte carbone ?'

Expand Down
4 changes: 2 additions & 2 deletions app/(public)/contenu/detecteur-co2/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Metadata } from 'next'
import React from 'react'
import DetecteurPage from 'src/views/DetecteurPage'
import Notion from 'components/Notion/Notion'
import { getNotionContentProps, getNotionRevalidate } from 'components/Notion/utils'
import { getNotionContentProps } from 'components/Notion/utils'
import Suggestion from 'components/layout/Suggestion'

export const revalidate = getNotionRevalidate()
export const revalidate = 900

const title = 'Le Détecteur CO₂'

Expand Down
4 changes: 2 additions & 2 deletions app/(public)/contenu/etiquette-carbone/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Metadata } from 'next'
import React from 'react'
import Notion from 'components/Notion/Notion'
import { getNotionContentProps, getNotionRevalidate } from 'components/Notion/utils'
import { getNotionContentProps } from 'components/Notion/utils'
import Suggestion from 'components/layout/Suggestion'

export const revalidate = getNotionRevalidate()
export const revalidate = 900

const title = 'L’étiquette carbone : présentation et tutoriel d’intégration'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Metadata } from 'next'
import React from 'react'
import Notion from 'components/Notion/Notion'
import { getNotionContentProps, getNotionRevalidate } from 'components/Notion/utils'
import { getNotionContentProps } from 'components/Notion/utils'
import Suggestion from 'components/layout/Suggestion'

const title = '4 conseils pour réduire l’impact carbone des séjours au ski'
Expand All @@ -15,7 +15,7 @@ export const metadata: Metadata = {
},
}

export const revalidate = getNotionRevalidate()
export const revalidate = 900

const SkiPage = async () => {
const recordMap = await getNotionContentProps('519fba8721a445e3b9cb10a6fa4d5208')
Expand Down
4 changes: 2 additions & 2 deletions app/(public)/contenu/nouveau-site/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Metadata } from 'next'
import React from 'react'
import Notion from 'components/Notion/Notion'
import { getNotionContentProps, getNotionRevalidate } from 'components/Notion/utils'
import { getNotionContentProps } from 'components/Notion/utils'
import Suggestion from 'components/layout/Suggestion'

export const revalidate = getNotionRevalidate()
export const revalidate = 900

const title = 'Le nouveau site “Impact CO2” est en ligne !'

Expand Down
4 changes: 2 additions & 2 deletions app/(public)/contenu/quiz-carbone/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Metadata } from 'next'
import React from 'react'
import Notion from 'components/Notion/Notion'
import { getNotionContentProps, getNotionRevalidate } from 'components/Notion/utils'
import { getNotionContentProps } from 'components/Notion/utils'
import Suggestion from 'components/layout/Suggestion'

export const revalidate = getNotionRevalidate()
export const revalidate = 900

const title = 'Quiz carbone : le nouveau jeu de cartes de l’ADEME est en ligne !'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Metadata } from 'next'
import React from 'react'
import Notion from 'components/Notion/Notion'
import { getNotionContentProps, getNotionRevalidate } from 'components/Notion/utils'
import { getNotionContentProps } from 'components/Notion/utils'
import Suggestion from 'components/layout/Suggestion'

export const revalidate = getNotionRevalidate()
export const revalidate = 900

const title = 'Semaine européenne de la mobilité : découverte du calculateur Impact Transport de l’ADEME'

Expand Down
3 changes: 1 addition & 2 deletions app/(public)/doc/exemples/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { Metadata } from 'next'
import React from 'react'
import ExamplesPage from 'src/views/ExamplesPage'
import { getCommunications, getExamples } from 'utils/examples'
import { getRevalidate } from 'utils/revalidate'
import Suggestion from 'components/layout/Suggestion'

export const revalidate = getRevalidate(process.env.NOTION_TABLE_REVALIDATE)
export const revalidate = 900

export const metadata: Metadata = {
title: "Exemples d'utilisation | Impact CO₂",
Expand Down
3 changes: 1 addition & 2 deletions app/(public)/doc/guide-utilisation/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Metadata } from 'next'
import React from 'react'
import { getGuideUtilisation } from 'utils/guideUtilisation'
import { getNotionRevalidate } from 'components/Notion/utils'
import GuideUtilisation from 'components/faq/GuideUtilisation'
import Suggestion from 'components/layout/Suggestion'

const title = "Guide d'utilisation"

export const revalidate = getNotionRevalidate()
export const revalidate = 900

export const metadata: Metadata = {
title: `${title} | Impact CO₂`,
Expand Down
6 changes: 5 additions & 1 deletion app/(public)/doc/livraison/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export const metadata: Metadata = {
},
}

export default function Documentation({ params: { slug } }: { params: { slug: string[] } }) {
export default async function Documentation(props: { params: Promise<{ slug: string[] }> }) {
const params = await props.params

const { slug } = params

return <DocumentationLivraisonSlugPage slug={slug.join('/')} />
}
3 changes: 1 addition & 2 deletions app/(public)/doc/questions-frequentes/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { Metadata } from 'next'
import React from 'react'
import FAQPage from 'src/views/FAQPage'
import { getFAQs } from 'utils/faq'
import { getRevalidate } from 'utils/revalidate'
import Suggestion from 'components/layout/Suggestion'

export const revalidate = getRevalidate(process.env.NOTION_TABLE_REVALIDATE)
export const revalidate = 900

export const metadata: Metadata = {
title: 'Questions fréquentes | Impact CO₂',
Expand Down
6 changes: 5 additions & 1 deletion app/(public)/doc/usage-numerique/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export const metadata: Metadata = {
},
}

export default function Documentation({ params: { slug } }: { params: { slug: string[] } }) {
export default async function Documentation(props: { params: Promise<{ slug: string[] }> }) {
const params = await props.params

const { slug } = params

return <DocumentationUsageNumeriqueSlugPage slug={slug.join('/')} />
}
11 changes: 7 additions & 4 deletions app/(public)/outils/[tool]/[equivalent]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ export async function generateStaticParams() {
}

type Props = {
params: { tool: string; equivalent: string }
searchParams: { [key: string]: string | string[] | undefined }
params: Promise<{ tool: string; equivalent: string }>
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
}

export async function generateMetadata({ params, searchParams }: Props, parent: ResolvingMetadata): Promise<Metadata> {
export async function generateMetadata(props: Props, parent: ResolvingMetadata): Promise<Metadata> {
const searchParams = await props.searchParams
const params = await props.params
const category = categories.find((category) => category.slug === params.tool)

if (!category || !category.equivalents) {
Expand Down Expand Up @@ -68,7 +70,8 @@ export async function generateMetadata({ params, searchParams }: Props, parent:
}
}

const EquivalentPage = ({ params }: Props) => {
const EquivalentPage = async (props: Props) => {
const params = await props.params
const category = categories.find((category) => category.slug === params.tool)
if (!category || !category.equivalents) {
return notFound()
Expand Down
12 changes: 9 additions & 3 deletions app/(public)/outils/[tool]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ export async function generateStaticParams() {
]
}

type Props = { params: { tool: string }; searchParams: { [key: string]: string | string[] | undefined } }
type Props = {
params: Promise<{ tool: string }>
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
}

export async function generateMetadata({ params, searchParams }: Props, parent: ResolvingMetadata): Promise<Metadata> {
export async function generateMetadata(props: Props, parent: ResolvingMetadata): Promise<Metadata> {
const searchParams = await props.searchParams
const params = await props.params
const tool = tools.find((tool) => tool.slug === params.tool)
if (tool) {
return {
Expand Down Expand Up @@ -52,7 +57,8 @@ export async function generateMetadata({ params, searchParams }: Props, parent:
return parent as Metadata
}

const OutilPage = ({ params }: Props) => {
const OutilPage = async (props: Props) => {
const params = await props.params
const tool = tools.find((tool) => tool.slug === params.tool)

if (tool) {
Expand Down
7 changes: 3 additions & 4 deletions app/(public)/outils/comparateur/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import ComparateurPage from 'components/outils/comparateur/ComparateurPage'
import { metaDescriptions, metaTitles } from 'utils/meta'
import Suggestion from 'components/layout/Suggestion'

export async function generateMetadata({
searchParams,
}: {
searchParams: { [key: string]: string | string[] | undefined }
export async function generateMetadata(props: {
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
}): Promise<Metadata> {
const searchParams = await props.searchParams
const language = (searchParams.language as string) || 'fr'
return {
title: `${metaTitles.comparateur[language]} | Impact CO₂`,
Expand Down
7 changes: 3 additions & 4 deletions app/(public)/outils/habillement/osez-changer/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { Metadata } from 'next'
import { redirect } from 'next/navigation'
import { metaDescriptions, metaTitles } from 'utils/meta'

export async function generateMetadata({
searchParams,
}: {
searchParams: { [key: string]: string | string[] | undefined }
export async function generateMetadata(props: {
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
}): Promise<Metadata> {
const searchParams = await props.searchParams
const language = (searchParams.language as string) || 'fr'
return {
title: `${metaTitles['osez-changer'][language]} | Impact CO₂`,
Expand Down
7 changes: 3 additions & 4 deletions app/(public)/outils/quiz/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import QuizPage from 'components/outils/quiz/QuizPage'
import { metaDescriptions, metaTitles } from 'utils/meta'
import Suggestion from 'components/layout/Suggestion'

export async function generateMetadata({
searchParams,
}: {
searchParams: { [key: string]: string | string[] | undefined }
export async function generateMetadata(props: {
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
}): Promise<Metadata> {
const searchParams = await props.searchParams
const language = (searchParams.language as string) || 'fr'
return {
title: `${metaTitles.quiz[language]} | Impact CO₂`,
Expand Down
7 changes: 3 additions & 4 deletions app/(public)/outils/transport/itineraire/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import Suggestion from 'components/layout/Suggestion'

const category = categories.find((category) => category.slug === 'transport') as CategoryType

export async function generateMetadata({
searchParams,
}: {
searchParams: { [key: string]: string | string[] | undefined }
export async function generateMetadata(props: {
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
}): Promise<Metadata> {
const searchParams = await props.searchParams
const language = (searchParams.language as string) || 'fr'
return {
title: `${metaTitles.transport[language]} | Impact CO₂`,
Expand Down
3 changes: 1 addition & 2 deletions app/(public)/stats/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Metadata } from 'next'
import React from 'react'
import StatisticsPage from 'src/views/StatisticsPage'
import { getRevalidate } from 'utils/revalidate'
import { getMatomoStats } from 'utils/stats'
import Suggestion from 'components/layout/Suggestion'

export const metadata: Metadata = {
title: 'Statistiques | Impact CO₂',
}

export const revalidate = getRevalidate(process.env.STATS_REVALIDATE)
export const revalidate = 900

export default async function StatistiquesPage() {
const stats = await getMatomoStats()
Expand Down
4 changes: 2 additions & 2 deletions app/api/dynamics/equivalents/[slug]/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const getFont = async (url: URL) => {

let fonts: { name: string; data: ArrayBuffer; style: FontStyle; weight: FontWeight }[] = []

export async function GET(req: NextRequest, context: { params: { slug: string } }) {
export async function GET(req: NextRequest, context: { params: Promise<{ slug: string }> }) {
if (process.env.NO_IMAGE === 'true') {
return NextResponse.json(`Please use ${process.env.NEXT_PUBLIC_IMAGE_URL}`, { status: 400 })
}

const [slug, carpool] = decodeURIComponent(context.params.slug).split('+')
const [slug, carpool] = decodeURIComponent((await context.params).slug).split('+')
if (!slug) {
return NextResponse.json('No slug specified', { status: 400 })
}
Expand Down
4 changes: 2 additions & 2 deletions app/api/v1/thematiques/ecv/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ const categoryValidation = z.object({
* $ref: '#/components/schemas/ECV'
*/

export async function GET(req: NextRequest, context: { params: { id: string } }) {
export async function GET(req: NextRequest, context: { params: Promise<{ id: string }> }) {
const { searchParams } = new URL(req.url)
const inputs = categoryValidation.safeParse({
...context.params,
...(await context.params),
detail: searchParams.get('detail'),
language: searchParams.get('language') || 'fr',
})
Expand Down
3 changes: 2 additions & 1 deletion app/pdf/[tool]/[equivalent]/recto/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { categories } from 'data/categories'
import Recto from 'components/outils/equivalents/pdf/Recto'
import 'components/outils/equivalents/pdf/pdf.css'

const EquivalentPage = ({ params }: { params: { tool: string; equivalent: string } }) => {
const EquivalentPage = async (props: { params: Promise<{ tool: string; equivalent: string }> }) => {
const params = await props.params
const category = categories.find((category) => category.slug === params.tool)
if (!category || !category.equivalents) {
return notFound()
Expand Down
Loading

0 comments on commit 00ff7a2

Please sign in to comment.