Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPDX-8216 - tools - fix commitment info - suggested changes #1074

Merged
merged 3 commits into from
Sep 17, 2024

Conversation

wjames111
Copy link
Contributor

Description

  • Suggested Changes Needs to be the default and not the fallback
  • Ticket #8131 MPDX-8131

Checklist:

  • I have given my PR a title with the format "MPDX-(JIRA#) (summary sentence max 80 chars)"
  • I have applied the appropriate labels. (Add the label "On Staging" to get the branch automatically merged into staging.)
  • I have requested a review from another person on the project

@wjames111 wjames111 added On Staging Will be merged to the staging branch by Github Actions Preview Environment Add this label to create an Amplify Preview labels Sep 16, 2024
@wjames111 wjames111 self-assigned this Sep 16, 2024
Copy link
Contributor

Copy link
Contributor

github-actions bot commented Sep 16, 2024

Bundle sizes [mpdx-react]

Compared against f06e55b

No significant changes found

@wjames111
Copy link
Contributor Author

@caleballdrin I talked with Andrew and unfortunately we can't get graphql fields for suggested changes, they need to be in JSON. Kind of unfortunate but not a big deal.

I researched a little more what's going on with the old MPDx. Like you said, It appears suggested changes is used as the default for populating the form. It also looks like the other graphql fields are used as a fallback.

In light of that I think all that's really needed is to switch around the pledgeAmount and pledgeFrequency. Does that sound right or do you think we need a different solution.

@dr-bizz
Copy link
Contributor

dr-bizz commented Sep 16, 2024

@wjames111 I wonder if you could fetch them using the GQL proxy?

@wjames111
Copy link
Contributor Author

@dr-bizz Never done that before, I could see if that works. I am currently able to get the suggested changes they're just in json format rather then gql. So it's just a matter of convenience. Would using the proxy get me gql fields or is it json as well?

@dr-bizz
Copy link
Contributor

dr-bizz commented Sep 16, 2024

Oh, I see. I would use what you have then (Not use proxy) and convert the JSON to what you need and use it.

Can you not use the JSON as is

@@ -249,9 +249,10 @@ const Contact: React.FC<Props> = ({
initialValues={{
statusValue: statusValue,
pledgeCurrency: amountCurrency,
pledgeAmount: amount || suggestedAmount,
Copy link
Contributor

@caleballdrin caleballdrin Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@canac Can you help us make sense of this? We don't know if Fix Commitment Info should set the initial values to blank, the suggested values, or the current values. On my personal account, it appears that it sets the initial values to the suggested values and leaves it blank if there is no suggested value.

However, in the Angular code, the mutateContacts service appears to use defaultTo to set the initial value to the original/current value and only use the suggested value if it doesn't have one. I was thinking you might be able to understand the angular better than we can.

https://github.com/CruGlobal/mpdx_web/blob/19c03ae0689609eeee8b9b516700cc75ee4f3f79/src/tools/fix/commitment/commitment.service.ts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On your account, is there a way to log out the contact.pledge_amount? I wonder if this is blank, which is why it's showing blank.

When you say blank, do you mean like this? where it only shows the "0" placeholder for the amount.
Screenshot 2024-09-16 at 3 48 39 PM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If so, this is because the pledge amount is null and there is no contact.suggested_changes.pledge_amount
Screenshot 2024-09-16 at 3 49 45 PM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code should read

pledgeAmount: suggestedAmount || amount,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if that makes sense

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that make sense?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status: suggestedChanges.status || statusValue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dr-bizz so to clarify?
Screenshot 2024-09-17 at 11 38 00 AM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is correct

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. So we have confirmed that the suggested values (status, frequency, amount) should be the initial form values. If they don't exist, then it will set the current values as the initial form values.

@wjames111 wjames111 changed the title Switch fallback from suggested changes to default fields on contacts. MPDX-8216 - tools - fix commitment info - suggested changes Sep 17, 2024
Copy link
Contributor

@caleballdrin caleballdrin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@wjames111 wjames111 merged commit 233f13f into main Sep 17, 2024
17 of 18 checks passed
@wjames111 wjames111 deleted the MPDX-8216-fix-commitment-info-suggested-changes branch September 17, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
On Staging Will be merged to the staging branch by Github Actions Preview Environment Add this label to create an Amplify Preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants