Fix offer fulfillment detection + consistencies between ClaimView and ConfirmGiftView #167

Merged
jose merged 8 commits from claimview-fullfills-offer into master 2025-09-08 08:37:03 +00:00
Owner
  • Modified the logic to look for fulfillsType "Offer" in the full claim details in order to show "fulfills an offer" link more reliably.
  • Matched wordings and spacings in the fulfills links of ClaimView and ConfirmGiftView for consistency.
- Modified the logic to look for fulfillsType "Offer" in the full claim details in order to show "fulfills an offer" link more reliably. - Matched wordings and spacings in the fulfills links of ClaimView and ConfirmGiftView for consistency.
jose added 2 commits 2025-08-14 13:08:54 +00:00
- 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.
- Added grouped conditional spacing to ensure a top margin before fulfills links
- Brought over icons and wording from ConfirmGiftView to ClaimView
trentlarson reviewed 2025-08-17 20:03:39 +00:00
@@ -704,0 +733,4 @@
}
const fulfills = this.detailsForGive.fullClaim.fulfills;
if (!Array.isArray(fulfills)) {
Owner

There is one more case here: the fullClaim.fulfills can potentially be a single claim object that is not in an array. (This is the case for most of the schema.org properties: they are defined with a particular type but they could be an array of that type.) So check for fulfills["@type"] of "Offer" to set other fulfills variables.

There is one more case here: the fullClaim.fulfills can potentially be a single claim object that is not in an array. (This is the case for most of the schema.org properties: they are defined with a particular type but they could be an array of that type.) So check for `fulfills["@type"]` of "Offer" to set other `fulfills` variables.
Author
Owner

What's a good way to recreate a claim object that has this particular structure? Gives that fulfill project offers always have @type: PlanAction, @type: Offer and @type: DonateAction. Gives that fulfill person offers always have @type: Offer and @type: DonateAction.

What's a good way to recreate a claim object that has this particular structure? Gives that fulfill project offers always have `@type: PlanAction`, `@type: Offer` and `@type: DonateAction`. Gives that fulfill person offers always have `@type: Offer` and `@type: DonateAction`.
Owner

You will have to create one by hand. I'll show how in the issue https://app.clickup.com/t/86b027guj

You will have to create one by hand. I'll show how in the issue https://app.clickup.com/t/86b027guj
Author
Owner

Thanks, the video was very helpful! I was able to update the code block to test for both array and single-object fulfills. Now, "This fulfills an offer" shows up for both scenarios.

Since the logic is used in two places, I made a utility method for it.

Thanks, the video was very helpful! I was able to update the code block to test for both array and single-object `fulfills`. Now, "This fulfills an offer" shows up for both scenarios. Since the logic is used in two places, I made a utility method for it.
trentlarson marked this conversation as resolved
trentlarson reviewed 2025-08-17 20:04:46 +00:00
@@ -761,0 +815,4 @@
* @param prefix - Optional prefix to add
* @returns Formatted string
*/
capitalizeAndInsertSpacesBeforeCapsWithAPrefix(text: string): string {
Owner

This is also in ConfirmGiftView, so it's worth pulling out into a "util" file so they can both use the same logic.

This is also in ConfirmGiftView, so it's worth pulling out into a "util" file so they can both use the same logic.
Author
Owner

In a new commit, I moved that function to endorserServer.ts, where a similar function capitalizeAndInsertSpacesBeforeCaps() already exists, and that both views also use.

In a new commit, I moved that function to `endorserServer.ts`, where a similar function `capitalizeAndInsertSpacesBeforeCaps()` already exists, and that both views also use.
trentlarson marked this conversation as resolved
trentlarson added 1 commit 2025-08-17 20:13:18 +00:00
Owner

This looks great!

I just recommended a few small tweaks.

This looks great! I just recommended a few small tweaks.
jose added 1 commit 2025-08-18 09:46:31 +00:00
- capitalizeAndInsertSpacesBeforeCapsWithAPrefix() defined in two places, unified and moved to endorserServer.ts
- Use capitalizeAndInsertSpacesBeforeCaps() that's already defined in endorserServer.ts
jose added 1 commit 2025-09-01 13:05:37 +00:00
Updated extractOfferFulfillment to support both array and single object
cases for the fulfills field. Previously only handled array format,
now also checks if fulfills is a single Offer object with @type "Offer".
jose added 1 commit 2025-09-01 13:16:58 +00:00
Updated extractOfferFulfillment to support both array and single object
cases for the fulfills field, matching the fix applied to ClaimView.
Now handles when fulfills contains a single Offer object with @type "Offer".
jose added 1 commit 2025-09-01 13:23:35 +00:00
Created extractOfferFulfillment utility in libs/util.ts to handle both
array and single object cases for fulfills field. Updated ClaimView and
ConfirmGiftView to use the shared utility, eliminating code duplication
and improving maintainability.
Owner

Looks great! 👍

Looks great! 👍
jose added 1 commit 2025-09-08 08:36:51 +00:00
jose merged commit bd072d95eb into master 2025-09-08 08:37:03 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: trent_larson/crowd-funder-for-time-pwa#167