🔥(frontend) remove coming-soon
Remove the coming-soon page and the redirection to it.
This commit is contained in:
@@ -1,35 +1,17 @@
|
|||||||
import { Loader } from '@openfun/cunningham-react';
|
import { Loader } from '@openfun/cunningham-react';
|
||||||
import { usePathname, useRouter } from 'next/navigation';
|
import { PropsWithChildren, useEffect } from 'react';
|
||||||
import { PropsWithChildren, useEffect, useState } from 'react';
|
|
||||||
|
|
||||||
import { Box } from '@/components';
|
import { Box } from '@/components';
|
||||||
|
|
||||||
import { useAuthStore } from './useAuthStore';
|
import { useAuthStore } from './useAuthStore';
|
||||||
export const Auth = ({ children }: PropsWithChildren) => {
|
export const Auth = ({ children }: PropsWithChildren) => {
|
||||||
const { authenticated, initAuth } = useAuthStore();
|
const { authenticated, initAuth } = useAuthStore();
|
||||||
const router = useRouter();
|
|
||||||
const [isDomainComingSoon, setIsDomainComingSoon] = useState(false);
|
|
||||||
const domainComingSoon = 'docs.numerique.gouv.fr';
|
|
||||||
const pathComingSoon = '/coming-soon/';
|
|
||||||
const pathname = usePathname();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (window.location.origin.includes(domainComingSoon)) {
|
|
||||||
router.push(pathComingSoon);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
initAuth();
|
initAuth();
|
||||||
}, [initAuth, router]);
|
}, [initAuth]);
|
||||||
|
|
||||||
useEffect(() => {
|
if (!authenticated) {
|
||||||
setIsDomainComingSoon(
|
|
||||||
window.location.origin.includes(domainComingSoon) &&
|
|
||||||
pathname === pathComingSoon,
|
|
||||||
);
|
|
||||||
}, [pathname]);
|
|
||||||
|
|
||||||
if (!authenticated && !isDomainComingSoon) {
|
|
||||||
return (
|
return (
|
||||||
<Box $height="100vh" $width="100vw" $align="center" $justify="center">
|
<Box $height="100vh" $width="100vw" $align="center" $justify="center">
|
||||||
<Loader />
|
<Loader />
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
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 (
|
|
||||||
<Box $margin="auto">
|
|
||||||
<Box $align="center" $gap="3rem">
|
|
||||||
<Icon404 aria-label="Image 404" role="img" />
|
|
||||||
<Box $direction="row" $align="flex-end" $gap="1rem">
|
|
||||||
<Text
|
|
||||||
as="h1"
|
|
||||||
$margin="auto"
|
|
||||||
$direction="row"
|
|
||||||
$align="center"
|
|
||||||
$gap="1rem"
|
|
||||||
>
|
|
||||||
{t('Coming soon ...')}
|
|
||||||
</Text>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
Page.getLayout = function getLayout(page: ReactElement) {
|
|
||||||
return <Box $minHeight="100vh">{page}</Box>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Page;
|
|
||||||
Reference in New Issue
Block a user