diff --git a/components/auth/account-popver.tsx b/components/auth/account-popver.tsx index 9991782..f715547 100644 --- a/components/auth/account-popver.tsx +++ b/components/auth/account-popver.tsx @@ -5,29 +5,38 @@ import { PopoverContent, PopoverTrigger, } from "@/components/ui/popover" -import { authClient } from "@/lib/auth-client" -import type { User } from "better-auth" -import { Loader, User as UserIcon } from "lucide-react" +import { authClient } from "@/lib/auth-client"; +import type { User } from "@prisma/client"; +import { Loader2, User as UserIcon } from "lucide-react" import { useRouter } from "next/navigation" import { useState } from "react" export function AccountPopover({ user }: { user?: User }) { + const session = authClient.useSession(); const [loading, setLoading] = useState(false) const router = useRouter() + + if (session.isPending) { + + + + } return ( + - + - {user?.name} + {session.data?.user?.name} - {user?.email} + {session.data?.user?.phoneNumber} + {user?.address} { setLoading(true) @@ -40,7 +49,7 @@ export function AccountPopover({ user }: { user?: User }) { }) setLoading(false) }}> - {loading ? : "Logout"} + {loading ? : "Logout"} diff --git a/components/auth/application-layout.tsx b/components/auth/application-layout.tsx index 59560c5..e42405f 100644 --- a/components/auth/application-layout.tsx +++ b/components/auth/application-layout.tsx @@ -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 ( @@ -47,7 +53,7 @@ export async function ApplicationLayout({ - + {children} diff --git a/components/auth/signup-form.tsx b/components/auth/signup-form.tsx index f5cc186..6e20497 100644 --- a/components/auth/signup-form.tsx +++ b/components/auth/signup-form.tsx @@ -20,7 +20,6 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select"; -import { Checkbox } from "../ui/checkbox"; type AtollWithIslands = Prisma.AtollGetPayload<{ include: { @@ -241,7 +240,8 @@ export default function SignUpForm({ atolls }: { atolls: AtollWithIslands[] }) { )} - - ({ name: `${faker.person.fullName().split(" ")[1]} House-${crypto @@ -22,9 +24,23 @@ async function main() { phoneNumberVerified: false, role: "USER", })); + await prisma.user.createMany({ data: users, }); + const FAAFU_ATOLL = await prisma.atoll.create({ + data: { + name: "F", + }, + }); + + const islands = DEFAULT_ISLANDS.map((name) => ({ + name, + atollId: FAAFU_ATOLL.id, + })); + await prisma.island.createMany({ + data: islands, + }); } main()
- {user?.email} + {session.data?.user?.phoneNumber}