import React, { memo } from 'react'; import type { DownloadHistoryEntry, DownloadedFile } from '../types'; import DownloadHistoryItem from './DownloadHistoryItem'; import { naturalSort } from '../utils/naturalSort'; interface DownloadHistoryProps { history: DownloadHistoryEntry[]; onDelete: (id: string) => void; onRetry: (entry: DownloadHistoryEntry) => void; onErrorClick: (details: string) => void; } const DownloadHistory: React.FC = ({ history, onDelete, onRetry, onErrorClick }) => { // Sort files within each history entry by natural sort const sortedHistory = React.useMemo(() => { return history.map(entry => ({ ...entry, files: naturalSort( entry.files, (file: DownloadedFile) => file.file_name || file.name || '' ) })); }, [history]); // Chỉ hiển thị 30 records mới nhất để tối ưu hiệu suất const displayedHistory = React.useMemo(() => sortedHistory.slice(0, 30), [sortedHistory]); return (

Lịch sử tải xuống

{displayedHistory.length} / {history.length} bản ghi
{displayedHistory.length > 0 ? (
{displayedHistory.map((entry) => ( ))}
) : (

Chưa có lịch sử tải xuống.

)}
); }; export default memo(DownloadHistory);