"use client"; import type React from "react"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { toast } from "sonner"; import { useAuth } from "@/hooks/use-auth"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Icons } from "@/components/icons"; import { Separator } from "@/components/ui/separator"; export default function ProfilePage() { const router = useRouter(); const { user, updateProfile } = useAuth(); const [isLoading, setIsLoading] = useState(false); const [username, setUsername] = useState(user?.username || ""); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!username.trim()) { toast.error("Username cannot be empty"); return; } setIsLoading(true); try { await updateProfile({ username }); toast.success("Username updated successfully"); router.push("/todos"); } catch (error) { console.error("Failed to update profile:", error); toast.error("Failed to update profile. Please try again."); } finally { setIsLoading(false); } }; return (

Profile Settings

Account Information Update your account information here.

{user?.username || "User"}

{user?.email || "user@example.com"}

setUsername(e.target.value)} placeholder="Enter your username" />

This is the name that will be displayed to other users.

Your email address cannot be changed.

Account Security Manage your account security settings.

Password

Change your password

Two-Factor Authentication

Add an extra layer of security to your account

Danger Zone Irreversible and destructive actions

Delete Account

Permanently delete your account and all of your data

); }