diff --git a/front/packages/ui/src/errors/setup.tsx b/front/packages/ui/src/errors/setup.tsx index eeb239db..a827eca1 100644 --- a/front/packages/ui/src/errors/setup.tsx +++ b/front/packages/ui/src/errors/setup.tsx @@ -5,27 +5,39 @@ import { Main } from "@expo/html-elements"; import { useYoshiki } from "yoshiki/native"; import Register from "@material-symbols/svg-400/rounded/app_registration.svg"; import { Navbar, NavbarProfile } from "../navbar"; +import { useEffect } from "react"; +import { useRouter } from "solito/router"; -export const SetupPage: QueryPage<{ step: Exclude }> = ({ step }) => { +export const SetupPage: QueryPage<{ step: SetupStep }> = ({ step }) => { const { css } = useYoshiki(); const { t } = useTranslation(); + const router = useRouter(); + const isValid = Object.values(SetupStep).includes(step) && step !== SetupStep.Done; + + useEffect(() => { + if (!isValid) router.replace("/"); + }, [isValid, router]); + + if (!isValid) return

Loading...

; return ( - <> - } /> -
-

{t(`errors.setup.${step}`)}

- {step === SetupStep.MissingAdminAccount && ( -
- +
+

{t(`errors.setup.${step}`)}

+ {step === SetupStep.MissingAdminAccount && ( +
); }; + +SetupPage.getLayout = ({ page }) => ( + <> + } /> + {page} + +); diff --git a/front/packages/ui/src/navbar/index.tsx b/front/packages/ui/src/navbar/index.tsx index 31ed2a33..a82109fc 100644 --- a/front/packages/ui/src/navbar/index.tsx +++ b/front/packages/ui/src/navbar/index.tsx @@ -172,7 +172,7 @@ export const Navbar = ({ left, right, ...props -}: { left?: ReactElement | null; right?: ReactElement | null }) => { +}: { left?: ReactElement | null; right?: ReactElement | null } & Stylable) => { const { css } = useYoshiki(); const { t } = useTranslation();