diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-07-03 18:22:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-03 18:22:40 +0300 |
commit | cb521315c2291eda6b273b5f8a2e014c24ea9758 (patch) | |
tree | 3a3a42a347760ccdf54dadeb7dfbcfd673f32947 /src/components/UploadImage | |
parent | 2e7f7610169391c78d852caea73190e5d8c0b978 (diff) | |
parent | 7fe63f3be94d8711bdfdf714d9a6129318546ef1 (diff) | |
download | which-ui-cb521315c2291eda6b273b5f8a2e014c24ea9758.tar.gz |
Merge pull request #58 from which-ecosystem/improvements
Improvements
Diffstat (limited to 'src/components/UploadImage')
-rw-r--r-- | src/components/UploadImage/UploadImage.tsx | 23 |
1 files 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<PropTypes> = ({ setIsOpen, isOpen, callback }) => { - const [url, setUrl] = useState(''); - const [isError, setIsError] = useState(false); + const [url, setUrl] = useState<string>(''); const handleClose = () => { @@ -24,19 +22,8 @@ const UploadImage: React.FC<PropTypes> = ({ 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<HTMLInputElement>) => { @@ -49,7 +36,7 @@ const UploadImage: React.FC<PropTypes> = ({ setIsOpen, isOpen, callback }) => { <DialogTitle>Upload an Image</DialogTitle> <DialogContent> <DialogContentText> - 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: </DialogContentText> <TextField autoFocus @@ -60,8 +47,6 @@ const UploadImage: React.FC<PropTypes> = ({ setIsOpen, isOpen, callback }) => { fullWidth autoComplete="off" onChange={handleChange} - error={isError} - helperText={isError === true ? 'invalid Url!' : ''} /> </DialogContent> <DialogActions> |