mirror of
https://github.com/morten-olsen/parcel.git
synced 2026-02-08 01:36:24 +01:00
sec
This commit is contained in:
44
src/screens/Decrypt.tsx
Normal file
44
src/screens/Decrypt.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
import React, { useContext, useEffect, useCallback } from 'react';
|
||||
import { Divider, Button } from 'antd';
|
||||
import { useHistory } from 'react-router';
|
||||
import FileList from '../components/FileList';
|
||||
import Add from '../components/decrypt/AddFile';
|
||||
import DecryptionContext from '../contexts/Decryption';
|
||||
import { downloadLink } from '../helpers/files';
|
||||
|
||||
const Decrypt: React.FC = () => {
|
||||
const history = useHistory();
|
||||
const { publicKey, files, deleteFile } = useContext(DecryptionContext);
|
||||
useEffect(() => {
|
||||
if (localStorage.getItem('welcome') !== 'seen') {
|
||||
history.replace('/welcome');
|
||||
}
|
||||
}, []);
|
||||
|
||||
const downloadPublicKey = useCallback(() => {
|
||||
const publicKeyBlob = new Blob([publicKey!]);
|
||||
downloadLink('public-key.asc', publicKeyBlob);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
onClick={downloadPublicKey}
|
||||
>
|
||||
Download you sharing key
|
||||
</Button>
|
||||
<Add />
|
||||
{Object.keys(files).length > 0 && (
|
||||
<>
|
||||
<Divider>Files</Divider>
|
||||
<FileList
|
||||
files={files}
|
||||
deleteFile={deleteFile}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Decrypt;
|
||||
@@ -1,13 +1,13 @@
|
||||
import React, { useContext, useEffect } from 'react';
|
||||
import { Divider } from 'antd';
|
||||
import { useHistory } from 'react-router';
|
||||
import Add from '../components/Add';
|
||||
import Add from '../components/encrypt/Add';
|
||||
import FileList from '../components/FileList';
|
||||
import EncryptionContext from '../contexts/Encryption';
|
||||
|
||||
const Encrypt: React.FC = () => {
|
||||
const history = useHistory();
|
||||
const { files } = useContext(EncryptionContext);
|
||||
const { files, deleteFile } = useContext(EncryptionContext);
|
||||
useEffect(() => {
|
||||
if (localStorage.getItem('welcome') !== 'seen') {
|
||||
history.replace('/welcome');
|
||||
@@ -20,7 +20,14 @@ const Encrypt: React.FC = () => {
|
||||
{Object.keys(files).length > 0 && (
|
||||
<>
|
||||
<Divider>Files</Divider>
|
||||
<FileList />
|
||||
<FileList
|
||||
files={files}
|
||||
deleteFile={deleteFile}
|
||||
/>
|
||||
<Divider />
|
||||
<i style={{ textAlign: 'center', paddingTop: '10px', display: 'block', fontSize: 12 }}>
|
||||
Note: files are not send to me, you still have to download the encrypted files and send it to me.
|
||||
</i>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user