diff --git a/src/views/ClaimView.vue b/src/views/ClaimView.vue index cd338e20..5a7d7637 100644 --- a/src/views/ClaimView.vue +++ b/src/views/ClaimView.vue @@ -39,6 +39,57 @@ {{ veriClaim.issuedAt?.replace(/T/, " ").replace(/Z/, " UTC") }} + + + + +
+ + Fulfills a bigger plan... + +
+ +
+ + + Fulfills + {{ + capitalizeAndInsertSpacesBeforeCaps( + detailsForGive.fulfillsType, + ) + }}... + +
+ + +
+ + Offered to a bigger plan... + +
@@ -54,7 +105,7 @@ confirmerIdList, ) " - @click="confirmClaim(veriClaim.id)" + @click="confirmClaim()" > Confirm @@ -177,7 +228,7 @@ @@ -229,13 +280,17 @@ interface Notification { export default class ClaimView extends Vue { $notify!: (notification: Notification, timeout?: number) => void; + accountIdentityStr: string = "null"; activeDid = ""; allMyDids: Array = []; allContacts: Array = []; apiServer = ""; + confirmerIdList: string[] = []; // list of DIDs that have confirmed this claim excluding the issuer confsVisibleErrorMessage = ""; confsVisibleToIdList: string[] = []; // list of DIDs that can see any confirmer + detailsForGive = null; + detailsForOffer = null; fullClaim = null; fullClaimDump = ""; fullClaimMessage = ""; @@ -247,6 +302,20 @@ export default class ClaimView extends Vue { libsUtil = libsUtil; serverUtil = serverUtil; + resetThisValues() { + this.confirmerIdList = []; + this.confsVisibleErrorMessage = ""; + this.confsVisibleToIdList = []; + this.detailsForGive = null; + this.detailsForOffer = null; + this.fullClaim = null; + this.fullClaimDump = ""; + this.fullClaimMessage = ""; + this.numConfsNotVisible = 0; + this.veriClaim = serverUtil.BLANK_GENERIC_SERVER_RECORD; + this.veriClaimDump = ""; + } + async created() { await db.open(); const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings; @@ -259,7 +328,8 @@ export default class ClaimView extends Vue { const accountsArr = await accounts?.toArray(); this.allMyDids = accountsArr.map((acc) => acc.did); const account = accountsArr.find((acc) => acc.did === this.activeDid); - const identity = JSON.parse(account?.identity || "null"); + this.accountIdentityStr = account?.identity || "null"; + const identity = JSON.parse(this.accountIdentityStr); const pathParam = window.location.pathname.substring("/claim/".length); let claimId; @@ -350,31 +420,50 @@ export default class ClaimView extends Vue { group: "alert", type: "danger", title: "Error", - text: "There was a problem getting that claim. See logs for more info.", + text: "There was a problem retrieving that claim.", }, -1, ); + return; } - } catch (error: unknown) { - const serverError = error as AxiosError; - console.error("Error retrieving claim:", serverError); - this.$notify( - { - group: "alert", - type: "danger", - title: "Error", - text: "Something went wrong retrieving that claim. See logs for more info.", - }, - -1, - ); - } - const confirmUrl = - this.apiServer + - "/api/report/issuersWhoClaimedOrConfirmed?claimId=" + - encodeURIComponent(serverUtil.stripEndorserPrefix(claimId)); - const confirmHeaders = await this.getHeaders(identity); - try { + // retrieve more details on Give, Offer, or Plan + if (this.veriClaim.claimType === "GiveAction") { + const giveUrl = + this.apiServer + + "/api/v2/report/gives?handleId=" + + encodeURIComponent(this.veriClaim.handleId as string); + const giveHeaders = await this.getHeaders(identity); + const giveResp = await this.axios.get(giveUrl, { + headers: giveHeaders, + }); + if (giveResp.status === 200) { + this.detailsForGive = giveResp.data.data[0]; + } else { + console.error("Error getting detailed give info:", giveResp); + } + } else if (this.veriClaim.claimType === "Offer") { + const offerUrl = + this.apiServer + + "/api/v2/report/offers?handleId=" + + encodeURIComponent(this.veriClaim.handleId as string); + const offerHeaders = await this.getHeaders(identity); + const offerResp = await this.axios.get(offerUrl, { + headers: offerHeaders, + }); + if (offerResp.status === 200) { + this.detailsForOffer = offerResp.data.data[0]; + } else { + console.error("Error getting detailed offer info:", offerResp); + } + } + + // retrieve the list of confirmers + const confirmUrl = + this.apiServer + + "/api/report/issuersWhoClaimedOrConfirmed?claimId=" + + encodeURIComponent(serverUtil.stripEndorserPrefix(claimId)); + const confirmHeaders = await this.getHeaders(identity); const response = await this.axios.get(confirmUrl, { headers: confirmHeaders, }); @@ -400,16 +489,23 @@ export default class ClaimView extends Vue { } } catch (error: unknown) { const serverError = error as AxiosError; - console.error("Error retrieving confirmations:", serverError); - this.confsVisibleErrorMessage = - "Had problems retrieving confirmations. See logs for more info."; + console.error("Error retrieving claim:", serverError); + this.$notify( + { + group: "alert", + type: "danger", + title: "Error", + text: "Something went wrong retrieving claim data.", + }, + -1, + ); } } async showFullClaim(claimId: string) { await accountsDB.open(); const accounts = accountsDB.accounts; - const accountsArr = await accounts?.toArray(); + const accountsArr: Account[] = await accounts?.toArray(); const account = accountsArr.find((acc) => acc.did === this.activeDid); const identity = JSON.parse(account?.identity || "null"); @@ -512,6 +608,16 @@ export default class ClaimView extends Vue { } } + showDifferentClaimPage(claimId: string) { + const route = { + path: "/claim/" + encodeURIComponent(claimId), + }; + this.$router.push(route).then(async () => { + this.resetThisValues(); + await this.loadClaim(claimId, JSON.parse(this.accountIdentityStr)); + }); + } + openFulfillGiftDialog() { const giver: GiverInputInfo = { did: libsUtil.offerGiverDid(this.veriClaim), diff --git a/src/views/ProjectViewView.vue b/src/views/ProjectViewView.vue index c54b2f44..89893114 100644 --- a/src/views/ProjectViewView.vue +++ b/src/views/ProjectViewView.vue @@ -699,11 +699,6 @@ export default class ProjectViewView extends Vue { claimType: "Offer", issuer: offer.offeredByDid, }; - console.log( - "checking for can fulfill ", - libsUtil.canFulfillOffer(offerRecord), - offerRecord, - ); return libsUtil.canFulfillOffer(offerRecord); }