Skip to content

Commit

Permalink
fix: add indicator when issue and remove unsupported proof format
Browse files Browse the repository at this point in the history
Signed-off-by: Nam Hoang <[email protected]>
  • Loading branch information
namhoang1604 committed Jul 28, 2023
1 parent f069715 commit 587c132
Showing 1 changed file with 32 additions and 28 deletions.
60 changes: 32 additions & 28 deletions packages/demo-explorer/src/components/IssueCredentialFromSchema.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'
import { Button, Card, Alert } from 'antd'
import { Button, Card, Alert, Spin } from 'antd'
import { issueCredential } from '../utils/signing'
import { useVeramo } from '@veramo-community/veramo-react'
import { useQuery } from 'react-query'
Expand Down Expand Up @@ -29,7 +29,7 @@ const IssueCredentialFromSchema: React.FC<IssueCredentialFromSchemaProps> = ({
}) => {
const { agent } = useVeramo()
const [errorMessage, setErrorMessage] = useState<null | string>()
const [sending] = useState(false)
const [sending, setSending] = useState(false)
const [formData, setFormData] = useState<any>({})
const [errors, setErrors] = useState<any>([])
const [schemaData, setSchemaData] = useState<any>({})
Expand Down Expand Up @@ -60,14 +60,14 @@ const IssueCredentialFromSchema: React.FC<IssueCredentialFromSchemaProps> = ({
const: 'lds',
title: 'lds',
},
{
const: 'EthereumEip712Signature2021',
title: 'EthereumEip712Signature2021',
},
{
const: 'OpenAttestationMerkleProofSignature2018',
title: 'OpenAttestationMerkleProofSignature2018',
},
// {
// const: 'EthereumEip712Signature2021',
// title: 'EthereumEip712Signature2021',
// },
// {
// const: 'OpenAttestationMerkleProofSignature2018',
// title: 'OpenAttestationMerkleProofSignature2018',
// },
],
},
issuer: {
Expand Down Expand Up @@ -104,6 +104,7 @@ const IssueCredentialFromSchema: React.FC<IssueCredentialFromSchemaProps> = ({
// @ts-ignore
console.log(schema['@context'])
try {
setSending(true)
await issueCredential(
agent,
formData.issuer,
Expand Down Expand Up @@ -131,6 +132,7 @@ const IssueCredentialFromSchema: React.FC<IssueCredentialFromSchemaProps> = ({
'Unable to Issue Credential. Check console log for more info.',
)
}
setSending(false)
}

return (
Expand All @@ -147,24 +149,26 @@ const IssueCredentialFromSchema: React.FC<IssueCredentialFromSchemaProps> = ({
/>
<br />
<br />
<Button
type="primary"
onClick={() => {
setErrorMessage('')
const fields: Field[] = []
for (let key in formData.credentialSubject as any) {
fields.push({
type: key,
value: (formData.credentialSubject as any)[key],
})
}
signVc(fields)
}}
style={{ marginRight: 5 }}
disabled={sending || errors.length !== 0}
>
Issue
</Button>
<Spin spinning={sending}>
<Button
type="primary"
onClick={() => {
setErrorMessage('')
const fields: Field[] = []
for (let key in formData.credentialSubject as any) {
fields.push({
type: key,
value: (formData.credentialSubject as any)[key],
})
}
signVc(fields)
}}
style={{ marginRight: 5 }}
disabled={sending || errors.length !== 0}
>
Issue
</Button>
</Spin>
{errorMessage && (
<>
<br />
Expand Down

0 comments on commit 587c132

Please sign in to comment.