Browse Source

ask for confirmation before submitting a confirm claim

pull/91/head
Trent Larson 11 months ago
parent
commit
59d0772881
  1. 88
      src/views/ClaimView.vue

88
src/views/ClaimView.vue

@ -121,7 +121,7 @@
You have confirmed this claim. You have confirmed this claim.
</div> </div>
<div v-else-if="containsHiddenDid(veriClaim.claim)"> <div v-else-if="containsHiddenDid(veriClaim.claim)">
You cannot confirm this claim because it contains a DID that is hidden You cannot confirm this claim because it contains data that is hidden
from you. from you.
</div> </div>
<div v-else> <div v-else>
@ -419,51 +419,53 @@ export default class ClaimView extends Vue {
} }
async confirmClaim() { async confirmClaim() {
// similar logic is found in endorser-mobile if (confirm("Do you personally confirm that this is true?")) {
const goodClaim = serverUtil.removeSchemaContext( // similar logic is found in endorser-mobile
serverUtil.removeVisibleToDids( const goodClaim = serverUtil.removeSchemaContext(
serverUtil.addLastClaimOrHandleAsIdIfMissing( serverUtil.removeVisibleToDids(
this.veriClaim.claim, serverUtil.addLastClaimOrHandleAsIdIfMissing(
this.veriClaim.id, this.veriClaim.claim,
this.veriClaim.handleId, this.veriClaim.id,
this.veriClaim.handleId,
),
), ),
),
);
const confirmationClaim: serverUtil.GenericVerifiableCredential & {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
object: any;
} = {
"@context": "https://schema.org",
"@type": "AgreeAction",
object: goodClaim,
};
const result = await serverUtil.createAndSubmitClaim(
confirmationClaim,
await this.getIdentity(this.activeDid),
this.apiServer,
this.axios,
);
if (result.type === "success") {
this.$notify(
{
group: "alert",
type: "success",
title: "Success",
text: "Confirmation submitted.",
},
5000,
); );
} else { const confirmationClaim: serverUtil.GenericVerifiableCredential & {
console.log("Got error submitting the confirmation:", result); // eslint-disable-next-line @typescript-eslint/no-explicit-any
this.$notify( object: any;
{ } = {
group: "alert", "@context": "https://schema.org",
type: "danger", "@type": "AgreeAction",
title: "Error", object: goodClaim,
text: "There was a problem submitting the confirmation. See logs for more info.", };
}, const result = await serverUtil.createAndSubmitClaim(
-1, confirmationClaim,
await this.getIdentity(this.activeDid),
this.apiServer,
this.axios,
); );
if (result.type === "success") {
this.$notify(
{
group: "alert",
type: "success",
title: "Success",
text: "Confirmation submitted.",
},
5000,
);
} else {
console.log("Got error submitting the confirmation:", result);
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text: "There was a problem submitting the confirmation. See logs for more info.",
},
-1,
);
}
} }
} }
} }

Loading…
Cancel
Save