From f45a21045ce1282ce3ea14f539f52ac1bcc2a59a Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Sun, 5 Jul 2020 12:34:53 +0300
Subject: feat: add isInstagramLink switch

---
 src/components/UploadImage/UploadImage.tsx | 31 ++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

(limited to 'src/components/UploadImage/UploadImage.tsx')

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">
-- 
cgit v1.2.3


From 7ba3047602d8850bb2f80d52448e08cc47290d23 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Sun, 5 Jul 2020 12:36:46 +0300
Subject: fix: remove console.log

---
 src/components/UploadImage/UploadImage.tsx | 1 -
 1 file changed, 1 deletion(-)

(limited to 'src/components/UploadImage/UploadImage.tsx')

diff --git a/src/components/UploadImage/UploadImage.tsx b/src/components/UploadImage/UploadImage.tsx
index 51e43c2..836b2a0 100644
--- a/src/components/UploadImage/UploadImage.tsx
+++ b/src/components/UploadImage/UploadImage.tsx
@@ -28,7 +28,6 @@ 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();
   };
-- 
cgit v1.2.3

