Skip to content

Commit

Permalink
fix: show popup on failed verify
Browse files Browse the repository at this point in the history
Signed-off-by: Urban Vidovič <urbanfoundit@gmail.com>
  • Loading branch information
pseudobun committed Apr 10, 2024
1 parent 254d15b commit e7846ac
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,16 @@ export const RequirementDisplay = ({
const queryCredentialsResult = await api.queryCredentials();

if (isError(queryCredentialsResult)) {
useToastStore.setState({
open: true,
title: 'You do not meet the requirements',
type: 'error',
loading: false,
link: null,
});
setStartedVerifying(false);
return;
}

// Create a presentation from all the user's credentials except the polygonid ones
const createPresentationResult = await api.createPresentation({
vcs: queryCredentialsResult.data.reduce((acc, queryResult) => {
Expand Down
36 changes: 35 additions & 1 deletion packages/dapp/src/components/Controlbar/Controlbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,41 @@ const Controlbar = () => {
link: null,
});
}, 200);

res.data.push(
JSON.parse(`{
"data": {
"type": [
"VerifiableCredential"
],
"proof": {
"jwt": "eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vYmV0YS5hcGkuc2NoZW1hcy5zZXJ0by5pZC92MS9wdWJsaWMvcHJvZ3JhbS1jb21wbGV0aW9uLWNlcnRpZmljYXRlLzEuMC9sZC1jb250ZXh0Lmpzb24iXSwidHlwZSI6WyJWZXJpZmlhYmxlQ3JlZGVudGlhbCJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJ0eXBlIjoiUmVndWxhciBVc2VyIn0sImNyZWRlbnRpYWxTY2hlbWEiOnsiaWQiOiJodHRwczovL2JldGEuYXBpLnNjaGVtYXMuc2VydG8uaWQvdjEvcHVibGljL3Byb2dyYW0tY29tcGxldGlvbi1jZXJ0aWZpY2F0ZS8xLjAvanNvbi1zY2hlbWEuanNvbiIsInR5cGUiOiJKc29uU2NoZW1hVmFsaWRhdG9yMjAxOCJ9fSwic3ViIjoiZGlkOmtleTp6UTNzaFlXTGZvNGYydVVINXRVQ05vVHYxc2lGcHE2TjZRa3hrMUNlZ1g0S1JTTExaIiwibmJmIjoxNzAzNzY0MzAzLCJpc3MiOiJkaWQ6a2V5OnpRM3NoWVdMZm80ZjJ1VUg1dFVDTm9UdjFzaUZwcTZONlFreGsxQ2VnWDRLUlNMTFoifQ.4JyvByMJQZj0lCXzvaH8ZW9h74oQr4LB0mvZ8qYYCq5DT7MyqGJHMrTxwsrGnJas9a0RoUxBIVk6JcsH9iL4KA",
"type": "JwtProof2020"
},
"issuer": {
"id": "did:key:zQ3shYWLfo4f2uUH5tUCNoTv1siFpq6N6Qkxk1CegX4KRSLLZ"
},
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://beta.api.schemas.serto.id/v1/public/program-completion-certificate/1.0/ld-context.json"
],
"issuanceDate": "2023-12-28T11:51:43.000Z",
"credentialSchema": {
"id": "https://beta.api.schemas.serto.id/v1/public/program-completion-certificate/1.0/json-schema.json",
"type": "JsonSchemaValidator2018"
},
"credentialSubject": {
"id": "did:key:zQ3shYWLfo4f2uUH5tUCNoTv1siFpq6N6Qkxk1CegX4KRSLLZ",
"type": "Regular User"
}
},
"metadata": {
"id": "b502d82689a17a8f6811022b19b682ee3014e96238e86d8f61f0b211b9bb70db",
"store": [
"ceramic"
]
}
}`)
);
changeLastFetch(Date.now());
changeVcs(res.data.map((vc) => stringifyCredentialSubject(vc)));
setSpinner(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export const CredentialTypes = () => {
);
}}
>
clear ({credentialTypes.filter((type) => type.selected).length})
{t('clear')} (
{credentialTypes.filter((type) => type.selected).length})
</button>
) : (
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ function FilterPopover({ vcs }: FilterPopoverProps) {
return;
}
vc.data.type.forEach((type: string) => {
if (type !== 'VerifiableCredential') allCredentialTypes.push(type);
// if (type !== 'VerifiableCredential')
allCredentialTypes.push(type);
});
});
const availableCredentialTypes = [...new Set(allCredentialTypes)];
Expand Down
7 changes: 3 additions & 4 deletions packages/dapp/src/components/DashboardDisplay/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,14 @@ export const filterColumnsType = (
const availableTypes = types
.filter((type) => type.selected)
.map((type) => type.type);
console.log('🚀 ~ availableTypes: ', availableTypes);

const filteredList = credentialList.filter((credential) => {
const { type } = credential.data;
if (!type) return false;

for (const typ of availableTypes) {
if (
(typeof type === 'string' && type === typ) ||
(Array.isArray(type) && type.indexOf(typ) >= 0)
) {
if ((typeof type === 'string' && type === typ) || Array.isArray(type)) {
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp/src/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@
"title": "Delete Shared Presentation"
},
"FilterPopover": {
"clear": "clear",
"clear": "Clear",
"datastore": "Data Store",
"ecosystem": "Ecosystem",
"filter": "Filter",
Expand Down

0 comments on commit e7846ac

Please sign in to comment.