From 6b104d112d8ff28bb1b0b6346c33efe801a12eec Mon Sep 17 00:00:00 2001 From: Chneemann Date: Tue, 22 Sep 2026 09:03:29 +0200 Subject: [PATCH] feat(settings): add online status selection UI --- components/settings/SettingsView.tsx | 63 ++++++++++++++++++++++++++-- db/schema.ts | 2 +- lib/constants/member.styles.ts | 4 +- 3 files changed, 63 insertions(+), 6 deletions(-) diff --git a/components/settings/SettingsView.tsx b/components/settings/SettingsView.tsx index 3d76780..9e30d7d 100644 --- a/components/settings/SettingsView.tsx +++ b/components/settings/SettingsView.tsx @@ -5,22 +5,48 @@ "use client"; +import { useState } from "react"; import { UserAvatar } from "@/components/ui/UserAvatar"; -import { User } from "@/db/schema"; +import { UserStatus, User } from "@/db/schema"; +import { MEMBER_STATUS_COLOR_CLASSES } from "@/lib/constants/member.styles"; +import { UserRound } from "lucide-react"; +/** Props for the SettingsView component. */ interface SettingsViewProps { userId: string; currentUser: User; } +/** Renders the user settings view for profile management and status selection. */ export function SettingsView({ userId, currentUser }: SettingsViewProps) { + const [selectedStatus, setSelectedStatus] = useState( + currentUser.status, + ); + + const statuses: { label: string; value: UserStatus }[] = [ + { label: "Online", value: "ONLINE" }, + { label: "Offline", value: "OFFLINE" }, + { label: "AFK", value: "AFK" }, + { label: "DND", value: "DND" }, + ]; + + /** Updates local status state on user selection. */ + const handleStatusChange = (newStatus: UserStatus) => { + setSelectedStatus(newStatus); + }; + if (!currentUser) return null; + const userWithUpdatedSettings = { + ...currentUser, + status: selectedStatus, + }; + return (
{/* Header */}
-

Settings

+

User Settings

Manage your profile, status, and account settings.

@@ -29,7 +55,7 @@ export function SettingsView({ userId, currentUser }: SettingsViewProps) { {/* Profile Overview Card */}
- +

{currentUser.username} @@ -37,6 +63,37 @@ export function SettingsView({ userId, currentUser }: SettingsViewProps) {

{currentUser.email}

+ + {/* Status Selection */} +
+

+ Online Status +

+
+ {statuses.map((status) => { + const isSelected = selectedStatus === status.value; + const statusBgColor = MEMBER_STATUS_COLOR_CLASSES[status.value]; + + return ( + + ); + })} +
+
); diff --git a/db/schema.ts b/db/schema.ts index d3d4769..6468e58 100644 --- a/db/schema.ts +++ b/db/schema.ts @@ -30,7 +30,7 @@ export const roleEnum = pgEnum("role", [ export const userStatusEnum = pgEnum("user_status", [ "ONLINE", "OFFLINE", - "IDLE", + "AFK", "DND", ]); diff --git a/lib/constants/member.styles.ts b/lib/constants/member.styles.ts index bd8307c..a05c169 100644 --- a/lib/constants/member.styles.ts +++ b/lib/constants/member.styles.ts @@ -29,7 +29,7 @@ export const MEMBER_COLOR_OPTIONS = Object.keys(MEMBER_COLOR_CLASSES); */ export const MEMBER_STATUS_COLOR_CLASSES: Record = { ONLINE: "bg-emerald-500", - IDLE: "bg-amber-500", - DND: "bg-rose-500", OFFLINE: "bg-slate-500", + AFK: "bg-amber-500", + DND: "bg-rose-500", };