diff --git a/src/pages/decrypt/index.tsx b/src/pages/decrypt/index.tsx index af3c2f5..1181ef7 100644 --- a/src/pages/decrypt/index.tsx +++ b/src/pages/decrypt/index.tsx @@ -5,6 +5,7 @@ import { useState } from 'react' import { LoadingSpinner } from '../../components/LoadingSpinner' import { decryptArrayBuffer } from '../../utils' import styles from './style.module.scss' +import { toast } from 'react-toastify' export const DecryptZip = () => { const [selectedFile, setSelectedFile] = useState(null) @@ -25,7 +26,14 @@ export const DecryptZip = () => { const arrayBuffer = await decryptArrayBuffer( encryptedArrayBuffer, encryptionKey - ) + ).catch((err) => { + console.log('err in decryption:>> ', err) + toast.error(err.message || 'An error occurred while decrypting file.') + setIsLoading(false) + return null + }) + + if (!arrayBuffer) return const blob = new Blob([arrayBuffer]) saveAs(blob, 'decrypted.zip')