chore: initial commit for phase05

This commit is contained in:
hibna
2026-02-21 16:59:21 +03:00
parent 218452706c
commit 0941a9ba46
43 changed files with 4431 additions and 17 deletions
+58
View File
@@ -0,0 +1,58 @@
import { useQuery } from '@tanstack/react-query';
import { api } from '@/lib/api';
import { Card, CardContent } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
interface AuditLog {
id: string;
action: string;
username: string;
ipAddress: string | null;
metadata: Record<string, unknown>;
createdAt: string;
}
interface PaginatedResponse<T> {
data: T[];
meta: { total: number };
}
export function AdminAuditLogsPage() {
const { data } = useQuery({
queryKey: ['admin-audit-logs'],
queryFn: () => api.get<PaginatedResponse<AuditLog>>('/admin/audit-logs'),
});
const logs = data?.data ?? [];
return (
<div className="space-y-6">
<h1 className="text-2xl font-bold">Audit Logs</h1>
<Card>
<CardContent className="p-0">
<div className="divide-y">
{logs.map((log) => (
<div key={log.id} className="flex items-center justify-between px-4 py-3">
<div className="flex items-center gap-3">
<Badge variant="outline">{log.action}</Badge>
<span className="text-sm">
<span className="font-medium">{log.username}</span>
{log.ipAddress && (
<span className="text-muted-foreground"> from {log.ipAddress}</span>
)}
</span>
</div>
<span className="text-xs text-muted-foreground">
{new Date(log.createdAt).toLocaleString()}
</span>
</div>
))}
{logs.length === 0 && (
<div className="py-12 text-center text-muted-foreground">No audit logs</div>
)}
</div>
</CardContent>
</Card>
</div>
);
}