/* eslint-disable no-case-declarations */ import MDBox from 'components/MDBox'; import PropTypes from 'prop-types'; import UploadIcon from 'assets/images/UploadIcon'; import MDTypography from 'components/MDTypography'; import pxToRem from 'assets/theme-dark/functions/pxToRem'; import { Button } from '@mui/material'; import Close from 'assets/images/Close'; function ImageUpload({ heading, accept, multiple, images, setImages }) { const addImage = (e) => { setImages([ ...images, { src: URL.createObjectURL(e.target.files[0]), file: e.target.files[0] } ]); }; const removeImage = (index) => { setImages(images.filter((_val, idx) => idx !== index)); }; return ( <> {!multiple && images.length ? null : } {!multiple && images.length ? 'Cannot add more images' : heading} {/* -----------img-preview----------- */} {images && images.map((item, idx) => { return ( placeholder ); })} ); } export default ImageUpload; ImageUpload.propTypes = { images: PropTypes.array, heading: PropTypes.string, multiple: PropTypes.bool, accept: PropTypes.string, setImages: PropTypes.func };