Skip to content

Commit aa21563

Browse files
authored
Revert "DRY up the code for the backTo param in routes"
1 parent 0f4e366 commit aa21563

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/ROUTES.ts

+15-13
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@ import CONST from './CONST';
55
* This is a file containing constants for all of the routes we want to be able to go to
66
*/
77

8-
/**
9-
* This is a file containing constants for all of the routes we want to be able to go to
10-
* Returns an encoded URI component for the backTo param which can be added to the end of URLs
11-
* @param backTo
12-
* @returns
13-
*/
14-
function getBackToParam(backTo?: string): string {
15-
return backTo ? `?backTo=${encodeURIComponent(backTo)}` : '';
16-
}
17-
188
export default {
199
HOME: '',
2010
/** This is a utility route used to go to the user's concierge chat, or the sign-in page if the user's not authenticated */
@@ -30,7 +20,10 @@ export default {
3020
},
3121
PROFILE: {
3222
route: 'a/:accountID',
33-
getRoute: (accountID: string | number, backTo?: string) => `a/${accountID}${getBackToParam(backTo)}`,
23+
getRoute: (accountID: string | number, backTo = '') => {
24+
const backToParam = backTo ? `?backTo=${encodeURIComponent(backTo)}` : '';
25+
return `a/${accountID}${backToParam}`;
26+
},
3427
},
3528

3629
TRANSITION_BETWEEN_APPS: 'transition',
@@ -56,7 +49,10 @@ export default {
5649
BANK_ACCOUNT_PERSONAL: 'bank-account/personal',
5750
BANK_ACCOUNT_WITH_STEP_TO_OPEN: {
5851
route: 'bank-account/:stepToOpen?',
59-
getRoute: (stepToOpen = '', policyID = '', backTo?: string): string => `bank-account/${stepToOpen}?policyID=${policyID}${getBackToParam(backTo)}`,
52+
getRoute: (stepToOpen = '', policyID = '', backTo = ''): string => {
53+
const backToParam = backTo ? `&backTo=${encodeURIComponent(backTo)}` : '';
54+
return `bank-account/${stepToOpen}?policyID=${policyID}${backToParam}`;
55+
},
6056
},
6157

6258
SETTINGS: 'settings',
@@ -108,7 +104,13 @@ export default {
108104
SETTINGS_PERSONAL_DETAILS_ADDRESS: 'settings/profile/personal-details/address',
109105
SETTINGS_PERSONAL_DETAILS_ADDRESS_COUNTRY: {
110106
route: 'settings/profile/personal-details/address/country',
111-
getRoute: (country: string, backTo?: string) => `settings/profile/personal-details/address/country?country=${country}${getBackToParam(backTo)}`,
107+
getRoute: (country: string, backTo?: string) => {
108+
let route = `settings/profile/personal-details/address/country?country=${country}`;
109+
if (backTo) {
110+
route += `&backTo=${encodeURIComponent(backTo)}`;
111+
}
112+
return route;
113+
},
112114
},
113115
SETTINGS_CONTACT_METHODS: 'settings/profile/contact-methods',
114116
SETTINGS_CONTACT_METHOD_DETAILS: {

0 commit comments

Comments
 (0)