2026-01-07 09:31:02 +00:00
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
|
import { Card } from '../ui/card';
|
|
|
|
|
import { Button } from '../ui/button';
|
2026-01-26 13:12:17 +00:00
|
|
|
import { Input } from '../ui/input';
|
2026-01-07 09:31:02 +00:00
|
|
|
import { UserTableRow } from './UserTableRow';
|
|
|
|
|
import { BanUserModal } from './modals/BanUserModal';
|
|
|
|
|
import { User } from '../../types';
|
2026-01-26 13:12:17 +00:00
|
|
|
import { Search, Shield, Activity, Users, Download, UserPlus, Loader2 } from 'lucide-react';
|
|
|
|
|
import { useToast } from '../../components/feedback/ToastProvider';
|
2026-01-07 09:31:02 +00:00
|
|
|
import { userService } from '../../services/userService';
|
|
|
|
|
import { logger } from '@/utils/logger';
|
|
|
|
|
|
|
|
|
|
export const AdminUsersView: React.FC = () => {
|
|
|
|
|
const { addToast } = useToast();
|
|
|
|
|
const [search, setSearch] = useState('');
|
|
|
|
|
const [users, setUsers] = useState<User[]>([]);
|
|
|
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
|
const [selectedUser, setSelectedUser] = useState<User | null>(null);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2026-01-13 18:47:57 +00:00
|
|
|
const loadUsers = async () => {
|
|
|
|
|
setLoading(true);
|
|
|
|
|
try {
|
|
|
|
|
const res = await userService.list();
|
|
|
|
|
setUsers(res.users);
|
|
|
|
|
} catch (e) {
|
2026-01-26 13:12:17 +00:00
|
|
|
logger.error('Failed to load users', { error: e });
|
|
|
|
|
addToast('Failed to load neural identities', 'error');
|
2026-01-13 18:47:57 +00:00
|
|
|
} finally {
|
|
|
|
|
setLoading(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
loadUsers();
|
2026-01-07 09:31:02 +00:00
|
|
|
}, []);
|
|
|
|
|
|
2026-01-26 13:12:17 +00:00
|
|
|
const handleBan = (duration: string) => {
|
2026-01-13 18:47:57 +00:00
|
|
|
if (!selectedUser) return;
|
2026-01-26 13:12:17 +00:00
|
|
|
addToast(`Node ${selectedUser.username} quarantined for ${duration}.`, 'success');
|
|
|
|
|
setUsers(users.filter((u) => u.id !== selectedUser.id));
|
2026-01-13 18:47:57 +00:00
|
|
|
setSelectedUser(null);
|
2026-01-07 09:31:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleDelete = (user: User) => {
|
2026-01-26 13:12:17 +00:00
|
|
|
if (confirm(`INITIATE PERMANENT DELETION: ${user.username}?`)) {
|
2026-01-13 18:47:57 +00:00
|
|
|
setUsers(users.filter((u) => u.id !== user.id));
|
2026-01-26 13:12:17 +00:00
|
|
|
addToast(`Identity purged: ${user.username}`, 'info');
|
2026-01-13 18:47:57 +00:00
|
|
|
}
|
2026-01-07 09:31:02 +00:00
|
|
|
};
|
|
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
const filteredUsers = users.filter(
|
|
|
|
|
(u) =>
|
|
|
|
|
u.username.toLowerCase().includes(search.toLowerCase()) ||
|
|
|
|
|
u.email.toLowerCase().includes(search.toLowerCase()),
|
2026-01-07 09:31:02 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
2026-01-26 13:12:17 +00:00
|
|
|
<div className="space-y-6 animate-fadeIn pb-24 container py-8">
|
|
|
|
|
<div className="flex flex-col md:flex-row justify-between items-end gap-6 border-b border-white/5 pb-8">
|
2026-01-13 18:47:57 +00:00
|
|
|
<div>
|
2026-02-12 00:49:07 +00:00
|
|
|
<h2 className="text-4xl font-heading font-bold text-foreground mb-2 flex items-center gap-3 tracking-tight">
|
2026-01-26 13:12:17 +00:00
|
|
|
<Users className="text-primary w-8 h-8" /> IDENTITY GRID
|
2026-01-13 18:47:57 +00:00
|
|
|
</h2>
|
2026-01-26 13:12:17 +00:00
|
|
|
<p className="text-muted-foreground font-mono text-xs tracking-[0.2em]">USER DIRECTORY • ACCESS PERMISSIONS</p>
|
2026-01-07 09:31:02 +00:00
|
|
|
</div>
|
2026-01-26 13:12:17 +00:00
|
|
|
<div className="flex gap-3">
|
feat(ui): semantic tokens in admin views (audit logs, users, dashboard)
- AdminAuditLogsView: border/divide/bg white/5 → border-border, bg-muted/*
- AdminSettingsView: toggle indicators bg-white → bg-background
- AdminUsersView: glass cards, table, pagination → border-border, bg-muted/*
- UserTableRow: text-white → text-foreground, hover states → muted/50
- AdminDashboardHeader: text-white, divider, button → foreground/border/muted
- AdminDashboardTabs: tabs list, cards, table → semantic tokens
- AdminDashboardTabs: remove unused React import
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-10 08:37:16 +00:00
|
|
|
<Button variant="outline" onClick={() => addToast('Generating CSV matrix...', 'info')} className="border-border hover:bg-muted/50 font-mono text-xs tracking-widest uppercase">
|
2026-01-26 13:12:17 +00:00
|
|
|
<Download className="w-4 h-4 mr-2" /> Export
|
2026-01-13 18:47:57 +00:00
|
|
|
</Button>
|
ui(tokens): migrate text-[10px] to text-xs across 23 components
Replace all arbitrary text-[10px] / text-[9px] with the standard Tailwind
text-xs token. Also migrates nearby arbitrary width values where applicable
(max-w-[200px] → max-w-48, max-w-[120px] → max-w-32, h-[1px] → h-px).
Only documented exceptions remain: avatar xs (text-[10px] for w-6 h-6
initials) and badge JSDoc reference.
Affected areas: admin views, marketplace, player, settings, chat, upload,
education, commerce, library, PWA, search, navbar, user card.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-08 21:47:19 +00:00
|
|
|
<Button variant="primary" onClick={() => addToast('Opening Registration Terminal...', 'info')} className="shadow-glow-cyan font-mono text-xs tracking-widest uppercase">
|
2026-01-26 13:12:17 +00:00
|
|
|
<UserPlus className="w-4 h-4 mr-2" /> New Entity
|
2026-01-13 18:47:57 +00:00
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-01-07 09:31:02 +00:00
|
|
|
|
feat(ui): semantic tokens in admin views (audit logs, users, dashboard)
- AdminAuditLogsView: border/divide/bg white/5 → border-border, bg-muted/*
- AdminSettingsView: toggle indicators bg-white → bg-background
- AdminUsersView: glass cards, table, pagination → border-border, bg-muted/*
- UserTableRow: text-white → text-foreground, hover states → muted/50
- AdminDashboardHeader: text-white, divider, button → foreground/border/muted
- AdminDashboardTabs: tabs list, cards, table → semantic tokens
- AdminDashboardTabs: remove unused React import
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-10 08:37:16 +00:00
|
|
|
<Card variant="glass" className="p-0 overflow-hidden bg-card/80 border-border">
|
|
|
|
|
<div className="p-6 border-b border-border bg-muted/20 flex flex-col md:flex-row gap-6 justify-between items-center">
|
2026-01-26 13:12:17 +00:00
|
|
|
<div className="w-full md:w-96 relative group">
|
|
|
|
|
<Input
|
|
|
|
|
icon={<Search className="w-4 h-4" />}
|
|
|
|
|
placeholder="Search by ID or frequency..."
|
2026-01-13 18:47:57 +00:00
|
|
|
value={search}
|
2026-01-26 13:12:17 +00:00
|
|
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setSearch(e.target.value)}
|
feat(ui): semantic tokens in admin views (audit logs, users, dashboard)
- AdminAuditLogsView: border/divide/bg white/5 → border-border, bg-muted/*
- AdminSettingsView: toggle indicators bg-white → bg-background
- AdminUsersView: glass cards, table, pagination → border-border, bg-muted/*
- UserTableRow: text-white → text-foreground, hover states → muted/50
- AdminDashboardHeader: text-white, divider, button → foreground/border/muted
- AdminDashboardTabs: tabs list, cards, table → semantic tokens
- AdminDashboardTabs: remove unused React import
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-10 08:37:16 +00:00
|
|
|
className="bg-muted/30 border-border"
|
2026-01-07 09:31:02 +00:00
|
|
|
/>
|
2026-01-13 18:47:57 +00:00
|
|
|
</div>
|
2026-01-26 13:12:17 +00:00
|
|
|
<div className="flex gap-3">
|
feat(ui): semantic tokens in admin views (audit logs, users, dashboard)
- AdminAuditLogsView: border/divide/bg white/5 → border-border, bg-muted/*
- AdminSettingsView: toggle indicators bg-white → bg-background
- AdminUsersView: glass cards, table, pagination → border-border, bg-muted/*
- UserTableRow: text-white → text-foreground, hover states → muted/50
- AdminDashboardHeader: text-white, divider, button → foreground/border/muted
- AdminDashboardTabs: tabs list, cards, table → semantic tokens
- AdminDashboardTabs: remove unused React import
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-10 08:37:16 +00:00
|
|
|
<Button variant="outline" size="sm" className="bg-muted/20 border-border hover:bg-muted/50 font-mono text-xs tracking-widest uppercase h-10">
|
2026-01-26 13:12:17 +00:00
|
|
|
<Shield className="w-3 h-3 mr-2 text-primary" /> Filter Role
|
2026-01-13 18:47:57 +00:00
|
|
|
</Button>
|
feat(ui): semantic tokens in admin views (audit logs, users, dashboard)
- AdminAuditLogsView: border/divide/bg white/5 → border-border, bg-muted/*
- AdminSettingsView: toggle indicators bg-white → bg-background
- AdminUsersView: glass cards, table, pagination → border-border, bg-muted/*
- UserTableRow: text-white → text-foreground, hover states → muted/50
- AdminDashboardHeader: text-white, divider, button → foreground/border/muted
- AdminDashboardTabs: tabs list, cards, table → semantic tokens
- AdminDashboardTabs: remove unused React import
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-10 08:37:16 +00:00
|
|
|
<Button variant="outline" size="sm" className="bg-muted/20 border-border hover:bg-muted/50 font-mono text-xs tracking-widest uppercase h-10">
|
2026-01-26 13:12:17 +00:00
|
|
|
<Activity className="w-3 h-3 mr-2 text-primary" /> Filter Status
|
2026-01-13 18:47:57 +00:00
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{loading ? (
|
2026-01-26 13:12:17 +00:00
|
|
|
<div className="flex justify-center py-20 opacity-40">
|
|
|
|
|
<Loader2 className="w-12 h-12 text-primary animate-spin" />
|
2026-01-13 18:47:57 +00:00
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<div className="overflow-x-auto">
|
2026-01-26 13:12:17 +00:00
|
|
|
<table className="w-full text-left">
|
2026-01-13 18:47:57 +00:00
|
|
|
<thead>
|
feat(ui): semantic tokens in admin views (audit logs, users, dashboard)
- AdminAuditLogsView: border/divide/bg white/5 → border-border, bg-muted/*
- AdminSettingsView: toggle indicators bg-white → bg-background
- AdminUsersView: glass cards, table, pagination → border-border, bg-muted/*
- UserTableRow: text-white → text-foreground, hover states → muted/50
- AdminDashboardHeader: text-white, divider, button → foreground/border/muted
- AdminDashboardTabs: tabs list, cards, table → semantic tokens
- AdminDashboardTabs: remove unused React import
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-10 08:37:16 +00:00
|
|
|
<tr className="text-xs text-muted-foreground uppercase tracking-[0.2em] border-b border-border bg-muted/30">
|
2026-01-26 13:12:17 +00:00
|
|
|
<th className="py-4 pl-8">Identity</th>
|
|
|
|
|
<th className="py-4">Access Origin</th>
|
|
|
|
|
<th className="py-4">Assigned Roles</th>
|
|
|
|
|
<th className="py-4">Network Plan</th>
|
|
|
|
|
<th className="py-4">Registered</th>
|
|
|
|
|
<th className="py-4">Last Sync</th>
|
|
|
|
|
<th className="py-4 text-right pr-8">Management</th>
|
2026-01-13 18:47:57 +00:00
|
|
|
</tr>
|
|
|
|
|
</thead>
|
feat(ui): semantic tokens in admin views (audit logs, users, dashboard)
- AdminAuditLogsView: border/divide/bg white/5 → border-border, bg-muted/*
- AdminSettingsView: toggle indicators bg-white → bg-background
- AdminUsersView: glass cards, table, pagination → border-border, bg-muted/*
- UserTableRow: text-white → text-foreground, hover states → muted/50
- AdminDashboardHeader: text-white, divider, button → foreground/border/muted
- AdminDashboardTabs: tabs list, cards, table → semantic tokens
- AdminDashboardTabs: remove unused React import
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-10 08:37:16 +00:00
|
|
|
<tbody className="text-sm divide-y divide-border font-sans">
|
2026-01-13 18:47:57 +00:00
|
|
|
{filteredUsers.map((user) => (
|
|
|
|
|
<UserTableRow
|
|
|
|
|
key={user.id}
|
|
|
|
|
user={user}
|
|
|
|
|
onBan={() => setSelectedUser(user)}
|
|
|
|
|
onDelete={() => handleDelete(user)}
|
2026-01-26 13:12:17 +00:00
|
|
|
onEditRole={() => addToast(`Modifying access roles for ${user.username}`, 'info')}
|
2026-01-13 18:47:57 +00:00
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
{filteredUsers.length === 0 && (
|
|
|
|
|
<tr>
|
2026-01-26 13:12:17 +00:00
|
|
|
<td colSpan={7} className="p-20 text-center text-muted-foreground font-mono uppercase tracking-widest opacity-30">
|
|
|
|
|
No entities found.
|
2026-01-13 18:47:57 +00:00
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
)}
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
2026-01-07 09:31:02 +00:00
|
|
|
)}
|
2026-01-13 18:47:57 +00:00
|
|
|
|
feat(ui): semantic tokens in admin views (audit logs, users, dashboard)
- AdminAuditLogsView: border/divide/bg white/5 → border-border, bg-muted/*
- AdminSettingsView: toggle indicators bg-white → bg-background
- AdminUsersView: glass cards, table, pagination → border-border, bg-muted/*
- UserTableRow: text-white → text-foreground, hover states → muted/50
- AdminDashboardHeader: text-white, divider, button → foreground/border/muted
- AdminDashboardTabs: tabs list, cards, table → semantic tokens
- AdminDashboardTabs: remove unused React import
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-10 08:37:16 +00:00
|
|
|
<div className="p-6 border-t border-border bg-muted/20 flex justify-between items-center">
|
ui(tokens): migrate text-[10px] to text-xs across 23 components
Replace all arbitrary text-[10px] / text-[9px] with the standard Tailwind
text-xs token. Also migrates nearby arbitrary width values where applicable
(max-w-[200px] → max-w-48, max-w-[120px] → max-w-32, h-[1px] → h-px).
Only documented exceptions remain: avatar xs (text-[10px] for w-6 h-6
initials) and badge JSDoc reference.
Affected areas: admin views, marketplace, player, settings, chat, upload,
education, commerce, library, PWA, search, navbar, user card.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-08 21:47:19 +00:00
|
|
|
<span className="text-xs font-mono text-muted-foreground uppercase tracking-widest">
|
2026-01-26 13:12:17 +00:00
|
|
|
Displaying {filteredUsers.length} / {users.length} active nodes
|
2026-01-13 18:47:57 +00:00
|
|
|
</span>
|
2026-01-26 13:12:17 +00:00
|
|
|
<div className="flex gap-3">
|
feat(ui): semantic tokens in admin views (audit logs, users, dashboard)
- AdminAuditLogsView: border/divide/bg white/5 → border-border, bg-muted/*
- AdminSettingsView: toggle indicators bg-white → bg-background
- AdminUsersView: glass cards, table, pagination → border-border, bg-muted/*
- UserTableRow: text-white → text-foreground, hover states → muted/50
- AdminDashboardHeader: text-white, divider, button → foreground/border/muted
- AdminDashboardTabs: tabs list, cards, table → semantic tokens
- AdminDashboardTabs: remove unused React import
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-10 08:37:16 +00:00
|
|
|
<Button variant="outline" size="sm" disabled className="border-border opacity-50 font-mono text-xs h-9">
|
2026-01-26 13:12:17 +00:00
|
|
|
PREV
|
|
|
|
|
</Button>
|
feat(ui): semantic tokens in admin views (audit logs, users, dashboard)
- AdminAuditLogsView: border/divide/bg white/5 → border-border, bg-muted/*
- AdminSettingsView: toggle indicators bg-white → bg-background
- AdminUsersView: glass cards, table, pagination → border-border, bg-muted/*
- UserTableRow: text-white → text-foreground, hover states → muted/50
- AdminDashboardHeader: text-white, divider, button → foreground/border/muted
- AdminDashboardTabs: tabs list, cards, table → semantic tokens
- AdminDashboardTabs: remove unused React import
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-10 08:37:16 +00:00
|
|
|
<Button variant="outline" size="sm" className="border-border hover:bg-muted/50 font-mono text-xs h-9">
|
2026-01-26 13:12:17 +00:00
|
|
|
NEXT
|
consistency: replace custom buttons with Button component (partial)
- Replaced custom button implementations with Button component in 14 files
- Files updated: LiveStreamDetailView, DashboardPage, CommentItem, PostCard, SocialPage, SocialView, AdminUsersView, UserTableRow, ProjectsManager, CloudFileBrowser, FileManagerView, CreatorModal, ImageCropper, BulkUploadModal
- ~31 buttons replaced across high-priority files
- Used appropriate Button variants: ghost, outline, default, secondary, link
- Preserved visual appearance with className overrides where needed
- Action 9.2.1.2 in progress (partial completion)
2026-01-16 01:06:14 +00:00
|
|
|
</Button>
|
2026-01-13 18:47:57 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
{selectedUser && (
|
|
|
|
|
<BanUserModal
|
|
|
|
|
username={selectedUser.username}
|
|
|
|
|
onClose={() => setSelectedUser(null)}
|
2026-01-26 13:12:17 +00:00
|
|
|
onConfirm={(reason, details, duration) => handleBan(duration)}
|
2026-01-13 18:47:57 +00:00
|
|
|
/>
|
|
|
|
|
)}
|
2026-01-07 09:31:02 +00:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|