-
Notifications
You must be signed in to change notification settings - Fork 9
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-204 buy credits #2477
Conversation
✅ Deploy Preview for regen-website ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
variant="determinate" | ||
value={props.percentComplete} | ||
/> | ||
{!hideProgress && typeof percentComplete !== 'undefined' && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this be percentComplete !== undefined
instead of using typeof
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually prefer using typeof
because this is safer if the variable hasn't already been declared, it won't throw an error, but I agree in this case, we could also use percentComplete !== undefined
I don't have a strong preference
|
||
type Props = { | ||
onPrev?: () => void; | ||
onSave?: () => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the "Save" button is always rendered but onSave
is optional. Since the button is visible, maybe onSave
should be required to avoid cases where the button has no functionality? Without onSave
, the button could still be enabled and not function properly when clicked. An option could be to disable it if onSave
is not present disabled={saveDisabled || !onSave}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you look at the code for the SaveFooter
you'll see the button has type="submit"
which means that if it's within a Form
it will just use onSubmit
from this form on click so no need to provide onSave
in this case
web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.test.tsx
Outdated
Show resolved
Hide resolved
web-marketplace/src/components/organisms/BuyCreditsModal/BuyCreditsModal.utils.tsx
Outdated
Show resolved
Hide resolved
web-marketplace/src/components/templates/ProjectDetails/hooks/useGetProject.ts
Outdated
Show resolved
Hide resolved
...s/react-query/ecocredit/marketplace/getSellOrdersExtendedQuery/getSellOrdersExtendedQuery.ts
Outdated
Show resolved
Hide resolved
9c490bf
to
d85f997
Compare
@erikalogie @clevinson see testing instructions |
This PR is looking absolutely awesome @blushi. Amazing work! One thing I'm wondering is, when I'm buying with crypto, if I have "retire credits now" selected and have an amount in the fields above, if I then select "buy tradable ecocredits" then the amount resets. Does it need to be this way? If not, could we change this in a follow-up issue? |
You're right, it doesn't always need to be reseted.
|
projectId: string; | ||
}; | ||
export const getFormModel = ({ | ||
_, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way that I think would be more efficient would be that instead of passing around _
we can use i18n
from import { i18n } from '@lingui/core';
That way we could directly do: i18n._(msg`Choose credits`)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading https://lingui.dev/ref/react#uselingui, I believe this might cause some issues when the user switches languages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right that there could be issues when switching languages. However, what I understand is that it can cause issues when i18n._()
is used in memoized functions or components. As long as we avoid using it in those contexts it seems that it should work fine.
Yes, that would be great. Do you want to open a follow-up task for this? Otherwise everything LGTM |
Just added it here |
|
@blushi I'm also realizing that the same issue that I identified with switching between retired and tradable also applies to switching between fiat and crypto or switching between the different crypto currencies. If the user enters a certain number of credits, and then change switches between fiat and crypto, then number of credits should stick rather than reset to 0, and same with the different crypto currencies. If there isn't enough credits in that particular denom, then we should show this error: https://www.figma.com/design/BTuUv6QXY4GbliZcXCe8RJ/Fiat-payments?node-id=174-102754&t=KznaoTIxXgotIAZ2-1. Also, can we move the error messages to be left-aligned with the field? We also want to make sure that this doesn't happen by having the italicized text move down to make room for the error: Can we make the default number of credits when the flow first loads be 1 rather than 0? I'm noticing that if I go through the flow and enter some number of credits and then exit out, and re-enter into it I come to the email part of the form. If I click the back button, then the number of credits is again 0, which shouldn't happen. It should store whatever the number of credits was that the user previously entered if we are taking them to where they left off in the form, and a number of 0 should not be possible. Screen.Recording.2024-10-02.at.9.40.27.AM.mov |
it could be that there are less than 1 credit available, ie 0.5 |
Could we make it 1 or the highest number available under 1? |
Nice work! Few bugs I want to highlight here as I'm going through QA- Input formsOn the dollar / credit input forms we allow for several Fiat PathwayNo bugs! Crypto PathwayWhen I:
Then:
Separate from the above issue, when successfully purchasing tradable credits, the success modal at the end says "View retirement certificate", instead of something like "View ecocredits". I know that we haven't implemented the entire buy flow yet, and there are still follow-ups remaining, but just wanted to make sure this particular issue was being tracked. |
There's indeed a follow up issue for the confirmation step: https://regennetwork.atlassian.net/browse/APP-361 |
orderedSellOrders: UISellOrderInfo[]; | ||
creditTypePrecision?: number | null; | ||
}; | ||
export const getCreditsAmount = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@r41ph just wanted to mention that those functions getCreditsAmount
and getCurrencyAmount
are one of the most important stuff to review in this PR, since it infers the sell orders (by the cheapest) based on the credits or currency amount provided
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blushi this looks great! I've tested it and it seems to work as expected. Just a few minor suggestions.
@erikalogie @clevinson could you have another look? |
LGTM |
You are 100% correct. I just made a version here, wdyt? https://www.figma.com/design/BTuUv6QXY4GbliZcXCe8RJ/Fiat-payments?node-id=5075-76841&t=lKYcqtNVA7T8TxHW-1 |
Looks good, just left a comment. |
web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.tsx
Outdated
Show resolved
Hide resolved
web-marketplace/src/components/templates/ProjectDetails/hooks/useGetProject.ts
Outdated
Show resolved
Hide resolved
web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.utils.tsx
Show resolved
Hide resolved
web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.utils.tsx
Outdated
Show resolved
Hide resolved
web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.utils.tsx
Outdated
Show resolved
Hide resolved
web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.utils.tsx
Outdated
Show resolved
Hide resolved
web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.utils.tsx
Outdated
Show resolved
Hide resolved
web-marketplace/src/components/molecules/CreditsAmount/CreditsAmount.utils.tsx
Outdated
Show resolved
Hide resolved
0746206
to
35ed494
Compare
Description
https://regennetwork.atlassian.net/browse/APP-204
This large PR has been initially code reviewed as part of separate smaller PRs:
#2480
#2482
#2484
Not implemented yet:
Since this PR was already too big, I've decided to have follow-ups for the following items (mapped to tasks on Jira):
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...
How to test
Please have a look at the list above of what's not implemented yet before testing.
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...