mirror of
https://github.com/SkalaraAI/skalara-web.git
synced 2025-04-07 05:50:18 -04:00
refactor(client): create navbar
This commit is contained in:
parent
292a2d3f33
commit
d518632820
37
app/page.tsx
37
app/page.tsx
|
@ -1,41 +1,8 @@
|
||||||
import { createServerComponentClient } from "@supabase/auth-helpers-nextjs";
|
import Navbar from "@/components/navbar";
|
||||||
import { cookies } from "next/headers";
|
|
||||||
import Link from "next/link";
|
|
||||||
import { buttonVariants } from "@/components/ui/button";
|
|
||||||
import LogoutButton from "@/components/logout";
|
|
||||||
|
|
||||||
export const dynamic = "force-dynamic";
|
|
||||||
|
|
||||||
export default async function Index() {
|
export default async function Index() {
|
||||||
const supabase = createServerComponentClient({ cookies });
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: { user },
|
|
||||||
} = await supabase.auth.getUser();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full flex flex-col items-center">
|
<div className="w-full flex flex-col items-center">
|
||||||
<nav className="w-full flex justify-center border-b border-b-foreground/10 h-16">
|
<Navbar />
|
||||||
<div className="w-full max-w-4xl flex justify-between items-center p-3 text-sm text-foreground">
|
|
||||||
<div />
|
|
||||||
<div>
|
|
||||||
{user ? (
|
|
||||||
<div className="flex items-center gap-4">
|
|
||||||
Hey, {user.email}!
|
|
||||||
<LogoutButton />
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<Link
|
|
||||||
href="/login"
|
|
||||||
className={buttonVariants({ variant: "default" })}
|
|
||||||
>
|
|
||||||
Login
|
|
||||||
</Link>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<div className="flex flex-col gap-14 max-w-4xl px-3 py-16 lg:py-24 text-foreground">
|
<div className="flex flex-col gap-14 max-w-4xl px-3 py-16 lg:py-24 text-foreground">
|
||||||
<div className="flex flex-col items-center mb-4 lg:mb-12">
|
<div className="flex flex-col items-center mb-4 lg:mb-12">
|
||||||
<p className="text-3xl lg:text-4xl !leading-tight mx-auto max-w-xl text-center my-12">
|
<p className="text-3xl lg:text-4xl !leading-tight mx-auto max-w-xl text-center my-12">
|
||||||
|
|
38
components/navbar.tsx
Normal file
38
components/navbar.tsx
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
import Link from "next/link";
|
||||||
|
import { buttonVariants } from "@/components/ui/button";
|
||||||
|
import LogoutButton from "@/components/logout";
|
||||||
|
import { createServerComponentClient } from "@supabase/auth-helpers-nextjs";
|
||||||
|
import { cookies } from "next/headers";
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
|
export default async function Navbar() {
|
||||||
|
const supabase = createServerComponentClient({ cookies });
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: { user },
|
||||||
|
} = await supabase.auth.getUser();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<nav className="w-full flex justify-center border-b border-b-foreground/10 h-16">
|
||||||
|
<div className="w-full max-w-4xl flex justify-between items-center p-3 text-sm text-foreground">
|
||||||
|
<div />
|
||||||
|
<div>
|
||||||
|
{user ? (
|
||||||
|
<div className="flex items-center gap-4">
|
||||||
|
Hey, {user.email}!
|
||||||
|
<LogoutButton />
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<Link
|
||||||
|
href="/login"
|
||||||
|
className={buttonVariants({ variant: "default" })}
|
||||||
|
>
|
||||||
|
Login
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user