2026-01-07 09:31:02 +00:00
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
|
import { Card } from '../ui/card';
|
|
|
|
|
import { Button } from '../ui/button';
|
|
|
|
|
import { Badge } from '../ui/badge';
|
|
|
|
|
import { Report } from '../../types';
|
2026-01-13 18:47:57 +00:00
|
|
|
import {
|
|
|
|
|
ShieldAlert,
|
|
|
|
|
CheckCircle,
|
|
|
|
|
Ban,
|
|
|
|
|
MessageSquare,
|
|
|
|
|
Clock,
|
|
|
|
|
Loader2,
|
|
|
|
|
} from 'lucide-react';
|
2026-01-26 13:12:17 +00:00
|
|
|
import { useToast } from '../../components/feedback/ToastProvider';
|
2026-01-07 09:31:02 +00:00
|
|
|
import { adminService } from '../../services/adminService';
|
|
|
|
|
import { logger } from '@/utils/logger';
|
|
|
|
|
|
|
|
|
|
export const AdminModerationView: React.FC = () => {
|
|
|
|
|
const { addToast } = useToast();
|
|
|
|
|
const [queue, setQueue] = useState<Report[]>([]);
|
2026-01-13 18:47:57 +00:00
|
|
|
const [activeTab, setActiveTab] = useState<
|
|
|
|
|
'pending' | 'reviewed' | 'resolved'
|
|
|
|
|
>('pending');
|
2026-01-07 09:31:02 +00:00
|
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2026-01-13 18:47:57 +00:00
|
|
|
const loadQueue = async () => {
|
|
|
|
|
setLoading(true);
|
|
|
|
|
try {
|
|
|
|
|
const data = await adminService.getModerationQueue('all');
|
|
|
|
|
setQueue(data);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
logger.error('Error loading moderation queue', {
|
|
|
|
|
error: e instanceof Error ? e.message : String(e),
|
|
|
|
|
stack: e instanceof Error ? e.stack : undefined,
|
|
|
|
|
});
|
|
|
|
|
} finally {
|
|
|
|
|
setLoading(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
loadQueue();
|
2026-01-07 09:31:02 +00:00
|
|
|
}, []);
|
|
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
const filteredQueue = queue.filter((r) =>
|
|
|
|
|
activeTab === 'pending'
|
|
|
|
|
? r.status === 'pending'
|
|
|
|
|
: activeTab === 'reviewed'
|
|
|
|
|
? r.status === 'reviewed'
|
|
|
|
|
: r.status === 'resolved' || r.status === 'dismissed',
|
2026-01-07 09:31:02 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const handleAction = async (id: string, action: string) => {
|
2026-01-13 18:47:57 +00:00
|
|
|
try {
|
|
|
|
|
await adminService.resolveReport(id, action);
|
|
|
|
|
addToast(`Report ${action}`, 'success');
|
|
|
|
|
setQueue(
|
|
|
|
|
queue.map((r) =>
|
|
|
|
|
r.id === id
|
|
|
|
|
? ({
|
|
|
|
|
...r,
|
|
|
|
|
status: action === 'dismissed' ? 'dismissed' : 'resolved',
|
|
|
|
|
} as any)
|
|
|
|
|
: r,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
addToast('Action failed', 'error');
|
|
|
|
|
}
|
2026-01-07 09:31:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="space-y-6 animate-fadeIn pb-20">
|
2026-01-15 22:54:05 +00:00
|
|
|
<h2 className="text-2xl font-display font-bold text-white mb-6">
|
2026-01-13 18:47:57 +00:00
|
|
|
MODERATION QUEUE
|
|
|
|
|
</h2>
|
2026-01-07 09:31:02 +00:00
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
<div className="border-b border-kodo-steel flex gap-6 mb-6">
|
|
|
|
|
{['pending', 'reviewed', 'resolved'].map((tab) => (
|
|
|
|
|
<button
|
|
|
|
|
key={tab}
|
|
|
|
|
onClick={() => setActiveTab(tab as any)}
|
2026-01-16 00:59:31 +00:00
|
|
|
className={`pb-3 text-sm font-bold uppercase tracking-wider border-b-2 transition-colors ${activeTab === tab ? 'border-kodo-red text-white' : 'border-transparent text-kodo-content-dim hover:text-kodo-text-main'}`}
|
2026-01-13 18:47:57 +00:00
|
|
|
>
|
|
|
|
|
{tab} (
|
|
|
|
|
{
|
|
|
|
|
queue.filter((r) =>
|
|
|
|
|
tab === 'pending'
|
|
|
|
|
? r.status === 'pending'
|
|
|
|
|
: tab === 'reviewed'
|
|
|
|
|
? r.status === 'reviewed'
|
|
|
|
|
: r.status === 'resolved' || r.status === 'dismissed',
|
|
|
|
|
).length
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
2026-01-07 09:31:02 +00:00
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
<div className="space-y-4">
|
|
|
|
|
{loading && (
|
aesthetic-improvements: align spacing to 8px grid (Action 11.2.1.3)
- Created automated script (scripts/align-8px-grid.py) to align all spacing to 8px grid
- Replaced non-8px-aligned spacing: gap-3/p-3/m-3 (12px) → gap-4/p-4/m-4 (16px), gap-5/p-5/m-5 (20px) → gap-6/p-6/m-6 (24px), gap-10/p-10/m-10 (40px) → gap-12/p-12/m-12 (48px), gap-20/p-20/m-20 (80px) → gap-24/p-24/m-24 (96px)
- Preserved: 4px values (gap-1, p-1, m-1) as they may be intentional fine-tuning, responsive breakpoints (sm:, md:, lg:), test files, documentation
- Modified files across all components to ensure consistent 8px grid alignment
- Action 11.2.1.3: Align all elements to 8px grid - COMPLETE
2026-01-16 10:50:46 +00:00
|
|
|
<div className="flex justify-center py-24">
|
aesthetic-improvements: reduce decorative cyan across multiple component categories (80/20 rule, batch 11)
- Social: FeedView, ConnectionsView, GroupsView, ExploreView, GroupDetailView loading spinners and decorative text, CreatePostModal decorative select text and hashtag links, PostCard decorative tag links and waveform bars and view comments link, CreateGroupModal decorative icon (9 instances)
- Settings: DataExportModal decorative icon, LoginHistory decorative IP text, AppearanceSettingsView decorative icon and selected theme checkmark, BackupsView decorative icon, CloudIntegrationView decorative icon, AccessibilitySettingsView decorative icon, SecuritySettings decorative icon, PasskeyModal decorative icon and loading spinner (8 instances)
- Studio: ProjectsManager loading spinner and progress percentage text, CloudFileBrowser decorative music icons, AIToolsView decorative music icon, ConnectivityView decorative icon, CreateProjectModal decorative icon, CloudSettingsView decorative icon (6 instances)
- Admin: AdminDashboardView loading spinner and decorative chart bars and icon, AdminSettingsView decorative icon, AdminModerationView loading spinner, AdminUsersView loading spinner (5 instances)
- Inventory: InventoryView loading spinner, EquipmentCard decorative price icon, EquipmentDetailView loading spinner and decorative icons and price text, AddEquipmentView decorative icon (5 instances)
- Seller: CreateProductView decorative icon, SellerDashboardView loading spinner and decorative icon and sales text (3 instances)
- Live: LiveStreamDetailView decorative streamer name text (1 instance)
- Developer: DeveloperDashboardView loading spinner, WebhooksView decorative icon (2 instances)
- Upload: BulkUploadModal decorative icon, FilePreviewCard decorative audio file icon, MetadataForm decorative button text, CoverArtUploadModal decorative icon, LyricsEditorModal decorative icon (5 instances)
- Notifications: NotificationItem decorative follow icon and mark as read button, NotificationBell decorative mark all read link (3 instances)
- Total: ~46 files, ~46 instances replaced
- Preserved: Active/selected states (CloudFileBrowser selected files checkmarks, CreatePostModal post type active state, GroupCard/GroupDetailView public/private badges - semantic indicators, DataExportModal checkbox accents - focus/interaction, AppearanceSettingsView selected theme - active state, PasskeyModal checkbox accent - focus/interaction, LyricsEditorModal checkbox accent - focus/interaction, FileUploadZone drag active state - active state, EquipmentDetailView support link - functional link, FlashSaleModal link - functional link, EquipmentDetailView image indicator dots - active state), primary actions, design system variants
- Action 11.3.1.3 in progress (eleventh batch: social, settings, studio, admin, inventory, seller, live, developer, upload, notifications components)
2026-01-16 10:26:33 +00:00
|
|
|
<Loader2 className="w-8 h-8 text-kodo-steel animate-spin" />
|
2026-01-13 18:47:57 +00:00
|
|
|
</div>
|
|
|
|
|
)}
|
2026-01-07 09:31:02 +00:00
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
{!loading && filteredQueue.length === 0 && (
|
aesthetic-improvements: align spacing to 8px grid (Action 11.2.1.3)
- Created automated script (scripts/align-8px-grid.py) to align all spacing to 8px grid
- Replaced non-8px-aligned spacing: gap-3/p-3/m-3 (12px) → gap-4/p-4/m-4 (16px), gap-5/p-5/m-5 (20px) → gap-6/p-6/m-6 (24px), gap-10/p-10/m-10 (40px) → gap-12/p-12/m-12 (48px), gap-20/p-20/m-20 (80px) → gap-24/p-24/m-24 (96px)
- Preserved: 4px values (gap-1, p-1, m-1) as they may be intentional fine-tuning, responsive breakpoints (sm:, md:, lg:), test files, documentation
- Modified files across all components to ensure consistent 8px grid alignment
- Action 11.2.1.3: Align all elements to 8px grid - COMPLETE
2026-01-16 10:50:46 +00:00
|
|
|
<div className="text-center py-24 text-kodo-content-dim">
|
2026-01-13 18:47:57 +00:00
|
|
|
<ShieldAlert className="w-12 h-12 mx-auto mb-4 opacity-30" />
|
|
|
|
|
<p>All caught up! No reports in this queue.</p>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2026-01-07 09:31:02 +00:00
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
{!loading &&
|
|
|
|
|
filteredQueue.map((report) => (
|
|
|
|
|
<Card
|
|
|
|
|
key={report.id}
|
|
|
|
|
variant="default"
|
|
|
|
|
className="border-l-4 border-l-kodo-red"
|
|
|
|
|
>
|
|
|
|
|
<div className="flex flex-col md:flex-row justify-between gap-4">
|
|
|
|
|
<div className="flex-1">
|
aesthetic-improvements: align spacing to 8px grid (Action 11.2.1.3)
- Created automated script (scripts/align-8px-grid.py) to align all spacing to 8px grid
- Replaced non-8px-aligned spacing: gap-3/p-3/m-3 (12px) → gap-4/p-4/m-4 (16px), gap-5/p-5/m-5 (20px) → gap-6/p-6/m-6 (24px), gap-10/p-10/m-10 (40px) → gap-12/p-12/m-12 (48px), gap-20/p-20/m-20 (80px) → gap-24/p-24/m-24 (96px)
- Preserved: 4px values (gap-1, p-1, m-1) as they may be intentional fine-tuning, responsive breakpoints (sm:, md:, lg:), test files, documentation
- Modified files across all components to ensure consistent 8px grid alignment
- Action 11.2.1.3: Align all elements to 8px grid - COMPLETE
2026-01-16 10:50:46 +00:00
|
|
|
<div className="flex items-center gap-4 mb-2">
|
2026-01-13 18:47:57 +00:00
|
|
|
<Badge label={report.targetType} variant="terminal" />
|
|
|
|
|
<span className="font-bold text-white text-lg">
|
|
|
|
|
{report.targetName}
|
|
|
|
|
</span>
|
2026-01-16 00:59:31 +00:00
|
|
|
<span className="text-xs text-kodo-content-dim font-mono flex items-center gap-1">
|
2026-01-13 18:47:57 +00:00
|
|
|
<Clock className="w-3 h-3" /> {report.timestamp}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
aesthetic-improvements: align spacing to 8px grid (Action 11.2.1.3)
- Created automated script (scripts/align-8px-grid.py) to align all spacing to 8px grid
- Replaced non-8px-aligned spacing: gap-3/p-3/m-3 (12px) → gap-4/p-4/m-4 (16px), gap-5/p-5/m-5 (20px) → gap-6/p-6/m-6 (24px), gap-10/p-10/m-10 (40px) → gap-12/p-12/m-12 (48px), gap-20/p-20/m-20 (80px) → gap-24/p-24/m-24 (96px)
- Preserved: 4px values (gap-1, p-1, m-1) as they may be intentional fine-tuning, responsive breakpoints (sm:, md:, lg:), test files, documentation
- Modified files across all components to ensure consistent 8px grid alignment
- Action 11.2.1.3: Align all elements to 8px grid - COMPLETE
2026-01-16 10:50:46 +00:00
|
|
|
<div className="bg-kodo-ink p-4 rounded border border-kodo-steel/50 mb-3">
|
2026-01-13 18:47:57 +00:00
|
|
|
<div className="text-xs font-bold text-kodo-red uppercase mb-1">
|
|
|
|
|
Reason: {report.reason}
|
2026-01-07 09:31:02 +00:00
|
|
|
</div>
|
2026-01-16 00:59:31 +00:00
|
|
|
<p className="text-sm text-kodo-text-main">
|
2026-01-13 18:47:57 +00:00
|
|
|
{report.description}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2026-01-16 00:59:31 +00:00
|
|
|
<div className="text-xs text-kodo-content-dim">
|
2026-01-13 18:47:57 +00:00
|
|
|
Reported by:{' '}
|
|
|
|
|
<span className="text-white">{report.reportedBy}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="flex flex-col gap-2 justify-center min-w-[140px]">
|
|
|
|
|
<Button
|
|
|
|
|
variant="primary"
|
|
|
|
|
size="sm"
|
2026-01-16 00:59:31 +00:00
|
|
|
className="bg-kodo-red hover:bg-kodo-red border-kodo-red text-white"
|
2026-01-13 18:47:57 +00:00
|
|
|
icon={<Ban className="w-4 h-4" />}
|
|
|
|
|
onClick={() => handleAction(report.id, 'banned')}
|
|
|
|
|
>
|
|
|
|
|
Ban User
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant="secondary"
|
|
|
|
|
size="sm"
|
|
|
|
|
icon={<CheckCircle className="w-4 h-4" />}
|
|
|
|
|
onClick={() => handleAction(report.id, 'resolved')}
|
|
|
|
|
>
|
|
|
|
|
Resolve
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="sm"
|
|
|
|
|
icon={<MessageSquare className="w-4 h-4" />}
|
|
|
|
|
onClick={() => addToast('Warning sent')}
|
|
|
|
|
>
|
|
|
|
|
Send Warning
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="sm"
|
2026-01-16 00:59:31 +00:00
|
|
|
className="text-kodo-content-dim hover:text-white"
|
2026-01-13 18:47:57 +00:00
|
|
|
onClick={() => handleAction(report.id, 'dismissed')}
|
|
|
|
|
>
|
|
|
|
|
Dismiss
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Card>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
2026-01-07 09:31:02 +00:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|