From a23753f65272dca3f0b54bed16d96512a3cbe20d Mon Sep 17 00:00:00 2001
From: schererleander <leander@schererleander.de>
Date: Fri, 26 Dec 2025 18:08:25 +0100
Subject: refactor(settings): split settings page into separate form components

---
 src/app/settings/page.tsx | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

(limited to 'src/app/settings/page.tsx')

diff --git a/src/app/settings/page.tsx b/src/app/settings/page.tsx
index 75d9d3d..1baba3f 100644
--- a/src/app/settings/page.tsx
+++ b/src/app/settings/page.tsx
@@ -1,22 +1,21 @@
 import { getServerSession } from "next-auth"
-import { redirect } from "next/navigation"
-import dbConnect from "@/lib/mongodb"
-import User from "@/model/User"
 import { authOptions } from "@/lib/auth"
-import SettingsContent from "./settings-content"
+import { SettingsForm } from "./settings-form"
+import { getUserProfile } from "@/services/user.service"
 
 export default async function SettingsPage() {
   const session = await getServerSession(authOptions)
-
+  
   if (!session?.user?.email) {
-    redirect("/login")
+    // This case should be handled by middleware, but for type safety:
+    return null 
   }
 
-  await dbConnect()
-  const user = await User.findOne({ email: session.user.email }).lean() as any
+  const user = await getUserProfile(session.user.email)
 
   if (!user) {
-    redirect("/login")
+    // This case suggests a data inconsistency (session exists but user not in DB)
+    return null
   }
 
   // Sanitize user object for client component
@@ -27,5 +26,5 @@ export default async function SettingsPage() {
     twoFactorEnabled: !!user.twoFactorEnabled,
   }
 
-  return <SettingsContent initialUser={initialUser} />
+  return <SettingsForm user={initialUser} />
 }
-- 
cgit v1.3.1

