import { PersonIcon } from "@radix-ui/react-icons";
import { PrismaClient, User } from "@repo/db";
import { AdminForm, ProfileForm } from "./_components/forms";

export default async ({ params }: { params: { id: string } }) => {
	const prisma = new PrismaClient();
	const { id } = params;

	const user: User | null = await prisma.user.findUnique({
		where: {
			id: id,
		},
	});

	console.log(user);

	return (
		<div className="grid grid-cols-6 gap-4">
			<div className="col-span-full">
				<p className="text-2xl font-semibold text-left flex items-center gap-2">
					<PersonIcon className="w-5 h-5" />
					{user?.firstname} {user?.lastname} #{user?.publicId}
				</p>
			</div>
			<div className="card bg-base-200 shadow-xl mb-4 col-span-6 xl:col-span-3">
				<ProfileForm user={user} />
			</div>
			<div className="card bg-base-200 shadow-xl mb-4 col-span-6 xl:col-span-3">
				<AdminForm user={user} />
			</div>
		</div>
	);
};
