// material-ui import RemoveCircleOutlineIcon from '@mui/icons-material/RemoveCircleOutline'; import * as React from 'react'; import { useEffect } from "react"; import { Box, IconButton, Stack, Table, TableBody, TableCell, TableHead, TableRow, Typography } from '@mui/material'; import { FormattedMessage, useIntl } from "react-intl"; // ==============================|| EVENT TABLE ||============================== // export default function UploadFileTable({ recordList, setUpdateRows, }) { const [rows, setRows] = React.useState(recordList); const intl = useIntl(); useEffect(() => { setRows(recordList); }, [recordList]); const handleCancelClick = (id) => { setRows((prevRows) => { const newRows = prevRows.filter((row) => row.id !== id); setUpdateRows(newRows); return newRows; }); }; const formatFileSize = (size) => `${Math.ceil(size / 1024)} KB`; if (rows.length === 0) { return ( ); } return ( {intl.formatMessage({ id: 'fileName' })} {intl.formatMessage({ id: 'fileSize' })} {rows.map((row) => ( handleCancelClick(row.id)} > {row.name} {formatFileSize(row.size)} ))}
); }