"use client"; import { useTranslation } from "react-i18next"; import Button from "@/lib/components/ui/Button"; import PageHeading from "@/lib/components/ui/PageHeading"; import Spinner from "@/lib/components/ui/Spinner"; import { useSupabase } from "@/lib/context/SupabaseProvider"; import { redirectToLogin } from "@/lib/router/redirectToLogin"; import { useInvitation } from "./hooks/useInvitation"; const InvitationPage = (): JSX.Element => { const { t } = useTranslation('invitation'); const { handleAccept, isProcessingRequest, handleDecline, isLoading, brainName, role, } = useInvitation(); const { session } = useSupabase(); if (isLoading) { return ; } if (session?.user === undefined) { redirectToLogin(); } if (role === undefined) { // This should never happen // It is a way to prevent the page from crashing when invitation is invalid instead of throwing an error // The user will be redirected to the home page (handled in the useInvitation hook) return
; } return (
{isProcessingRequest ? (

{t("processingRequest",{ns: "invitation"})}

) : (
)}
); }; export default InvitationPage;