-
Notifications
You must be signed in to change notification settings - Fork 306
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
GRWT-3133 / Kate / [DTrader-V2] Tech Debt: Refactor Stake component [WIP] #17620
Draft
kate-deriv
wants to merge
6
commits into
deriv-com:master
Choose a base branch
from
kate-deriv:kate/DTRA-2396/stake_refactor
base: master
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.
Draft
GRWT-3133 / Kate / [DTrader-V2] Tech Debt: Refactor Stake component [WIP] #17620
kate-deriv
wants to merge
6
commits into
deriv-com:master
from
kate-deriv:kate/DTRA-2396/stake_refactor
+379
−13
Conversation
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
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
A production App ID was automatically generated for this PR. (log)
Click here to copy & paste above information.
|
🚨 Lighthouse report for the changes in this PR:
Lighthouse ran with https://deriv-app-git-fork-kate-deriv-kate-dtra-2396stakerefactor.binary.sx/ |
⏳ Generating Lighthouse report... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes:
Stake validation refactoring:
Instead of executing onChange function from trade store (that will change store values and send new proposal with them) when user is typing, we are going to use useDtraderQuery hook without subscription. It will allow us to validate the new values + we can extract more information from response. Because we are not subscribing, the store values won't be changed and we won't form a new proposal request with subscription. That will also allow us to restore original values in case of page reload & clicking on back arrow & closing without saving, so there is no need in stake in v2_params_initial_values. Only when user clicks on 'Save' button we'll call onChange.
Stake error snackbar refactoring:
Refactoring the logic of snackbar executing should include removing it outside of the Stake component.
Current problems:
Each trade param has it's own logic for triggering a snackbar (code duplications)
Because at the same moment we have 2 instances of the same component at the page (e.g. stake big and stake minimized), BOTH of them triggers snackbar. As a result there are a lot of bugs, where same error is shown twice.
Suggested:
To create a component for trade param error snackbar (TradeParamErrorSnackbar) and keep all the logic of triggering/showing the snackbar there. Not in multiple places across all the trade params.
To render this component in top level, in trade.tsx for e.g. In this case, even if we have 2 instances of the same component with the same error, we will have only one snackbar.
To create a hook (useTradeParamError), which will incapsulate the logic of errors checking. We will just pass fields, which it should track (e.g. ['take_profit', 'stop_loss', 'stake']) and get from hook info if this field has error and what is the error text.
Acceptance Criteria
Screenshots:
Please provide some screenshots of the change.