aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-07-05 12:34:53 +0300
committereug-vs <eug-vs@keemail.me>2020-07-05 12:34:53 +0300
commitf45a21045ce1282ce3ea14f539f52ac1bcc2a59a (patch)
tree275b67da4f9063af0ca56810263f254b59f7e157 /src
parent202f2ab4209a836e51a57081e5f78e255973c6f1 (diff)
downloadwhich-ui-f45a21045ce1282ce3ea14f539f52ac1bcc2a59a.tar.gz
feat: add isInstagramLink switch
Diffstat (limited to 'src')
-rw-r--r--src/components/UploadImage/UploadImage.tsx31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/components/UploadImage/UploadImage.tsx b/src/components/UploadImage/UploadImage.tsx
index 8ad65d5..51e43c2 100644
--- a/src/components/UploadImage/UploadImage.tsx
+++ b/src/components/UploadImage/UploadImage.tsx
@@ -1,11 +1,15 @@
import React, { useState } from 'react';
-import Button from '@material-ui/core/Button';
-import TextField from '@material-ui/core/TextField';
-import Dialog from '@material-ui/core/Dialog';
-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 {
+ Button,
+ TextField,
+ Dialog,
+ DialogActions,
+ DialogContent,
+ DialogContentText,
+ DialogTitle,
+ FormControlLabel,
+ Switch
+} from '@material-ui/core';
interface PropTypes {
isOpen: boolean;
@@ -15,6 +19,7 @@ interface PropTypes {
const UploadImage: React.FC<PropTypes> = ({ setIsOpen, isOpen, callback }) => {
const [url, setUrl] = useState<string>('');
+ const [isInstagramLink, setIsInstagramLink] = useState<boolean>(false);
const handleClose = () => {
@@ -22,14 +27,20 @@ const UploadImage: React.FC<PropTypes> = ({ setIsOpen, isOpen, callback }) => {
};
const handleSubmit = () => {
+ const result = isInstagramLink ? `${url.slice(0, url.length - 29)}/media/?size=l` : url;
+ console.log(result)
+ callback(result || '');
handleClose();
- callback(url || '');
};
const handleChange = (event:React.ChangeEvent<HTMLInputElement>) => {
setUrl(event.target.value);
};
+ const handleSwitch = () => {
+ setIsInstagramLink(!isInstagramLink);
+ };
+
return (
<div>
<Dialog open={isOpen} onClose={handleClose}>
@@ -48,6 +59,10 @@ const UploadImage: React.FC<PropTypes> = ({ setIsOpen, isOpen, callback }) => {
autoComplete="off"
onChange={handleChange}
/>
+ <FormControlLabel
+ control={<Switch color="primary" onClick={handleSwitch} checked={isInstagramLink} size="small" />}
+ label="It's an Instagram link"
+ />
</DialogContent>
<DialogActions>
<Button onClick={handleClose} color="primary">