"use client"; import { useCallback, useState } from 'react'; import { Button, Label, LoadingWithAnimation, } from "@common/components"; import DataGrid from '@/components/module/DataGrid'; import { CodeSelectWithAll } from '@/entities/code'; import { statisticsAPi } from '@/entities/statistics/api/statistics-service'; import type { StatisticsLogRequest } from '@/entities/statistics/model/statistics-interface'; import { toGridRows } from '@/components/util/grid/gridFunction'; import { LogHistoryColumn } from '@/components/util/column/management/LogHistoryColumn'; import { LogHistoryTablePagination } from '@/components/statistics/management/LogHistoryTablePagination'; const PAGE_SIZE = 100; const LogHistory = () => { // const { setMessage: alert } = useAlertStore((state) => state); const [statsCd, setStatsCd] = useState(''); const [isLoading, setIsLoading] = useState(false); const [rowData, setRowData] = useState[]>([]); const [pageIndex, setPageIndex] = useState(0); const [totalPages, setTotalPages] = useState(0); const loadLogs = useCallback(async (page1Based: number) => { const param: StatisticsLogRequest = { statsCd: (statsCd === '' || statsCd === 'ALL') ? '' : statsCd, page: page1Based, size: PAGE_SIZE, }; try { setIsLoading(true); const response = await statisticsAPi.getLogList(param); if (response.status === 'success') { setRowData(toGridRows(response.data?.statsLogList ?? [])); setTotalPages(response.data?.pageInfo?.totalPages ?? 0); setPageIndex(Math.max(0, page1Based - 1)); } else { alert(response.message || '데이터 조회 중 오류가 발생했습니다.'); } } catch { alert('데이터 조회 중 오류가 발생했습니다.'); } finally { setIsLoading(false); } }, [statsCd]); const handleSearch = async (e: React.FormEvent) => { e.preventDefault(); await loadLogs(1); }; return (
{isLoading &&
} { }} /> { void loadLogs(idx + 1); }} />
); }; export default LogHistory;