Skip to content

Commit

Permalink
feat: add password field in file upload ui (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Bender authored Sep 24, 2022
1 parent dc926e9 commit 4a75337
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/pages/Upload.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Collapse, Group, Progress, Select, Title } from '@mantine/core';
import { Button, Collapse, Group, Progress, Select, Title, PasswordInput } from '@mantine/core';
import { randomId, useClipboard } from '@mantine/hooks';
import { showNotification, updateNotification } from '@mantine/notifications';
import Dropzone from 'components/dropzone/Dropzone';
Expand Down Expand Up @@ -48,6 +48,7 @@ export default function Upload() {
const [progress, setProgress] = useState(0);
const [loading, setLoading] = useState(false);
const [expires, setExpires] = useState('never');
const [password, setPassword] = useState('');

useEffect(() => {
window.addEventListener('paste', (e: ClipboardEvent) => {
Expand Down Expand Up @@ -143,6 +144,7 @@ export default function Upload() {
req.open('POST', '/api/upload');
req.setRequestHeader('Authorization', user.token);
expires !== 'never' && req.setRequestHeader('Expires-At', 'date=' + expires_at.toISOString());
password !== '' && req.setRequestHeader('Password', password);

req.send(body);
};
Expand All @@ -162,6 +164,12 @@ export default function Upload() {
</Collapse>

<Group position='right' mt='md'>
<PasswordInput
style={{width: '252px'}}
placeholder='Password'
value={password}
onChange={(e) => setPassword(e.currentTarget.value)}
/>
<Select
value={expires}
onChange={(e) => setExpires(e)}
Expand Down

0 comments on commit 4a75337

Please sign in to comment.