import { useTheme } from "@emotion/react"; import PropTypes from "prop-types"; import { Box, IconButton, LinearProgress, Stack, Typography } from "@mui/material"; import CloseIcon from "@mui/icons-material/Close"; import ErrorOutlineOutlinedIcon from "@mui/icons-material/ErrorOutlineOutlined"; import "./index.css"; /** * @param {Object} props - The component props. * @param {JSX.Element} props.icon - The icon element to display (optional). * @param {string} props.label - The label text for the progress item. * @param {string} props.size - The size information for the progress item. * @param {number} props.progress - The current progress value (0-100). * @param {function} props.onClick - The function to handle click events on the remove button. * @param {string} props.error - Error message to display if there's an error (optional). * @returns {JSX.Element} The rendered component. */ const ProgressUpload = ({ icon, label, size, progress = 0, onClick, error }) => { const theme = useTheme(); return ( .MuiStack-root > svg": { fill: theme.palette.error.contrastText, width: "20px", height: "20px", }, }, }} > {error ? ( ) : icon ? ( {icon} ) : ( "" )} {error ? ( {error} ) : ( {error ? error : label} {!error && size} )} {!error ? ( {progress} % ) : ( "" )} ); }; ProgressUpload.propTypes = { icon: PropTypes.element, // JSX element for the icon (optional) label: PropTypes.string.isRequired, // Label text for the progress item size: PropTypes.string.isRequired, // Size information for the progress item progress: PropTypes.number.isRequired, // Current progress value (0-100) onClick: PropTypes.func.isRequired, // Function to handle click events on the remove button error: PropTypes.string, // Error message to display if there's an error (optional) }; export default ProgressUpload;