Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import {addTrailingForwardSlash} from './libs/Url';
*/

const REPORT = 'r';
const IOU_REQUEST = 'iou/request';
const IOU_BILL = 'iou/split';
const IOU_SEND = 'iou/send';
const IOU_DETAILS = 'iou/details';

export default {
BANK_ACCOUNT: 'bank-account/:stepToOpen?',
Expand All @@ -27,20 +31,23 @@ 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_SEND: 'iou/send/:reportID',
getIOUSendRoute: reportID => `/iou/send/${reportID}`,
IOU_SEND_CURRENCY: 'iou/send/:reportID/currency',
getIouSendCurrencyRoute: reportID => `iou/send/${reportID}/currency`,
IOU_DETAILS: 'iou/details',
IOU_DETAILS_WITH_IOU_REPORT_ID: 'iou/details/:chatReportID/:iouReportID/',
IOU_REQUEST,
IOU_BILL,
IOU_SEND,
IOU_REQUEST_WITH_REPORT_ID: `${IOU_REQUEST}/:reportID?`,
IOU_BILL_WITH_REPORTID: `${IOU_BILL}/:reportID?`,
IOU_SEND_WITH_REPORTID: `${IOU_SEND}/:reportID?`,
getIouRequestRoute: reportID => `${IOU_REQUEST}/${reportID}`,
getIouSplitRoute: reportID => `${IOU_BILL}/${reportID}`,
getIOUSendRoute: reportID => `${IOU_SEND}/${reportID}`,
IOU_BILL_CURRENCY: `${IOU_BILL}/:reportID/currency`,
IOU_REQUEST_CURRENCY: `${IOU_REQUEST}/:reportID/currency`,
IOU_SEND_CURRENCY: `${IOU_SEND}/:reportID/currency`,
getIouRequestCurrencyRoute: reportID => `${IOU_REQUEST}/${reportID}/currency`,
getIouBillCurrencyRoute: reportID => `${IOU_BILL}/${reportID}/currency`,
getIouSendCurrencyRoute: reportID => `${IOU_SEND}/${reportID}/currency`,
IOU_DETAILS,
IOU_DETAILS_WITH_IOU_REPORT_ID: `${IOU_DETAILS}/:chatReportID/:iouReportID/`,
Comment on lines +34 to +50

@jasperhuangg jasperhuangg Jul 7, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: Have we defined a pattern for how we want to organize these routes? It seems like they're grouped by the pages they're related to. I personally think it's more clear if the getter for a route is placed right after the route itself.

This might be a good opportunity to define a clearer way to organize routes since this list is only going to get longer and longer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally think it's more clear if the getter for a route is placed right after the route itself.

I tried to reorganize things in a way that made sense to me, but definitely prioritizing the bug fix over the engineering efficiency of having things in a certain order. 😄

getIouDetailsRoute: (chatReportID, iouReportID) => `iou/details/${chatReportID}/${iouReportID}`,
SEARCH: 'search',
SET_PASSWORD_WITH_VALIDATE_CODE: 'setpassword/:accountID/:validateCode',
Expand Down
6 changes: 3 additions & 3 deletions src/libs/Navigation/linkingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ 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,
},
},
IOU_Send: {
screens: {
IOU_Send_Root: ROUTES.IOU_SEND,
IOU_Send_Root: ROUTES.IOU_SEND_WITH_REPORTID,
IOU_Send_Currency: ROUTES.IOU_SEND_CURRENCY,
},
},
Expand Down
5 changes: 3 additions & 2 deletions src/pages/iou/IOUModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ class IOUModal extends Component {

render() {
const currentStep = this.steps[this.state.currentStepIndex];
const reportID = lodashGet(this.props, 'route.params.reportID', '');
return (
<ScreenWrapper onTransitionEnd={this.getReady}>
{({didScreenTransitionEnd}) => (
Expand Down Expand Up @@ -327,7 +328,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}
Expand Down Expand Up @@ -371,7 +372,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,
Expand Down