@@ -5,16 +5,6 @@ import CONST from './CONST';
5
5
* This is a file containing constants for all of the routes we want to be able to go to
6
6
*/
7
7
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
-
18
8
export default {
19
9
HOME : '' ,
20
10
/** 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 {
30
20
} ,
31
21
PROFILE : {
32
22
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
+ } ,
34
27
} ,
35
28
36
29
TRANSITION_BETWEEN_APPS : 'transition' ,
@@ -56,7 +49,10 @@ export default {
56
49
BANK_ACCOUNT_PERSONAL : 'bank-account/personal' ,
57
50
BANK_ACCOUNT_WITH_STEP_TO_OPEN : {
58
51
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
+ } ,
60
56
} ,
61
57
62
58
SETTINGS : 'settings' ,
@@ -108,7 +104,13 @@ export default {
108
104
SETTINGS_PERSONAL_DETAILS_ADDRESS : 'settings/profile/personal-details/address' ,
109
105
SETTINGS_PERSONAL_DETAILS_ADDRESS_COUNTRY : {
110
106
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
+ } ,
112
114
} ,
113
115
SETTINGS_CONTACT_METHODS : 'settings/profile/contact-methods' ,
114
116
SETTINGS_CONTACT_METHOD_DETAILS : {
0 commit comments