diff --git a/src/pages/AuditLogs.jsx b/src/pages/AuditLogs.jsx index e6cd05d..7b3f741 100644 --- a/src/pages/AuditLogs.jsx +++ b/src/pages/AuditLogs.jsx @@ -1,56 +1,87 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; +import { API_BASE_URL } from '../config'; +import { useAuth } from '../context/AuthContext'; const AuditLogs = () => { - const [logs] = useState([ - { id: 221, admin: 'admin', action: 'approve_seller', target: 'Seller #2', details: 'KYC verified for ElectroHub', time: '2026-08-15 15:30:22' }, - { id: 220, admin: 'admin', action: 'issue_refund', target: 'Order #ORD88761', details: '₹2,499.00 processed via PhonePe', time: '2026-08-15 14:15:10' }, - { id: 219, admin: 'moderator', action: 'create_return', target: 'Order #ORD88120', details: 'Shadowfax AWB SF_RET_AWB_776152', time: '2026-08-14 11:22:45' }, - { id: 218, admin: 'admin', action: 'hold_product', target: 'Product #101', details: 'Held: Stock verification pending', time: '2026-08-12 09:05:00' }, - ]); + const { token } = useAuth(); + const [logs, setLogs] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + const fetchLogs = async () => { + try { + setLoading(true); + const res = await fetch(`${API_BASE_URL}/audit-logs/`, { + headers: { + 'Authorization': `Bearer ${token}` + } + }); + if (!res.ok) throw new Error('Failed to fetch system audit logs'); + const data = await res.json(); + setLogs(data); + } catch (err) { + setError(err.message); + } finally { + setLoading(false); + } + }; + fetchLogs(); + }, [token]); return (
| Log ID | -Admin User | -Action | -Target Object | -Operation Details | -Timestamp | -||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| #{log.id} | -{log.admin} | -- - {log.action} - - | -{log.target} | -{log.details} | -{log.time} | + {loading ? ( +
| Log ID | +Admin User | +Action | +Target Object | +Operation Details | +Timestamp |
|---|
Verify uploaded KYC Aadhar and PAN records.
-Approve wallet transfers and input Bank UTR details.
-Check failed doorstep quality check (QC) status.
-{task.desc}
+