import React, { useState } from 'react'; import { makeStyles } from '@material-ui/core/styles'; import { CardActionArea, CardMedia, Typography } from '@material-ui/core'; import ClearIcon from '@material-ui/icons/CancelOutlined'; import AttachLink from '../../components/AttachLink/AttachLink'; import FileUpload from '../../components/FileUpload/FileUpload'; interface PropTypes { callback: (file?: File | string) => void; } const useStyles = makeStyles({ root: { display: 'flex', justifyContent: 'center', flexDirection: 'column', alignItems: 'center', width: '50%' }, clearIcon: { opacity: '.5', fontSize: 50 }, media: { height: '100%', width: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center' } }); const PollCreationImage: React.FC = ({ callback }) => { const classes = useStyles(); const [url, setUrl] = useState(); const handleClear = (): void => { setUrl(undefined); callback(undefined); }; const childrenCallback = (fileUrl: string, file?: File) => { setUrl(fileUrl); callback(file || fileUrl); }; const Upload = (
or
); const Media = ( ); return url ? Media : Upload; }; export default PollCreationImage;