From e69156407e9be45e352a8572b93535b1b0150db4 Mon Sep 17 00:00:00 2001 From: Mathis HERRIOT <197931332+0x485254@users.noreply.github.com> Date: Wed, 21 Jan 2026 15:43:43 +0100 Subject: [PATCH] feat(settings): add account deletion feature and improve UI - Introduced "Delete Account" functionality with confirmation dialog and success/error notifications. - Enhanced general settings page UI, including updated card layouts and improved form elements. - Added support for theme selection with a more user-friendly design. - Refined typography and button styling for better visual consistency. --- .../src/app/(dashboard)/settings/page.tsx | 346 +++++++++++------- 1 file changed, 221 insertions(+), 125 deletions(-) diff --git a/frontend/src/app/(dashboard)/settings/page.tsx b/frontend/src/app/(dashboard)/settings/page.tsx index 9caeb12..3c772f0 100644 --- a/frontend/src/app/(dashboard)/settings/page.tsx +++ b/frontend/src/app/(dashboard)/settings/page.tsx @@ -2,19 +2,34 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { + AlertTriangle, Laptop, Loader2, Moon, Palette, Save, + Settings, Sun, + Trash2, User as UserIcon, } from "lucide-react"; +import { useRouter } from "next/navigation"; import { useTheme } from "next-themes"; import * as React from "react"; import { useForm } from "react-hook-form"; import { toast } from "sonner"; import * as z from "zod"; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; import { Card, @@ -49,8 +64,10 @@ type SettingsFormValues = z.infer; export default function SettingsPage() { const { theme, setTheme } = useTheme(); - const { user, isLoading, refreshUser } = useAuth(); + const { user, isLoading, refreshUser, logout } = useAuth(); + const router = useRouter(); const [isSaving, setIsSaving] = React.useState(false); + const [isDeleting, setIsDeleting] = React.useState(false); const [mounted, setMounted] = React.useState(false); React.useEffect(() => { @@ -111,146 +128,225 @@ export default function SettingsPage() { } }; + const handleDeleteAccount = async () => { + setIsDeleting(true); + try { + await UserService.removeMe(); + toast.success("Votre compte a été supprimé."); + logout(); + router.push("/"); + } catch (error) { + console.error(error); + toast.error("Erreur lors de la suppression du compte."); + } finally { + setIsDeleting(false); + } + }; + return (
- +
-

Paramètres du profil

+

Paramètres

- - - Informations personnelles - - Mettez à jour vos informations publiques. Ces données seront visibles par - les autres utilisateurs. - - - -
- -
- - Nom d'utilisateur - - - - - Le nom d'utilisateur ne peut pas être modifié. - - - - ( +
+ + +
+ + Informations personnelles +
+ + Mettez à jour vos informations publiques. Ces données seront visibles par + les autres utilisateurs. + +
+ + + +
+
- Nom d'affichage + Nom d'utilisateur - - - - Le nom qui sera affiché sur votre profil et vos mèmes. - - - - )} - /> - - ( - - Bio - -