feat: initial implementation of modern modular webshop (shop core)
This commit is contained in:
29
shop/components/auth-button.tsx
Normal file
29
shop/components/auth-button.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import Link from "next/link";
|
||||
import { Button } from "./ui/button";
|
||||
import { createClient } from "@/lib/supabase/server";
|
||||
import { LogoutButton } from "./logout-button";
|
||||
|
||||
export async function AuthButton() {
|
||||
const supabase = await createClient();
|
||||
|
||||
// You can also use getUser() which will be slower.
|
||||
const { data } = await supabase.auth.getClaims();
|
||||
|
||||
const user = data?.claims;
|
||||
|
||||
return user ? (
|
||||
<div className="flex items-center gap-4">
|
||||
Hey, {user.email}!
|
||||
<LogoutButton />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex gap-2">
|
||||
<Button asChild size="sm" variant={"outline"}>
|
||||
<Link href="/auth/login">Sign in</Link>
|
||||
</Button>
|
||||
<Button asChild size="sm" variant={"default"}>
|
||||
<Link href="/auth/sign-up">Sign up</Link>
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user