Skip to content

Commit

Permalink
Add import when there is no web3Id credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Hjort committed Aug 18, 2023
1 parent 4a12cc1 commit e2f4bb2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ import { VerifiableCredentialCard } from './VerifiableCredentialCard';
import VerifiableCredentialDetails from './VerifiableCredentialDetails';
import { useVerifiableCredentialExport } from '../VerifiableCredentialBackup/utils';

async function goToImportPage() {
await popupMessageHandler.sendInternalMessage(InternalMessageType.LoadWeb3IdBackup);
window.close();
}

/**
* Component to display while loading verifiable credentials from storage.
*/
Expand All @@ -37,9 +42,22 @@ function LoadingVerifiableCredentials() {
*/
function NoVerifiableCredentials() {
const { t } = useTranslation('verifiableCredential');

const menuButton = useMemo(() => {
const importButton = {
title: t('menu.import'),
onClick: goToImportPage,
};

return {
type: ButtonTypes.More,
items: [importButton],
};
}, []);

return (
<>
<Topbar title={t('topbar.list')} />
<Topbar title={t('topbar.list')} menuButton={menuButton} />
<div className="verifiable-credential-wrapper">
<div className="flex-column align-center">
<p className="m-t-20 m-h-30">You do not have any verifiable credentials in your wallet.</p>
Expand Down Expand Up @@ -107,9 +125,6 @@ export default function VerifiableCredentialList() {
const exportCredentials = useVerifiableCredentialExport();

const menuButton = useMemo(() => {
const goToImportPage = () =>
popupMessageHandler.sendInternalMessage(InternalMessageType.LoadWeb3IdBackup).then(() => window.close());

const backupButton = {
title: t('menu.export'),
onClick: exportCredentials,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function DisplayResult({ imported }: { imported: VerifiableCredential[] }) {
{imported.map((credential) => {
return (
<VerifiableCredentialCardWithStatusFromChain
key={credential.id}
className="verifiable-credential-import__card"
credential={credential}
/>
Expand Down

0 comments on commit e2f4bb2

Please sign in to comment.