Spaces:
Running
Running
File size: 919 Bytes
17fabdd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
"use client";
import { signOut } from "@/utils/signOut";
import { Button } from "./ui/button";
import { ExitIcon } from "@radix-ui/react-icons";
import { useState } from "react";
import { Loader2 } from "lucide-react";
const SignOutButton = () => {
const [isLoading, setIsLoading] = useState<boolean>(false);
async function handleSignOut() {
try {
setIsLoading(true);
await signOut();
setIsLoading(false);
} catch (error) {}
}
return (
<>
<Button
className="hover:bg-slate-100"
variant={"ghost"}
onClick={handleSignOut}
>
{isLoading ? (
<>
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
Logging Out
</>
) : (
<>
<ExitIcon className="mr-2 h-4 w-4" />
Log Out
</>
)}
</Button>
</>
);
};
export default SignOutButton;
|