-
Notifications
You must be signed in to change notification settings - Fork 79
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
LF-4410: Add limit on creating animals and batches and tests #3542
Open
Tbrid
wants to merge
3
commits into
integration
Choose a base branch
from
LF-4410-Limit-1000-Animal-Create
base: integration
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Thank you for working on this!
Sorry, we should've explained this first... When the checkbox is selected and the count is 1000, 1000 animals will be created. If the checkbox is not selected, a batch with 1000 animals (one record in the DB) will be created instead. The latter is a valid case, so it would be great if you could add a condition to set a maximum limit when the checkbox is selected 🙏
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.
Hi, Sayaka. So I put a hook to deal with this, but then I found it wouldn't change the displayed value in the input when I only use setValue, (i.e. if number is 2000 and user clicks the checkbox, the value will be set to the limit, but still displayed as 2000) so I put a "value" prop for the NumberedInput, let me know what you think about it.
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.
Sorry for the late reply! Sending
value
toNumberInput
seems good, but it looks likevalue
will be automatically passed through without modifyingNumberInput
, since...props
is added toInputBase
. Could you double check?Would it work if we move the logic from the
useEffect
to the checkbox'sonChange
instead?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 found that it doesn't propagate to the InputBase without specifying the value as a prop.
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.
Oh right,
inputProps
's value overrides it.@navDhammu The number in the
NumberInput
doesn't update when the value is changed viasetValue
. Do you think we should update the logic inuseNumberInput
to handle this? (I believe that's the right thing to do!)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.
@SayakaOno The reason it doesn't update with
setValue
is becauseNumberInput
manages its own state, so when changing value with setValue it doesn't update NumberInput's internal state, which is why you still see the previous number.I don't think its a good idea to update the logic inside the
useNumberInput
to handle this because then you would probably have to add a useEffect to update the state based on changes to some prop, and this isn't best practices for react.Better ways of handling this in my opinion:
Also, sending
value
toNumberInput
is not a good idea because it overrides the value given byuseNumberInput
which is a formatted string based on the locale. So overriding that breaks the localization feature.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.
Thank you for your input, I'll discuss the solution with the team!
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.
@navDhammu Thanks for explaining. @SayakaOno I think the 2nd way of using a key is the easiest.
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 agree, but I'm hesitant to go with that approach because we may encounter the same issue in the future. Needing to add a key each time doesn't seem like a sustainable solution...
I'll bring this up in tech daily early next week (feel free to join if you'd like) and get back to you!