aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-07-03 17:44:02 +0300
committereug-vs <eug-vs@keemail.me>2020-07-03 17:44:02 +0300
commitd68052300c2f52dfd0396a64f16645d639b8a52b (patch)
treebcb6da001c5f05204b0c9b9d9ea013eced306ec7
parent58d4c457ba418837acfceaac6ed787797ca73a6b (diff)
downloadwhich-ui-d68052300c2f52dfd0396a64f16645d639b8a52b.tar.gz
feat!: remove url validation
-rw-r--r--src/components/UploadImage/UploadImage.tsx23
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>