From a1388539c1518214226adf9b22924b6d941a7d59 Mon Sep 17 00:00:00 2001 From: Jose Olarte III Date: Thu, 14 Aug 2025 18:53:12 +0800 Subject: [PATCH] Fix: improve offer fulfillment detection in ClaimView - Remove outdated fulfillsType logic that was checking for non-PlanAction items - Keep only the new offer fulfillment extraction from fullClaim.fulfills array - Apply consistent changes to both ClaimView and ConfirmGiftView This ensures that "Fulfills Offer..." links appear correctly when gives are created from offers, by directly parsing the fulfills array instead of relying on API-processed fields that only capture the first relationship. --- src/views/ClaimView.vue | 57 +++++++++++++++++++++++++++-------- src/views/ConfirmGiftView.vue | 48 +++++++++++++++++++++++------ 2 files changed, 83 insertions(+), 22 deletions(-) diff --git a/src/views/ClaimView.vue b/src/views/ClaimView.vue index f594dc9b..76b283f9 100644 --- a/src/views/ClaimView.vue +++ b/src/views/ClaimView.vue @@ -119,25 +119,17 @@ Fulfills a bigger plan... - -
+ +
Fulfills {{ capitalizeAndInsertSpacesBeforeCaps( - detailsForGive.fulfillsType, + offerFulfillment.offerType || "Offer", ) }}... @@ -556,6 +548,17 @@ export default class ClaimView extends Vue { fulfillsPlanHandleId?: string; fulfillsType?: string; fulfillsHandleId?: string; + fullClaim?: { + fulfills?: Array<{ + "@type": string; + identifier?: string; + }>; + }; + } | null = null; + // Additional offer information extracted from the fulfills array + offerFulfillment: { + offerHandleId?: string; + offerType?: string; } | null = null; detailsForOffer: { fulfillsPlanHandleId?: string } | null = null; // Project information for fulfillsPlanHandleId @@ -689,6 +692,7 @@ export default class ClaimView extends Vue { this.confsVisibleToIdList = []; this.detailsForGive = null; this.detailsForOffer = null; + this.offerFulfillment = null; this.projectInfo = null; this.fullClaim = null; this.fullClaimDump = ""; @@ -701,6 +705,33 @@ export default class ClaimView extends Vue { this.veriClaimDidsVisible = {}; } + /** + * Extract offer fulfillment information from the fulfills array + */ + extractOfferFulfillment() { + if (!this.detailsForGive?.fullClaim?.fulfills) { + this.offerFulfillment = null; + return; + } + + const fulfills = this.detailsForGive.fullClaim.fulfills; + if (!Array.isArray(fulfills)) { + this.offerFulfillment = null; + return; + } + + // Find the Offer in the fulfills array + const offerFulfill = fulfills.find((item) => item["@type"] === "Offer"); + if (offerFulfill) { + this.offerFulfillment = { + offerHandleId: offerFulfill.identifier, + offerType: offerFulfill["@type"], + }; + } else { + this.offerFulfillment = null; + } + } + // ================================================= // UTILITY METHODS // ================================================= @@ -821,6 +852,8 @@ export default class ClaimView extends Vue { }); if (giveResp.status === 200 && giveResp.data.data?.length > 0) { this.detailsForGive = giveResp.data.data[0]; + // Extract offer information from the fulfills array + this.extractOfferFulfillment(); } else { await this.$logError( "Error getting detailed give info: " + JSON.stringify(giveResp), diff --git a/src/views/ConfirmGiftView.vue b/src/views/ConfirmGiftView.vue index c2274dab..cf3f3a0c 100644 --- a/src/views/ConfirmGiftView.vue +++ b/src/views/ConfirmGiftView.vue @@ -113,26 +113,20 @@ />
- -
+ +
This fulfills {{ capitalizeAndInsertSpacesBeforeCapsWithAPrefix( - giveDetails?.fulfillsType || "", + offerFulfillment.offerType || "Offer", ) }} item["@type"] === "Offer"); + if (offerFulfill) { + this.offerFulfillment = { + offerHandleId: offerFulfill.identifier, + offerType: offerFulfill["@type"], + }; + } else { + this.offerFulfillment = null; + } + } + /** * Fetches confirmer information for the claim */