refactor(settings): extract MEMBER_STATUS_OPTIONS into member constants
All checks were successful
Deploy Waveform to VPS / deploy (push) Successful in 1m14s
All checks were successful
Deploy Waveform to VPS / deploy (push) Successful in 1m14s
This commit is contained in:
parent
2bc0a508ea
commit
b64356381d
2 changed files with 14 additions and 18 deletions
|
|
@ -11,6 +11,7 @@ import { UserStatus } from "@/db/schema";
|
||||||
import {
|
import {
|
||||||
MEMBER_STATUS_COLOR_CLASSES,
|
MEMBER_STATUS_COLOR_CLASSES,
|
||||||
MEMBER_COLOR_OPTIONS,
|
MEMBER_COLOR_OPTIONS,
|
||||||
|
MEMBER_STATUS_OPTIONS,
|
||||||
} from "@/lib/constants/member.styles";
|
} from "@/lib/constants/member.styles";
|
||||||
import { UserRound, Palette, ChevronDown } from "lucide-react";
|
import { UserRound, Palette, ChevronDown } from "lucide-react";
|
||||||
import { useUser } from "@/lib/context/UserContext";
|
import { useUser } from "@/lib/context/UserContext";
|
||||||
|
|
@ -21,13 +22,6 @@ interface SettingsProfileCardProps {
|
||||||
defaultOpen?: boolean;
|
defaultOpen?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const STATUSES: { label: string; value: UserStatus }[] = [
|
|
||||||
{ label: "Online", value: "ONLINE" },
|
|
||||||
{ label: "Offline", value: "OFFLINE" },
|
|
||||||
{ label: "AFK", value: "AFK" },
|
|
||||||
{ label: "DND", value: "DND" },
|
|
||||||
];
|
|
||||||
|
|
||||||
/** Renders a collapsible card for managing user profile details, status, and theme color. */
|
/** Renders a collapsible card for managing user profile details, status, and theme color. */
|
||||||
export function SettingsProfileCard({
|
export function SettingsProfileCard({
|
||||||
onUpdate,
|
onUpdate,
|
||||||
|
|
@ -72,7 +66,7 @@ export function SettingsProfileCard({
|
||||||
<UserRound className="w-4 h-4 text-muted" /> Online Status
|
<UserRound className="w-4 h-4 text-muted" /> Online Status
|
||||||
</h3>
|
</h3>
|
||||||
<div className="grid grid-cols-2 sm:grid-cols-4 gap-3">
|
<div className="grid grid-cols-2 sm:grid-cols-4 gap-3">
|
||||||
{STATUSES.map((status) => {
|
{MEMBER_STATUS_OPTIONS.map((status) => {
|
||||||
const isSelected = currentUser.status === status.value;
|
const isSelected = currentUser.status === status.value;
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
/**
|
/**
|
||||||
* @file lib/constants/member.styles.ts
|
* @file lib/constants/member.styles.ts
|
||||||
|
* @description Tailwind CSS color mapping constants and status options for server members.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { UserStatus } from "@/db/schema";
|
import type { UserStatus } from "@/db/schema";
|
||||||
|
|
||||||
/**
|
/** Shared Tailwind CSS class constants mapping available member background color keys to their respective CSS utility classes. */
|
||||||
* Shared Tailwind CSS class constants mapping available member background color keys to their respective CSS utility classes.
|
|
||||||
*/
|
|
||||||
export const MEMBER_COLOR_CLASSES: Record<string, string> = {
|
export const MEMBER_COLOR_CLASSES: Record<string, string> = {
|
||||||
"bg-indigo-500": "bg-indigo-500",
|
"bg-indigo-500": "bg-indigo-500",
|
||||||
"bg-emerald-500": "bg-emerald-500",
|
"bg-emerald-500": "bg-emerald-500",
|
||||||
|
|
@ -18,18 +17,21 @@ export const MEMBER_COLOR_CLASSES: Record<string, string> = {
|
||||||
"bg-cyan-500": "bg-cyan-500",
|
"bg-cyan-500": "bg-cyan-500",
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/** List of available color option class names for member icon selection. */
|
||||||
* List of available color option class names for member icon selection.
|
|
||||||
* Dynamically generated from MEMBER_COLOR_OPTIONS to avoid duplicate maintenance.
|
|
||||||
*/
|
|
||||||
export const MEMBER_COLOR_OPTIONS = Object.keys(MEMBER_COLOR_CLASSES);
|
export const MEMBER_COLOR_OPTIONS = Object.keys(MEMBER_COLOR_CLASSES);
|
||||||
|
|
||||||
/**
|
/** Mapping of user status keys to their respective Tailwind CSS indicator background colors. */
|
||||||
* Mapping of user status keys to their respective Tailwind CSS indicator background colors.
|
|
||||||
*/
|
|
||||||
export const MEMBER_STATUS_COLOR_CLASSES: Record<UserStatus, string> = {
|
export const MEMBER_STATUS_COLOR_CLASSES: Record<UserStatus, string> = {
|
||||||
ONLINE: "bg-emerald-500",
|
ONLINE: "bg-emerald-500",
|
||||||
OFFLINE: "bg-slate-500",
|
OFFLINE: "bg-slate-500",
|
||||||
AFK: "bg-amber-500",
|
AFK: "bg-amber-500",
|
||||||
DND: "bg-rose-500",
|
DND: "bg-rose-500",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Selectable options array for user status values and human-readable labels. */
|
||||||
|
export const MEMBER_STATUS_OPTIONS: { label: string; value: UserStatus }[] = [
|
||||||
|
{ label: "Online", value: "ONLINE" },
|
||||||
|
{ label: "Offline", value: "OFFLINE" },
|
||||||
|
{ label: "AFK", value: "AFK" },
|
||||||
|
{ label: "DND", value: "DND" },
|
||||||
|
];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue