feat: implement EditProfile functionality with form validation and update user profile API integration

This commit is contained in:
2025-09-06 20:22:40 +02:00
parent fc7dacc6fb
commit 19520c832f
6 changed files with 345 additions and 17 deletions

View File

@@ -0,0 +1,39 @@
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
import { getMe } from "@/lib/api";
import {
Card,
CardHeader,
CardTitle,
CardDescription,
} from "@/components/ui/card";
import { EditProfileForm } from "@/components/edit-profile-form";
// This is a Server Component to fetch initial data
export default async function EditProfilePage() {
const token = (await cookies()).get("auth_token")?.value;
if (!token) {
redirect("/login");
}
const me = await getMe(token).catch(() => null);
if (!me) {
redirect("/login");
}
return (
<div className="space-y-6">
<Card>
<CardHeader>
<CardTitle>Edit Profile</CardTitle>
<CardDescription>
Update your public profile information.
</CardDescription>
</CardHeader>
<EditProfileForm currentUser={me} />
</Card>
</div>
);
}