Refactor authentication components and enhance user session handling

- Updated AccountPopover to utilize session data for user information display.
- Modified ApplicationLayout to fetch user details from the database using Prisma.
- Replaced Checkbox components with native input elements in SignUpForm for better accessibility.
- Enhanced seed script to include default islands and create related data in the database.
This commit is contained in:
2024-12-01 07:40:21 +05:00
parent b91f34b6b1
commit 3f8bb4e70a
4 changed files with 45 additions and 12 deletions

View File

@ -15,6 +15,7 @@ import {
SidebarTrigger,
} from "@/components/ui/sidebar";
import { auth } from "@/lib/auth";
import prisma from "@/lib/db";
import { headers } from "next/headers";
import { AccountPopover } from "./account-popver";
@ -22,7 +23,12 @@ export async function ApplicationLayout({
children,
}: { children: React.ReactNode }) {
const session = await auth.api.getSession({
headers: await headers(), // you need to pass the headers object.
headers: await headers()
});
const user = await prisma.user.findUnique({
where: {
id: session?.user?.id,
},
});
return (
<SidebarProvider>
@ -47,7 +53,7 @@ export async function ApplicationLayout({
<div className="flex items-center gap-2">
<ModeToggle />
<AccountPopover user={session?.user} />
<AccountPopover user={user || undefined} />
</div>
</header>
<div className="p-4">{children}</div>