forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathROUTES.js
105 lines (99 loc) · 4.64 KB
/
ROUTES.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import lodashGet from 'lodash/get';
import {addTrailingForwardSlash} from './libs/Url';
/**
* This is a file containing constants for all of the routes we want to be able to go to
*/
const REPORT = 'r';
const IOU_REQUEST = 'iou/request';
const IOU_BILL = 'iou/split';
const IOU_SEND = 'iou/send';
const IOU_DETAILS = 'iou/details';
const IOU_REQUEST_CURRENCY = `${IOU_REQUEST}/currency`;
const IOU_BILL_CURRENCY = `${IOU_BILL}/currency`;
const IOU_SEND_CURRENCY = `${IOU_SEND}/currency`;
export default {
BANK_ACCOUNT: 'bank-account/:stepToOpen?',
BANK_ACCOUNT_PERSONAL: 'bank-account/personal',
getBankAccountRoute: (stepToOpen = '') => `bank-account/${stepToOpen}`,
HOME: '',
SETTINGS: 'settings',
SETTINGS_PROFILE: 'settings/profile',
SETTINGS_PREFERENCES: 'settings/preferences',
SETTINGS_PASSWORD: 'settings/password',
SETTINGS_ABOUT: 'settings/about',
SETTINGS_APP_DOWNLOAD_LINKS: 'settings/about/app-download-links',
SETTINGS_PAYMENTS: 'settings/payments',
SETTINGS_ADD_PAYPAL_ME: 'settings/payments/add-paypal-me',
SETTINGS_ADD_LOGIN: 'settings/addlogin/:type',
getSettingsAddLoginRoute: type => `settings/addlogin/${type}`,
NEW_GROUP: 'new/group',
NEW_CHAT: 'new/chat',
REPORT,
REPORT_WITH_ID: 'r/:reportID',
getReportRoute: reportID => `r/${reportID}`,
IOU_REQUEST,
IOU_BILL,
IOU_SEND,
IOU_REQUEST_WITH_REPORT_ID: `${IOU_REQUEST}/:reportID?`,
IOU_BILL_WITH_REPORT_ID: `${IOU_BILL}/:reportID?`,
IOU_SEND_WITH_REPORT_ID: `${IOU_SEND}/:reportID?`,
getIouRequestRoute: reportID => `${IOU_REQUEST}/${reportID}`,
getIouSplitRoute: reportID => `${IOU_BILL}/${reportID}`,
getIOUSendRoute: reportID => `${IOU_SEND}/${reportID}`,
IOU_BILL_CURRENCY: `${IOU_BILL_CURRENCY}/:reportID?`,
IOU_REQUEST_CURRENCY: `${IOU_REQUEST_CURRENCY}/:reportID?`,
IOU_SEND_CURRENCY: `${IOU_SEND_CURRENCY}/:reportID?`,
getIouRequestCurrencyRoute: reportID => `${IOU_REQUEST_CURRENCY}/${reportID}`,
getIouBillCurrencyRoute: reportID => `${IOU_BILL_CURRENCY}/${reportID}`,
getIouSendCurrencyRoute: reportID => `${IOU_SEND_CURRENCY}/${reportID}`,
IOU_DETAILS,
IOU_DETAILS_WITH_IOU_REPORT_ID: `${IOU_DETAILS}/:chatReportID/:iouReportID/`,
getIouDetailsRoute: (chatReportID, iouReportID) => `iou/details/${chatReportID}/${iouReportID}`,
SEARCH: 'search',
SET_PASSWORD_WITH_VALIDATE_CODE: 'setpassword/:accountID/:validateCode',
DETAILS: 'details',
getDetailsRoute: login => `details?login=${encodeURIComponent(login)}`,
REPORT_PARTICIPANTS: 'r/:reportID/participants',
getReportParticipantsRoute: reportID => `r/${reportID}/participants`,
REPORT_PARTICIPANT: 'r/:reportID/participants/details',
getReportParticipantRoute: (
reportID,
login,
) => `r/${reportID}/participants/details?login=${encodeURIComponent(login)}`,
REPORT_WITH_ID_DETAILS: 'r/:reportID/details',
getReportDetailsRoute: reportID => `r/${reportID}/details`,
VALIDATE_LOGIN: 'v',
VALIDATE_LOGIN_WITH_VALIDATE_CODE: 'v/:accountID/:validateCode',
// This is a special validation URL that will take the user to /workspace/new after validation. This is used
// when linking users from e.com in order to share a session in this app.
LOGIN_WITH_VALIDATE_CODE_NEW_WORKSPACE: 'v/:accountID/:validateCode/new-workspace',
LOGIN_WITH_VALIDATE_CODE_2FA_NEW_WORKSPACE: 'v/:accountID/:validateCode/2fa/new-workspace',
LOGIN_WITH_VALIDATE_CODE_WORKSPACE_CARD: 'v/:accountID/:validateCode/workspace/:policyID/card',
LOGIN_WITH_VALIDATE_CODE_2FA_WORKSPACE_CARD: 'v/:accountID/:validateCode/2fa/workspace/:policyID/card',
ENABLE_PAYMENTS: 'enable-payments',
WORKSPACE: 'workspace',
WORKSPACE_CARD: ':policyID/card',
WORKSPACE_PEOPLE: ':policyID/people',
getWorkspaceCardRoute: policyID => `workspace/${policyID}/card`,
getWorkspacePeopleRoute: policyID => `workspace/${policyID}/people`,
getWorkspaceInviteRoute: policyID => `workspace/${policyID}/invite`,
WORKSPACE_INVITE: 'workspace/:policyID/invite',
getRequestCallRoute: taskID => `request-call/${taskID}`,
REQUEST_CALL: 'request-call/:taskID',
getWorkspaceEditorRoute: policyID => `workspace/${policyID}/edit`,
WORKSPACE_EDITOR: 'workspace/:policyID/edit',
/**
* @param {String} route
* @returns {Object}
*/
parseReportRouteParams: (route) => {
if (!route.startsWith(addTrailingForwardSlash(REPORT))) {
return {};
}
const pathSegments = route.split('/');
return {
reportID: lodashGet(pathSegments, 1),
isParticipantsRoute: Boolean(lodashGet(pathSegments, 2)),
};
},
};