blob: a0fd309909fa195fab4adf9d774ece2bf86b9e52 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
import React from 'react';
import Modal from 'react-modal';
import {Form, ModalHeader, modalStyles} from './shared'
import { useRouter } from 'next/router'
import { Text } from '../Inputs'
import { useClipboard } from 'use-clipboard-copy';
import {Button} from "../Common/Button";
const PasteModal = (props) => {
const fullURL = `https://ctrl-v.app/${props.hash}`;
const clipboard = useClipboard({ copiedTimeout: 3000 });
Modal.setAppElement('body');
const router = useRouter()
const redir = (e) => {
e.preventDefault();
const redirUrl = `/${props.hash}`
router.push(redirUrl);
}
return (
<Modal
isOpen={props.hash !== ''}
style={modalStyles}
contentLabel="paste created"
>
<Form onSubmit={redir}>
<ModalHeader>
<span role="img" aria-label="success">📎 </span>paste created
</ModalHeader>
<Text
label="url"
type="text"
value={fullURL}
readOnly
ref={clipboard.target} />
<Button
type="submit">
go to paste
</Button>
<Button
secondary
type="button"
onClick={clipboard.copy}>
{clipboard.copied ? 'copied' : 'copy url'}
</Button>
</Form>
</Modal>
);
}
export default PasteModal
|