Skip to content
This repository was archived by the owner on Nov 7, 2023. It is now read-only.

Commit a6b0e84

Browse files
jessgusclarkjaviesses
authored andcommitted
Extract message and refactor to use in Credential section.
1 parent 9994afb commit a6b0e84

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react'
2+
3+
interface DownloadErrorMessageInterface {
4+
keyError: string
5+
}
6+
7+
const DownloadErrorMessage: React.FC<DownloadErrorMessageInterface> = ({ keyError }) => (
8+
<p className="alert error">This content is encrypted, and your wallet is unable to decrypt the key <em>{keyError}</em>.</p>
9+
)
10+
11+
export default DownloadErrorMessage

src/app/DataVault/panels/CredentialDisplay.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import CredentialIcon from '../../../assets/images/icons/credential.svg'
66
import DecryptKey from '../components/DecryptKey'
77
import DeleteDvContentButton from '../components/DeleteDvContentButton'
88
import PresentCredential from '../components/PresentCredential'
9+
import DownloadErrorMessage from '../components/DownloadErrorMessage'
910

1011
interface CredentialDisplayInterface {
1112
credentials: DataVaultKey
@@ -16,15 +17,18 @@ interface CredentialDisplayInterface {
1617

1718
const CredentialDisplay: React.FC<CredentialDisplayInterface> = ({ credentials, getKeyContent, deleteValue, createPresentation }) => {
1819
const [isGettingContent, setIsGettingContent] = useState<string[]>([])
20+
const [isDownloadError, setIsDownloadError] = useState<null | string>(null)
1921
const handleGetContent = (key: string) => {
2022
setIsGettingContent([...isGettingContent, key])
23+
setIsDownloadError(null)
2124
getKeyContent(key)
22-
.catch((err: Error) => console.log(err.message))
25+
.catch(() => setIsDownloadError(key))
2326
.finally(() => setIsGettingContent(isGettingContent.filter((k: string) => k !== key)))
2427
}
2528

2629
return (
2730
<Panel title={<><img src={CredentialIcon} /> Credentials</>} className="display credentials">
31+
{isDownloadError && <DownloadErrorMessage keyError={isDownloadError} />}
2832
<table>
2933
<thead>
3034
<tr>

src/app/DataVault/panels/DeclarativeDetailsDisplay.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { DataVaultContent, DataVaultKey } from '../../state/reducers/datavault'
66
import EditValueModal from '../../../components/Modal/EditValueModal'
77
import DeleteDvContentButton from '../components/DeleteDvContentButton'
88
import DecryptKey from '../components/DecryptKey'
9+
import DownloadErrorMessage from '../components/DownloadErrorMessage'
910

1011
interface DeclarativeDetailsDisplayInterface {
1112
deleteValue: (key: string, id: string) => Promise<any>
@@ -68,7 +69,7 @@ const DeclarativeDetailsDisplay: React.FC<DeclarativeDetailsDisplayInterface> =
6869
return (
6970
<Panel title={<><img src={declarativeIcon} /> Declarative Details</>} className="display">
7071
{showDownloadMessage() && <p className="intro">Click on the download button to decrypt the content. Your wallet will request to decrypt each piece of content.</p>}
71-
{isDownloadError && <p className="alert error">This content is encrypted, and your wallet is unable to decrypt the key <em>{isDownloadError}</em>.</p>}
72+
{isDownloadError && <DownloadErrorMessage keyError={isDownloadError} />}
7273
<table>
7374
<thead>
7475
<tr>

0 commit comments

Comments
 (0)