diff --git a/app/(manage)/manage/users/users-client.tsx b/app/(manage)/manage/users/users-client.tsx index c3a267b..9a26dae 100644 --- a/app/(manage)/manage/users/users-client.tsx +++ b/app/(manage)/manage/users/users-client.tsx @@ -3,7 +3,7 @@ import { useEffect, useMemo, useState } from "react" import Image from "next/image" import { authClient } from "@/lib/auth-client" -import { Loader2, SearchIcon, BanIcon, UserCheckIcon } from "lucide-react" +import { Loader2, SearchIcon, BanIcon, UserCheckIcon, ShieldIcon, UsersIcon } from "lucide-react" type Role = "user" | "contributor" | "admin" @@ -30,6 +30,21 @@ function getInitial(name: string) { return name?.charAt(0)?.toUpperCase() || "?" } +function RoleBadge({ role }: { role: Role }) { + const config = { + admin: { bg: "bg-red-500/10", text: "text-red-400", icon: ShieldIcon }, + contributor: { bg: "bg-blue-500/10", text: "text-blue-400", icon: UserCheckIcon }, + user: { bg: "bg-text/5", text: "text-text/50", icon: UsersIcon }, + }[role] + const Icon = config.icon + return ( + + + {role.charAt(0).toUpperCase() + role.slice(1)} + + ) +} + export function UsersClient() { const [users, setUsers] = useState([]) const [loading, setLoading] = useState(true) @@ -96,6 +111,15 @@ export function UsersClient() { return (
+ {/* Header with count */} +
+
+ +

Users

+ ({filteredUsers.length}) +
+
+ {/* Search */}
@@ -104,130 +128,94 @@ export function UsersClient() { value={search} onChange={(e) => setSearch(e.target.value)} placeholder="Search by name or email..." - className="w-full pl-9 pr-4 py-2 rounded-md bg-text/5 border border-border text-sm text-text placeholder:text-text/40 focus:outline-none focus:border-primary/60 transition-colors" + className="w-full pl-9 pr-4 py-2.5 rounded-lg bg-text/5 border border-border text-sm text-text placeholder:text-text/40 focus:outline-none focus:border-primary/60 transition-colors" />
- {/* Table */} -
- - - - - - - - - - - - {loading ? ( - - - - ) : filteredUsers.length === 0 ? ( - - - - ) : ( - filteredUsers.map((user) => ( - + + + ) : filteredUsers.length === 0 ? ( +
+ +

No users found

+
+ ) : ( +
+ {filteredUsers.map((user) => ( +
+ {/* Avatar */} + {user.image ? ( + + ) : ( +
+ {getInitial(user.name)} +
+ )} + + {/* User Info */} +
+
+

{user.name || "Unnamed"}

+ {user.banned && ( + + Banned + + )} +
+

{user.email}

+

Joined {formatDate(user.createdAt)}

+
+ + {/* Role Selector */} + + + {/* Action Button */} + {actionLoading[user.id] ? ( + + ) : user.banned ? ( +
- - - - - - )) - )} - -
- User - - Role - - Status - - Joined - - Actions -
- -
- No users found. -
-
- {user.image ? ( - - ) : ( -
- {getInitial(user.name)} -
- )} -
-

- {user.name || "Unnamed"} -

-

{user.email}

-
-
-
- - -
- - - {user.banned ? "Banned" : "Active"} - -
-
- {formatDate(user.createdAt)} - - {actionLoading[user.id] ? ( - - ) : user.banned ? ( - - ) : ( - - )} -
-
+ + Unban + + ) : ( + + )} +
+ ))} + + )} ) }