-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update download jwt button verify page (#116)
* feat: update download JWT button in Verify page * test: add test for json block * ci: fix build pipeline * ci: cp app-config.json when build * refactor: check vc response from api in verify page * refactor: response of issuing VC api * refactor: change download button on verify page following the design * docs: update document for rendering verified credential page * test: update unit test in JsonBlock and CredentialTabs * ci: update yarn lock * refactor: pass decode jwt in verify page as props for json block and credential tabs * refactor: change name of the props from decodeCredential to decodedEnvelopedVC * test: update test in CredentialTabs and JsonBlock * refactor: remove unused code * fix: resolve conflict * refactor: remove unused code * ci: update yarn lock to retry pipeline * chore: adjust yarn lock Signed-off-by: Nam Hoang <[email protected]> * refactor: change code in download button of verify page --------- Signed-off-by: Nam Hoang <[email protected]> Co-authored-by: Nam Hoang <[email protected]>
- Loading branch information
1 parent
c5c9d74
commit 962e099
Showing
14 changed files
with
156 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
packages/mock-app/src/components/CredentialInfo/CredentialInfo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/mock-app/src/components/CredentialRender/CredentialRender.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/mock-app/src/components/DownloadCredentialButton/DownloadCredentialButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import CloudDownloadOutlinedIcon from '@mui/icons-material/CloudDownloadOutlined'; | ||
import { Button, IconButton, useMediaQuery, useTheme } from '@mui/material'; | ||
import { UnsignedCredential, VerifiableCredential } from '@vckit/core-types'; | ||
|
||
export const DownloadCredentialButton = ({ credential }: { credential: VerifiableCredential | UnsignedCredential }) => { | ||
const theme = useTheme(); | ||
const isMobile = useMediaQuery(theme.breakpoints.down('sm')); | ||
/** | ||
* handle click on download button | ||
*/ | ||
const handleClickDownloadVC = async () => { | ||
const element = document.createElement('a'); | ||
const file = new Blob([JSON.stringify({ verifiableCredential: credential }, null, 2)], { | ||
type: 'text/plain', | ||
}); | ||
element.href = URL.createObjectURL(file); | ||
element.download = 'vc.json'; | ||
document.body.appendChild(element); // Required for this to work in FireFox | ||
element.click(); | ||
}; | ||
|
||
return ( | ||
<> | ||
{isMobile ? ( | ||
<IconButton color='primary' aria-label='download' onClick={handleClickDownloadVC}> | ||
<CloudDownloadOutlinedIcon /> | ||
</IconButton> | ||
) : ( | ||
<Button variant='text' onClick={handleClickDownloadVC} startIcon={<CloudDownloadOutlinedIcon />}> | ||
Download | ||
</Button> | ||
)} | ||
</> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/mock-app/src/components/DownloadCredentialButton/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './DownloadCredentialButton'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.