From 36e5d0a6f58ab3909379bb9b00ec3c99ca72ec6d Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sat, 28 Sep 2024 17:31:58 -0600 Subject: [PATCH] switch BVC-meeting-end gift to be from the plan, and add display of providers on claim-view page --- CHANGELOG.md | 4 ++ src/libs/endorserServer.ts | 10 +++- src/views/ClaimView.vue | 85 ++++++++++++++++++++++++++++- src/views/GiftedDetailsView.vue | 2 + src/views/ProjectViewView.vue | 2 +- src/views/QuickActionBvcEndView.vue | 14 ++++- 6 files changed, 110 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3df09b8..5a83444 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [?] +### Added +- Display of providers on claim view page +### Changed +- Switched BVC-meeting-ending gift to be a gift from the group. ## [0.3.27] - 2024.09.22 - ee23e6f005e47f5bd6f04d804599f6395371b0e4 diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index d01b033..c050057 100644 --- a/src/libs/endorserServer.ts +++ b/src/libs/endorserServer.ts @@ -141,6 +141,7 @@ export interface GiveVerifiableCredential extends GenericVerifiableCredential { identifier?: string; image?: string; object?: { amountOfThisGood: number; unitCode: string }; + provider?: Array; // typically @type & identifier recipient?: { identifier: string }; } @@ -592,6 +593,7 @@ export function hydrateGive( fulfillsOfferHandleId?: string, isTrade: boolean = false, imageUrl?: string, + providers?: Array, // typically @type & identifier lastClaimId?: string, ): GiveVerifiableCredential { // Remember: replace values or erase if it's null @@ -650,6 +652,8 @@ export function hydrateGive( vcClaim.image = imageUrl || undefined; + vcClaim.provider = providers || undefined; + return vcClaim; } @@ -674,6 +678,7 @@ export async function createAndSubmitGive( fulfillsOfferHandleId?: string, isTrade: boolean = false, imageUrl?: string, + providers?: Array, ): Promise { const vcClaim = hydrateGive( undefined, @@ -686,6 +691,7 @@ export async function createAndSubmitGive( fulfillsOfferHandleId, isTrade, imageUrl, + providers, undefined, ); return createAndSubmitClaim( @@ -718,6 +724,7 @@ export async function editAndSubmitGive( fulfillsOfferHandleId?: string, isTrade: boolean = false, imageUrl?: string, + providers?: Array, ): Promise { const vcClaim = hydrateGive( fullClaim.claim, @@ -730,6 +737,7 @@ export async function editAndSubmitGive( fulfillsOfferHandleId, isTrade, imageUrl, + providers, fullClaim.id, ); return createAndSubmitClaim( @@ -1180,7 +1188,7 @@ export const claimSpecialDescription = ( export const BVC_MEETUPS_PROJECT_CLAIM_ID = import.meta.env.VITE_BVC_MEETUPS_PROJECT_CLAIM_ID || - "https://endorser.ch/entity/01HWE8FWHQ1YGP7GFZYYPS272F"; // this won't resolve as a URL on production; it's a URN only found in the test system + "https://endorser.ch/entity/01GXYPFF7FA03NXKPYY142PY4H"; // production value, which seems like the safest value if forgotten export const bvcMeetingJoinClaim = (did: string, startTime: string) => { return { diff --git a/src/views/ClaimView.vue b/src/views/ClaimView.vue index d87248f..523cc10 100644 --- a/src/views/ClaimView.vue +++ b/src/views/ClaimView.vue @@ -89,7 +89,7 @@ -
+
Fulfills {{ @@ -136,6 +136,41 @@ Offered to a bigger plan...
+ + + +
@@ -465,6 +500,11 @@ import { OfferVerifiableCredential, } from "@/libs/endorserServer"; +interface ProviderInfo { + identifier: string; // could be a DID or a handleId + linkConfirmed: boolean; +} + @Component({ components: { GiftedDialog, QuickNav }, }) @@ -488,6 +528,7 @@ export default class ClaimView extends Vue { isEditedGlobalId = false; isRegistered = false; numConfsNotVisible = 0; // number of hidden DIDs in the confirmerIdList, minus the issuer if they aren't visible + providersForGive: ProviderInfo[] = []; showDidCopy = false; showIdCopy = false; showVeriClaimDump = false; @@ -620,11 +661,40 @@ export default class ClaimView extends Vue { const giveResp = await this.axios.get(giveUrl, { headers: giveHeaders, }); - if (giveResp.status === 200) { + if (giveResp.status === 200 && giveResp.data.data?.length > 0) { this.detailsForGive = giveResp.data.data[0]; } else { console.error("Error getting detailed give info:", giveResp); } + + // look for providers + const providerUrl = + this.apiServer + + "/api/v2/report/providersToGive?handleId=" + + encodeURIComponent(this.veriClaim.handleId as string); + console.log("providerUrl:", providerUrl); + const providerHeaders = await serverUtil.getHeaders(userDid); + const providerResp = await this.axios.get(providerUrl, { + headers: providerHeaders, + }); + // should be at least an empty array + if ( + providerResp.status === 200 && + Array.isArray(providerResp.data.data) + ) { + this.providersForGive = providerResp.data.data; + } else { + console.error("Error getting give providers:", giveResp); + this.$notify( + { + group: "alert", + type: "warning", + title: "Error", + text: "Got error retrieving linked provider data.", + }, + -1, + ); + } } else if (this.veriClaim.claimType === "Offer") { const offerUrl = this.apiServer + @@ -638,6 +708,15 @@ export default class ClaimView extends Vue { this.detailsForOffer = offerResp.data.data[0]; } else { console.error("Error getting detailed offer info:", offerResp); + this.$notify( + { + group: "alert", + type: "warning", + title: "Error", + text: "Got error retrieving linked offer data.", + }, + -1, + ); } } diff --git a/src/views/GiftedDetailsView.vue b/src/views/GiftedDetailsView.vue index e55ccff..ff2fc0b 100644 --- a/src/views/GiftedDetailsView.vue +++ b/src/views/GiftedDetailsView.vue @@ -640,6 +640,7 @@ export default class GiftedDetails extends Vue { this.offerId, this.isTrade, this.imageUrl, + [], ); } @@ -708,6 +709,7 @@ export default class GiftedDetails extends Vue { this.offerId, this.isTrade, this.imageUrl, + [], this.prevCredToEdit?.id as string, ); const claimStr = JSON.stringify(giveClaim); diff --git a/src/views/ProjectViewView.vue b/src/views/ProjectViewView.vue index a816b46..bae97e6 100644 --- a/src/views/ProjectViewView.vue +++ b/src/views/ProjectViewView.vue @@ -385,7 +385,7 @@ {{ serverUtil.didInfo( - give.agentDid, + give.recipientDid, activeDid, allMyDids, allContacts, diff --git a/src/views/QuickActionBvcEndView.vue b/src/views/QuickActionBvcEndView.vue index c7d6585..d7ac41a 100644 --- a/src/views/QuickActionBvcEndView.vue +++ b/src/views/QuickActionBvcEndView.vue @@ -97,7 +97,7 @@

Anything else?

- Someone else gave + The group provided = [ + { + "@type": "PlanAction", + identifier: BVC_MEETUPS_PROJECT_CLAIM_ID, + }, + ]; const giveResult = await createAndSubmitGive( axios, this.apiServer, @@ -314,7 +320,11 @@ export default class QuickActionBvcBeginView extends Vue { this.description, undefined, undefined, - BVC_MEETUPS_PROJECT_CLAIM_ID, + undefined, + undefined, + false, + undefined, + providers, ); giveSucceeded = giveResult.type === "success"; if (!giveSucceeded) {