import { FilterCollection } from '@/components/list-filter-bar/interface'; import SvgIcon from '@/components/svg-icon'; import { useIsDarkTheme } from '@/components/theme-provider'; import { useFetchDocumentList } from '@/hooks/use-document-request'; import { t } from 'i18next'; import { CircleQuestionMark } from 'lucide-react'; import { FC, useEffect, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { RunningStatus, RunningStatusMap } from '../dataset/constant'; import { LogTabs } from './dataset-common'; import { DatasetFilter } from './dataset-filter'; import { useFetchFileLogList, useFetchOverviewTital } from './hook'; import FileLogsTable from './overview-table'; interface StatCardProps { title: string; value: number; icon: JSX.Element; children?: JSX.Element; } interface CardFooterProcessProps { success: number; failed: number; } const StatCard: FC = ({ title, value, children, icon }) => { return (

{title}

{icon}
{value}
{children}
); }; const CardFooterProcess: FC = ({ success = 0, failed = 0, }) => { const { t } = useTranslation(); return (
{t('knowledgeDetails.success')}
{success || 0}
{t('knowledgeDetails.failed')}
{failed || 0}
); }; const filters = [ { field: 'operation_status', label: t('knowledgeDetails.status'), list: Object.values(RunningStatus).map((value) => { // const value = key as RunningStatus; console.log(value); return { id: value, label: RunningStatusMap[value].label, }; }), }, { field: 'types', label: t('knowledgeDetails.task'), list: [ { id: 'Parse', label: 'Parse', }, { id: 'Download', label: 'Download', }, ], }, ]; const FileLogsPage: FC = () => { const { t } = useTranslation(); const [topAllData, setTopAllData] = useState({ totalFiles: { value: 0, precent: 0, }, downloads: { value: 0, success: 0, failed: 0, }, processing: { value: 0, success: 0, failed: 0, }, }); const { data: topData } = useFetchOverviewTital(); const { pagination: { total: fileTotal }, } = useFetchDocumentList(); useEffect(() => { setTopAllData((prev) => { return { ...prev, processing: { value: topData?.processing || 0, success: topData?.finished || 0, failed: topData?.failed || 0, }, }; }); }, [topData]); useEffect(() => { setTopAllData((prev) => { return { ...prev, totalFiles: { value: fileTotal || 0, precent: 0, }, }; }); }, [fileTotal]); const { data: tableOriginData, searchString, handleInputChange, pagination, setPagination, active, filterValue, handleFilterSubmit, setActive, } = useFetchFileLogList(); const tableList = useMemo(() => { console.log('tableList', tableOriginData); if (tableOriginData && tableOriginData.logs?.length) { return tableOriginData.logs.map((item) => { return { ...item, fileName: item.document_name, statusName: item.operation_status, }; }); } }, [tableOriginData]); const changeActiveLogs = (active: (typeof LogTabs)[keyof typeof LogTabs]) => { setActive(active); }; const handlePaginationChange = (page: number, pageSize: number) => { console.log('Pagination changed:', { page, pageSize }); setPagination({ ...pagination, page, pageSize: pageSize, }); }; const isDark = useIsDarkTheme(); return (
{/* Stats Cards */}
) : ( ) } >
{topAllData.totalFiles.precent > 0 ? '+' : ''} {topAllData.totalFiles.precent}%{' '} from last week
) : ( ) } > ) : ( ) } >
{/* Tabs & Search */} {/* Table */}
); }; export default FileLogsPage;