diff --git a/components/settings/SettingsHeader.tsx b/components/settings/SettingsHeader.tsx new file mode 100644 index 0000000..492f6a9 --- /dev/null +++ b/components/settings/SettingsHeader.tsx @@ -0,0 +1,18 @@ +/** + * @file components/settings/SettingsHeader.tsx + * @description Header section for the settings view with title and subtitle. + */ + +"use client"; + +/** Renders the settings view header containing the main title and description. */ +export function SettingsHeader() { + return ( +
+

User Settings

+

+ Manage your profile, status, and account settings. +

+
+ ); +} diff --git a/components/settings/SettingsProfileCard.tsx b/components/settings/SettingsProfileCard.tsx new file mode 100644 index 0000000..8d4b953 --- /dev/null +++ b/components/settings/SettingsProfileCard.tsx @@ -0,0 +1,105 @@ +/** + * @file components/settings/SettingsProfileCard.tsx + * @description Card component managing user profile overview, status picker, and color selection. + */ + +"use client"; + +import { UserAvatar } from "@/components/ui/UserAvatar"; +import { UserStatus } from "@/db/schema"; +import { + MEMBER_STATUS_COLOR_CLASSES, + MEMBER_COLOR_OPTIONS, +} from "@/lib/constants/member.styles"; +import { UserRound, Palette } from "lucide-react"; +import { useUser } from "@/lib/context/UserContext"; + +/** Props for the SettingsProfileCard component. */ +interface SettingsProfileCardProps { + onUpdate: (fields: Partial<{ status: UserStatus; color: string }>) => void; +} + +const STATUSES: { label: string; value: UserStatus }[] = [ + { label: "Online", value: "ONLINE" }, + { label: "Offline", value: "OFFLINE" }, + { label: "AFK", value: "AFK" }, + { label: "DND", value: "DND" }, +]; + +/** Renders a card for managing user profile details, online status, and theme color preferences. */ +export function SettingsProfileCard({ onUpdate }: SettingsProfileCardProps) { + const { currentUser } = useUser(); + + if (!currentUser) return null; + + return ( +
+ {/* User Info Header */} +
+ +
+

+ {currentUser.username} +

+

{currentUser.email}

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

+ Online Status +

+
+ {STATUSES.map((status) => { + const isSelected = currentUser.status === status.value; + return ( + + ); + })} +
+
+ + {/* Color Palette Selection */} +
+

+ Profile Color +

+
+ {MEMBER_COLOR_OPTIONS.map((colorClass) => { + const isSelected = currentUser.color === colorClass; + return ( +
+
+
+ ); +} diff --git a/components/settings/SettingsView.tsx b/components/settings/SettingsView.tsx index e27b6b1..50f6708 100644 --- a/components/settings/SettingsView.tsx +++ b/components/settings/SettingsView.tsx @@ -1,30 +1,18 @@ /** * @file components/settings/SettingsView.tsx - * @description Settings view component for updating user profile attributes like online status and avatar color. + * @description Main container for user settings view displaying header and profile card. */ "use client"; -import { UserAvatar } from "@/components/ui/UserAvatar"; -import { UserStatus } from "@/db/schema"; -import { - MEMBER_STATUS_COLOR_CLASSES, - MEMBER_COLOR_OPTIONS, -} from "@/lib/constants/member.styles"; -import { UserRound, Palette } from "lucide-react"; import { useUser } from "@/lib/context/UserContext"; +import { SettingsHeader } from "./SettingsHeader"; +import { SettingsProfileCard } from "./SettingsProfileCard"; -/** Renders the user settings view allowing profile, online status, and color customizations. */ +/** Renders the settings view layout for managing user profile settings. */ export function SettingsView() { const { currentUser, updateCurrentUser } = useUser(); - const statuses: { label: string; value: UserStatus }[] = [ - { label: "Online", value: "ONLINE" }, - { label: "Offline", value: "OFFLINE" }, - { label: "AFK", value: "AFK" }, - { label: "DND", value: "DND" }, - ]; - /** Sends optimistic updates to context and persists profile changes to the server API. */ const updateProfile = (fields: Partial) => { updateCurrentUser(fields); @@ -39,82 +27,8 @@ export function SettingsView() { return (
- {/* Header */} -
-

User Settings

-

- Manage your profile, status, and account settings. -

-
- - {/* Profile Overview Card */} -
-
- -
-

- {currentUser.username} -

-

{currentUser.email}

-
-
- - {/* Status Selection */} -
-

- Online Status -

-
- {statuses.map((status) => { - const isSelected = currentUser.status === status.value; - return ( - - ); - })} -
-
- - {/* Color Palette Selection */} -
-

- Profile Color -

-
- {MEMBER_COLOR_OPTIONS.map((colorClass) => { - const isSelected = currentUser.color === colorClass; - return ( -
-
-
+ +
); }