diff --git a/.talismanrc b/.talismanrc index 88e098e74..64dea90ae 100644 --- a/.talismanrc +++ b/.talismanrc @@ -117,6 +117,8 @@ fileignoreconfig: checksum: 437a1f461d7764c51f288128de18506f4c22078c109238a41e8883a813b7ac55 - filename: server/src/common/actions/effectifs.actions.ts checksum: 32225fd2335732e86cceb6b3bb90e5e4a93c976090cf9445c7243f555638fd86 +- filename: ui/pages/mentions-legales.tsx + checksum: a2f835244846eceb8330f07846c128d318de81c5e46741be536b554726b4372c scopeconfig: - scope: node custom_patterns: diff --git a/server/package.json b/server/package.json index 0fab6e17a..e63358320 100644 --- a/server/package.json +++ b/server/package.json @@ -74,7 +74,6 @@ "node-ovh-objectstorage": "2.0.5", "nodemailer": "6.8.0", "nodemailer-html-to-text": "3.2.0", - "notion-client": "^6.16.0", "oleoduc": "0.7.0", "omit-deep": "0.3.0", "openapi3-ts": "4.0.2", diff --git a/server/src/http/server.ts b/server/src/http/server.ts index 6bade537f..8e4f15571 100644 --- a/server/src/http/server.ts +++ b/server/src/http/server.ts @@ -8,7 +8,6 @@ import cors from "cors"; import express, { Application } from "express"; import Joi from "joi"; import { ObjectId, WithId } from "mongodb"; -import { NotionAPI } from "notion-client"; import passport from "passport"; import { typesEffectifNominatif } from "shared/constants/indicateurs"; import swaggerUi from "swagger-ui-express"; @@ -140,8 +139,6 @@ import organismesRouter from "./routes/specific.routes/organismes.routes"; const openapiSpecs = JSON.parse(fs.readFileSync(openApiFilePath, "utf8")); -const notion = new NotionAPI(); - /** * Create the express app */ @@ -211,13 +208,6 @@ function setupRoutes(app: Application) { }; }) ) - .get( - "/api/mentions-legales", - returnResult(async () => { - const recordMap = await notion.getPage("Mentions-l-gales-002a2868ea2f46cdb2d73207d12b6075"); - return recordMap; - }) - ) .post( "/api/v1/organismes/search-by-siret", returnResult(async (req) => { diff --git a/ui/package.json b/ui/package.json index 2ed035d21..a4210a53a 100644 --- a/ui/package.json +++ b/ui/package.json @@ -44,6 +44,7 @@ "luxon": "3.3.0", "next": "13.2.3", "next-plausible": "3.7.2", + "notion-client": "^6.16.0", "notion-types": "^6.16.0", "react": "18.2.0", "react-accessible-treeview": "2.8.0", diff --git a/ui/pages/mentions-legales.tsx b/ui/pages/mentions-legales.tsx index 052671471..0cbe20c23 100644 --- a/ui/pages/mentions-legales.tsx +++ b/ui/pages/mentions-legales.tsx @@ -1,51 +1,26 @@ -import { Center, Spinner } from "@chakra-ui/react"; -import { GetServerSidePropsContext } from "next"; +import { GetStaticProps, InferGetStaticPropsType } from "next"; +import { NotionAPI } from "notion-client"; import { ExtendedRecordMap } from "notion-types"; -import { useEffect, useState } from "react"; +import { NotionRenderer } from "react-notion-x"; import { _get } from "@/common/httpClient"; -import { NotionDoc } from "@/components/NotionDoc"; import SimplePage from "@/components/Page/SimplePage"; import "react-notion-x/src/styles.css"; -const isInitialServerSideProps = (context: GetServerSidePropsContext) => - context.req?.url?.indexOf("/_next/data/") === -1; - -export const getServerSideProps = async (context) => { - try { - const isInitial = isInitialServerSideProps(context); - if (!isInitial) return { props: {} }; - const dataSSR = await _get("/api/mentions-legales"); - return { props: { dataSSR } }; - } catch (e) { - console.error(e); - return { props: {} }; - } -}; - -export default function Home({ dataSSR }: { dataSSR: ExtendedRecordMap }) { - const [data, setData] = useState(dataSSR); - const [isLoading, setIsLoading] = useState(!dataSSR); - - useEffect(() => { - if (dataSSR) return; - (async () => { - setIsLoading(true); - setData(await _get("/api/mentions-legales")); - setIsLoading(false); - })(); - }, []); +export const getStaticProps = (async () => { + const notion = new NotionAPI(); + const recordMap = await notion.getPage("Mentions-l-gales-002a2868ea2f46cdb2d73207d12b6075"); + // const data = await _get("/api/mentions-legales"); + return { props: { data: recordMap }, revalidate: 60 * 30 }; +}) satisfies GetStaticProps<{ + data: ExtendedRecordMap; +}>; +export default function MentionsLegales({ data }: InferGetStaticPropsType) { return ( - {isLoading ? ( -
- -
- ) : ( - - )} +
); } diff --git a/yarn.lock b/yarn.lock index 52bde4cb9..f12618834 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18137,7 +18137,6 @@ request-debug@latest: node-ovh-objectstorage: 2.0.5 nodemailer: 6.8.0 nodemailer-html-to-text: 3.2.0 - notion-client: ^6.16.0 oleoduc: 0.7.0 omit-deep: 0.3.0 openapi3-ts: 4.0.2 @@ -19785,6 +19784,7 @@ request-debug@latest: luxon: 3.3.0 next: 13.2.3 next-plausible: 3.7.2 + notion-client: ^6.16.0 notion-types: ^6.16.0 react: 18.2.0 react-accessible-treeview: 2.8.0