ChrQR
3c39510aa3
All checks were successful
Vercel Preview Deployment / Deploy-Preview (push) Successful in 2m15s
33 lines
764 B
TypeScript
33 lines
764 B
TypeScript
"use client";
|
|
|
|
import { signIn, signOut } from "next-auth/react";
|
|
import { SyntheticEvent } from "react";
|
|
import { Session } from "next-auth";
|
|
import { Button } from "@nextui-org/button";
|
|
|
|
interface SignInProps {
|
|
session: Session | null;
|
|
}
|
|
|
|
export default function SignIn({ session }: SignInProps) {
|
|
const handleSignIn = async (event: SyntheticEvent) => {
|
|
event.preventDefault();
|
|
await signIn("github");
|
|
};
|
|
|
|
const handleSignOut = async (event: SyntheticEvent) => {
|
|
event.preventDefault();
|
|
await signOut();
|
|
};
|
|
|
|
return session?.user ? (
|
|
<form onSubmit={handleSignOut}>
|
|
<Button type="submit">Sign out</Button>
|
|
</form>
|
|
) : (
|
|
<form onSubmit={handleSignIn}>
|
|
<Button type="submit">Sign in</Button>
|
|
</form>
|
|
);
|
|
}
|