import React, { useState } from "react"; import { DocumentText, DocumentDownload, Refresh, Activity, InfoCircle } from "iconsax-react"; import Button from "../../components/Button"; import Pagination from "../../components/Pagination"; import TitleLine from "../../components/TitleLine"; import PageLoading from "../../components/PageLoading"; // import Error from "../../components/Error"; // Using custom error display import FilterPanel from "./components/FilterPanel"; import AccessLogsTable from "./components/AccessLogsTable"; import LogDetailsModal from "./components/LogDetailsModal"; import { useAccessLogs, useAccessLogDetail } from "./hooks/useAccessLogs"; import { AccessLog } from "./types/AccessLogTypes"; const AccessLogsList: React.FC = () => { const { logs, loading, error, total, filters, updateFilters, resetFilters, exportLogs, refetch, } = useAccessLogs(); const { log: selectedLog, fetchLog, clearLog } = useAccessLogDetail(); const [isDetailsModalOpen, setIsDetailsModalOpen] = useState(false); const handleViewDetails = async (log: AccessLog) => { await fetchLog(log.id); setIsDetailsModalOpen(true); }; const handleCloseDetailsModal = () => { setIsDetailsModalOpen(false); clearLog(); }; const handleSort = (field: string, order: "ASC" | "DESC") => { updateFilters({ sortBy: field, sortOrder: order }); }; const handlePageChange = (page: number) => { updateFilters({ page }); }; const handleExport = async () => { try { await exportLogs(); } catch (error) { console.error("خطا در خروجی گرفتن:", error); } }; if (error) { return (

{error}

); } return (
{/* Header */}

مشاهده و مدیریت تمام فعالیت‌های سیستم

{/* Stats Summary */}

کل لاگ‌ها

{(total || 0).toLocaleString('fa-IR')}

صفحه فعلی

{filters.page || 1}

نمایش در صفحه

{filters.limit || 20}

{/* Filter Panel */} {/* Loading State */} {loading && } {/* Table */} {!loading && ( <> {/* Pagination */} {total > (filters.limit || 20) && (
)} )} {/* Details Modal */} {/* Empty State Info */} {!loading && (!logs || logs.length === 0) && !error && (

راهنما

از فیلترهای بالا برای جستجوی دقیق‌تر استفاده کنید. می‌توانید بر اساس نوع عملیات، کاربر، تاریخ و سایر معیارها جستجو کنید.

)}
); }; export default AccessLogsList;