fix: ui fixes
This commit is contained in:
@@ -8,6 +8,8 @@ import { ListShell, EmptyRow } from "@/components/list-shell";
|
||||
import { Table, THead, TR, TH, TD } from "@/components/ui/table";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Modal } from "@/components/ui/modal";
|
||||
import { RowMenu, type MenuItem } from "@/components/ui/menu";
|
||||
import { Avatar } from "@/components/ui/avatar";
|
||||
import { useConfirm } from "@/components/confirm";
|
||||
import { Input, Textarea } from "@/components/ui/input";
|
||||
import { fmtDate } from "@/lib/utils";
|
||||
@@ -44,6 +46,21 @@ export default function UsersPage() {
|
||||
}
|
||||
}
|
||||
|
||||
function menuItems(u: AdminUser): MenuItem[] {
|
||||
const items: MenuItem[] = [
|
||||
{ label: "Send notification", onClick: () => setNotify(u) },
|
||||
];
|
||||
// No ban option for fellow admins (avoid locking each other out).
|
||||
if (u.role !== "admin") {
|
||||
items.push({
|
||||
label: u.banned_at ? "Unban account" : "Ban account",
|
||||
onClick: () => toggleBan(u),
|
||||
destructive: !u.banned_at,
|
||||
});
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
return (
|
||||
<ListShell
|
||||
title="Users"
|
||||
@@ -57,7 +74,7 @@ export default function UsersPage() {
|
||||
<TR>
|
||||
<TH>User</TH>
|
||||
<TH>Email</TH>
|
||||
<TH>Role</TH>
|
||||
<TH>Posts</TH>
|
||||
<TH>Joined</TH>
|
||||
<TH className="text-right">Actions</TH>
|
||||
</TR>
|
||||
@@ -69,36 +86,30 @@ export default function UsersPage() {
|
||||
list.items.map((u) => (
|
||||
<TR key={u.id}>
|
||||
<TD>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-medium">{u.name}</span>
|
||||
{u.banned_at ? (
|
||||
<span className="rounded bg-destructive/10 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-destructive">
|
||||
Suspended
|
||||
</span>
|
||||
) : null}
|
||||
<div className="flex items-center gap-3">
|
||||
<Avatar src={u.avatar_url} name={u.name} />
|
||||
<div className="min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-medium">{u.name}</span>
|
||||
{u.banned_at ? (
|
||||
<span className="rounded bg-destructive/10 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-destructive">
|
||||
Suspended
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="text-xs text-muted-foreground">
|
||||
@{u.handle}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-xs text-muted-foreground">@{u.handle}</div>
|
||||
</TD>
|
||||
<TD>
|
||||
{u.email ?? <span className="text-muted-foreground">—</span>}
|
||||
</TD>
|
||||
<TD className="capitalize">{u.role}</TD>
|
||||
<TD>{u.post_count}</TD>
|
||||
<TD className="whitespace-nowrap">{fmtDate(u.created_at)}</TD>
|
||||
<TD className="text-right">
|
||||
<div className="flex flex-wrap justify-end gap-2">
|
||||
<Button size="sm" variant="outline" onClick={() => setNotify(u)}>
|
||||
Notify
|
||||
</Button>
|
||||
{u.role !== "admin" ? (
|
||||
<Button
|
||||
size="sm"
|
||||
variant={u.banned_at ? "outline" : "destructive"}
|
||||
onClick={() => toggleBan(u)}
|
||||
>
|
||||
{u.banned_at ? "Unban" : "Ban"}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
<RowMenu items={menuItems(u)} />
|
||||
</TD>
|
||||
</TR>
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user