mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-19 08:42:08 +03:00
9c8e0aa0e4
* 🗑️ remove date input from fetch_user_id_from_credentials * ♻️ refactor backend utils by splitting it into files * 💡 comments for next actions to update /upload * 🚚 move SupabaseProvider tp libs * 🚚 move useAxios to hooks * ♻️ refacto brain routes * 🚨 update lintermfor paths * ✨ new brain context provider * ✨ new brain component in navbar * 🚨 fix linter and async * 🇸🇪 add feature flag for multiple-brains
63 lines
1.8 KiB
TypeScript
63 lines
1.8 KiB
TypeScript
/* eslint-disable */
|
|
"use client";
|
|
import Link from "next/link";
|
|
import { useRouter } from "next/navigation";
|
|
import { useState } from "react";
|
|
|
|
import Button from "@/lib/components/ui/Button";
|
|
import Card from "@/lib/components/ui/Card";
|
|
import PageHeading from "@/lib/components/ui/PageHeading";
|
|
import { useSupabase } from "@/lib/context/SupabaseProvider";
|
|
import { useToast } from "@/lib/hooks/useToast";
|
|
|
|
export default function Logout() {
|
|
const { supabase } = useSupabase();
|
|
const [isPending, setIsPending] = useState(false);
|
|
|
|
const { publish } = useToast();
|
|
const router = useRouter();
|
|
|
|
const handleLogout = async () => {
|
|
setIsPending(true);
|
|
const { error } = await supabase.auth.signOut();
|
|
|
|
if (error) {
|
|
console.error("Error logging out:", error.message);
|
|
publish({
|
|
variant: "danger",
|
|
text: `Error logging out: ${error.message}`,
|
|
});
|
|
} else {
|
|
publish({
|
|
variant: "success",
|
|
text: "Logged out successfully",
|
|
});
|
|
router.replace("/");
|
|
}
|
|
setIsPending(false);
|
|
};
|
|
|
|
return (
|
|
<main>
|
|
<section className="w-full min-h-[80vh] h-full outline-none flex flex-col gap-5 items-center justify-center p-6">
|
|
<PageHeading title="Logout" subtitle="See you next time" />
|
|
<Card className="max-w-md w-full p-5 sm:p-10 text-center flex flex-col items-center gap-5">
|
|
<h2 className="text-lg">Are you sure you want to sign out?</h2>
|
|
<div className="flex gap-5 items-center justify-center">
|
|
<Link href={"/"}>
|
|
<Button variant={"primary"}>Go back</Button>
|
|
</Link>
|
|
<Button
|
|
isLoading={isPending}
|
|
variant={"danger"}
|
|
onClick={() => handleLogout()}
|
|
>
|
|
Log Out
|
|
</Button>
|
|
</div>
|
|
</Card>
|
|
</section>
|
|
</main>
|
|
);
|
|
}
|