-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Refactor how data is loaded into the edit request page #28645
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,9 +90,8 @@ const defaultProps = { | |
| policyTags: {}, | ||
| }; | ||
|
|
||
| function EditRequestPage({betas, report, route, parentReport, policy, session, policyCategories, policyTags}) { | ||
| const parentReportAction = ReportActionsUtils.getParentReportAction(report); | ||
| const transaction = TransactionUtils.getLinkedTransaction(parentReportAction); | ||
| function EditRequestPage({betas, report, route, parentReport, policy, session, policyCategories, policyTags, parentReportActions, transaction}) { | ||
| const parentReportAction = parentReportActions[report.parentReportActionID]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can use lodashGet function here to fetch parentReportAction.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we could. Ideally, this would be done in the
This will be possible once Expensify/react-native-onyx#385 is merged. |
||
| const { | ||
| amount: transactionAmount, | ||
| currency: transactionCurrency, | ||
|
|
@@ -292,18 +291,15 @@ EditRequestPage.defaultProps = defaultProps; | |
| export default compose( | ||
| withCurrentUserPersonalDetails, | ||
| withOnyx({ | ||
| betas: { | ||
| key: ONYXKEYS.BETAS, | ||
| }, | ||
| report: { | ||
| key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.threadReportID}`, | ||
| }, | ||
| }), | ||
| // eslint-disable-next-line rulesdir/no-multiple-onyx-in-file | ||
| withOnyx({ | ||
| betas: { | ||
| key: ONYXKEYS.BETAS, | ||
| }, | ||
| parentReport: { | ||
| key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT}${report ? report.parentReportID : '0'}`, | ||
| }, | ||
| policy: { | ||
| key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, | ||
| }, | ||
|
|
@@ -313,5 +309,21 @@ export default compose( | |
| policyTags: { | ||
| key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${report ? report.policyID : '0'}`, | ||
| }, | ||
| parentReport: { | ||
| key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT}${report ? report.parentReportID : '0'}`, | ||
| }, | ||
| parentReportActions: { | ||
| key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : '0'}`, | ||
| canEvict: false, | ||
| }, | ||
| }), | ||
| // eslint-disable-next-line rulesdir/no-multiple-onyx-in-file | ||
| withOnyx({ | ||
| transaction: { | ||
| key: ({report, parentReportActions}) => { | ||
| const parentReportAction = lodashGet(parentReportActions, [report.parentReportActionID]); | ||
| return `${ONYXKEYS.COLLECTION.TRANSACTION}${lodashGet(parentReportAction, 'originalMessage.IOUTransactionID', 0)}`; | ||
| }, | ||
| }, | ||
| }), | ||
| )(EditRequestPage); | ||
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.
Why not combining both
withOnyx? I am reading this and I am not totally sure why they can't be combined.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'm glad you caught that! Basically, it can't be done until Expensify/react-native-onyx#385 is merged and implemented.
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.
Gotcha! Thank you for clarifying!