From 6a053b19fbf779bb2b9b07fe5c5e0bf7d57a5878 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Wed, 19 Jun 2024 12:50:51 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(frontend)=20coming=20soon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a coming soon page bind to the regie.numerique.gouv.fr domain. --- src/frontend/apps/desk/src/core/auth/Auth.tsx | 26 +++++++++++--- .../apps/desk/src/pages/coming-soon/index.tsx | 35 +++++++++++++++++++ 2 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 src/frontend/apps/desk/src/pages/coming-soon/index.tsx diff --git a/src/frontend/apps/desk/src/core/auth/Auth.tsx b/src/frontend/apps/desk/src/core/auth/Auth.tsx index 865a815f..5786dc79 100644 --- a/src/frontend/apps/desk/src/core/auth/Auth.tsx +++ b/src/frontend/apps/desk/src/core/auth/Auth.tsx @@ -1,5 +1,6 @@ import { Loader } from '@openfun/cunningham-react'; -import { PropsWithChildren, useEffect } from 'react'; +import { usePathname, useRouter } from 'next/navigation'; +import { PropsWithChildren, useEffect, useState } from 'react'; import { Box } from '@/components'; @@ -7,12 +8,29 @@ import { useAuthStore } from './useAuthStore'; export const Auth = ({ children }: PropsWithChildren) => { const { authenticated, initAuth } = useAuthStore(); + const router = useRouter(); + const [isDomainComingSoon, setIsDomainComingSoon] = useState(false); + const domainComingSoon = 'regie.numerique.gouv.fr'; + const pathComingSoon = '/coming-soon'; + const pathname = usePathname(); useEffect(() => { - initAuth(); - }, [initAuth]); + if (window.location.origin.includes(domainComingSoon)) { + router.push(pathComingSoon); + return; + } - if (!authenticated) { + initAuth(); + }, [initAuth, router]); + + useEffect(() => { + setIsDomainComingSoon( + window.location.origin.includes(domainComingSoon) && + pathname === pathComingSoon, + ); + }, [pathname]); + + if (!authenticated && !isDomainComingSoon) { return ( diff --git a/src/frontend/apps/desk/src/pages/coming-soon/index.tsx b/src/frontend/apps/desk/src/pages/coming-soon/index.tsx new file mode 100644 index 00000000..cd5de772 --- /dev/null +++ b/src/frontend/apps/desk/src/pages/coming-soon/index.tsx @@ -0,0 +1,35 @@ +import { ReactElement } from 'react'; +import { useTranslation } from 'react-i18next'; + +import Icon404 from '@/assets/icons/icon-404.svg'; +import { Box, Text } from '@/components'; +import { NextPageWithLayout } from '@/types/next'; + +const Page: NextPageWithLayout = () => { + const { t } = useTranslation(); + + return ( + + + + + + {t('Coming soon ...')} + + + + + ); +}; + +Page.getLayout = function getLayout(page: ReactElement) { + return {page}; +}; + +export default Page;