Files
void-sentinel/web/components/LoginButton.tsx

40 lines
1.5 KiB
TypeScript

import { signIn, signOut } from "@/auth"
import { Button } from "@/components/ui/button"
import Link from "next/link"
export function LoginButton({ session }: { session: any }) {
if (session) {
return (
<div className="flex gap-4 items-center">
<Link href="/dashboard" className="hover:cursor-pointer px-6 py-2 bg-blue-600 hover:bg-blue-700 rounded-full font-semibold transition-all hover:scale-105">
Dashboard
</Link>
<form
action={async () => {
"use server"
await signOut()
}}
>
<Button type="submit" size={'lg'} className="hover:cursor-pointer text-white px-6 py-2 bg-red-500/20 hover:bg-red-500/40 border border-red-500 rounded-full font-semibold transition-all hover:scale-105">
Sign Out
</Button>
</form>
</div>
)
}
return (
<form
action={async () => {
"use server"
await signIn("discord", { redirectTo: "/dashboard" })
}}
>
<Button type="submit" className="hover:cursor-pointer px-6 py-6 text-white bg-indigo-600 hover:bg-indigo-700 rounded-full font-semibold transition-all hover:scale-105 shadow-lg shadow-indigo-500/30">
Login with Discord
</Button>
</form>
)
}