feat(components): copy url to clipboard when uploading image
This commit is contained in:
parent
474024ea55
commit
386cad0474
3 changed files with 5 additions and 5 deletions
|
@ -6,7 +6,7 @@
|
|||
"dev": "NODE_ENV=development node server",
|
||||
"build": "npm-run-all build:schema build:next",
|
||||
"build:next": "next build",
|
||||
"build:schema": "prisma generate --schema=prisma/schema.shared.prisma",
|
||||
"build:schema": "prisma generate --schema=prisma/schema.sqlite.prisma",
|
||||
"start": "node server",
|
||||
"lint": "next lint",
|
||||
"ts-node": "./node_modules/.bin/ts-node --compiler-options \"{\\\"module\\\":\\\"commonjs\\\"}\" --transpile-only",
|
||||
|
|
|
@ -3,13 +3,13 @@ import { Typography, Button, CardActionArea, Paper, Box } from '@material-ui/cor
|
|||
import { Upload as UploadIcon } from '@material-ui/icons';
|
||||
import Dropzone from 'react-dropzone';
|
||||
|
||||
import useFetch from 'hooks/useFetch';
|
||||
import Backdrop from 'components/Backdrop';
|
||||
import Alert from 'components/Alert';
|
||||
import { useStoreSelector } from 'lib/redux/store';
|
||||
import CenteredBox from 'components/CenteredBox';
|
||||
import copy from 'copy-to-clipboard';
|
||||
|
||||
export default function Manage({ route }) {
|
||||
export default function Upload({ route }) {
|
||||
const user = useStoreSelector(state => state.user);
|
||||
|
||||
const [file, setFile] = useState(null);
|
||||
|
@ -34,7 +34,8 @@ export default function Manage({ route }) {
|
|||
if (res.ok && json.error === undefined) {
|
||||
setOpen(true);
|
||||
setSeverity('success');
|
||||
setMessage(`File uploaded! ${json.url}`);
|
||||
setMessage(`Copied to clipboard! ${json.url}`);
|
||||
copy(json.url);
|
||||
} else {
|
||||
setOpen(true);
|
||||
setSeverity('error');
|
||||
|
|
|
@ -22,7 +22,6 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
});
|
||||
if (!user) return res.forbid('authorization incorect');
|
||||
if (!req.file) return res.error('no file');
|
||||
console.log(req.file);
|
||||
|
||||
const ext = req.file.originalname.split('.').pop();
|
||||
|
||||
|
|
Loading…
Reference in a new issue