init
This commit is contained in:
55
app/main/admin/page.tsx
Normal file
55
app/main/admin/page.tsx
Normal file
@@ -0,0 +1,55 @@
|
||||
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>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user