This commit is contained in:
Leon van Zyl
2025-08-11 12:38:39 +02:00
parent 2af182a3a8
commit c412e6e76d
21 changed files with 7522 additions and 120 deletions

View File

@@ -0,0 +1,29 @@
"use client"
import { signIn, useSession } from "@/lib/auth-client"
import { Button } from "@/components/ui/button"
export function SignInButton() {
const { data: session, isPending } = useSession()
if (isPending) {
return <Button disabled>Loading...</Button>
}
if (session) {
return null
}
return (
<Button
onClick={async () => {
await signIn.social({
provider: "google",
callbackURL: "/dashboard",
})
}}
>
Sign in with Google
</Button>
)
}

View File

@@ -0,0 +1,33 @@
"use client"
import { signOut, useSession } from "@/lib/auth-client"
import { Button } from "@/components/ui/button"
export function SignOutButton() {
const { data: session, isPending } = useSession()
if (isPending) {
return <Button disabled>Loading...</Button>
}
if (!session) {
return null
}
return (
<Button
variant="outline"
onClick={async () => {
await signOut({
fetchOptions: {
onSuccess: () => {
window.location.href = "/"
},
},
})
}}
>
Sign out
</Button>
)
}

View File

@@ -0,0 +1,40 @@
"use client"
import { useSession } from "@/lib/auth-client"
import { SignInButton } from "./sign-in-button"
import { SignOutButton } from "./sign-out-button"
export function UserProfile() {
const { data: session, isPending } = useSession()
if (isPending) {
return <div>Loading...</div>
}
if (!session) {
return (
<div className="flex flex-col items-center gap-4 p-6">
<h2 className="text-xl font-semibold">Welcome</h2>
<p className="text-muted-foreground">Please sign in to continue</p>
<SignInButton />
</div>
)
}
return (
<div className="flex flex-col items-center gap-4 p-6">
<div className="text-center">
{session.user?.image && (
<img
src={session.user.image}
alt={session.user.name || "User"}
className="w-16 h-16 rounded-full mx-auto mb-4"
/>
)}
<h2 className="text-xl font-semibold">{session.user?.name}</h2>
<p className="text-muted-foreground">{session.user?.email}</p>
</div>
<SignOutButton />
</div>
)
}