"use client"; import React, { useState } from "react"; import { useTheme } from "next-themes"; import { ArrowRightLeft } from "lucide-react"; import { Dialog, Transition } from "@headlessui/react"; // ui import { Button } from "@plane/propel/button"; import { TOAST_TYPE, setToast } from "@plane/propel/toast"; // hooks import { useUser } from "@/hooks/store/user"; import { useAppRouter } from "@/hooks/use-app-router"; type Props = { isOpen: boolean; onClose: () => void; }; export const SwitchAccountModal: React.FC = (props) => { const { isOpen, onClose } = props; // states const [switchingAccount, setSwitchingAccount] = useState(false); // router const router = useAppRouter(); // store hooks const { data: userData, signOut } = useUser(); const { setTheme } = useTheme(); const handleClose = () => { setSwitchingAccount(false); onClose(); }; const handleSwitchAccount = async () => { setSwitchingAccount(true); await signOut() .then(() => { setTheme("system"); router.push("/"); handleClose(); }) .catch(() => setToast({ type: TOAST_TYPE.ERROR, title: "Error!", message: "Failed to sign out. Please try again.", }) ) .finally(() => setSwitchingAccount(false)); }; return (
Switch account {userData?.email && (
If you have signed up via {userData.email}{" "} un-intentionally, you can switch your account to a different one from here.
)}
); };