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

Merged
jose merged 8 commits from claimview-fullfills-offer into master 1 month ago
jose commented 2 months ago
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 2 months ago
a1388539c1 Fix: improve offer fulfillment detection in ClaimView
693173f09d UI: wording and spacing consistencies
trentlarson reviewed 2 months ago
}
const fulfills = this.detailsForGive.fullClaim.fulfills;
if (!Array.isArray(fulfills)) {
Poster
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.
jose commented 2 months ago
Poster
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`.
Poster
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
jose commented 1 month ago
Poster
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 2 months ago
* @param prefix - Optional prefix to add
* @returns Formatted string
*/
capitalizeAndInsertSpacesBeforeCapsWithAPrefix(text: string): string {
Poster
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.
jose commented 2 months ago
Poster
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 2 months ago
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 2 months ago
e5ad71505c Chore: move function to serverUtil
jose added 1 commit 1 month ago
d87f44b75d fix(claims): handle single Offer object in fulfills field
jose added 1 commit 1 month ago
3e5e2cd0bb fix(claims): handle single Offer object in fulfills field for ConfirmGiftView
jose added 1 commit 1 month ago
1eeb013638 refactor(claims): extract offer fulfillment logic to utility function
Owner

Looks great! 👍

Looks great! 👍
jose added 1 commit 1 month ago
jose merged commit bd072d95eb into master 1 month ago
The pull request has been merged as bd072d95eb.
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This pull request currently doesn't have any dependencies.

Loading…
There is no content yet.