nyx-dashboard/components/AuthButton.js

48 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2023-03-03 17:48:43 +01:00
import { signIn, signOut, useSession } from "next-auth/client";
import { Button } from "@chakra-ui/react";
export default function Page() {
const [session, loading] = useSession();
return (
<>
{!session && (
<>
<Button
display={{ base: "none", md: "inline-flex" }}
fontSize={"sm"}
fontWeight={600}
color={"white"}
bg={"teal.400"}
href={"#"}
_hover={{
bg: "teal.300",
}}
onClick={() => signIn()}
>
Sign In
</Button>
</>
)}
{session && (
<>
<Button
display={{ base: "none", md: "inline-flex" }}
fontSize={"sm"}
fontWeight={600}
color={"white"}
bg={"teal.400"}
href={"#"}
_hover={{
bg: "teal.300",
}}
onClick={() => signOut()}
>
Sign Out
</Button>
</>
)}
</>
);
}