From d68052300c2f52dfd0396a64f16645d639b8a52b Mon Sep 17 00:00:00 2001 From: eug-vs Date: Fri, 3 Jul 2020 17:44:02 +0300 Subject: feat!: remove url validation --- src/components/UploadImage/UploadImage.tsx | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/components/UploadImage/UploadImage.tsx b/src/components/UploadImage/UploadImage.tsx index f5e680d..8ad65d5 100644 --- a/src/components/UploadImage/UploadImage.tsx +++ b/src/components/UploadImage/UploadImage.tsx @@ -6,7 +6,6 @@ import DialogActions from '@material-ui/core/DialogActions'; import DialogContent from '@material-ui/core/DialogContent'; import DialogContentText from '@material-ui/core/DialogContentText'; import DialogTitle from '@material-ui/core/DialogTitle'; -import get from 'axios'; interface PropTypes { isOpen: boolean; @@ -15,8 +14,7 @@ interface PropTypes { } const UploadImage: React.FC = ({ setIsOpen, isOpen, callback }) => { - const [url, setUrl] = useState(''); - const [isError, setIsError] = useState(false); + const [url, setUrl] = useState(''); const handleClose = () => { @@ -24,19 +22,8 @@ const UploadImage: React.FC = ({ setIsOpen, isOpen, callback }) => { }; const handleSubmit = () => { - get(url).then(res => { - if (res.headers['content-type'] === 'image/jpeg') { - callback(url || ''); - setIsOpen(false); - setIsError(false); - } else { - // console.warn(res); TODO: handle error if response status is ok but not an image - setIsError(true); - } - }).catch(() => { - // console.warn(err); TODO: handle error if resposne status is not ok - setIsError(true); - }); + handleClose(); + callback(url || ''); }; const handleChange = (event:React.ChangeEvent) => { @@ -49,7 +36,7 @@ const UploadImage: React.FC = ({ setIsOpen, isOpen, callback }) => { Upload an Image - Unfortunetly we do not support uploading images yet. Please provide a valid URL to your image. + Unfortunetly we do not support uploading images yet. Please provide a valid URL to your image: = ({ setIsOpen, isOpen, callback }) => { fullWidth autoComplete="off" onChange={handleChange} - error={isError} - helperText={isError === true ? 'invalid Url!' : ''} /> -- cgit v1.2.3