import { LogOut, Trash } from "lucide-react"; import { Button } from "../ui/button"; import { clearCache } from "~/lib/utils"; import { Card, CardContent } from "../ui/card"; import { Avatar, AvatarFallback } from "../ui/avatar"; import { logout, type User } from "~/lib/api"; import { Label } from "../ui/label"; import { Badge } from "../ui/badge"; import { useQueryClient } from "@tanstack/react-query"; import { useNavigate } from "react-router"; export default function Profile({ user }: { user: User }) { const navigate = useNavigate(); const useLogout = () => { const queryClient = useQueryClient(); // Logout, invalidate user cache, and redirect to login return async () => { try { await logout(); queryClient.removeQueries({ queryKey: ["user"] }); navigate("/login", { replace: true }); } catch (error) { console.error("Logout failed:", error); } }; }; const handleLogout = useLogout(); return ( {/* Avatar Section */}
{/* */} {user.fullName .split(" ") .map((n) => n[0]) .join("")}

{user.fullName}

{user.email}

{user.className}
{/* Form Fields */}

{user.fullName}

{user.email}

{/* Logout Button */}
); }