quivr/frontend/app/invitation/[brainId]/page.tsx
Zineb El Bachiri 0b091bd8c9
Feat/shareable brains open link authenticated (#676)
* ♻️ use Single Responsibility Principle on brains_subscription

*  new brain subscription endpoints for invited user

* 📝 add documentation to endpoints

* 🎨 add base_frontend_url to send custom url for brain share

* ✏️ brains instead of brain in url

*  use origin in header for frontend url in subscription email

* 🚚 move and remove unused code

*  new subscription API for BE endpoints in frontend

*  new addBrain to  add a shared brain in frontend

* 🥚 new hook for brain invitations

*  new page for brain invitation

*  change frontend url to copy for brain subscription

* ✏️ call RBAC with wrapper function

* ✏️ last typos
2023-07-18 09:47:59 +02:00

53 lines
1.5 KiB
TypeScript

"use client";
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 { handleAccept, handleDecline, isLoading } = useInvitation();
const { session } = useSupabase();
// Show the loader while invitation validity is being checked
if (isLoading) {
return <Spinner />;
}
// TODO: Modify this to fetch the brain name from the database
const brain = { name: "TestBrain" };
if (session?.user === undefined) {
redirectToLogin();
}
return (
<main className="pt-10">
<PageHeading
title={`Welcome to ${brain.name}!`}
subtitle="You have been exclusively invited to join this brain and start exploring. Do you accept this exciting journey?"
/>
<div className="flex flex-col items-center justify-center gap-5 mt-5">
<Button
onClick={() => void handleAccept()}
variant={"secondary"}
className="py-3"
>
Yes, count me in!
</Button>
<Button
onClick={() => void handleDecline()}
variant={"danger"}
className="py-3"
>
No, thank you.
</Button>
</div>
</main>
);
};
export default InvitationPage;