"use client"; import { useState } from "react"; import Link from "next/link"; import { Notice } from "@/components/ui"; type P = { email: string; displayName: string; publicName: string; phone: string; sellerType: "OWNER" | "AGENT"; bio: string; prefs: { notifications?: Record; privacy?: Record; termsAcceptedAt?: string } }; export function ProfileForm({ initial }: { initial: P }) { const [f, setF] = useState(initial); const [msg, setMsg] = useState(null); const [busy, setBusy] = useState(false); const n = { inquiries: true, viewings: true, alerts: true, marketing: false, ...(f.prefs.notifications ?? {}) }; const pv = { showPhone: false, showNameOnListings: true, ...(f.prefs.privacy ?? {}) }; const save = async (e: React.FormEvent) => { e.preventDefault(); setBusy(true); setMsg(null); const r = await fetch("/api/me", { method: "PATCH", headers: { "content-type": "application/json" }, body: JSON.stringify({ displayName: f.displayName || null, publicName: f.publicName || null, phone: f.phone || null, sellerType: f.sellerType, bio: f.bio || null, prefs: { notifications: n, privacy: pv } }) }); setBusy(false); setMsg(r.ok ? "Profil enregistré." : "Erreur d'enregistrement."); }; const setN = (k: string, v: boolean) => setF({ ...f, prefs: { ...f.prefs, notifications: { ...n, [k]: v } } }); const setP = (k: string, v: boolean) => setF({ ...f, prefs: { ...f.prefs, privacy: { ...pv, [k]: v } } }); return (

Profil et préférences

Identifiant : {f.email} (vérifié). Changer d'adresse ou gérer les sessions.