Dental Care
This commit is contained in:
44
app/(main)/patient/settings/page.tsx
Normal file
44
app/(main)/patient/settings/page.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
import { requireAuth } from "@/lib/auth-session/auth-server";
|
||||
import { redirect } from "next/navigation";
|
||||
import { UserSettingsContent } from "@/components/user/settings-content";
|
||||
import { prisma } from "@/lib/types/prisma";
|
||||
import { DashboardLayout } from "@/components/layout/dashboard-layout";
|
||||
|
||||
// Force dynamic rendering since this page uses authentication (headers)
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function UserSettingsPage() {
|
||||
const session = await requireAuth();
|
||||
|
||||
if (session.user.role !== "patient") {
|
||||
redirect("/");
|
||||
}
|
||||
|
||||
// Fetch full user data
|
||||
const user = await prisma.user.findUnique({
|
||||
where: { id: session.user.id },
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
email: true,
|
||||
phone: true,
|
||||
image: true,
|
||||
dateOfBirth: true,
|
||||
address: true,
|
||||
role: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
redirect("/sign-in");
|
||||
}
|
||||
|
||||
return (
|
||||
<DashboardLayout
|
||||
user={{ ...user, role: user.role || "patient" }}
|
||||
role="patient"
|
||||
>
|
||||
<UserSettingsContent user={{ ...user, role: user.role || "patient" }} />
|
||||
</DashboardLayout>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user