diff --git a/src/components/Type.tsx b/src/components/Type.tsx
index b854446..2c401ce 100644
--- a/src/components/Type.tsx
+++ b/src/components/Type.tsx
@@ -37,8 +37,11 @@ function Placeholder({ text, Icon, ...props }) {
}
export default function Type({ file, popup = false, disableMediaPreview, ...props }) {
- const type = (file.type || file.mimetype).split('/')[0];
- const name = file.name || file.file;
+ const type =
+ (file.type ?? file.mimetype) === ''
+ ? file.name.split('.').pop()
+ : (file.type ?? file.mimetype).split('/')[0];
+ const name = file.name ?? file.file;
const media = /^(video|audio|image|text)/.test(type);
diff --git a/src/components/dropzone/Dropzone.tsx b/src/components/dropzone/Dropzone.tsx
index 482f7b1..f6035c7 100644
--- a/src/components/dropzone/Dropzone.tsx
+++ b/src/components/dropzone/Dropzone.tsx
@@ -1,4 +1,4 @@
-import { Group, Text, useMantineTheme } from '@mantine/core';
+import { Box, Group, SimpleGrid, Text, useMantineTheme } from '@mantine/core';
import { Dropzone as MantineDropzone } from '@mantine/dropzone';
import { ImageIcon } from 'components/icons';
@@ -6,16 +6,23 @@ export default function Dropzone({ loading, onDrop, children }) {
const theme = useMantineTheme();
return (
-
-
-
+
+
+
+
-
- Drag files here or click to select files
-
-
-
- {children}
-
+
+ Drag files here or click to select files
+
+
+
+ {children}
+
);
}
diff --git a/src/components/dropzone/DropzoneFile.tsx b/src/components/dropzone/DropzoneFile.tsx
index 0b38562..6fa8fd4 100644
--- a/src/components/dropzone/DropzoneFile.tsx
+++ b/src/components/dropzone/DropzoneFile.tsx
@@ -1,5 +1,6 @@
-import { Badge, Group, HoverCard, Table, useMantineTheme } from '@mantine/core';
+import { ActionIcon, Badge, Box, Card, Group, HoverCard, Table, useMantineTheme } from '@mantine/core';
import Type from 'components/Type';
+import { X } from 'react-feather';
export function FilePreview({ file }: { file: File }) {
return (
@@ -16,15 +17,36 @@ export function FilePreview({ file }: { file: File }) {
);
}
-export default function FileDropzone({ file }: { file: File }) {
+export default function FileDropzone({ file, onRemove }: { file: File; onRemove: () => void }) {
const theme = useMantineTheme();
return (
- {file.name}
+ {/* {file.name} */}
+
+
+ {file.name}
+
+
+ {/* x button that will remove file */}
+
+
+
+
+
+
diff --git a/src/components/pages/Manage/Flameshot.tsx b/src/components/pages/Manage/Flameshot.tsx
index 91b69a9..2d20629 100644
--- a/src/components/pages/Manage/Flameshot.tsx
+++ b/src/components/pages/Manage/Flameshot.tsx
@@ -60,8 +60,6 @@ export default function Flameshot({ user, open, setOpen }) {
curl.push(`"${key}: ${value}"`);
}
- console.log(curl);
-
let shell;
if (values.type === 'upload-file') {
shell = `#!/bin/bash${values.wlCompositorNotSupported ? '\nexport XDG_CURRENT_DESKTOP=sway\n' : ''}
diff --git a/src/components/pages/Upload/File.tsx b/src/components/pages/Upload/File.tsx
index 9b108f3..00139d8 100644
--- a/src/components/pages/Upload/File.tsx
+++ b/src/components/pages/Upload/File.tsx
@@ -1,4 +1,5 @@
import {
+ Box,
Button,
Collapse,
Group,
@@ -6,6 +7,8 @@ import {
PasswordInput,
Progress,
Select,
+ Stack,
+ Text,
Title,
Tooltip,
} from '@mantine/core';
@@ -15,6 +18,7 @@ import { showNotification, updateNotification } from '@mantine/notifications';
import Dropzone from 'components/dropzone/Dropzone';
import FileDropzone from 'components/dropzone/DropzoneFile';
import { ClockIcon, CrossIcon, UploadIcon } from 'components/icons';
+import MutedText from 'components/MutedText';
import { invalidateFiles } from 'lib/queries/files';
import { userSelector } from 'lib/recoil/user';
import { expireReadToDate, randomChars } from 'lib/utils/client';
@@ -281,28 +285,46 @@ export default function File({ chunks: chunks_config }) {
Upload Files
setFiles([...files, ...f])}>
-
- {files.map((file) => (
-
- ))}
-
+
+ {files.length ? (
+
+ {files.map((file) => (
+ setFiles(files.filter((f) => f !== file))}
+ />
+ ))}
+
+ ) : (
+
+ Files will appear here once you drop/select them
+
+ )}
+
+
+
+
+
+ }
+ onClick={handleUpload}
+ disabled={files.length === 0 ? true : false}
+ >
+ Upload
+
+
+
+
+ {progress !== 0 && }
+
+
+
-
-
- {progress !== 0 && }
-
-
-
-
-
- } onClick={handleUpload} disabled={files.length === 0 ? true : false}>
- Upload
-
-
>
);
}
diff --git a/src/components/pages/Upload/useUploadOptions.tsx b/src/components/pages/Upload/useUploadOptions.tsx
index 55b1308..2542ede 100644
--- a/src/components/pages/Upload/useUploadOptions.tsx
+++ b/src/components/pages/Upload/useUploadOptions.tsx
@@ -10,7 +10,7 @@ import {
Title,
} from '@mantine/core';
import { ClockIcon, ImageIcon, KeyIcon, TypeIcon, UserIcon } from 'components/icons';
-import React, { Dispatch, SetStateAction, useState } from 'react';
+import React, { Dispatch, SetStateAction, useReducer, useState } from 'react';
export default function useUploadOptions(): [
{
@@ -25,24 +25,38 @@ export default function useUploadOptions(): [
Dispatch>,
React.FC
] {
- const [expires, setExpires] = useState('never');
- const [password, setPassword] = useState('');
- const [maxViews, setMaxViews] = useState(0);
- const [compression, setCompression] = useState('none');
- const [zeroWidth, setZeroWidth] = useState(false);
- const [embedded, setEmbedded] = useState(false);
- const [format, setFormat] = useState('default');
+ // const [expires, setExpires] = useState('never');
+ // const [password, setPassword] = useState('');
+ // const [maxViews, setMaxViews] = useState(0);
+ // const [compression, setCompression] = useState('none');
+ // const [zeroWidth, setZeroWidth] = useState(false);
+ // const [embedded, setEmbedded] = useState(false);
+ // const [format, setFormat] = useState('default');
+
+ // migrate this to useReducer
+
+ const [state, setState] = useReducer((state, newState) => ({ ...state, ...newState }), {
+ expires: 'never',
+ password: '',
+ maxViews: 0,
+ compression: 'none',
+ zeroWidth: false,
+ embedded: false,
+ format: 'default',
+ });
const [opened, setOpened] = useState(false);
const reset = () => {
- setExpires('never');
- setPassword('');
- setMaxViews(0);
- setCompression('none');
- setZeroWidth(false);
- setEmbedded(false);
- setFormat('default');
+ setState({
+ expires: 'never',
+ password: '',
+ maxViews: 0,
+ compression: 'none',
+ zeroWidth: false,
+ embedded: false,
+ format: 'default',
+ });
};
const OptionsModal: React.FC = () => (
@@ -51,8 +65,8 @@ export default function useUploadOptions(): [
setState({ maxViews: e })}
min={0}
icon={}
/>
@@ -60,8 +74,8 @@ export default function useUploadOptions(): [
@@ -158,17 +172,5 @@ export default function useUploadOptions(): [
);
- return [
- {
- expires,
- password,
- maxViews,
- compression,
- zeroWidth,
- embedded,
- format,
- },
- setOpened,
- OptionsModal,
- ];
+ return [state, setOpened, OptionsModal];
}