From 610381439de192597f37c2cc1d7907bcd7445343 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Thu, 1 Jul 2021 10:52:13 -1000 Subject: [PATCH] Fix routing for IOU --- src/ROUTES.js | 20 ++++++++++++-------- src/libs/Navigation/linkingConfig.js | 4 ++-- src/pages/iou/IOUModal.js | 5 +++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/ROUTES.js b/src/ROUTES.js index d77cf02ed13a..7450dae7941a 100644 --- a/src/ROUTES.js +++ b/src/ROUTES.js @@ -6,6 +6,8 @@ import {addTrailingForwardSlash} from './libs/Url'; */ const REPORT = 'r'; +const IOU_REQUEST = 'iou/request'; +const IOU_BILL = 'iou/split'; export default { BANK_ACCOUNT: 'bank-account/:stepToOpen?', @@ -26,14 +28,16 @@ export default { REPORT, REPORT_WITH_ID: 'r/:reportID', getReportRoute: reportID => `r/${reportID}`, - IOU_BILL_CURRENCY: 'iou/split/:reportID/currency', - IOU_REQUEST_CURRENCY: 'iou/request/:reportID/currency', - getIouRequestCurrencyRoute: reportID => `iou/request/${reportID}/currency`, - getIouBillCurrencyRoute: reportID => `iou/split/${reportID}/currency`, - IOU_REQUEST: 'iou/request/:reportID', - IOU_BILL: 'iou/split/:reportID', - getIouRequestRoute: reportID => `iou/request/${reportID}`, - getIouSplitRoute: reportID => `iou/split/${reportID}`, + IOU_BILL_CURRENCY: `${IOU_BILL}/:reportID/currency`, + IOU_REQUEST_CURRENCY: `${IOU_REQUEST}/:reportID/currency`, + getIouRequestCurrencyRoute: reportID => `${IOU_REQUEST}/${reportID}/currency`, + getIouBillCurrencyRoute: reportID => `${IOU_BILL}/${reportID}/currency`, + IOU_REQUEST, + IOU_BILL, + IOU_REQUEST_WITH_REPORT_ID: `${IOU_REQUEST}/:reportID?`, + IOU_BILL_WITH_REPORTID: `${IOU_BILL}/:reportID?`, + getIouRequestRoute: reportID => `${IOU_REQUEST}/${reportID}`, + getIouSplitRoute: reportID => `${IOU_BILL}/${reportID}`, IOU_DETAILS: 'iou/details', IOU_DETAILS_WITH_IOU_REPORT_ID: 'iou/details/:chatReportID/:iouReportID/', getIouDetailsRoute: (chatReportID, iouReportID) => `iou/details/${chatReportID}/${iouReportID}`, diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index 12928046940f..8f963c81560a 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -94,13 +94,13 @@ export default { }, IOU_Request: { screens: { - IOU_Request_Root: ROUTES.IOU_REQUEST, + IOU_Request_Root: ROUTES.IOU_REQUEST_WITH_REPORT_ID, IOU_Request_Currency: ROUTES.IOU_REQUEST_CURRENCY, }, }, IOU_Bill: { screens: { - IOU_Bill_Root: ROUTES.IOU_BILL, + IOU_Bill_Root: ROUTES.IOU_BILL_WITH_REPORTID, IOU_Bill_Currency: ROUTES.IOU_BILL_CURRENCY, }, }, diff --git a/src/pages/iou/IOUModal.js b/src/pages/iou/IOUModal.js index 1c5f78f32d49..48395ca675c2 100755 --- a/src/pages/iou/IOUModal.js +++ b/src/pages/iou/IOUModal.js @@ -265,6 +265,7 @@ class IOUModal extends Component { render() { const currentStep = this.steps[this.state.currentStepIndex]; + const reportID = lodashGet(this.props, 'route.params.reportID', ''); return ( {({didScreenTransitionEnd}) => ( @@ -314,7 +315,7 @@ class IOUModal extends Component { this.navigateToNextStep(); }} currencySelected={this.currencySelected} - reportID={this.props.route.params.reportID} + reportID={reportID} selectedCurrency={this.state.selectedCurrency} hasMultipleParticipants={this.props.hasMultipleParticipants} selectedAmount={this.state.amount} @@ -358,7 +359,7 @@ export default compose( withLocalize, withOnyx({ report: { - key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID}`, + key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${lodashGet(route, 'params.reportID', '')}`, }, iousReport: { key: ONYXKEYS.COLLECTION.REPORT_IOUS,