From 338f6ee1371a109500a32a4fa11c7b0c3a01c002 Mon Sep 17 00:00:00 2001 From: Xavier Desoindre Date: Wed, 4 Dec 2024 11:01:36 +0100 Subject: [PATCH] chore: use explicit scroll on extra simulator --- src/components/outils/CategoryPage.tsx | 8 +--- src/components/outils/ExtraSimulator.tsx | 47 +++++++++++++++++------- src/utils/notion.ts | 3 ++ 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/components/outils/CategoryPage.tsx b/src/components/outils/CategoryPage.tsx index 33551dc2d..bd9a792d3 100644 --- a/src/components/outils/CategoryPage.tsx +++ b/src/components/outils/CategoryPage.tsx @@ -38,13 +38,7 @@ const CategoryPage = ({ {category.sources && } - {extraSimulator && ( - - - {extraSimulator.simulator} - - - )} + {extraSimulator && {extraSimulator.simulator}} { const overScreens = useMemo( () => - slug === 'osez-changer' + simulator.slug === 'osez-changer' ? overScreenOsezChangerValues() - : overScreenCategoryValues({ id: 2, unit: slug, slug, name: tracking }), - [slug, tracking] + : overScreenCategoryValues({ id: 2, unit: simulator.slug, slug: simulator.slug, name: simulator.tracking }), + [simulator] ) - const simulator = ( - + useEffect(() => { + if (window && window.location.hash) { + console.log(window.location.hash) + const anchor = window.location.hash.replace('#', '') + const element = document.getElementById(anchor) + if (element) { + element.scrollIntoView({ behavior: 'smooth' }) + } + } + }, []) + + const component = ( + {children} ) - return small ?
{simulator}
: simulator + return ( + + {simulator.small ?
{component}
: component} +
+ ) } export default ExtraSimulator diff --git a/src/utils/notion.ts b/src/utils/notion.ts index 46e7c353c..016459696 100644 --- a/src/utils/notion.ts +++ b/src/utils/notion.ts @@ -60,6 +60,9 @@ export const NotionCommandValidation = z export type NotionCommand = z.infer export const getAllNotionDB = async (url: string): Promise<{ id: string; properties: T }[]> => { + if (!process.env.NOTION_API_KEY) { + return [] + } let results: { id: string; properties: T }[] = [] let axiosResponse: | AxiosResponse<{