From 82082cb862c2dc5d196c767ccbfe8ed6ce6b9a18 Mon Sep 17 00:00:00 2001 From: amee Date: Fri, 3 Apr 2026 15:23:19 +0530 Subject: [PATCH] fix: .gitignore logs removed. --- .gitignore | 2 - src/application/logs/LogsPage.tsx | 99 +++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 src/application/logs/LogsPage.tsx diff --git a/.gitignore b/.gitignore index a547bf3..75a23ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ # Logs -logs -*.log npm-debug.log* yarn-debug.log* yarn-error.log* diff --git a/src/application/logs/LogsPage.tsx b/src/application/logs/LogsPage.tsx new file mode 100644 index 0000000..f670fe9 --- /dev/null +++ b/src/application/logs/LogsPage.tsx @@ -0,0 +1,99 @@ +import { useEffect, useState } from 'react'; +import { History, RefreshCcw } from "lucide-react"; +import { DataTable } from "../../components/custom/CustomTable"; +import type { ColumnDef } from '../../components/custom/CustomTable'; +import CustomButton from "../../components/custom/CustomButton"; +import { apiClient } from "../../lib/apiClient"; + +interface AuditLog extends Record { + id: string; + module_name: string; + action_type: string; + entity_name: string; + performed_by_email: string; + ip_address: string; + description: string; + created_at: string; +} + +interface AuditLogListResponse { + items: AuditLog[]; + total: number; + limit: number; + offset: number; +} + +const LogsPage = () => { + const [logs, setLogs] = useState([]); + const [isLoading, setIsLoading] = useState(true); + + const fetchLogs = async () => { + try { + setIsLoading(true); + const response = await apiClient.get( + '/api/admin/audit-logs/', + { silent: true } + ); + setLogs(response.items); + } catch (error) { + console.error("Failed to fetch logs", error); + } finally { + setIsLoading(false); + } + }; + + useEffect(() => { + fetchLogs(); + }, []); + + const columns: ColumnDef[] = [ + { key: "module_name", header: "Module", searchable: true }, + { + key: "action_type", + header: "Action", + render: (row) => ( + + {row.action_type} + + ) + }, + { key: "description", header: "Description" }, + { key: "performed_by_email", header: "Performed By", searchable: true }, + { key: "ip_address", header: "IP Address" }, + { + key: "created_at", + header: "Timestamp", + render: (row) => new Date(row.created_at).toLocaleString() + }, + ]; + + return ( +
+
+

+ System Logs +

+ } + > + Refresh + +
+ + + data={logs} + columns={columns} + isLoading={isLoading} + exportFileName="audit_logs.csv" + /> +
+ ); +}; + +export default LogsPage; \ No newline at end of file