From 9b8b4290dccb9fae87971507f1db9184569b13a7 Mon Sep 17 00:00:00 2001 From: Adrian Bonpin Date: Sun, 26 Apr 2026 11:05:22 -0500 Subject: [PATCH] feat: add settings profile sub-tab with name editing --- components/profile/settings-profile-tab.tsx | 108 ++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 components/profile/settings-profile-tab.tsx diff --git a/components/profile/settings-profile-tab.tsx b/components/profile/settings-profile-tab.tsx new file mode 100644 index 0000000..70f99b5 --- /dev/null +++ b/components/profile/settings-profile-tab.tsx @@ -0,0 +1,108 @@ +"use client" + +import { useState } from "react" +import { authClient } from "@/lib/auth-client" +import { Loader2, Save } from "lucide-react" +import { motion } from "motion/react" + +interface SettingsProfileTabProps { + name: string + email: string + role: string | null + createdAt: string +} + +export function SettingsProfileTab({ name, email, role, createdAt }: SettingsProfileTabProps) { + const [displayName, setDisplayName] = useState(name) + const [isSaving, setIsSaving] = useState(false) + const [message, setMessage] = useState<{ type: "success" | "error"; text: string } | null>(null) + + const handleSaveName = async () => { + if (!displayName.trim()) { + setMessage({ type: "error", text: "Name cannot be empty" }) + return + } + + setIsSaving(true) + setMessage(null) + + const { error } = await authClient.updateUser({ + name: displayName.trim(), + }) + + if (error) { + setMessage({ type: "error", text: error.message || "Failed to update name" }) + } else { + setMessage({ type: "success", text: "Name updated successfully" }) + } + setIsSaving(false) + } + + const joinDate = new Date(createdAt).toLocaleDateString("en-US", { + month: "long", + year: "numeric", + }) + + return ( + + {/* Display Name */} +
+

Display Name

+
+
+ setDisplayName(e.target.value)} + className="w-full px-3 py-2 rounded-lg bg-text/5 border border-border text-sm text-text focus:outline-none focus:border-primary/60 focus:ring-1 focus:ring-primary/30 transition-colors" + placeholder="Your display name" + /> +
+ +
+ {message && ( +

+ {message.text} +

+ )} +
+ + {/* Email (read-only) */} +
+

Email

+

{email}

+

Email changes require verification. Contact support if needed.

+
+ + {/* Account Info (read-only) */} +
+

Account Info

+
+
+ Role +

{role || "user"}

+
+
+ Member since +

{joinDate}

+
+
+
+
+ ) +}