titles/components/SignIn.tsx
ChrQR 3c39510aa3
All checks were successful
Vercel Preview Deployment / Deploy-Preview (push) Successful in 2m15s
set up nextui and framer motion
2024-05-17 10:44:41 +02:00

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>
);
}