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

feat: APP-364 order summary card #2498

Merged
merged 13 commits into from
Oct 23, 2024
Merged

feat: APP-364 order summary card #2498

merged 13 commits into from
Oct 23, 2024

Conversation

blushi
Copy link
Member

@blushi blushi commented Oct 9, 2024

Description

https://regennetwork.atlassian.net/browse/APP-364


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • provided a link to the relevant issue or specification
  • provided instructions on how to test
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

How to test

https://deploy-preview-2498--regen-marketplace.netlify.app/project/C01-001/buy
Update the credits amount from the order summary card from different steps in the flow and verify the resulting amount to pay updates accordingly.

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items
.

I have...

  • confirmed all author checklist items have been addressed
  • reviewed code correctness and readability
  • verified React components follow DRY principles
  • reviewed documentation is accurate
  • reviewed tests
  • manually tested (if applicable)

@blushi blushi mentioned this pull request Oct 9, 2024
10 tasks
@blushi blushi force-pushed the feat-APP-364-order-summary-card branch from b0d8f9f to 30bd970 Compare October 10, 2024 14:10
@blushi blushi requested a review from r41ph October 10, 2024 15:37
@blushi blushi marked this pull request as ready for review October 10, 2024 15:37
Base automatically changed from feat-APP-204-buy-credits to dev October 15, 2024 14:38
@blushi blushi force-pushed the feat-APP-364-order-summary-card branch from 757e5f6 to 6627fea Compare October 16, 2024 08:40
Copy link

netlify bot commented Oct 16, 2024

Deploy Preview for regen-website ready!

Name Link
🔨 Latest commit d3efc66
🔍 Latest deploy log https://app.netlify.com/sites/regen-website/deploys/6718d1fd35e1560008b93207
😎 Deploy Preview https://deploy-preview-2498--regen-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@blushi blushi requested a review from r41ph October 16, 2024 09:52
@blushi
Copy link
Member Author

blushi commented Oct 16, 2024

@erikalogie see testing instructions

@erikalogie
Copy link
Collaborator

Order summary looks good. Maybe as a separate bug, when I click on tradable credits after choosing the max number of retirable credits, I get this error:
Screen Shot 2024-10-16 at 1 07 38 PM

@blushi
Copy link
Member Author

blushi commented Oct 16, 2024

Order summary looks good. Maybe as a separate bug, when I click on tradable credits after choosing the max number of retirable credits, I get this error: Screen Shot 2024-10-16 at 1 07 38 PM

Just a missing translation, I just need to re-run our i18n extraction script to fix this so I don't think we need a separate task

@erikalogie
Copy link
Collaborator

Wdyt if we make the field wider for the number of credits when you go to edit it? When I went to update it, I couldn't see the whole number because of all the decimals.
Monosnap Buena Vista Heights Conservation Area | Regen Marketplace 2024-10-16 16-07-55

@blushi
Copy link
Member Author

blushi commented Oct 17, 2024

Wdyt if we make the field wider for the number of credits when you go to edit it? When I went to update it, I couldn't see the whole number because of all the decimals. Monosnap Buena Vista Heights Conservation Area | Regen Marketplace 2024-10-16 16-07-55

@erikalogie updated

@erikalogie
Copy link
Collaborator

Wdyt if we make the field wider for the number of credits when you go to edit it? When I went to update it, I couldn't see the whole number because of all the decimals. Monosnap Buena Vista Heights Conservation Area | Regen Marketplace 2024-10-16 16-07-55

@erikalogie updated

Looks good!

@erikalogie
Copy link
Collaborator

@blushi Christian found this bug while testing on this branch: "Cannot change dollar amount of credits to purchase. When I do, I get an error page with an n.toFixed is not a Function message. "

He tried to change the dollar amount when trying to buy fiat credits with a web 2.0 only account

See this video at 12:23: https://us02web.zoom.us/rec/share/t30QW8KPjkaqmm6N3_ZLQyZMd6lhp6zgKxmoT2ct8Kfu-J4D_XYo2obx_71creby.z-JaUieYQqpeH0GX
Passcode: Y^qUb8AY

If this should be a separate bug, let me know and I can file it.

@erikalogie
Copy link
Collaborator

@blushi another bug that Christian found:
"When I logged with my KEPLR address, there was a message that said something about this REGEN address being associated with the e-mail address that I logged in with. But, I do not believe that I logged in with an e-mail address, just web 3, so I’ve left confused. "

You'll find the issue at 18:48 in the video above.

@blushi
Copy link
Member Author

blushi commented Oct 17, 2024

@blushi Christian found this bug while testing on this branch: "Cannot change dollar amount of credits to purchase. When I do, I get an error page with an n.toFixed is not a Function message. "

He tried to change the dollar amount when trying to buy fiat credits with a web 2.0 only account

See this video at 12:23: https://us02web.zoom.us/rec/share/t30QW8KPjkaqmm6N3_ZLQyZMd6lhp6zgKxmoT2ct8Kfu-J4D_XYo2obx_71creby.z-JaUieYQqpeH0GX Passcode: Y^qUb8AY

If this should be a separate bug, let me know and I can file it.

Yeah let's file a separate bug please

@blushi
Copy link
Member Author

blushi commented Oct 17, 2024

@blushi another bug that Christian found: "When I logged with my KEPLR address, there was a message that said something about this REGEN address being associated with the e-mail address that I logged in with. But, I do not believe that I logged in with an e-mail address, just web 3, so I’ve left confused. "

You'll find the issue at 18:48 in the video above.

It doesn't seem related to the buy flow itself but rather some issues related to the app state not being updated correctly immediately after logging in, since it works after reloading. Unfortunately I can't reproduce it but we should file a bug nevertheless.

@erikalogie
Copy link
Collaborator

Ok I filed separate bugs for the above: https://regennetwork.atlassian.net/browse/APP-404 and https://regennetwork.atlassian.net/browse/APP-405

web-marketplace/src/pages/BuyCredits/BuyCredits.Form.tsx Outdated Show resolved Hide resolved
const currency = data?.[CURRENCY];
const creditsAmount = data?.[CREDITS_AMOUNT];
const currencyAmount = data?.[CURRENCY_AMOUNT];
const creditTypePrecision = creditTypeData?.creditType?.precision;
Copy link
Contributor

@r41ph r41ph Oct 22, 2024

Choose a reason for hiding this comment

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

@blushi Shouldn't we memoize this as well? It is used as a dependency for creating creditsAvailable and also passed as prop to ChooseCreditsForm. Actually, ChooseCreditsForm should be wrap with React.memo() too to prevent unnecessary re-renders.

Copy link
Member Author

Choose a reason for hiding this comment

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

we use useMemo to wrap creditsAvailable
but we can use React.memo for ChooseCreditsForm too
I was also thinking about potentially creating a BuyCreditsContext, instead of having to pass all those props to the child components, wdyt? But maybe can be refactored later.

Copy link
Contributor

Choose a reason for hiding this comment

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

My thinking is that since creditTypePrecision is recreated on every render, it will cause creditsAvailable to recalculate each time. Memoizing creditTypePrecision could prevent that, as well as unnecessary re-renders of ChooseCreditsForm .

I like your idea about a BuyCreditsContext, it will help simplify things.

Copy link
Member Author

@blushi blushi Oct 23, 2024

Choose a reason for hiding this comment

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

but creditTypePrecision doesn't change on every render, the actual value will only change once we get the correspond query response so this should only cause creditsAvailable to recalcule this time (if we exclude other dependencies)

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the issue is that the variable is recreated and it's reference changes when react re-executes the component - even if its value remains the same - and that is what can trigger a creditsAvailable recalculation and a ChooseCreditsForm re-render

Copy link
Member Author

Choose a reason for hiding this comment

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

but creditTypePrecision is a copy using some react query data which is cached and stable across re-renders (unless the data changes) so I don't think we need useMemo in this particular case
if that was another type of variable, then this would be useful indeed.

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right about the data being cached and stable across re-renders. However, my concern is that if the component re-renders for any reason, creditTypePrecision will be recreated, even if the value hasn't changed, which may lead to unnecessary recalculations for dependent variables or components. If we repeat this pattern throughout the app it might impact performance.

That said, I’ll go ahead and approve the PR so we can move forward. Perhaps we can chat about this another time?

Copy link
Contributor

@r41ph r41ph left a comment

Choose a reason for hiding this comment

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

See comments please

@blushi blushi requested a review from r41ph October 22, 2024 08:24
@blushi blushi force-pushed the feat-APP-364-order-summary-card branch from e21959c to 77088c0 Compare October 23, 2024 06:21
@blushi blushi force-pushed the feat-APP-364-order-summary-card branch from 77088c0 to d3efc66 Compare October 23, 2024 10:37
@blushi blushi merged commit 01f2590 into dev Oct 23, 2024
14 checks passed
@blushi blushi deleted the feat-APP-364-order-summary-card branch October 23, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants