forked from jsnbuchanan/crowd-funder-for-time-pwa
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),
|
||||
|
||||
@@ -113,26 +113,20 @@
|
||||
/>
|
||||
</router-link>
|
||||
</div>
|
||||
<!-- if there's another, it's probably fulfilling an offer, too -->
|
||||
<div
|
||||
v-if="
|
||||
giveDetails?.fulfillsType &&
|
||||
giveDetails?.fulfillsType !== 'PlanAction' &&
|
||||
giveDetails?.fulfillsHandleId
|
||||
"
|
||||
>
|
||||
<!-- Show offer fulfillment if this give fulfills an offer -->
|
||||
<div v-if="offerFulfillment?.offerHandleId">
|
||||
<!-- router-link to /claim/ only changes URL path -->
|
||||
<router-link
|
||||
:to="
|
||||
'/claim/' +
|
||||
encodeURIComponent(giveDetails?.fulfillsHandleId || '')
|
||||
encodeURIComponent(offerFulfillment.offerHandleId || '')
|
||||
"
|
||||
class="text-blue-500 mt-2 cursor-pointer"
|
||||
>
|
||||
This fulfills
|
||||
{{
|
||||
capitalizeAndInsertSpacesBeforeCapsWithAPrefix(
|
||||
giveDetails?.fulfillsType || "",
|
||||
offerFulfillment.offerType || "Offer",
|
||||
)
|
||||
}}
|
||||
<font-awesome
|
||||
@@ -493,6 +487,11 @@ export default class ConfirmGiftView extends Vue {
|
||||
confsVisibleErrorMessage = "";
|
||||
confsVisibleToIdList: string[] = []; // list of DIDs that can see any confirmer
|
||||
giveDetails?: GiveSummaryRecord;
|
||||
// Additional offer information extracted from the fulfills array
|
||||
offerFulfillment: {
|
||||
offerHandleId?: string;
|
||||
offerType?: string;
|
||||
} | null = null;
|
||||
giverName = "";
|
||||
issuerName = "";
|
||||
isLoading = false;
|
||||
@@ -648,6 +647,8 @@ export default class ConfirmGiftView extends Vue {
|
||||
|
||||
if (resp.status === 200) {
|
||||
this.giveDetails = resp.data.data[0];
|
||||
// Extract offer information from the fulfills array
|
||||
this.extractOfferFulfillment();
|
||||
} else {
|
||||
throw new Error("Error getting detailed give info: " + resp.status);
|
||||
}
|
||||
@@ -707,6 +708,33 @@ export default class ConfirmGiftView extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract offer fulfillment information from the fulfills array
|
||||
*/
|
||||
private extractOfferFulfillment() {
|
||||
if (!this.giveDetails?.fullClaim?.fulfills) {
|
||||
this.offerFulfillment = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const fulfills = this.giveDetails.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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches confirmer information for the claim
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user