-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[HOLD for payment 2023-08-16] [$1000] Refactor MoneyAmountRequestPage
to make it more reusable
#23149
Comments
MoneyAmountRequestPage
to make it more reusableMoneyAmountRequestPage
to make it more reusable
Job added to Upwork: https://www.upwork.com/jobs/~018aca51d5f6723c8c |
Triggered auto assignment to @sophiepintoraetz ( |
Triggered auto assignment to @twisterdotcom ( |
Triggered auto assignment to Design team member for new feature review - @shawnborton ( |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @eVoloshchak ( |
📣 @eVoloshchak Please request via NewDot manual requests for the Contributor role ($1000) |
ProposalThe Q: MoneyRequestAmountPage has a hard dependency on props.iou. AFAICT that is a temporary Onyx key where we are storing things about a request that is currently being staged for creation. The long term plan is to use the transaction object. So, the first challenge is decoupling that dependency anywhere it is referenced.
Q: There is some navigation handling that should be moved out of this component. It also has a dependency on the props.iou Onyx key. There are a lot of things being derived from navigation params - ideally, we would be able to pass those as props and handle the navigation params in a parent page?
Q: It would be good if all of the hooks were documented better + have some comment about why they are being used.
Q: Having a useEffect() detect a change in props and then set state feels like an anti-pattern? Can we just use the prop?
Q: This is referencing an errors prop that doesn't seem to exist.
Q: I am confused about why all of these values are stored in refs here.
By following this plan, we aim to make |
If I may express my thoughts, considering the intricacy of MoneyRequestAmountPage, which isn't a brief file with approximately 500 lines, the task of refactoring it is not entirely straightforward. Beyond restructuring the code, we also need to guarantee that it operates flawlessly, devoid of any bugs or regressions. Given the scope of the task, I believe a minimum price range of $1500 to $2000 would be a more equitable starting point for this job |
ProposalPlease re-state the problem that we are trying to solve in this issue.Refactor the What changes do you think we should make in order to solve the problem?###Strategy
I think the bounty is fine, but a more lenient time window to complete the refactor may be appropriate. What alternative solutions did you explore? (Optional)N/A |
ProposalPlease re-state the problem that we are trying to solve in this issue.The
What is the root cause of that problem?The root cause of these problems can be attributed to the way the What changes do you think we should make in order to solve the problem?
// Before
function MoneyRequestAmountPage(props) {
const id = props.iou.id;
// Rest of the component
}
// After
function MoneyRequestAmountPage({id, ...props}) {
// Now use id directly
// Rest of the component
}
Create a custom navigation handling hook that accepts the necessary parameters and handles the navigation accordingly. // Custom hook for navigation
function useNavigationHandler(iouType, reportID, iouId) {
const navigation = useNavigation();
useEffect(() => {
// navigation logic...
}, [iouId]);
}
// Use the custom hook in the component
function MoneyRequestAmountPage({iouType, reportID, iouId, ...props}) {
useNavigationHandler(iouType, reportID, iouId);
// Rest of the component
}
// Parent component
function ParentComponent() {
const route = useRoute();
const params = route.params;
return <MoneyRequestAmountPage {...params} />;
}
// Child component
function MoneyRequestAmountPage({iouType, reportID, ...props}) {
// Use iouType and reportID directly
// Rest of the component
}
// Before
useEffect(() => {
setAmount(props.iou.amount);
}, [props.iou.amount]);
// After
// Use props.iou.amount directly in the component
// AmountRequestPage.js
function AmountRequestPage({amount, onAmountChange}) {
// Shared logic
return (
<div>
<input type="number" value={amount} onChange={onAmountChange} />
{/* More shared UI elements... */}
</div>
);
}
// MoneyRequestAmountPage.js
function MoneyRequestAmountPage({iou, ...props}) {
const onAmountChange = useCallback((newAmount) => {
// Update amount in iou...
}, []);
return <AmountRequestPage amount={iou.amount} onAmountChange={onAmountChange} />;
}
// EditRequestAmountPage.js
function EditRequestAmountPage({transaction, ...props}) {
const onAmountChange = useCallback((newAmount) => {
// Update amount in transaction...
}, []);
return <AmountRequestAmountPage amount={transaction.amount} onAmountChange={onAmountChange} />;
}
These proposed changes aim to improve the What alternative solutions did you explore? (Optional)None. |
@marcaaron do we need a C+ here to evaluate the proposals, or will you do it? Any thoughts on bumping the price here as @ygshbht proposes? Our usual process is to rely on the market of proposals and bump if we don't think there are any within a week that are good to go. Secondly, if the proposer we want to go with requests more to complete the job, we can discuss that then. |
Hi :) I'm very close to opening my draft PR. But before I do that I need to do some cleanup and I've got one question: is there any possible scenario that would require that logic? Can we have a situation when the iou id from params don't match the iou id from Onyx? I'm asking because I feel that it's no longer necessary, but maybe I'm missing something and I just wanted to confirm. |
Good question, I think that you are right, but we might as well discover this during testing |
Without having a ton of context (and being quite confused myself about it) I think the best path would be to try and git blame whichever PR added it and make sure we are not re-introducing any regressions / follow whatever test steps we had when it was first added. |
@koko57 Lets make sure to raise the PR tomorrow and lets work with some C+ to get it merged ASAP. We are focusing a lot now to finish the edit money request feature and this refactor/ improvement will help a lot so (its harder to continue without it and it will double the work for one of us) if we could nail this tomorrow, it would be super helpful. I can help out to get some C+ who could actively help to test it with you tomorrow Here is WIP PR for the edit money request btw #23703 |
Draft PR #23979 |
Can I get assigned here? |
@marcaaron @mountiny I've opened a draft follow-up PR addressing all the NAB comments from #23979. I replied to some of them explaining why I solved the problems a bit differently. Let me know if I can open the PR for review. I'll be ooo tomorrow, so if you request any changes, I'll be working on them on Friday. |
@s77rt - is this for the reviews? |
@twisterdotcom Yes |
📣 @eVoloshchak Please request via NewDot manual requests for the Reviewer role ($1000) |
📣 @s77rt 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
@koko57 Is there anything left to do in this issue? |
No, I think everything's done here |
MoneyAmountRequestPage
to make it more reusableMoneyAmountRequestPage
to make it more reusable
thanks! @twisterdotcom I think we can then pay @s77rt for the review $1000 and close this out. Thank you! |
@twisterdotcom Payment is handled already on #24125 |
Ah, nice! |
The
MoneyRequestAmountPage
needs to be improved to make it more reusable for the "Edit Request" flow here. There are also some issues with the code.Issues...
MoneyRequestAmountPage
has a hard dependency on props.iou. AFAICT that is a temporary Onyx key where we are storing things about a request that is currently being staged for creation. The long term plan is to use thetransaction
object. So, the first challenge is decoupling that dependency anywhere it is referenced.Other things that are possibly incorrect...
useEffect()
detect a change in props and then set state feels like an anti-pattern? Can we just use the prop?Deliverables:
AmountRequestPage
and then have aMoneyRequestAmountPage
andEditRequestAmountPage
that both useAmountRequestPage
.MoneyRequestAmountPage
- custom navigation stuff, uses the iou Onyx prop, etc.EditRequestAmountPage
- different navigation stuff, uses the transaction Onyx propThoughts on this approach?
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: