-
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
fix: APP-404 update field and trigger validation instead of using onChange #2514
base: dev
Are you sure you want to change the base?
Conversation
👷 Deploy Preview for regen-website processing.
|
@erikalogie see testing instructions |
LGTM |
const currency = useWatch({ | ||
control, | ||
name: CURRENCY, | ||
}); | ||
|
||
const handleOnChange = useCallback( | ||
(event: ChangeEvent<HTMLInputElement>) => { | ||
// Remove zeros in non decimal values and update the value | ||
const value = event.target.value; | ||
if (!value.includes('.')) setValue(CURRENCY_AMOUNT, Number(value)); |
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.
removing this introduces another bug, you can't type a number with 2 decimals if the first decimal is 0, eg 21,05
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.
Reverting doesn't seem to work either. There seems to be an error that may be related to stripe when introducing numbers 2.01. Any idea what the thrown error is about @blushi . Also the user gets stuck in the error screen because the amount introduced is in the Local Storage.
Screen.Recording.2024-10-24.at.16.30.26.mov
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 think that should be a separated issue btw. If we are happy with the fix for the current issue we may want to merge this so other features don't have to deal with not being able to use the currency input.
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.
Stripe doesn't allow amounts with more than 2 decimals for USD
we provide to stripe the amount in cents, so for 2.01 it should be 201 but I guess when we do 2.01*100 in JS it gives 200.99999999999997 because of its floating point representation, this is why in some places I use .toFixed(...)
, we should use it in this case as well
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.
ok, thanks - I have added a possible solution to this too
d55160a
to
e3bd394
Compare
c554305
to
4b2f4bd
Compare
Description
https://regennetwork.atlassian.net/browse/APP-404
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
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...