From 70efcfeaa0603415dd992cb662d8efb960e6e49a Mon Sep 17 00:00:00 2001
From: Armand Philippot
Date: Tue, 26 Sep 2023 15:54:28 +0200
Subject: refactor(routes): replace hardcoded routes with constants
It makes it easier to change a route if needed and it avoid typo
mistakes.
I also refactored a bit the concerned files to be complient with the
new ESlint config. However, I should rewrite the pages to reduce
the number of statements.
---
src/pages/404.tsx | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
(limited to 'src/pages/404.tsx')
diff --git a/src/pages/404.tsx b/src/pages/404.tsx
index 67daae1..af95a36 100644
--- a/src/pages/404.tsx
+++ b/src/pages/404.tsx
@@ -1,6 +1,6 @@
-import { GetStaticProps } from 'next';
+import type { GetStaticProps } from 'next';
import Head from 'next/head';
-import { ReactNode } from 'react';
+import type { ReactNode } from 'react';
import { useIntl } from 'react-intl';
import {
getLayout,
@@ -15,11 +15,12 @@ import {
getTotalThematics,
getTotalTopics,
} from '../services/graphql';
-import {
- type NextPageWithLayout,
- type RawThematicPreview,
- type RawTopicPreview,
+import type {
+ NextPageWithLayout,
+ RawThematicPreview,
+ RawTopicPreview,
} from '../types';
+import { ROUTES } from '../utils/constants';
import { getLinksListItems, getPageLinkFromRawData } from '../utils/helpers';
import { loadTranslation, type Messages } from '../utils/helpers/server';
import { useBreadcrumb, useSettings } from '../utils/hooks';
@@ -52,12 +53,12 @@ const Error404Page: NextPageWithLayout = ({
description: 'Error404Page: page body',
},
{
- link: (chunks: ReactNode) => {chunks},
+ link: (chunks: ReactNode) => {chunks},
}
);
const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({
title,
- url: `/404`,
+ url: ROUTES.NOT_FOUND,
});
const pageTitle = intl.formatMessage(
{
@@ -88,6 +89,7 @@ const Error404Page: NextPageWithLayout = ({
<>
{pageTitle}
+ {/*eslint-disable-next-line react/jsx-no-literals -- Name allowed */}
= ({
breadcrumbSchema={breadcrumbSchema}
widgets={[
@@ -106,6 +109,7 @@ const Error404Page: NextPageWithLayout = ({
level={2}
/>,
getPageLinkFromRawData(topic, 'topic'))
@@ -123,7 +127,7 @@ const Error404Page: NextPageWithLayout = ({
id: 'XKy7rx',
})}
-
+
>
);
--
cgit v1.2.3