"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 (
{user?.username || "User"}
{user?.email || "user@example.com"}
Change your password
Add an extra layer of security to your account
Permanently delete your account and all of your data