Files
twimg-frontend/app/main/admin/page.tsx
Logan Cusano 7d3f08cae9 init
2025-07-13 19:03:13 -04:00

55 lines
1.9 KiB
TypeScript

const AdminPage = () => {
const [message, setMessage] = useState('');
const [error, setError] = useState('');
const auth = useAuth();
const handleScan = async () => {
setError('');
setMessage('Scanning...');
try {
const data = await apiRequest('/videos/scan', { method: 'POST', token: auth.token });
setMessage(data.message);
} catch (err) {
setError(err.message);
}
};
// In a real app, you'd fetch users and votes here
const users = [{email: 'admin@example.com', role: 'admin'}, {email: 'user@example.com', role: 'user'}];
const votes = [{video_id: 'xyz', decision: 'approve', reason: 'Good clip'}];
if (auth.user?.role !== 'admin') {
return <p>Access Denied. You must be an admin to view this page.</p>;
}
return (
<div className="space-y-8">
<Card>
<CardHeader>
<CardTitle>Admin Actions</CardTitle>
</CardHeader>
<CardContent>
<Button onClick={handleScan}>Scan Videos Directory</Button>
{message && <p className="mt-4 text-green-600">{message}</p>}
{error && <p className="mt-4 text-red-600">{error}</p>}
</CardContent>
</Card>
<Card>
<CardHeader><CardTitle>Users</CardTitle></CardHeader>
<CardContent>
{/* User list would be rendered here */}
<p>User list functionality would go here.</p>
</CardContent>
</Card>
<Card>
<CardHeader><CardTitle>Votes</CardTitle></CardHeader>
<CardContent>
{/* Vote list would be rendered here */}
<p>Vote list functionality would go here.</p>
</CardContent>
</Card>
</div>
);
};