"use client"; import React, { useState } from "react"; import { useRouter } from "next/navigation"; import { useTheme } from "next-themes"; import { ArrowRightLeft } from "lucide-react"; import { Dialog, Transition } from "@headlessui/react"; // ui import { Button, TOAST_TYPE, setToast } from "@plane/ui"; // hooks import { useUser } from "@/hooks/store"; 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 = useRouter(); // 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.
)}
); };