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.
This commit is contained in:
@@ -119,25 +119,17 @@
|
||||
Fulfills a bigger plan...
|
||||
</router-link>
|
||||
</div>
|
||||
<!-- if there's another, it's probably fulfilling an offer, too -->
|
||||
<div
|
||||
v-if="
|
||||
detailsForGive?.fulfillsType &&
|
||||
detailsForGive?.fulfillsType !== 'PlanAction' &&
|
||||
detailsForGive?.fulfillsHandleId
|
||||
"
|
||||
>
|
||||
<!-- Show offer fulfillment if this give fulfills an offer -->
|
||||
<div v-if="offerFulfillment?.offerHandleId">
|
||||
<!-- router-link to /claim/ only changes URL path -->
|
||||
<a
|
||||
class="text-blue-500 mt-4 cursor-pointer"
|
||||
@click="
|
||||
showDifferentClaimPage(detailsForGive?.fulfillsHandleId)
|
||||
"
|
||||
@click="showDifferentClaimPage(offerFulfillment.offerHandleId)"
|
||||
>
|
||||
Fulfills
|
||||
{{
|
||||
capitalizeAndInsertSpacesBeforeCaps(
|
||||
detailsForGive.fulfillsType,
|
||||
offerFulfillment.offerType || "Offer",
|
||||
)
|
||||
}}...
|
||||
</a>
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user