import React, { useState } from 'react'; import { Button, TextField, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@material-ui/core'; interface PropTypes { isOpen: boolean; setIsOpen: (value: boolean) => void; callback: (url: string) => void; } const Modal: React.FC = ({ setIsOpen, isOpen, callback }) => { const [url, setUrl] = useState(''); const handleClose = () => { setIsOpen(false); }; const handleSubmit = () => { let result = url; if (url.startsWith('https://www.instagram.com/')) { const match = url.match('/p/(.*)/'); const id = match && match[1]; result = `https://www.instagram.com/p/${id}/media/?size=l`; } else if (url.startsWith('https://drive.google.com/')) { const match = url.match('/d/(.*)/'); const fileId = match && match[1]; result = `https://drive.google.com/uc?export=view&id=${fileId}`; } callback(result || ''); handleClose(); }; const handleChange = (event:React.ChangeEvent) => { setUrl(event.target.value); }; return (
Upload via link Provide a valid URL to your image:
); }; export default Modal;