Refactor: Implement Dedicated Reward Claim Dialog and Button Logic #1973
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.
What does this PR do?
Fixes #1776
This PR refactors the reward claiming mechanism as per your suggestions, introducing a dedicated
ClaimRewardDialog
and improving the logic for the "Claim Reward" button.Description:
Thank you for your detailed feedback, @KoalaSat! I've implemented the changes as discussed. Here’s how this PR addresses your comments:
Claim Reward Flow - Separate Popup:
ClaimRewardDialog.tsx
, which now encapsulates the reward claiming form.ProfileDialog
now opens this newClaimRewardDialog
.ClaimRewardDialog
. It will only be displayed after a claim attempt (simulated here) fails, as per your suggestion. This ensures the user first attempts to claim via invoice before being advised to contact a coordinator for issues.Button State - Disable until rewards available:
ProfileDialog
is now disabled by default.hasClaimableRewards
is true, which is determined by checking ifrobot?.earnedRewards > 0
for any of the known coordinators. This prevents users from attempting to claim when there are no rewards available.UI/Layout Issues:
ProfileDialog
and used standard Material-UI components andsx
props, which are generally responsive. For theListItemAvatar
, I've addedminWidth: 0
andmarginLeft
toListItemAvatar
andflexShrink: 0
toRobotAvatar
's style to give it fixed dimensions and prevent it from affecting theListItemText
's width. This should help in preventing unexpected width expansions.sx
for styling should help maintain layout across different screen sizes. I've conducted initial checks, and the dialog adapts well.ListItemAvatar
now hasminWidth: 0
to allow theListItemText
to take more space, andmarginLeft
for appropriate spacing. TheRobotAvatar
itself hasflexShrink: 0
to ensure its defined width/height are respected, keeping it within its intended bounds.This approach provides a clearer and more guided user experience for claiming rewards.
Checklist before merging
pip install pre-commit
, thenpre-commit install
. Pre-commit installs git hooks that automatically check the codebase. If pre-commit fails when you commit your changes, please fix the problems it points out.