From 7fb66cdd840ba14f5c958dd60fc1bb4f75d58bab Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Sat, 23 Sep 2023 09:48:25 +0800 Subject: [PATCH 1/6] Organize and cleanup --- src/ROUTES.ts | 323 ++++++++---------- src/components/AttachmentModal.js | 2 +- src/components/AvatarWithDisplayName.js | 8 +- src/components/DistanceRequest.js | 8 +- .../HTMLRenderers/AnchorRenderer.js | 2 +- .../HTMLRenderers/ImageRenderer.js | 2 +- .../HTMLRenderers/MentionUserRenderer.js | 4 +- src/components/HeaderWithBackButton/index.js | 2 +- .../MoneyRequestConfirmationList.js | 14 +- src/components/ParentNavigationSubtitle.js | 2 +- .../ReportActionItem/MoneyRequestAction.js | 6 +- .../ReportActionItem/MoneyRequestView.js | 10 +- .../ReportActionItem/ReportActionItemImage.js | 2 +- .../ReportActionItem/ReportPreview.js | 2 +- .../ReportActionItem/TaskPreview.js | 2 +- src/components/ReportActionItem/TaskView.js | 8 +- src/components/ReportWelcomeText.js | 4 +- src/libs/Navigation/Navigation.js | 2 +- src/libs/Navigation/linkingConfig.js | 100 +++--- ...bscribeToReportCommentPushNotifications.js | 2 +- src/libs/ReportUtils.js | 8 +- src/libs/actions/App.js | 4 +- src/libs/actions/IOU.js | 10 +- .../ReimbursementAccount/navigation.js | 2 +- src/libs/actions/Report.js | 28 +- src/libs/actions/Welcome.js | 2 +- src/pages/EditRequestAmountPage.js | 2 +- .../PrivateNotes/PrivateNotesListPage.js | 2 +- .../PrivateNotes/PrivateNotesViewPage.js | 2 +- src/pages/ProfilePage.js | 2 +- .../ReimbursementAccount/Enable2FAPrompt.js | 4 +- .../ReimbursementAccountPage.js | 2 +- src/pages/ReportDetailsPage.js | 10 +- src/pages/ReportParticipantsPage.js | 2 +- src/pages/ShareCodePage.js | 6 +- src/pages/home/ReportScreen.js | 2 +- .../report/ContextMenu/ContextMenuActions.js | 8 +- .../report/ReactionList/BaseReactionList.js | 2 +- .../home/report/ReportActionItemSingle.js | 6 +- src/pages/home/report/ReportAttachments.js | 2 +- src/pages/home/sidebar/SidebarLinks.js | 2 +- src/pages/iou/IOUCurrencySelection.js | 2 +- src/pages/iou/MoneyRequestCategoryPage.js | 4 +- src/pages/iou/MoneyRequestDatePage.js | 4 +- src/pages/iou/MoneyRequestDescriptionPage.js | 4 +- src/pages/iou/MoneyRequestMerchantPage.js | 4 +- src/pages/iou/MoneyRequestTagPage.js | 2 +- src/pages/iou/WaypointEditor.js | 8 +- .../iou/steps/MoneyRequestConfirmPage.js | 8 +- .../MoneyRequestParticipantsPage.js | 8 +- src/pages/iou/steps/NewRequestAmountPage.js | 10 +- .../Profile/Contacts/ContactMethodsPage.js | 2 +- .../Report/NotificationPreferencePage.js | 2 +- .../settings/Report/ReportSettingsPage.js | 10 +- src/pages/settings/Report/RoomNamePage.js | 2 +- .../settings/Report/WriteCapabilityPage.js | 2 +- src/pages/workspace/WorkspaceInitialPage.js | 16 +- .../workspace/WorkspaceInviteMessagePage.js | 4 +- src/pages/workspace/WorkspaceInvitePage.js | 4 +- src/pages/workspace/WorkspaceMembersPage.js | 4 +- .../workspace/WorkspacePageWithSections.js | 2 +- src/pages/workspace/WorkspaceSettingsPage.js | 2 +- src/pages/workspace/WorkspacesListPage.js | 2 +- .../reimburse/WorkspaceRateAndUnitPage.js | 4 +- .../reimburse/WorkspaceReimburseView.js | 2 +- tests/actions/IOUTest.js | 4 +- tests/e2e/ADDING_TESTS.md | 8 +- 67 files changed, 341 insertions(+), 396 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index feead4890114..09d237a6e2e9 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -11,204 +11,147 @@ type ParseReportRouteParams = { isSubReportPageRoute: boolean; }; -const REPORT = 'r'; -const IOU_REQUEST = 'request/new'; -const IOU_SEND = 'send/new'; -const NEW_TASK = 'new/task'; -const SETTINGS_PERSONAL_DETAILS = 'settings/profile/personal-details'; -const SETTINGS_CONTACT_METHODS = 'settings/profile/contact-methods'; -const SETTINGS_STATUS = 'settings/profile/status'; -const SETTINGS_STATUS_SET = 'settings/profile/status/set'; - +// prettier-ignore export default { - BANK_ACCOUNT: 'bank-account', - BANK_ACCOUNT_NEW: 'bank-account/new', - BANK_ACCOUNT_WITH_STEP_TO_OPEN: 'bank-account/:stepToOpen?', - BANK_ACCOUNT_PERSONAL: 'bank-account/personal', - getBankAccountRoute: (stepToOpen = '', policyID = '', backTo = ''): string => { - const backToParam = backTo ? `&backTo=${encodeURIComponent(backTo)}` : ''; - return `bank-account/${stepToOpen}?policyID=${policyID}${backToParam}`; - }, - HOME: '', - SETTINGS: 'settings', - SETTINGS_PROFILE: 'settings/profile', - SETTINGS_SHARE_CODE: 'settings/shareCode', - SETTINGS_DISPLAY_NAME: 'settings/profile/display-name', - SETTINGS_TIMEZONE: 'settings/profile/timezone', - SETTINGS_TIMEZONE_SELECT: 'settings/profile/timezone/select', - SETTINGS_PRONOUNS: 'settings/profile/pronouns', - SETTINGS_LOUNGE_ACCESS: 'settings/profile/lounge-access', - SETTINGS_PREFERENCES: 'settings/preferences', - SETTINGS_PRIORITY_MODE: 'settings/preferences/priority-mode', - SETTINGS_LANGUAGE: 'settings/preferences/language', - SETTINGS_THEME: 'settings/preferences/theme', - SETTINGS_WORKSPACES: 'settings/workspaces', - SETTINGS_SECURITY: 'settings/security', - SETTINGS_CLOSE: 'settings/security/closeAccount', - SETTINGS_ABOUT: 'settings/about', - SETTINGS_APP_DOWNLOAD_LINKS: 'settings/about/app-download-links', - SETTINGS_WALLET: 'settings/wallet', - SETTINGS_ADD_DEBIT_CARD: 'settings/wallet/add-debit-card', - SETTINGS_ADD_BANK_ACCOUNT: 'settings/wallet/add-bank-account', - SETTINGS_ENABLE_PAYMENTS: 'settings/wallet/enable-payments', - getSettingsAddLoginRoute: (type: string) => `settings/addlogin/${type}`, - SETTINGS_WALLET_TRANSFER_BALANCE: 'settings/wallet/transfer-balance', - SETTINGS_WALLET_CHOOSE_TRANSFER_ACCOUNT: 'settings/wallet/choose-transfer-account', - SETTINGS_PERSONAL_DETAILS, - SETTINGS_PERSONAL_DETAILS_LEGAL_NAME: `${SETTINGS_PERSONAL_DETAILS}/legal-name`, - SETTINGS_PERSONAL_DETAILS_DATE_OF_BIRTH: `${SETTINGS_PERSONAL_DETAILS}/date-of-birth`, - SETTINGS_PERSONAL_DETAILS_ADDRESS: `${SETTINGS_PERSONAL_DETAILS}/address`, - SETTINGS_CONTACT_METHODS, - SETTINGS_CONTACT_METHOD_DETAILS: `${SETTINGS_CONTACT_METHODS}/:contactMethod/details`, - getEditContactMethodRoute: (contactMethod: string) => `${SETTINGS_CONTACT_METHODS}/${encodeURIComponent(contactMethod)}/details`, - SETTINGS_NEW_CONTACT_METHOD: `${SETTINGS_CONTACT_METHODS}/new`, - SETTINGS_2FA: 'settings/security/two-factor-auth', - SETTINGS_STATUS, - SETTINGS_STATUS_SET, - NEW: 'new', - NEW_CHAT: 'new/chat', - NEW_ROOM: 'new/room', - NEW_TASK, - REPORT, - REPORT_WITH_ID: 'r/:reportID?/:reportActionID?', - EDIT_REQUEST: 'r/:threadReportID/edit/:field', - getEditRequestRoute: (threadReportID: string, field: ValueOf) => `r/${threadReportID}/edit/${field}`, - EDIT_CURRENCY_REQUEST: 'r/:threadReportID/edit/currency', - getEditRequestCurrencyRoute: (threadReportID: string, currency: string, backTo: string) => `r/${threadReportID}/edit/currency?currency=${currency}&backTo=${backTo}`, - getReportRoute: (reportID: string) => `r/${reportID}`, - REPORT_WITH_ID_DETAILS_SHARE_CODE: 'r/:reportID/details/shareCode', - getReportShareCodeRoute: (reportID: string) => `r/${reportID}/details/shareCode`, - REPORT_ATTACHMENTS: 'r/:reportID/attachment', - getReportAttachmentRoute: (reportID: string, source: string) => `r/${reportID}/attachment?source=${encodeURI(source)}`, - + HOME: '', /** 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 */ CONCIERGE: 'concierge', - - IOU_REQUEST, - IOU_SEND, - - // To see the available iouType, please refer to CONST.IOU.MONEY_REQUEST_TYPE - MONEY_REQUEST: ':iouType/new/:reportID?', - MONEY_REQUEST_AMOUNT: ':iouType/new/amount/:reportID?', - MONEY_REQUEST_PARTICIPANTS: ':iouType/new/participants/:reportID?', - MONEY_REQUEST_CONFIRMATION: ':iouType/new/confirmation/:reportID?', - MONEY_REQUEST_DATE: ':iouType/new/date/:reportID?', - MONEY_REQUEST_CURRENCY: ':iouType/new/currency/:reportID?', - MONEY_REQUEST_DESCRIPTION: ':iouType/new/description/:reportID?', - MONEY_REQUEST_CATEGORY: ':iouType/new/category/:reportID?', - MONEY_REQUEST_TAG: ':iouType/new/tag/:reportID?', - MONEY_REQUEST_MERCHANT: ':iouType/new/merchant/:reportID?', - MONEY_REQUEST_MANUAL_TAB: ':iouType/new/:reportID?/manual', - MONEY_REQUEST_SCAN_TAB: ':iouType/new/:reportID?/scan', - MONEY_REQUEST_DISTANCE_TAB: ':iouType/new/:reportID?/distance', - MONEY_REQUEST_WAYPOINT: ':iouType/new/waypoint/:waypointIndex', - MONEY_REQUEST_ADDRESS: ':iouType/new/address/:reportID?', - IOU_SEND_ADD_BANK_ACCOUNT: `${IOU_SEND}/add-bank-account`, - IOU_SEND_ADD_DEBIT_CARD: `${IOU_SEND}/add-debit-card`, - IOU_SEND_ENABLE_PAYMENTS: `${IOU_SEND}/enable-payments`, - getMoneyRequestRoute: (iouType: string, reportID = '') => `${iouType}/new/${reportID}`, - getMoneyRequestAmountRoute: (iouType: string, reportID = '') => `${iouType}/new/amount/${reportID}`, - getMoneyRequestParticipantsRoute: (iouType: string, reportID = '') => `${iouType}/new/participants/${reportID}`, - getMoneyRequestConfirmationRoute: (iouType: string, reportID = '') => `${iouType}/new/confirmation/${reportID}`, - getMoneyRequestCreatedRoute: (iouType: string, reportID = '') => `${iouType}/new/date/${reportID}`, - getMoneyRequestCurrencyRoute: (iouType: string, reportID: string, currency: string, backTo: string) => `${iouType}/new/currency/${reportID}?currency=${currency}&backTo=${backTo}`, - getMoneyRequestDescriptionRoute: (iouType: string, reportID = '') => `${iouType}/new/description/${reportID}`, - getMoneyRequestCategoryRoute: (iouType: string, reportID = '') => `${iouType}/new/category/${reportID}`, - getMoneyRequestMerchantRoute: (iouType: string, reportID = '') => `${iouType}/new/merchant/${reportID}`, - getMoneyRequestDistanceTabRoute: (iouType: string, reportID = '') => `${iouType}/new/${reportID}/distance`, - getMoneyRequestWaypointRoute: (iouType: string, waypointIndex: number) => `${iouType}/new/waypoint/${waypointIndex}`, - getMoneyRequestAddressRoute: (iouType: string, reportID = '') => `${iouType}/new/address/${reportID}`, - getMoneyRequestTagRoute: (iouType: string, reportID = '') => `${iouType}/new/tag/${reportID}`, - SPLIT_BILL_DETAILS: `r/:reportID/split/:reportActionID`, - getSplitBillDetailsRoute: (reportID: string, reportActionID: string) => `r/${reportID}/split/${reportActionID}`, - getNewTaskRoute: (reportID: string) => `${NEW_TASK}/${reportID}`, - NEW_TASK_WITH_REPORT_ID: `${NEW_TASK}/:reportID?`, - TASK_TITLE: 'r/:reportID/title', - TASK_DESCRIPTION: 'r/:reportID/description', - TASK_ASSIGNEE: 'r/:reportID/assignee', - getTaskReportTitleRoute: (reportID: string) => `r/${reportID}/title`, - getTaskReportDescriptionRoute: (reportID: string) => `r/${reportID}/description`, - getTaskReportAssigneeRoute: (reportID: string) => `r/${reportID}/assignee`, - NEW_TASK_ASSIGNEE: `${NEW_TASK}/assignee`, - NEW_TASK_SHARE_DESTINATION: `${NEW_TASK}/share-destination`, - NEW_TASK_DETAILS: `${NEW_TASK}/details`, - NEW_TASK_TITLE: `${NEW_TASK}/title`, - NEW_TASK_DESCRIPTION: `${NEW_TASK}/description`, - FLAG_COMMENT: `flag/:reportID/:reportActionID`, - getFlagCommentRoute: (reportID: string, reportActionID: string) => `flag/${reportID}/${reportActionID}`, - SEARCH: 'search', - TEACHERS_UNITE: 'teachersunite', - I_KNOW_A_TEACHER: 'teachersunite/i-know-a-teacher', - I_AM_A_TEACHER: 'teachersunite/i-am-a-teacher', - INTRO_SCHOOL_PRINCIPAL: 'teachersunite/intro-school-principal', - DETAILS: 'details', - getDetailsRoute: (login: string) => `details?login=${encodeURIComponent(login)}`, - PROFILE: 'a/:accountID', - getProfileRoute: (accountID: string | number, backTo = '') => { + FLAG_COMMENT: { route: 'flag/:reportID/:reportActionID', getRoute: (reportID: string, reportActionID: string) => `flag/${reportID}/${reportActionID}`}, + SEARCH: 'search', + DETAILS: { route: 'details', getRoute: (login: string) => `details?login=${encodeURIComponent(login)}`}, + PROFILE: { route: 'a/:accountID', getRoute: (accountID: string | number, backTo = '') => { const backToParam = backTo ? `?backTo=${encodeURIComponent(backTo)}` : ''; return `a/${accountID}${backToParam}`; - }, - REPORT_PARTICIPANTS: 'r/:reportID/participants', - getReportParticipantsRoute: (reportID: string) => `r/${reportID}/participants`, - REPORT_WITH_ID_DETAILS: 'r/:reportID/details', - getReportDetailsRoute: (reportID: string) => `r/${reportID}/details`, - REPORT_SETTINGS: 'r/:reportID/settings', - getReportSettingsRoute: (reportID: string) => `r/${reportID}/settings`, - REPORT_SETTINGS_ROOM_NAME: 'r/:reportID/settings/room-name', - getReportSettingsRoomNameRoute: (reportID: string) => `r/${reportID}/settings/room-name`, - REPORT_SETTINGS_NOTIFICATION_PREFERENCES: 'r/:reportID/settings/notification-preferences', - getReportSettingsNotificationPreferencesRoute: (reportID: string) => `r/${reportID}/settings/notification-preferences`, - REPORT_WELCOME_MESSAGE: 'r/:reportID/welcomeMessage', - getReportWelcomeMessageRoute: (reportID: string) => `r/${reportID}/welcomeMessage`, - REPORT_SETTINGS_WRITE_CAPABILITY: 'r/:reportID/settings/who-can-post', - getReportSettingsWriteCapabilityRoute: (reportID: string) => `r/${reportID}/settings/who-can-post`, - TRANSITION_BETWEEN_APPS: 'transition', - VALIDATE_LOGIN: 'v/:accountID/:validateCode', - GET_ASSISTANCE: 'get-assistance/:taskID', - getGetAssistanceRoute: (taskID: string) => `get-assistance/${taskID}`, - UNLINK_LOGIN: 'u/:accountID/:validateCode', - - APPLE_SIGN_IN: 'sign-in-with-apple', - GOOGLE_SIGN_IN: 'sign-in-with-google', - DESKTOP_SIGN_IN_REDIRECT: 'desktop-signin-redirect', - - // Routes related to private notes added to the report - PRIVATE_NOTES_VIEW: 'r/:reportID/notes/:accountID', - getPrivateNotesViewRoute: (reportID: string, accountID: string | number) => `r/${reportID}/notes/${accountID}`, - PRIVATE_NOTES_LIST: 'r/:reportID/notes', - getPrivateNotesListRoute: (reportID: string) => `r/${reportID}/notes`, - PRIVATE_NOTES_EDIT: 'r/:reportID/notes/:accountID/edit', - getPrivateNotesEditRoute: (reportID: string, accountID: string | number) => `r/${reportID}/notes/${accountID}/edit`, + }}, + TRANSITION_BETWEEN_APPS: 'transition', + VALIDATE_LOGIN: 'v/:accountID/:validateCode', + GET_ASSISTANCE: { route: 'get-assistance/:taskID', getRoute: (taskID: string) => `get-assistance/${taskID}`}, + UNLINK_LOGIN: 'u/:accountID/:validateCode', + APPLE_SIGN_IN: 'sign-in-with-apple', + GOOGLE_SIGN_IN: 'sign-in-with-google', + DESKTOP_SIGN_IN_REDIRECT: 'desktop-signin-redirect', // 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. - ENABLE_PAYMENTS: 'enable-payments', - WALLET_STATEMENT_WITH_DATE: 'statements/:yearMonth', - getWalletStatementWithDateRoute: (yearMonth: string) => `statements/${yearMonth}`, - WORKSPACE_NEW: 'workspace/new', - WORKSPACE_INITIAL: 'workspace/:policyID', - WORKSPACE_INVITE: 'workspace/:policyID/invite', - WORKSPACE_INVITE_MESSAGE: 'workspace/:policyID/invite-message', - WORKSPACE_SETTINGS: 'workspace/:policyID/settings', - WORKSPACE_CARD: 'workspace/:policyID/card', - WORKSPACE_REIMBURSE: 'workspace/:policyID/reimburse', - WORKSPACE_RATE_AND_UNIT: 'workspace/:policyID/rateandunit', - WORKSPACE_BILLS: 'workspace/:policyID/bills', - WORKSPACE_INVOICES: 'workspace/:policyID/invoices', - WORKSPACE_TRAVEL: 'workspace/:policyID/travel', - WORKSPACE_MEMBERS: 'workspace/:policyID/members', - WORKSPACE_NEW_ROOM: 'workspace/new-room', - getWorkspaceInitialRoute: (policyID: string) => `workspace/${policyID}`, - getWorkspaceInviteRoute: (policyID: string) => `workspace/${policyID}/invite`, - getWorkspaceInviteMessageRoute: (policyID: string) => `workspace/${policyID}/invite-message`, - getWorkspaceSettingsRoute: (policyID: string) => `workspace/${policyID}/settings`, - getWorkspaceCardRoute: (policyID: string) => `workspace/${policyID}/card`, - getWorkspaceReimburseRoute: (policyID: string) => `workspace/${policyID}/reimburse`, - getWorkspaceRateAndUnitRoute: (policyID: string) => `workspace/${policyID}/rateandunit`, - getWorkspaceBillsRoute: (policyID: string) => `workspace/${policyID}/bills`, - getWorkspaceInvoicesRoute: (policyID: string) => `workspace/${policyID}/invoices`, - getWorkspaceTravelRoute: (policyID: string) => `workspace/${policyID}/travel`, - getWorkspaceMembersRoute: (policyID: string) => `workspace/${policyID}/members`, + ENABLE_PAYMENTS: 'enable-payments', + WALLET_STATEMENT_WITH_DATE: 'statements/:yearMonth', + + BANK_ACCOUNT: 'bank-account', + BANK_ACCOUNT_NEW: 'bank-account/new', + BANK_ACCOUNT_PERSONAL: 'bank-account/personal', + BANK_ACCOUNT_WITH_STEP_TO_OPEN: { route: 'bank-account/:stepToOpen?', getRoute: (stepToOpen = '', policyID = '', backTo = ''): string => { + const backToParam = backTo ? `&backTo=${encodeURIComponent(backTo)}` : ''; + return `bank-account/${stepToOpen}?policyID=${policyID}${backToParam}`; + }}, + + SETTINGS: 'settings', + SETTINGS_PROFILE: 'settings/profile', + SETTINGS_SHARE_CODE: 'settings/shareCode', + SETTINGS_DISPLAY_NAME: 'settings/profile/display-name', + SETTINGS_TIMEZONE: 'settings/profile/timezone', + SETTINGS_TIMEZONE_SELECT: 'settings/profile/timezone/select', + SETTINGS_PRONOUNS: 'settings/profile/pronouns', + SETTINGS_LOUNGE_ACCESS: 'settings/profile/lounge-access', + SETTINGS_PREFERENCES: 'settings/preferences', + SETTINGS_PRIORITY_MODE: 'settings/preferences/priority-mode', + SETTINGS_LANGUAGE: 'settings/preferences/language', + SETTINGS_THEME: 'settings/preferences/theme', + SETTINGS_WORKSPACES: 'settings/workspaces', + SETTINGS_SECURITY: 'settings/security', + SETTINGS_CLOSE: 'settings/security/closeAccount', + SETTINGS_ABOUT: 'settings/about', + SETTINGS_APP_DOWNLOAD_LINKS: 'settings/about/app-download-links', + SETTINGS_WALLET: 'settings/wallet', + SETTINGS_ADD_DEBIT_CARD: 'settings/wallet/add-debit-card', + SETTINGS_ADD_BANK_ACCOUNT: 'settings/wallet/add-bank-account', + SETTINGS_ENABLE_PAYMENTS: 'settings/wallet/enable-payments', + SETTINGS_WALLET_TRANSFER_BALANCE: 'settings/wallet/transfer-balance', + SETTINGS_WALLET_CHOOSE_TRANSFER_ACCOUNT: 'settings/wallet/choose-transfer-account', + SETTINGS_PERSONAL_DETAILS: 'settings/profile/personal-details', + SETTINGS_PERSONAL_DETAILS_LEGAL_NAME: 'settings/profile/personal-details/legal-name', + SETTINGS_PERSONAL_DETAILS_DATE_OF_BIRTH: 'settings/profile/personal-details/date-of-birth', + SETTINGS_PERSONAL_DETAILS_ADDRESS: 'settings/profile/personal-details/address', + SETTINGS_CONTACT_METHODS: 'settings/profile/contact-methods', + SETTINGS_CONTACT_METHOD_DETAILS: { route: 'settings/profile/contact-methods/:contactMethod/details', getRoute: (contactMethod: string) => `settings/profile/contact-methods/${encodeURIComponent(contactMethod)}/details`}, + SETTINGS_NEW_CONTACT_METHOD: 'settings/profile/contact-methods/new', + SETTINGS_2FA: 'settings/security/two-factor-auth', + SETTINGS_STATUS: 'settings/profile/status', + SETTINGS_STATUS_SET: 'settings/profile/status/set', + + NEW: 'new', + NEW_CHAT: 'new/chat', + NEW_ROOM: 'new/room', + + REPORT: 'r', + REPORT_WITH_ID: { route: 'r/:reportID?/:reportActionID?', getRoute: (reportID: string) => `r/${reportID}`}, + EDIT_REQUEST: { route: 'r/:threadReportID/edit/:field', getRoute: (threadReportID: string, field: ValueOf) => `r/${threadReportID}/edit/${field}`}, + EDIT_CURRENCY_REQUEST: { route: 'r/:threadReportID/edit/currency', getRoute: (threadReportID: string, currency: string, backTo: string) => `r/${threadReportID}/edit/currency?currency=${currency}&backTo=${backTo}`}, + REPORT_WITH_ID_DETAILS_SHARE_CODE: { route: 'r/:reportID/details/shareCode', getRoute: (reportID: string) => `r/${reportID}/details/shareCode`}, + REPORT_ATTACHMENTS: { route: 'r/:reportID/attachment', getRoute: (reportID: string, source: string) => `r/${reportID}/attachment?source=${encodeURI(source)}`}, + REPORT_PARTICIPANTS: { route: 'r/:reportID/participants', getRoute: (reportID: string) => `r/${reportID}/participants`}, + REPORT_WITH_ID_DETAILS: { route: 'r/:reportID/details', getRoute: (reportID: string) => `r/${reportID}/details`}, + REPORT_SETTINGS: { route: 'r/:reportID/settings', getRoute: (reportID: string) => `r/${reportID}/settings`}, + REPORT_SETTINGS_ROOM_NAME: { route: 'r/:reportID/settings/room-name', getRoute: (reportID: string) => `r/${reportID}/settings/room-name`}, + REPORT_SETTINGS_NOTIFICATION_PREFERENCES: {route: 'r/:reportID/settings/notification-preferences', getRoute: (reportID: string) => `r/${reportID}/settings/notification-preferences`}, + REPORT_SETTINGS_WRITE_CAPABILITY: { route: 'r/:reportID/settings/who-can-post', getRoute: (reportID: string) => `r/${reportID}/settings/who-can-post`}, + REPORT_WELCOME_MESSAGE: { route: 'r/:reportID/welcomeMessage', getRoute: (reportID: string) => `r/${reportID}/welcomeMessage`}, + SPLIT_BILL_DETAILS: { route: 'r/:reportID/split/:reportActionID', getRoute: (reportID: string, reportActionID: string) => `r/${reportID}/split/${reportActionID}`}, + TASK_TITLE: { route: 'r/:reportID/title', getRoute: (reportID: string) => `r/${reportID}/title`}, + TASK_DESCRIPTION: { route: 'r/:reportID/description', getRoute: (reportID: string) => `r/${reportID}/description`}, + TASK_ASSIGNEE: { route: 'r/:reportID/assignee', getRoute: (reportID: string) => `r/${reportID}/assignee`}, + PRIVATE_NOTES_VIEW: { route: 'r/:reportID/notes/:accountID', getRoute: (reportID: string, accountID: string | number) => `r/${reportID}/notes/${accountID}`}, + PRIVATE_NOTES_LIST: { route: 'r/:reportID/notes', getRoute: (reportID: string) => `r/${reportID}/notes`}, + PRIVATE_NOTES_EDIT: { route: 'r/:reportID/notes/:accountID/edit', getRoute: (reportID: string, accountID: string | number) => `r/${reportID}/notes/${accountID}/edit`}, + + // To see the available iouType, please refer to CONST.IOU.MONEY_REQUEST_TYPE + MONEY_REQUEST: { route: ':iouType/new/:reportID?', getRoute: (iouType: string, reportID = '') => `${iouType}/new/${reportID}`}, + MONEY_REQUEST_AMOUNT: { route: ':iouType/new/amount/:reportID?', getRoute: (iouType: string, reportID = '') => `${iouType}/new/amount/${reportID}`}, + MONEY_REQUEST_PARTICIPANTS: { route: ':iouType/new/participants/:reportID?', getRoute: (iouType: string, reportID = '') => `${iouType}/new/participants/${reportID}`}, + MONEY_REQUEST_CONFIRMATION: { route: ':iouType/new/confirmation/:reportID?', getRoute: (iouType: string, reportID = '') => `${iouType}/new/confirmation/${reportID}`}, + MONEY_REQUEST_DATE: { route: ':iouType/new/date/:reportID?', getRoute: (iouType: string, reportID = '') => `${iouType}/new/date/${reportID}`}, + MONEY_REQUEST_CURRENCY: { route: ':iouType/new/currency/:reportID?', getRoute: (iouType: string, reportID: string, currency: string, backTo: string) => `${iouType}/new/currency/${reportID}?currency=${currency}&backTo=${backTo}`}, + MONEY_REQUEST_DESCRIPTION: { route: ':iouType/new/description/:reportID?', getRoute: (iouType: string, reportID = '') => `${iouType}/new/description/${reportID}`}, + MONEY_REQUEST_CATEGORY: { route: ':iouType/new/category/:reportID?', getRoute: (iouType: string, reportID = '') => `${iouType}/new/category/${reportID}`}, + MONEY_REQUEST_TAG: { route: ':iouType/new/tag/:reportID?', getRoute: (iouType: string, reportID = '') => `${iouType}/new/tag/${reportID}`}, + MONEY_REQUEST_MERCHANT: { route: ':iouType/new/merchant/:reportID?', getRoute: (iouType: string, reportID = '') => `${iouType}/new/merchant/${reportID}`}, + MONEY_REQUEST_WAYPOINT: { route: ':iouType/new/waypoint/:waypointIndex', getRoute: (iouType: string, waypointIndex: number) => `${iouType}/new/waypoint/${waypointIndex}`}, + MONEY_REQUEST_ADDRESS: { route: ':iouType/new/address/:reportID?', getRoute: (iouType: string, reportID = '') => `${iouType}/new/address/${reportID}`}, + MONEY_REQUEST_DISTANCE_TAB: { route: ':iouType/new/:reportID?/distance', getRoute: (iouType: string, reportID = '') => `${iouType}/new/${reportID}/distance`}, + MONEY_REQUEST_MANUAL_TAB: ':iouType/new/:reportID?/manual', + MONEY_REQUEST_SCAN_TAB: ':iouType/new/:reportID?/scan', + + IOU_REQUEST: 'request/new', + IOU_SEND: 'send/new', + IOU_SEND_ADD_BANK_ACCOUNT: 'send/new/add-bank-account', + IOU_SEND_ADD_DEBIT_CARD: 'send/new/add-debit-card', + IOU_SEND_ENABLE_PAYMENTS: 'send/new/enable-payments', + + NEW_TASK: 'new/task', + NEW_TASK_WITH_REPORT_ID: 'new/task/:reportID?', + NEW_TASK_ASSIGNEE: 'new/task/assignee', + NEW_TASK_SHARE_DESTINATION: 'new/task/share-destination', + NEW_TASK_DETAILS: 'new/task/details', + NEW_TASK_TITLE: 'new/task/title', + NEW_TASK_DESCRIPTION: 'new/task/description', + + TEACHERS_UNITE: 'teachersunite', + I_KNOW_A_TEACHER: 'teachersunite/i-know-a-teacher', + I_AM_A_TEACHER: 'teachersunite/i-am-a-teacher', + INTRO_SCHOOL_PRINCIPAL: 'teachersunite/intro-school-principal', + + WORKSPACE_NEW: 'workspace/new', + WORKSPACE_NEW_ROOM: 'workspace/new-room', + WORKSPACE_INITIAL: { route: 'workspace/:policyID', getRoute: (policyID: string) => `workspace/${policyID}`}, + WORKSPACE_INVITE: { route: 'workspace/:policyID/invite', getRoute: (policyID: string) => `workspace/${policyID}/invite`}, + WORKSPACE_INVITE_MESSAGE: { route: 'workspace/:policyID/invite-message', getRoute: (policyID: string) => `workspace/${policyID}/invite-message`}, + WORKSPACE_SETTINGS: { route: 'workspace/:policyID/settings', getRoute: (policyID: string) => `workspace/${policyID}/settings`}, + WORKSPACE_CARD: { route: 'workspace/:policyID/card', getRoute: (policyID: string) => `workspace/${policyID}/card`}, + WORKSPACE_REIMBURSE: { route: 'workspace/:policyID/reimburse', getRoute: (policyID: string) => `workspace/${policyID}/reimburse`}, + WORKSPACE_RATE_AND_UNIT: { route: 'workspace/:policyID/rateandunit', getRoute: (policyID: string) => `workspace/${policyID}/rateandunit`}, + WORKSPACE_BILLS: { route: 'workspace/:policyID/bills', getRoute: (policyID: string) => `workspace/${policyID}/bills`}, + WORKSPACE_INVOICES: { route: 'workspace/:policyID/invoices', getRoute: (policyID: string) => `workspace/${policyID}/invoices`}, + WORKSPACE_TRAVEL: { route: 'workspace/:policyID/travel', getRoute: (policyID: string) => `workspace/${policyID}/travel`}, + WORKSPACE_MEMBERS: { route: 'workspace/:policyID/members', getRoute: (policyID: string) => `workspace/${policyID}/members`}, // These are some on-off routes that will be removed once they're no longer needed (see GH issues for details) SAASTR: 'saastr', diff --git a/src/components/AttachmentModal.js b/src/components/AttachmentModal.js index 946b5e2ddec9..3f89f4032061 100755 --- a/src/components/AttachmentModal.js +++ b/src/components/AttachmentModal.js @@ -363,7 +363,7 @@ function AttachmentModal(props) { icon: Expensicons.Camera, text: props.translate('common.replace'), onSelected: () => { - onModalHideCallbackRef.current = () => Navigation.navigate(ROUTES.getEditRequestRoute(props.report.reportID, CONST.EDIT_REQUEST_FIELD.RECEIPT)); + onModalHideCallbackRef.current = () => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(props.report.reportID, CONST.EDIT_REQUEST_FIELD.RECEIPT)); closeModal(); }, }, diff --git a/src/components/AvatarWithDisplayName.js b/src/components/AvatarWithDisplayName.js index e82dbe05a6d0..63a148f9d8b6 100644 --- a/src/components/AvatarWithDisplayName.js +++ b/src/components/AvatarWithDisplayName.js @@ -57,12 +57,12 @@ const defaultProps = { const showActorDetails = (report) => { if (ReportUtils.isExpenseReport(report)) { - Navigation.navigate(ROUTES.getProfileRoute(report.ownerAccountID)); + Navigation.navigate(ROUTES.PROFILE.getRoute(report.ownerAccountID)); return; } if (ReportUtils.isIOUReport(report)) { - Navigation.navigate(ROUTES.getReportParticipantsRoute(report.reportID)); + Navigation.navigate(ROUTES.REPORT_PARTICIPANTS.getRoute(report.reportID)); return; } @@ -71,13 +71,13 @@ const showActorDetails = (report) => { const actorAccountID = lodashGet(parentReportAction, 'actorAccountID', -1); // in an ideal situation account ID won't be 0 if (actorAccountID > 0) { - Navigation.navigate(ROUTES.getProfileRoute(actorAccountID)); + Navigation.navigate(ROUTES.PROFILE.getRoute(actorAccountID)); return; } } // report detail route is added as fallback but based on the current implementation this route won't be executed - Navigation.navigate(ROUTES.getReportDetailsRoute(report.reportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID)); }; function AvatarWithDisplayName(props) { diff --git a/src/components/DistanceRequest.js b/src/components/DistanceRequest.js index 4ac49a5889a8..888b1fd7f6d8 100644 --- a/src/components/DistanceRequest.js +++ b/src/components/DistanceRequest.js @@ -189,12 +189,12 @@ function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken, useEffect(updateGradientVisibility, [scrollContainerHeight, scrollContentHeight]); const navigateBack = () => { - Navigation.goBack(isEditing ? ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID) : ROUTES.HOME); + Navigation.goBack(isEditing ? ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID) : ROUTES.HOME); }; const navigateToNextPage = () => { if (isEditing) { - Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID)); + Navigation.goBack(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID)); return; } @@ -237,7 +237,7 @@ function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken, secondaryIcon={waypointIcon} secondaryIconFill={theme.icon} shouldShowRightIcon - onPress={() => Navigation.navigate(ROUTES.getMoneyRequestWaypointRoute('request', index))} + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_WAYPOINT.getRoute('request', index))} key={key} /> ); @@ -263,7 +263,7 @@ function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken, icon={Expensicons.Plus} onPress={() => { const newIndex = _.size(lodashGet(transaction, 'comment.waypoints', {})); - Navigation.navigate(ROUTES.getMoneyRequestWaypointRoute('request', newIndex)); + Navigation.navigate(ROUTES.MONEY_REQUEST_WAYPOINT.getRoute('request', newIndex)); }} text={translate('distance.addStop')} isDisabled={numberOfWaypoints === MAX_WAYPOINTS} diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js b/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js index f8c5bbc066a6..92a313cf1e0a 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js @@ -44,7 +44,7 @@ function AnchorRenderer(props) { // the reportID is extracted from the URL and then opened as an internal link, taking the user straight to the chat in the same tab. if (hasExpensifyOrigin && attrHref.indexOf('newdotreport?reportID=') > -1) { const reportID = attrHref.split('newdotreport?reportID=').pop(); - const reportRoute = ROUTES.getReportRoute(reportID); + const reportRoute = ROUTES.REPORT_WITH_ID.getRoute(reportID); Navigation.navigate(reportRoute); return; } diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js index 74cf83a4a6f0..f5fac7b49e0f 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js @@ -62,7 +62,7 @@ function ImageRenderer(props) { { - const route = ROUTES.getReportAttachmentRoute(report.reportID, source); + const route = ROUTES.REPORT_ATTACHMENTS.getRoute(report.reportID, source); Navigation.navigate(route); }} onLongPress={(event) => diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.js b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.js index 947a15ac6efb..a6b3fe02b891 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.js @@ -27,7 +27,7 @@ const propTypes = { * @param {String} email * @returns {void} * */ -const showUserDetails = (email) => Navigation.navigate(ROUTES.getDetailsRoute(email)); +const showUserDetails = (email) => Navigation.navigate(ROUTES.DETAILS.getRoute(email)); function MentionUserRenderer(props) { const defaultRendererProps = _.omit(props, ['TDefaultRenderer', 'style']); @@ -50,7 +50,7 @@ function MentionUserRenderer(props) { showUserDetails(loginWithoutLeadingAt)} // Add testID so it is NOT selected as an anchor tag by SelectionScraper diff --git a/src/components/HeaderWithBackButton/index.js b/src/components/HeaderWithBackButton/index.js index 7bcd57385d5f..c720529371d7 100755 --- a/src/components/HeaderWithBackButton/index.js +++ b/src/components/HeaderWithBackButton/index.js @@ -121,7 +121,7 @@ function HeaderWithBackButton({ {shouldShowGetAssistanceButton && ( Navigation.navigate(ROUTES.getGetAssistanceRoute(guidesCallTaskID))} + onPress={() => Navigation.navigate(ROUTES.GET_ASSISTANCE.getRoute(guidesCallTaskID))} style={[styles.touchableButtonImage]} accessibilityRole="button" accessibilityLabel={translate('getAssistancePage.questionMarkButtonTooltip')} diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 13471407914f..06e21f70c9d5 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -364,9 +364,9 @@ function MoneyRequestConfirmationList(props) { if (option.accountID) { const activeRoute = Navigation.getActiveRoute().replace(/\?.*/, ''); - Navigation.navigate(ROUTES.getProfileRoute(option.accountID, activeRoute)); + Navigation.navigate(ROUTES.PROFILE.getRoute(option.accountID, activeRoute)); } else if (option.reportID) { - Navigation.navigate(ROUTES.getReportDetailsRoute(option.reportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(option.reportID)); } }; @@ -474,7 +474,7 @@ function MoneyRequestConfirmationList(props) { shouldParseTitle title={props.iouComment} description={translate('common.description')} - onPress={() => Navigation.navigate(ROUTES.getMoneyRequestDescriptionRoute(props.iouType, props.reportID))} + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_DESCRIPTION.getRoute(props.iouType, props.reportID))} style={[styles.moneyRequestMenuItem, styles.mb2]} titleStyle={styles.flex1} disabled={didConfirm || props.isReadOnly} @@ -503,7 +503,7 @@ function MoneyRequestConfirmationList(props) { description={translate('common.date')} style={[styles.moneyRequestMenuItem, styles.mb2]} titleStyle={styles.flex1} - onPress={() => Navigation.navigate(ROUTES.getMoneyRequestCreatedRoute(props.iouType, props.reportID))} + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_DATE.getRoute(props.iouType, props.reportID))} disabled={didConfirm || props.isReadOnly || !isTypeRequest} /> {props.isDistanceRequest ? ( @@ -523,7 +523,7 @@ function MoneyRequestConfirmationList(props) { description={translate('common.merchant')} style={[styles.moneyRequestMenuItem, styles.mb2]} titleStyle={styles.flex1} - onPress={() => Navigation.navigate(ROUTES.getMoneyRequestMerchantRoute(props.iouType, props.reportID))} + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_MERCHANT.getRoute(props.iouType, props.reportID))} disabled={didConfirm || props.isReadOnly || !isTypeRequest} /> )} @@ -532,7 +532,7 @@ function MoneyRequestConfirmationList(props) { shouldShowRightIcon={!props.isReadOnly} title={props.iouCategory} description={translate('common.category')} - onPress={() => Navigation.navigate(ROUTES.getMoneyRequestCategoryRoute(props.iouType, props.reportID))} + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_CATEGORY.getRoute(props.iouType, props.reportID))} style={[styles.moneyRequestMenuItem, styles.mb2]} disabled={didConfirm || props.isReadOnly} /> @@ -542,7 +542,7 @@ function MoneyRequestConfirmationList(props) { shouldShowRightIcon={!props.isReadOnly} title={props.iouTag} description={tagListName || translate('common.tag')} - onPress={() => Navigation.navigate(ROUTES.getMoneyRequestTagRoute(props.iouType, props.reportID))} + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_TAG.getRoute(props.iouType, props.reportID))} style={[styles.moneyRequestMenuItem, styles.mb2]} disabled={didConfirm || props.isReadOnly} /> diff --git a/src/components/ParentNavigationSubtitle.js b/src/components/ParentNavigationSubtitle.js index fd388b00a8a7..037489294073 100644 --- a/src/components/ParentNavigationSubtitle.js +++ b/src/components/ParentNavigationSubtitle.js @@ -38,7 +38,7 @@ function ParentNavigationSubtitle(props) { return ( { - Navigation.navigate(ROUTES.getReportRoute(props.parentReportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.parentReportID)); }} accessibilityLabel={translate('threads.parentNavigationSummary', {rootReportName, workspaceName})} accessibilityRole={CONST.ACCESSIBILITY_ROLE.LINK} diff --git a/src/components/ReportActionItem/MoneyRequestAction.js b/src/components/ReportActionItem/MoneyRequestAction.js index 3b310bb6b4fa..b4a5e010b7a8 100644 --- a/src/components/ReportActionItem/MoneyRequestAction.js +++ b/src/components/ReportActionItem/MoneyRequestAction.js @@ -98,7 +98,7 @@ function MoneyRequestAction({ const onMoneyRequestPreviewPressed = () => { if (isSplitBillAction) { const reportActionID = lodashGet(action, 'reportActionID', '0'); - Navigation.navigate(ROUTES.getSplitBillDetailsRoute(chatReportID, reportActionID)); + Navigation.navigate(ROUTES.SPLIT_BILL_DETAILS.getRoute(chatReportID, reportActionID)); return; } @@ -108,11 +108,11 @@ function MoneyRequestAction({ const thread = ReportUtils.buildTransactionThread(action, requestReportID); const userLogins = PersonalDetailsUtils.getLoginsByAccountIDs(thread.participantAccountIDs); Report.openReport(thread.reportID, userLogins, thread, action.reportActionID); - Navigation.navigate(ROUTES.getReportRoute(thread.reportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(thread.reportID)); return; } Report.openReport(childReportID); - Navigation.navigate(ROUTES.getReportRoute(childReportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(childReportID)); }; let shouldShowPendingConversionMessage = false; diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 178cab75a0c2..cbfa8e88d950 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -143,7 +143,7 @@ function MoneyRequestView({betas, report, parentReport, policyCategories, should titleStyle={styles.newKansasLarge} interactive={canEdit} shouldShowRightIcon={canEdit} - onPress={() => Navigation.navigate(ROUTES.getEditRequestRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.AMOUNT))} + onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.AMOUNT))} brickRoadIndicator={hasErrors && transactionAmount === 0 ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''} subtitle={hasErrors && transactionAmount === 0 ? translate('common.error.enterAmount') : ''} subtitleTextStyle={styles.textLabelError} @@ -157,7 +157,7 @@ function MoneyRequestView({betas, report, parentReport, policyCategories, should interactive={canEdit} shouldShowRightIcon={canEdit} titleStyle={styles.flex1} - onPress={() => Navigation.navigate(ROUTES.getEditRequestRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.DESCRIPTION))} + onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.DESCRIPTION))} wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]} numberOfLinesTitle={0} /> @@ -169,7 +169,7 @@ function MoneyRequestView({betas, report, parentReport, policyCategories, should interactive={canEdit} shouldShowRightIcon={canEdit} titleStyle={styles.flex1} - onPress={() => Navigation.navigate(ROUTES.getEditRequestRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.DATE))} + onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.DATE))} brickRoadIndicator={hasErrors && transactionDate === '' ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''} subtitle={hasErrors && transactionDate === '' ? translate('common.error.enterDate') : ''} subtitleTextStyle={styles.textLabelError} @@ -182,7 +182,7 @@ function MoneyRequestView({betas, report, parentReport, policyCategories, should interactive={canEdit} shouldShowRightIcon={canEdit} titleStyle={styles.flex1} - onPress={() => Navigation.navigate(ROUTES.getEditRequestRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.MERCHANT))} + onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.MERCHANT))} brickRoadIndicator={hasErrors && isEmptyMerchant ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''} subtitle={hasErrors && isEmptyMerchant ? translate('common.error.enterMerchant') : ''} subtitleTextStyle={styles.textLabelError} @@ -196,7 +196,7 @@ function MoneyRequestView({betas, report, parentReport, policyCategories, should interactive={canEdit} shouldShowRightIcon={canEdit} titleStyle={styles.flex1} - onPress={() => Navigation.navigate(ROUTES.getEditRequestRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.CATEGORY))} + onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.CATEGORY))} /> )} diff --git a/src/components/ReportActionItem/ReportActionItemImage.js b/src/components/ReportActionItem/ReportActionItemImage.js index 070f534f4924..98bdede0fe26 100644 --- a/src/components/ReportActionItem/ReportActionItemImage.js +++ b/src/components/ReportActionItem/ReportActionItemImage.js @@ -59,7 +59,7 @@ function ReportActionItemImage({thumbnail, image, enablePreviewModal}) { { - const route = ROUTES.getReportAttachmentRoute(report.reportID, imageSource); + const route = ROUTES.REPORT_ATTACHMENTS.getRoute(report.reportID, imageSource); Navigation.navigate(route); }} accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON} diff --git a/src/components/ReportActionItem/ReportPreview.js b/src/components/ReportActionItem/ReportPreview.js index 1350c62bda88..a79cfd315b12 100644 --- a/src/components/ReportActionItem/ReportPreview.js +++ b/src/components/ReportActionItem/ReportPreview.js @@ -170,7 +170,7 @@ function ReportPreview(props) { { - Navigation.navigate(ROUTES.getReportRoute(props.iouReportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.iouReportID)); }} onPressIn={() => DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()} onPressOut={() => ControlSelection.unblock()} diff --git a/src/components/ReportActionItem/TaskPreview.js b/src/components/ReportActionItem/TaskPreview.js index d0181e3d736a..1da348bb067b 100644 --- a/src/components/ReportActionItem/TaskPreview.js +++ b/src/components/ReportActionItem/TaskPreview.js @@ -81,7 +81,7 @@ function TaskPreview(props) { return ( Navigation.navigate(ROUTES.getReportRoute(props.taskReportID))} + onPress={() => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(props.taskReportID))} style={[styles.flexRow, styles.justifyContentBetween]} accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON} accessibilityLabel={props.translate('task.task')} diff --git a/src/components/ReportActionItem/TaskView.js b/src/components/ReportActionItem/TaskView.js index ae77a18b980f..39807ab037d5 100644 --- a/src/components/ReportActionItem/TaskView.js +++ b/src/components/ReportActionItem/TaskView.js @@ -72,7 +72,7 @@ function TaskView(props) { e.currentTarget.blur(); } - Navigation.navigate(ROUTES.getTaskReportTitleRoute(props.report.reportID)); + Navigation.navigate(ROUTES.TASK_TITLE.getRoute(props.report.reportID)); })} style={({pressed}) => [ styles.ph5, @@ -132,7 +132,7 @@ function TaskView(props) { shouldParseTitle description={props.translate('task.description')} title={props.report.description || ''} - onPress={() => Navigation.navigate(ROUTES.getTaskReportDescriptionRoute(props.report.reportID))} + onPress={() => Navigation.navigate(ROUTES.TASK_DESCRIPTION.getRoute(props.report.reportID))} shouldShowRightIcon={isOpen} disabled={disableState} wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]} @@ -150,7 +150,7 @@ function TaskView(props) { iconType={CONST.ICON_TYPE_AVATAR} avatarSize={CONST.AVATAR_SIZE.SMALLER} titleStyle={styles.assigneeTextStyle} - onPress={() => Navigation.navigate(ROUTES.getTaskReportAssigneeRoute(props.report.reportID))} + onPress={() => Navigation.navigate(ROUTES.TASK_ASSIGNEE.getRoute(props.report.reportID))} shouldShowRightIcon={isOpen} disabled={disableState} wrapperStyle={[styles.pv2]} @@ -162,7 +162,7 @@ function TaskView(props) { ) : ( Navigation.navigate(ROUTES.getTaskReportAssigneeRoute(props.report.reportID))} + onPress={() => Navigation.navigate(ROUTES.TASK_ASSIGNEE.getRoute(props.report.reportID))} shouldShowRightIcon={isOpen} disabled={disableState} wrapperStyle={[styles.pv2]} diff --git a/src/components/ReportWelcomeText.js b/src/components/ReportWelcomeText.js index 80c26b5d6b3f..071e53de1776 100644 --- a/src/components/ReportWelcomeText.js +++ b/src/components/ReportWelcomeText.js @@ -102,7 +102,7 @@ function ReportWelcomeText(props) { {roomWelcomeMessage.showReportName && ( Navigation.navigate(ROUTES.getReportDetailsRoute(props.report.reportID))} + onPress={() => Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(props.report.reportID))} suppressHighlighting > {ReportUtils.getReportName(props.report)} @@ -122,7 +122,7 @@ function ReportWelcomeText(props) { ) : ( Navigation.navigate(ROUTES.getProfileRoute(accountID))} + onPress={() => Navigation.navigate(ROUTES.PROFILE.getRoute(accountID))} suppressHighlighting > {displayName} diff --git a/src/libs/Navigation/Navigation.js b/src/libs/Navigation/Navigation.js index 1264ec777b28..dc4f35a59cba 100644 --- a/src/libs/Navigation/Navigation.js +++ b/src/libs/Navigation/Navigation.js @@ -165,7 +165,7 @@ function dismissModal(targetReportID) { case SCREENS.REPORT_ATTACHMENTS: // if we are not in the target report, we need to navigate to it after dismissing the modal if (targetReportID && targetReportID !== getTopmostReportId(rootState)) { - const state = getStateFromPath(ROUTES.getReportRoute(targetReportID)); + const state = getStateFromPath(ROUTES.REPORT_WITH_ID.getRoute(targetReportID)); const action = getActionFromState(state, linkingConfig.config); action.type = 'REPLACE'; diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index f4420330fbd9..1a3253bf424b 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -16,7 +16,7 @@ export default { AppleSignInDesktop: ROUTES.APPLE_SIGN_IN, GoogleSignInDesktop: ROUTES.GOOGLE_SIGN_IN, [SCREENS.DESKTOP_SIGN_IN_REDIRECT]: ROUTES.DESKTOP_SIGN_IN_REDIRECT, - [SCREENS.REPORT_ATTACHMENTS]: ROUTES.REPORT_ATTACHMENTS, + [SCREENS.REPORT_ATTACHMENTS]: ROUTES.REPORT_ATTACHMENTS.route, // Demo routes [CONST.DEMO_PAGES.SAASTR]: ROUTES.SAASTR, @@ -29,7 +29,7 @@ export default { [NAVIGATORS.CENTRAL_PANE_NAVIGATOR]: { screens: { - [SCREENS.REPORT]: ROUTES.REPORT_WITH_ID, + [SCREENS.REPORT]: ROUTES.REPORT_WITH_ID.route, }, }, [SCREENS.NOT_FOUND]: '*', @@ -126,7 +126,7 @@ export default { exact: true, }, Settings_ContactMethodDetails: { - path: ROUTES.SETTINGS_CONTACT_METHOD_DETAILS, + path: ROUTES.SETTINGS_CONTACT_METHOD_DETAILS.route, }, Settings_Lounge_Access: { path: ROUTES.SETTINGS_LOUNGE_ACCESS, @@ -168,79 +168,79 @@ export default { exact: true, }, Workspace_Initial: { - path: ROUTES.WORKSPACE_INITIAL, + path: ROUTES.WORKSPACE_INITIAL.route, }, Workspace_Settings: { - path: ROUTES.WORKSPACE_SETTINGS, + path: ROUTES.WORKSPACE_SETTINGS.route, }, Workspace_Card: { - path: ROUTES.WORKSPACE_CARD, + path: ROUTES.WORKSPACE_CARD.route, }, Workspace_Reimburse: { - path: ROUTES.WORKSPACE_REIMBURSE, + path: ROUTES.WORKSPACE_REIMBURSE.route, }, Workspace_RateAndUnit: { - path: ROUTES.WORKSPACE_RATE_AND_UNIT, + path: ROUTES.WORKSPACE_REIMBURSE.route, }, Workspace_Bills: { - path: ROUTES.WORKSPACE_BILLS, + path: ROUTES.WORKSPACE_BILLS.route, }, Workspace_Invoices: { - path: ROUTES.WORKSPACE_INVOICES, + path: ROUTES.WORKSPACE_INVOICES.route, }, Workspace_Travel: { - path: ROUTES.WORKSPACE_TRAVEL, + path: ROUTES.WORKSPACE_TRAVEL.route, }, Workspace_Members: { - path: ROUTES.WORKSPACE_MEMBERS, + path: ROUTES.WORKSPACE_MEMBERS.route, }, Workspace_Invite: { - path: ROUTES.WORKSPACE_INVITE, + path: ROUTES.WORKSPACE_INITIAL.route, }, Workspace_Invite_Message: { - path: ROUTES.WORKSPACE_INVITE_MESSAGE, + path: ROUTES.WORKSPACE_INVITE_MESSAGE.route, }, ReimbursementAccount: { - path: ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN, + path: ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.route, exact: true, }, GetAssistance: { - path: ROUTES.GET_ASSISTANCE, + path: ROUTES.GET_ASSISTANCE.route, }, }, }, Private_Notes: { screens: { - PrivateNotes_View: ROUTES.PRIVATE_NOTES_VIEW, - PrivateNotes_List: ROUTES.PRIVATE_NOTES_LIST, - PrivateNotes_Edit: ROUTES.PRIVATE_NOTES_EDIT, + PrivateNotes_View: ROUTES.PRIVATE_NOTES_VIEW.route, + PrivateNotes_List: ROUTES.PRIVATE_NOTES_LIST.route, + PrivateNotes_Edit: ROUTES.PRIVATE_NOTES_EDIT.route, }, }, Report_Details: { screens: { - Report_Details_Root: ROUTES.REPORT_WITH_ID_DETAILS, - Report_Details_Share_Code: ROUTES.REPORT_WITH_ID_DETAILS_SHARE_CODE, + Report_Details_Root: ROUTES.REPORT_WITH_ID_DETAILS.route, + Report_Details_Share_Code: ROUTES.REPORT_WITH_ID_DETAILS_SHARE_CODE.route, }, }, Report_Settings: { screens: { Report_Settings_Root: { - path: ROUTES.REPORT_SETTINGS, + path: ROUTES.REPORT_SETTINGS.route, }, Report_Settings_Room_Name: { - path: ROUTES.REPORT_SETTINGS_ROOM_NAME, + path: ROUTES.REPORT_SETTINGS_ROOM_NAME.route, }, Report_Settings_Notification_Preferences: { - path: ROUTES.REPORT_SETTINGS_NOTIFICATION_PREFERENCES, + path: ROUTES.REPORT_SETTINGS_NOTIFICATION_PREFERENCES.route, }, Report_Settings_Write_Capability: { - path: ROUTES.REPORT_SETTINGS_WRITE_CAPABILITY, + path: ROUTES.REPORT_SETTINGS_WRITE_CAPABILITY.route, }, }, }, Report_WelcomeMessage: { screens: { - Report_WelcomeMessage_Root: ROUTES.REPORT_WELCOME_MESSAGE, + Report_WelcomeMessage_Root: ROUTES.REPORT_WELCOME_MESSAGE.route, }, }, NewChat: { @@ -286,23 +286,23 @@ export default { }, Details: { screens: { - Details_Root: ROUTES.DETAILS, + Details_Root: ROUTES.DETAILS.route, }, }, Profile: { screens: { - Profile_Root: ROUTES.PROFILE, + Profile_Root: ROUTES.PROFILE.route, }, }, Participants: { screens: { - ReportParticipants_Root: ROUTES.REPORT_PARTICIPANTS, + ReportParticipants_Root: ROUTES.REPORT_PARTICIPANTS.route, }, }, MoneyRequest: { screens: { Money_Request: { - path: ROUTES.MONEY_REQUEST, + path: ROUTES.MONEY_REQUEST.route, exact: true, screens: { manual: { @@ -314,22 +314,22 @@ export default { exact: true, }, distance: { - path: ROUTES.MONEY_REQUEST_DISTANCE_TAB, + path: ROUTES.WORKSPACE_MEMBERS.route, exact: true, }, }, }, - Money_Request_Amount: ROUTES.MONEY_REQUEST_AMOUNT, - Money_Request_Participants: ROUTES.MONEY_REQUEST_PARTICIPANTS, - Money_Request_Confirmation: ROUTES.MONEY_REQUEST_CONFIRMATION, - Money_Request_Date: ROUTES.MONEY_REQUEST_DATE, - Money_Request_Currency: ROUTES.MONEY_REQUEST_CURRENCY, - Money_Request_Description: ROUTES.MONEY_REQUEST_DESCRIPTION, - Money_Request_Category: ROUTES.MONEY_REQUEST_CATEGORY, - Money_Request_Tag: ROUTES.MONEY_REQUEST_TAG, - Money_Request_Merchant: ROUTES.MONEY_REQUEST_MERCHANT, - Money_Request_Waypoint: ROUTES.MONEY_REQUEST_WAYPOINT, - Money_Request_Address: ROUTES.MONEY_REQUEST_ADDRESS, + Money_Request_Amount: ROUTES.MONEY_REQUEST_AMOUNT.route, + Money_Request_Participants: ROUTES.MONEY_REQUEST_PARTICIPANTS.route, + Money_Request_Confirmation: ROUTES.MONEY_REQUEST_CONFIRMATION.route, + Money_Request_Date: ROUTES.MONEY_REQUEST_DATE.route, + Money_Request_Currency: ROUTES.MONEY_REQUEST_CURRENCY.route, + Money_Request_Description: ROUTES.MONEY_REQUEST_DESCRIPTION.route, + Money_Request_Category: ROUTES.MONEY_REQUEST_CATEGORY.route, + Money_Request_Tag: ROUTES.MONEY_REQUEST_TAG.route, + Money_Request_Merchant: ROUTES.MONEY_REQUEST_MERCHANT.route, + Money_Request_Waypoint: ROUTES.MONEY_REQUEST_WAYPOINT.route, + Money_Request_Address: ROUTES.MONEY_REQUEST_ADDRESS.route, IOU_Send_Enable_Payments: ROUTES.IOU_SEND_ENABLE_PAYMENTS, IOU_Send_Add_Bank_Account: ROUTES.IOU_SEND_ADD_BANK_ACCOUNT, IOU_Send_Add_Debit_Card: ROUTES.IOU_SEND_ADD_DEBIT_CARD, @@ -337,14 +337,14 @@ export default { }, SplitDetails: { screens: { - SplitDetails_Root: ROUTES.SPLIT_BILL_DETAILS, + SplitDetails_Root: ROUTES.SPLIT_BILL_DETAILS.route, }, }, Task_Details: { screens: { - Task_Title: ROUTES.TASK_TITLE, - Task_Description: ROUTES.TASK_DESCRIPTION, - Task_Assignee: ROUTES.TASK_ASSIGNEE, + Task_Title: ROUTES.TASK_TITLE.route, + Task_Description: ROUTES.TASK_DESCRIPTION.route, + Task_Assignee: ROUTES.TASK_ASSIGNEE.route, }, }, AddPersonalBankAccount: { @@ -359,18 +359,18 @@ export default { }, Wallet_Statement: { screens: { - WalletStatement_Root: ROUTES.WALLET_STATEMENT_WITH_DATE, + WalletStatement_Root: ROUTES.WALLET_STATEMENT_WITH_DATE.route, }, }, Flag_Comment: { screens: { - FlagComment_Root: ROUTES.FLAG_COMMENT, + FlagComment_Root: ROUTES.FLAG_COMMENT.route, }, }, EditRequest: { screens: { - EditRequest_Root: ROUTES.EDIT_REQUEST, - EditRequest_Currency: ROUTES.EDIT_CURRENCY_REQUEST, + EditRequest_Root: ROUTES.EDIT_REQUEST.route, + EditRequest_Currency: ROUTES.EDIT_CURRENCY_REQUEST.route, }, }, SignIn: { diff --git a/src/libs/Notification/PushNotification/subscribeToReportCommentPushNotifications.js b/src/libs/Notification/PushNotification/subscribeToReportCommentPushNotifications.js index 8e16bb72f656..aadc7d6c3983 100644 --- a/src/libs/Notification/PushNotification/subscribeToReportCommentPushNotifications.js +++ b/src/libs/Notification/PushNotification/subscribeToReportCommentPushNotifications.js @@ -31,7 +31,7 @@ export default function subscribeToReportCommentPushNotifications() { } Log.info('[PushNotification] onSelected() - Navigation is ready. Navigating...', false, {reportID, reportActionID}); - Navigation.navigate(ROUTES.getReportRoute(reportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID)); } catch (error) { Log.alert('[PushNotification] onSelected() - failed', {reportID, reportActionID, error: error.message}); } diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index eee9d6549f6c..b32b9cbb666d 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -422,7 +422,7 @@ function isPublicAnnounceRoom(report) { * @returns {String} */ function getBankAccountRoute(report) { - return isPolicyExpenseChat(report) ? ROUTES.getBankAccountRoute('', report.policyID) : ROUTES.SETTINGS_ADD_BANK_ACCOUNT; + return isPolicyExpenseChat(report) ? ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute('', report.policyID) : ROUTES.SETTINGS_ADD_BANK_ACCOUNT; } /** @@ -1815,14 +1815,14 @@ function navigateToDetailsPage(report) { const participantAccountIDs = lodashGet(report, 'participantAccountIDs', []); if (isChatRoom(report) || isPolicyExpenseChat(report) || isChatThread(report) || isTaskReport(report)) { - Navigation.navigate(ROUTES.getReportDetailsRoute(report.reportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID)); return; } if (participantAccountIDs.length === 1) { - Navigation.navigate(ROUTES.getProfileRoute(participantAccountIDs[0])); + Navigation.navigate(ROUTES.PROFILE.getRoute(participantAccountIDs[0])); return; } - Navigation.navigate(ROUTES.getReportParticipantsRoute(report.reportID)); + Navigation.navigate(ROUTES.REPORT_PARTICIPANTS.getRoute(report.reportID)); } /** diff --git a/src/libs/actions/App.js b/src/libs/actions/App.js index 570b25040855..b8be35aa1919 100644 --- a/src/libs/actions/App.js +++ b/src/libs/actions/App.js @@ -325,10 +325,10 @@ function createWorkspaceAndNavigateToIt(policyOwnerEmail = '', makeMeAdmin = fal } if (shouldNavigateToAdminChat) { - Navigation.navigate(ROUTES.getReportRoute(adminsChatReportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(adminsChatReportID)); } - Navigation.navigate(ROUTES.getWorkspaceInitialRoute(policyID)); + Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(policyID)); }) .then(endSignOnTransition); } diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 86cd791f7fce..7feca4524855 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -1473,14 +1473,14 @@ function deleteMoneyRequest(transactionID, reportAction, isSingleTransactionView if (isSingleTransactionView && shouldDeleteTransactionThread && !shouldDeleteIOUReport) { // Pop the deleted report screen before navigating. This prevents navigating to the Concierge chat due to the missing report. Navigation.goBack(ROUTES.HOME); - Navigation.navigate(ROUTES.getReportRoute(iouReport.reportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(iouReport.reportID)); return; } if (shouldDeleteIOUReport) { // Pop the deleted report screen before navigating. This prevents navigating to the Concierge chat due to the missing report. Navigation.goBack(ROUTES.HOME); - Navigation.navigate(ROUTES.getReportRoute(iouReport.chatReportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(iouReport.chatReportID)); } } @@ -1982,7 +1982,7 @@ function replaceReceipt(transactionID, receipt, filePath) { */ function startMoneyRequest(iouType, reportID = '') { resetMoneyRequestInfo(`${iouType}${reportID}`); - Navigation.navigate(ROUTES.getMoneyRequestRoute(iouType, reportID)); + Navigation.navigate(ROUTES.MONEY_REQUEST.getRoute(iouType, reportID)); } /** @@ -2112,10 +2112,10 @@ function navigateToNextPage(iou, iouType, reportID, report) { .value(); setMoneyRequestParticipants(participants); } - Navigation.navigate(ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID)); + Navigation.navigate(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID)); return; } - Navigation.navigate(ROUTES.getMoneyRequestParticipantsRoute(iouType)); + Navigation.navigate(ROUTES.MONEY_REQUEST_PARTICIPANTS.getRoute(iouType)); } export { diff --git a/src/libs/actions/ReimbursementAccount/navigation.js b/src/libs/actions/ReimbursementAccount/navigation.js index ae655c1ab8cf..1b75e6f16a58 100644 --- a/src/libs/actions/ReimbursementAccount/navigation.js +++ b/src/libs/actions/ReimbursementAccount/navigation.js @@ -20,7 +20,7 @@ function goToWithdrawalAccountSetupStep(stepID, newAchData) { * @param {string} [backTo=''] - An optional return path. If provided, it will be URL-encoded and appended to the resulting URL. */ function navigateToBankAccountRoute(policyId, backTo) { - Navigation.navigate(ROUTES.getBankAccountRoute('', policyId, backTo)); + Navigation.navigate(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute('', policyId, backTo)); } export {goToWithdrawalAccountSetupStep, navigateToBankAccountRoute}; diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 9fa1e5fe0567..d154373812e0 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -622,7 +622,7 @@ function navigateToAndOpenReport(userLogins, shouldDismissModal = true) { if (shouldDismissModal) { Navigation.dismissModal(reportID); } else { - Navigation.navigate(ROUTES.getReportRoute(reportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID)); } } @@ -655,7 +655,7 @@ function navigateToAndOpenReportWithAccountIDs(participantAccountIDs) { function navigateToAndOpenChildReport(childReportID = '0', parentReportAction = {}, parentReportID = '0') { if (childReportID !== '0') { openReport(childReportID); - Navigation.navigate(ROUTES.getReportRoute(childReportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(childReportID)); } else { const participantAccountIDs = _.uniq([currentUserAccountID, Number(parentReportAction.actorAccountID)]); const parentReport = allReports[parentReportID]; @@ -676,7 +676,7 @@ function navigateToAndOpenChildReport(childReportID = '0', parentReportAction = const participantLogins = PersonalDetailsUtils.getLoginsByAccountIDs(newChat.participantAccountIDs); openReport(newChat.reportID, participantLogins, newChat, parentReportAction.reportActionID); - Navigation.navigate(ROUTES.getReportRoute(newChat.reportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(newChat.reportID)); } } @@ -946,7 +946,7 @@ function handleReportChanged(report) { // Only re-route them if they are still looking at the optimistically created report if (Navigation.getActiveRoute().includes(`/r/${report.reportID}`)) { // Pass 'FORCED_UP' type to replace new report on second login with proper one in the Navigation - Navigation.navigate(ROUTES.getReportRoute(report.preexistingReportID), CONST.NAVIGATION.TYPE.FORCED_UP); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.preexistingReportID), CONST.NAVIGATION.TYPE.FORCED_UP); } return; } @@ -1273,7 +1273,7 @@ function saveReportActionDraftNumberOfLines(reportID, reportActionID, numberOfLi */ function updateNotificationPreferenceAndNavigate(reportID, previousValue, newValue) { if (previousValue === newValue) { - Navigation.goBack(ROUTES.getReportSettingsRoute(reportID)); + Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(reportID)); return; } const optimisticData = [ @@ -1291,7 +1291,7 @@ function updateNotificationPreferenceAndNavigate(reportID, previousValue, newVal }, ]; API.write('UpdateReportNotificationPreference', {reportID, notificationPreference: newValue}, {optimisticData, failureData}); - Navigation.goBack(ROUTES.getReportSettingsRoute(reportID)); + Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(reportID)); } /** @@ -1331,7 +1331,7 @@ function updateWelcomeMessage(reportID, previousValue, newValue) { */ function updateWriteCapabilityAndNavigate(report, newValue) { if (report.writeCapability === newValue) { - Navigation.goBack(ROUTES.getReportSettingsRoute(report.reportID)); + Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(report.reportID)); return; } @@ -1351,7 +1351,7 @@ function updateWriteCapabilityAndNavigate(report, newValue) { ]; API.write('UpdateReportWriteCapability', {reportID: report.reportID, writeCapability: newValue}, {optimisticData, failureData}); // Return to the report settings page since this field utilizes push-to-page - Navigation.goBack(ROUTES.getReportSettingsRoute(report.reportID)); + Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(report.reportID)); } /** @@ -1366,7 +1366,7 @@ function navigateToConciergeChat() { navigateToAndOpenReport([CONST.EMAIL.CONCIERGE], false); }); } else { - Navigation.navigate(ROUTES.getReportRoute(conciergeChatReportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(conciergeChatReportID)); } } @@ -1516,7 +1516,7 @@ function updatePolicyRoomNameAndNavigate(policyRoomReport, policyRoomName) { // No change needed, navigate back if (previousName === policyRoomName) { - Navigation.goBack(ROUTES.getReportSettingsRoute(reportID)); + Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(reportID)); return; } const optimisticData = [ @@ -1555,7 +1555,7 @@ function updatePolicyRoomNameAndNavigate(policyRoomReport, policyRoomName) { }, ]; API.write('UpdatePolicyRoomName', {reportID, policyRoomName}, {optimisticData, successData, failureData}); - Navigation.goBack(ROUTES.getReportSettingsRoute(reportID)); + Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(reportID)); } /** @@ -1651,7 +1651,7 @@ function showReportActionNotification(reportID, action) { reportAction: action, onClick: () => { // Navigate to this report onClick - Navigation.navigate(ROUTES.getReportRoute(reportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID)); }, }); notifyNewAction(reportID, action.actorAccountID, action.reportActionID); @@ -1890,7 +1890,7 @@ function leaveRoom(reportID) { Navigation.goBack(ROUTES.HOME); } if (report.parentReportID) { - Navigation.navigate(ROUTES.getReportRoute(report.parentReportID), CONST.NAVIGATION.TYPE.FORCED_UP); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.parentReportID), CONST.NAVIGATION.TYPE.FORCED_UP); return; } navigateToConciergeChat(); @@ -1911,7 +1911,7 @@ function setLastOpenedPublicRoom(reportID) { function openLastOpenedPublicRoom(lastOpenedPublicRoomID) { Navigation.isNavigationReady().then(() => { setLastOpenedPublicRoom(''); - Navigation.navigate(ROUTES.getReportRoute(lastOpenedPublicRoomID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(lastOpenedPublicRoomID)); }); } diff --git a/src/libs/actions/Welcome.js b/src/libs/actions/Welcome.js index 6e6fe2512dff..8e1832edb9a7 100644 --- a/src/libs/actions/Welcome.js +++ b/src/libs/actions/Welcome.js @@ -134,7 +134,7 @@ function show({routes, showCreateMenu = () => {}, showPopoverMenu = () => {}}) { } if (shouldNavigateToWorkspaceChat && workspaceChatReport) { - Navigation.navigate(ROUTES.getReportRoute(workspaceChatReport.reportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(workspaceChatReport.reportID)); // If showPopoverMenu exists and returns true then it opened the Popover Menu successfully, and we can update isFirstTimeNewExpensifyUser // so the Welcome logic doesn't run again diff --git a/src/pages/EditRequestAmountPage.js b/src/pages/EditRequestAmountPage.js index b24275cbdfc0..9f72c9afbc23 100644 --- a/src/pages/EditRequestAmountPage.js +++ b/src/pages/EditRequestAmountPage.js @@ -43,7 +43,7 @@ function EditRequestAmountPage({defaultAmount, defaultCurrency, onSubmit, report const navigateToCurrencySelectionPage = () => { // Remove query from the route and encode it. const activeRoute = encodeURIComponent(Navigation.getActiveRoute().replace(/\?.*/, '')); - Navigation.navigate(ROUTES.getEditRequestCurrencyRoute(reportID, defaultCurrency, activeRoute)); + Navigation.navigate(ROUTES.EDIT_CURRENCY_REQUEST.getRoute(reportID, defaultCurrency, activeRoute)); }; useFocusEffect( diff --git a/src/pages/PrivateNotes/PrivateNotesListPage.js b/src/pages/PrivateNotes/PrivateNotesListPage.js index fdfaa4c60e33..da6d0d611bc5 100644 --- a/src/pages/PrivateNotes/PrivateNotesListPage.js +++ b/src/pages/PrivateNotes/PrivateNotesListPage.js @@ -110,7 +110,7 @@ function PrivateNotesListPage({report, personalDetailsList, network, session}) { title: Number(lodashGet(session, 'accountID', null)) === Number(accountID) ? translate('privateNotes.myNote') : lodashGet(personalDetailsList, [accountID, 'login'], ''), icon: UserUtils.getAvatar(lodashGet(personalDetailsList, [accountID, 'avatar'], UserUtils.getDefaultAvatar(accountID)), accountID), iconType: CONST.ICON_TYPE_AVATAR, - action: () => Navigation.navigate(ROUTES.getPrivateNotesViewRoute(report.reportID, accountID)), + action: () => Navigation.navigate(ROUTES.PRIVATE_NOTES_VIEW.getRoute(report.reportID, accountID)), brickRoadIndicator: privateNoteBrickRoadIndicator(accountID), })) .value(); diff --git a/src/pages/PrivateNotes/PrivateNotesViewPage.js b/src/pages/PrivateNotes/PrivateNotesViewPage.js index 4c6d960d5d9a..d09f1bbdee47 100644 --- a/src/pages/PrivateNotes/PrivateNotesViewPage.js +++ b/src/pages/PrivateNotes/PrivateNotesViewPage.js @@ -75,7 +75,7 @@ function PrivateNotesViewPage({route, personalDetailsList, session, report}) { isCurrentUserNote && Navigation.navigate(ROUTES.getPrivateNotesEditRoute(report.reportID, route.params.accountID))} + onPress={() => isCurrentUserNote && Navigation.navigate(ROUTES.PRIVATE_NOTES_EDIT.getRoute(report.reportID, route.params.accountID))} shouldShowRightIcon={isCurrentUserNote} numberOfLinesTitle={0} shouldRenderAsHTML diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js index ddec4e5a86ae..60037e4755c0 100755 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.js @@ -243,7 +243,7 @@ function ProfilePage(props) { title={`${props.translate('privateNotes.title')}`} titleStyle={styles.flex1} icon={Expensicons.Pencil} - onPress={() => Navigation.navigate(ROUTES.getPrivateNotesListRoute(chatReportWithCurrentUser.reportID))} + onPress={() => Navigation.navigate(ROUTES.PRIVATE_NOTES_LIST.getRoute(chatReportWithCurrentUser.reportID))} wrapperStyle={styles.breakAll} shouldShowRightIcon brickRoadIndicator={Report.hasErrorInPrivateNotes(chatReportWithCurrentUser) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''} diff --git a/src/pages/ReimbursementAccount/Enable2FAPrompt.js b/src/pages/ReimbursementAccount/Enable2FAPrompt.js index 829ac9b63848..33424669903f 100644 --- a/src/pages/ReimbursementAccount/Enable2FAPrompt.js +++ b/src/pages/ReimbursementAccount/Enable2FAPrompt.js @@ -13,7 +13,9 @@ const propTypes = { ...withLocalizePropTypes, }; function Enable2FAPrompt(props) { - const secureYourAccountUrl = encodeURI(`settings?param={"section":"account","action":"enableTwoFactorAuth","exitTo":"${ROUTES.getBankAccountRoute()}","isFromNewDot":"true"}`); + const secureYourAccountUrl = encodeURI( + `settings?param={"section":"account","action":"enableTwoFactorAuth","exitTo":"${ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute()}","isFromNewDot":"true"}`, + ); return (
Navigation.navigate(ROUTES.getReportShareCodeRoute(props.report.reportID)), + action: () => Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS_SHARE_CODE.getRoute(props.report.reportID)), }, ]; @@ -95,7 +95,7 @@ function ReportDetailsPage(props) { subtitle: participants.length, isAnonymousAction: false, action: () => { - Navigation.navigate(ROUTES.getReportParticipantsRoute(props.report.reportID)); + Navigation.navigate(ROUTES.REPORT_PARTICIPANTS.getRoute(props.report.reportID)); }, }); } @@ -107,7 +107,7 @@ function ReportDetailsPage(props) { icon: Expensicons.Gear, isAnonymousAction: false, action: () => { - Navigation.navigate(ROUTES.getReportSettingsRoute(props.report.reportID)); + Navigation.navigate(ROUTES.REPORT_SETTINGS.getRoute(props.report.reportID)); }, }); } @@ -119,7 +119,7 @@ function ReportDetailsPage(props) { translationKey: 'privateNotes.title', icon: Expensicons.Pencil, isAnonymousAction: false, - action: () => Navigation.navigate(ROUTES.getPrivateNotesListRoute(props.report.reportID)), + action: () => Navigation.navigate(ROUTES.PRIVATE_NOTES_LIST.getRoute(props.report.reportID)), brickRoadIndicator: Report.hasErrorInPrivateNotes(props.report) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '', }); } @@ -177,7 +177,7 @@ function ReportDetailsPage(props) { accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON} accessibilityLabel={chatRoomSubtitle} onPress={() => { - Navigation.navigate(ROUTES.getWorkspaceInitialRoute(props.report.policyID)); + Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(props.report.policyID)); }} > {chatRoomSubtitleText} diff --git a/src/pages/ReportParticipantsPage.js b/src/pages/ReportParticipantsPage.js index c10401fb90db..7f453d16817b 100755 --- a/src/pages/ReportParticipantsPage.js +++ b/src/pages/ReportParticipantsPage.js @@ -130,7 +130,7 @@ function ReportParticipantsPage(props) { }, ]} onSelectRow={(option) => { - Navigation.navigate(ROUTES.getProfileRoute(option.accountID)); + Navigation.navigate(ROUTES.PROFILE.getRoute(option.accountID)); }} hideSectionHeaders showTitleTooltip diff --git a/src/pages/ShareCodePage.js b/src/pages/ShareCodePage.js index f19c79db5459..75bf5fd24f1d 100644 --- a/src/pages/ShareCodePage.js +++ b/src/pages/ShareCodePage.js @@ -47,8 +47,8 @@ class ShareCodePage extends React.Component { const subtitle = isReport ? ReportUtils.getParentNavigationSubtitle(this.props.report).workspaceName || ReportUtils.getChatRoomSubtitle(this.props.report) : formattedEmail; const urlWithTrailingSlash = Url.addTrailingForwardSlash(this.props.environmentURL); const url = isReport - ? `${urlWithTrailingSlash}${ROUTES.getReportRoute(this.props.report.reportID)}` - : `${urlWithTrailingSlash}${ROUTES.getProfileRoute(this.props.session.accountID)}`; + ? `${urlWithTrailingSlash}${ROUTES.REPORT_WITH_ID.getRoute(this.props.report.reportID)}` + : `${urlWithTrailingSlash}${ROUTES.PROFILE.getRoute(this.props.session.accountID)}`; const platform = getPlatform(); const isNative = platform === CONST.PLATFORM.IOS || platform === CONST.PLATFORM.ANDROID; @@ -57,7 +57,7 @@ class ShareCodePage extends React.Component { Navigation.goBack(isReport ? ROUTES.getReportDetailsRoute(this.props.report.reportID) : ROUTES.SETTINGS)} + onBackButtonPress={() => Navigation.goBack(isReport ? ROUTES.REPORT_WITH_ID_DETAILS.getRoute(this.props.report.reportID) : ROUTES.SETTINGS)} /> diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 922b74d3b6a3..15bf25695fd3 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -250,7 +250,7 @@ function ReportScreen({ }, []); const chatWithAccountManager = useCallback(() => { - Navigation.navigate(ROUTES.getReportRoute(accountManagerReportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(accountManagerReportID)); }, [accountManagerReportID]); /** diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 173bda0e5221..2a65bc2e67ab 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -298,11 +298,11 @@ export default [ const thread = ReportUtils.buildTransactionThread(reportAction, reportID); const userLogins = PersonalDetailsUtils.getLoginsByAccountIDs(thread.participantAccountIDs); Report.openReport(thread.reportID, userLogins, thread, reportAction.reportActionID); - Navigation.navigate(ROUTES.getReportRoute(thread.reportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(thread.reportID)); return; } Report.openReport(childReportID); - Navigation.navigate(ROUTES.getReportRoute(childReportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(childReportID)); return; } const editAction = () => Report.saveReportActionDraft(reportID, reportAction.reportActionID, _.isEmpty(draftMessage) ? getActionText(reportAction) : ''); @@ -382,10 +382,10 @@ export default [ reportAction.actorAccountID !== CONST.ACCOUNT_ID.CONCIERGE, onPress: (closePopover, {reportID, reportAction}) => { if (closePopover) { - hideContextMenu(false, () => Navigation.navigate(ROUTES.getFlagCommentRoute(reportID, reportAction.reportActionID))); + hideContextMenu(false, () => Navigation.navigate(ROUTES.FLAG_COMMENT.getRoute(reportID, reportAction.reportActionID))); } - Navigation.navigate(ROUTES.getFlagCommentRoute(reportID, reportAction.reportActionID)); + Navigation.navigate(ROUTES.FLAG_COMMENT.getRoute(reportID, reportAction.reportActionID)); }, getDescription: () => {}, }, diff --git a/src/pages/home/report/ReactionList/BaseReactionList.js b/src/pages/home/report/ReactionList/BaseReactionList.js index 0b77fca7c645..b082ca510edd 100755 --- a/src/pages/home/report/ReactionList/BaseReactionList.js +++ b/src/pages/home/report/ReactionList/BaseReactionList.js @@ -79,7 +79,7 @@ function BaseReactionList(props) { hoverStyle={styles.hoveredComponentBG} onSelectRow={() => { props.onClose(); - Navigation.navigate(ROUTES.getProfileRoute(item.accountID)); + Navigation.navigate(ROUTES.PROFILE.getRoute(item.accountID)); }} option={{ text: Str.removeSMSDomain(item.displayName), diff --git a/src/pages/home/report/ReportActionItemSingle.js b/src/pages/home/report/ReportActionItemSingle.js index bfbce8aed336..97dd5e37482e 100644 --- a/src/pages/home/report/ReportActionItemSingle.js +++ b/src/pages/home/report/ReportActionItemSingle.js @@ -80,11 +80,11 @@ const defaultProps = { }; const showUserDetails = (accountID) => { - Navigation.navigate(ROUTES.getProfileRoute(accountID)); + Navigation.navigate(ROUTES.PROFILE.getRoute(accountID)); }; const showWorkspaceDetails = (reportID) => { - Navigation.navigate(ROUTES.getReportDetailsRoute(reportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(reportID)); }; function ReportActionItemSingle(props) { @@ -149,7 +149,7 @@ function ReportActionItemSingle(props) { } else { // Show participants page IOU report preview if (displayAllActors) { - Navigation.navigate(ROUTES.getReportParticipantsRoute(iouReportID)); + Navigation.navigate(ROUTES.REPORT_PARTICIPANTS.getRoute(iouReportID)); return; } showUserDetails(props.action.delegateAccountID ? props.action.delegateAccountID : actorAccountID); diff --git a/src/pages/home/report/ReportAttachments.js b/src/pages/home/report/ReportAttachments.js index c8b5dd1ae685..4146be0d3971 100644 --- a/src/pages/home/report/ReportAttachments.js +++ b/src/pages/home/report/ReportAttachments.js @@ -32,7 +32,7 @@ function ReportAttachments(props) { source={source} onModalHide={() => Navigation.dismissModal(reportID)} onCarouselAttachmentChange={(attachment) => { - const route = ROUTES.getReportAttachmentRoute(reportID, attachment.source); + const route = ROUTES.REPORT_ATTACHMENTS.getRoute(reportID, attachment.source); Navigation.navigate(route); }} /> diff --git a/src/pages/home/sidebar/SidebarLinks.js b/src/pages/home/sidebar/SidebarLinks.js index c38ac9e01ccb..9ff9cc261af4 100644 --- a/src/pages/home/sidebar/SidebarLinks.js +++ b/src/pages/home/sidebar/SidebarLinks.js @@ -141,7 +141,7 @@ class SidebarLinks extends React.PureComponent { ) { return; } - Navigation.navigate(ROUTES.getReportRoute(option.reportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(option.reportID)); this.props.onLinkClick(); } diff --git a/src/pages/iou/IOUCurrencySelection.js b/src/pages/iou/IOUCurrencySelection.js index 966cd2f87af6..e8c5cd6b3a92 100644 --- a/src/pages/iou/IOUCurrencySelection.js +++ b/src/pages/iou/IOUCurrencySelection.js @@ -138,7 +138,7 @@ function IOUCurrencySelection(props) { <> Navigation.goBack(ROUTES.getMoneyRequestRoute(iouType, reportID))} + onBackButtonPress={() => Navigation.goBack(ROUTES.MONEY_REQUEST.getRoute(iouType, reportID))} /> { - Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID)); + Navigation.goBack(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID)); }; const updateCategory = (category) => { @@ -56,7 +56,7 @@ function MoneyRequestCategoryPage({route, report, iou}) { IOU.setMoneyRequestCategory(category.searchText); } - Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID)); + Navigation.goBack(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID)); }; return ( diff --git a/src/pages/iou/MoneyRequestDatePage.js b/src/pages/iou/MoneyRequestDatePage.js index 2d2f9c519c50..032b1642006a 100644 --- a/src/pages/iou/MoneyRequestDatePage.js +++ b/src/pages/iou/MoneyRequestDatePage.js @@ -62,12 +62,12 @@ function MoneyRequestDatePage({iou, route, selectedTab}) { } if (!isDistanceRequest && (_.isEmpty(iou.participantAccountIDs) || (iou.amount === 0 && !iou.receiptPath) || shouldReset)) { - Navigation.goBack(ROUTES.getMoneyRequestRoute(iouType, reportID), true); + Navigation.goBack(ROUTES.MONEY_REQUEST.getRoute(iouType, reportID), true); } }, [iou.id, iou.participantAccountIDs, iou.amount, iou.receiptPath, iouType, reportID, isDistanceRequest]); function navigateBack() { - Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID)); + Navigation.goBack(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID)); } /** diff --git a/src/pages/iou/MoneyRequestDescriptionPage.js b/src/pages/iou/MoneyRequestDescriptionPage.js index 61f688f5d4bd..eb67aa95be5b 100644 --- a/src/pages/iou/MoneyRequestDescriptionPage.js +++ b/src/pages/iou/MoneyRequestDescriptionPage.js @@ -84,12 +84,12 @@ function MoneyRequestDescriptionPage({iou, route, selectedTab}) { } if (!isDistanceRequest && (_.isEmpty(iou.participantAccountIDs) || (iou.amount === 0 && !iou.receiptPath) || shouldReset)) { - Navigation.goBack(ROUTES.getMoneyRequestRoute(iouType, reportID), true); + Navigation.goBack(ROUTES.MONEY_REQUEST.getRoute(iouType, reportID), true); } }, [iou.id, iou.participantAccountIDs, iou.amount, iou.receiptPath, iouType, reportID, isDistanceRequest]); function navigateBack() { - Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID)); + Navigation.goBack(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID)); } /** diff --git a/src/pages/iou/MoneyRequestMerchantPage.js b/src/pages/iou/MoneyRequestMerchantPage.js index dddf63a49673..cb3e97f2bc90 100644 --- a/src/pages/iou/MoneyRequestMerchantPage.js +++ b/src/pages/iou/MoneyRequestMerchantPage.js @@ -59,12 +59,12 @@ function MoneyRequestMerchantPage({iou, route}) { } if (_.isEmpty(iou.participantAccountIDs) || (iou.amount === 0 && !iou.receiptPath) || shouldReset) { - Navigation.goBack(ROUTES.getMoneyRequestRoute(iouType, reportID), true); + Navigation.goBack(ROUTES.MONEY_REQUEST.getRoute(iouType, reportID), true); } }, [iou.id, iou.participantAccountIDs, iou.amount, iou.receiptPath, iouType, reportID]); function navigateBack() { - Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID)); + Navigation.goBack(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID)); } const validate = useCallback((value) => { diff --git a/src/pages/iou/MoneyRequestTagPage.js b/src/pages/iou/MoneyRequestTagPage.js index fcd2b412fbe8..32c21d949f2c 100644 --- a/src/pages/iou/MoneyRequestTagPage.js +++ b/src/pages/iou/MoneyRequestTagPage.js @@ -64,7 +64,7 @@ function MoneyRequestTagPage({route, report, policyTags, iou}) { const tagListName = lodashGet(tagList, 'name', translate('common.tag')); const navigateBack = () => { - Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, report.reportID)); + Navigation.goBack(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, report.reportID)); }; const updateTag = (selectedTag) => { diff --git a/src/pages/iou/WaypointEditor.js b/src/pages/iou/WaypointEditor.js index 11459cca3aa8..1e0622bc85ba 100644 --- a/src/pages/iou/WaypointEditor.js +++ b/src/pages/iou/WaypointEditor.js @@ -147,13 +147,13 @@ function WaypointEditor({transactionID, route: {params: {iouType = '', waypointI } // Other flows will be handled by selecting a waypoint with selectWaypoint as this is mainly for the offline flow - Navigation.goBack(ROUTES.getMoneyRequestDistanceTabRoute(iouType)); + Navigation.goBack(ROUTES.WORKSPACE_MEMBERS.getRoute(iouType)); }; const deleteStopAndHideModal = () => { Transaction.removeWaypoint(transactionID, waypointIndex); setIsDeleteStopModalOpen(false); - Navigation.goBack(ROUTES.getMoneyRequestDistanceTabRoute(iouType)); + Navigation.goBack(ROUTES.WORKSPACE_MEMBERS.getRoute(iouType)); }; const selectWaypoint = (values) => { @@ -163,7 +163,7 @@ function WaypointEditor({transactionID, route: {params: {iouType = '', waypointI address: values.address, }; saveWaypoint(waypoint); - Navigation.goBack(ROUTES.getMoneyRequestDistanceTabRoute(iouType)); + Navigation.goBack(ROUTES.WORKSPACE_MEMBERS.getRoute(iouType)); }; const focusAddressInput = () => { @@ -187,7 +187,7 @@ function WaypointEditor({transactionID, route: {params: {iouType = '', waypointI title={translate(wayPointDescriptionKey)} shouldShowBackButton onBackButtonPress={() => { - Navigation.goBack(ROUTES.getMoneyRequestDistanceTabRoute(iouType)); + Navigation.goBack(ROUTES.WORKSPACE_MEMBERS.getRoute(iouType)); }} shouldShowThreeDotsButton={shouldShowThreeDotsButton} threeDotsAnchorPosition={styles.threeDotsPopoverOffset(windowWidth)} diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index 82b3c4a4909d..9d4468c8aff4 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -91,7 +91,7 @@ function MoneyRequestConfirmPage(props) { if (!isDistanceRequest && prevMoneyRequestId.current !== props.iou.id) { // The ID is cleared on completing a request. In that case, we will do nothing. if (props.iou.id) { - Navigation.goBack(ROUTES.getMoneyRequestRoute(iouType.current, reportID.current), true); + Navigation.goBack(ROUTES.MONEY_REQUEST.getRoute(iouType.current, reportID.current), true); } return; } @@ -104,7 +104,7 @@ function MoneyRequestConfirmPage(props) { } if (_.isEmpty(props.iou.participants) || (props.iou.amount === 0 && !props.iou.receiptPath && !isDistanceRequest) || shouldReset) { - Navigation.goBack(ROUTES.getMoneyRequestRoute(iouType.current, reportID.current), true); + Navigation.goBack(ROUTES.MONEY_REQUEST.getRoute(iouType.current, reportID.current), true); } return () => { @@ -115,9 +115,9 @@ function MoneyRequestConfirmPage(props) { const navigateBack = () => { let fallback; if (reportID.current) { - fallback = ROUTES.getMoneyRequestRoute(iouType.current, reportID.current); + fallback = ROUTES.MONEY_REQUEST.getRoute(iouType.current, reportID.current); } else { - fallback = ROUTES.getMoneyRequestParticipantsRoute(iouType.current); + fallback = ROUTES.MONEY_REQUEST_PARTICIPANTS.getRoute(iouType.current); } Navigation.goBack(fallback); }; diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js index b737e40b8e4b..8d745903eb40 100644 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js @@ -67,21 +67,21 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) { if (option.reportID) { isNewReportIDSelectedLocally.current = true; IOU.setMoneyRequestId(`${moneyRequestType}${option.reportID}`); - Navigation.navigate(ROUTES.getMoneyRequestConfirmationRoute(moneyRequestType, option.reportID)); + Navigation.navigate(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(moneyRequestType, option.reportID)); return; } IOU.setMoneyRequestId(moneyRequestType); - Navigation.navigate(ROUTES.getMoneyRequestConfirmationRoute(moneyRequestType, reportID.current)); + Navigation.navigate(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(moneyRequestType, reportID.current)); }; const navigateToSplitStep = (moneyRequestType) => { IOU.setMoneyRequestId(moneyRequestType); - Navigation.navigate(ROUTES.getMoneyRequestConfirmationRoute(moneyRequestType, reportID.current)); + Navigation.navigate(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(moneyRequestType, reportID.current)); }; const navigateBack = (forceFallback = false) => { - Navigation.goBack(ROUTES.getMoneyRequestRoute(iouType.current, reportID.current), forceFallback); + Navigation.goBack(ROUTES.MONEY_REQUEST.getRoute(iouType.current, reportID.current), forceFallback); }; useEffect(() => { diff --git a/src/pages/iou/steps/NewRequestAmountPage.js b/src/pages/iou/steps/NewRequestAmountPage.js index 9746fd602eb6..92bc40a2af51 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.js +++ b/src/pages/iou/steps/NewRequestAmountPage.js @@ -106,7 +106,7 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { if (!iou.id) { return; } - Navigation.goBack(ROUTES.getMoneyRequestRoute(iouType, reportID), true); + Navigation.goBack(ROUTES.MONEY_REQUEST.getRoute(iouType, reportID), true); return; } const moneyRequestID = `${iouType}${reportID}`; @@ -116,7 +116,7 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { } if (!isDistanceRequestTab && (_.isEmpty(iou.participantAccountIDs) || iou.amount === 0 || shouldReset)) { - Navigation.goBack(ROUTES.getMoneyRequestRoute(iouType, reportID), true); + Navigation.goBack(ROUTES.MONEY_REQUEST.getRoute(iouType, reportID), true); } } @@ -126,7 +126,7 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { }, [iou.participantAccountIDs, iou.amount, iou.id, isEditing, iouType, reportID, isDistanceRequestTab]); const navigateBack = () => { - Navigation.goBack(isEditing ? ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID) : ROUTES.HOME); + Navigation.goBack(isEditing ? ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID) : ROUTES.HOME); }; const navigateToCurrencySelectionPage = () => { @@ -138,7 +138,7 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { // Remove query from the route and encode it. const activeRoute = encodeURIComponent(Navigation.getActiveRoute().replace(/\?.*/, '')); - Navigation.navigate(ROUTES.getMoneyRequestCurrencyRoute(iouType, reportID, currency, activeRoute)); + Navigation.navigate(ROUTES.MONEY_REQUEST_CURRENCY.getRoute(iouType, reportID, currency, activeRoute)); }; const navigateToNextPage = (currentAmount) => { @@ -147,7 +147,7 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { IOU.setMoneyRequestCurrency(currency); if (isEditing) { - Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID)); + Navigation.goBack(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID)); return; } diff --git a/src/pages/settings/Profile/Contacts/ContactMethodsPage.js b/src/pages/settings/Profile/Contacts/ContactMethodsPage.js index b5e05cf017df..de1979e425b5 100644 --- a/src/pages/settings/Profile/Contacts/ContactMethodsPage.js +++ b/src/pages/settings/Profile/Contacts/ContactMethodsPage.js @@ -100,7 +100,7 @@ function ContactMethodsPage(props) { Navigation.navigate(ROUTES.getEditContactMethodRoute(partnerUserID))} + onPress={() => Navigation.navigate(ROUTES.SETTINGS_CONTACT_METHOD_DETAILS.getRoute(partnerUserID))} brickRoadIndicator={indicator} shouldShowBasicTitle shouldShowRightIcon diff --git a/src/pages/settings/Report/NotificationPreferencePage.js b/src/pages/settings/Report/NotificationPreferencePage.js index 57619bc3659f..b6dbf5f42c83 100644 --- a/src/pages/settings/Report/NotificationPreferencePage.js +++ b/src/pages/settings/Report/NotificationPreferencePage.js @@ -50,7 +50,7 @@ function NotificationPreferencePage(props) { Navigation.goBack(ROUTES.getReportSettingsRoute(props.report.reportID))} + onBackButtonPress={() => Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(props.report.reportID))} /> Navigation.goBack(ROUTES.getReportDetailsRoute(report.reportID))} + onBackButtonPress={() => Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID))} /> {report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN && ( @@ -87,7 +87,7 @@ function ReportSettingsPage(props) { shouldShowRightIcon title={notificationPreference} description={translate('notificationPreferencesPage.label')} - onPress={() => Navigation.navigate(ROUTES.getReportSettingsNotificationPreferencesRoute(report.reportID))} + onPress={() => Navigation.navigate(ROUTES.REPORT_SETTINGS_NOTIFICATION_PREFERENCES.getRoute(report.reportID))} /> )} {shouldShowRoomName && ( @@ -117,7 +117,7 @@ function ReportSettingsPage(props) { shouldShowRightIcon title={report.reportName} description={translate('newRoomPage.roomName')} - onPress={() => Navigation.navigate(ROUTES.getReportSettingsRoomNameRoute(report.reportID))} + onPress={() => Navigation.navigate(ROUTES.REPORT_SETTINGS_ROOM_NAME.getRoute(report.reportID))} /> )} @@ -127,7 +127,7 @@ function ReportSettingsPage(props) { shouldShowRightIcon title={writeCapabilityText} description={translate('writeCapabilityPage.label')} - onPress={() => Navigation.navigate(ROUTES.getReportSettingsWriteCapabilityRoute(report.reportID))} + onPress={() => Navigation.navigate(ROUTES.REPORT_SETTINGS_WRITE_CAPABILITY.getRoute(report.reportID))} /> ) : ( @@ -184,7 +184,7 @@ function ReportSettingsPage(props) { Navigation.navigate(ROUTES.getReportWelcomeMessageRoute(report.reportID))} + onPress={() => Navigation.navigate(ROUTES.REPORT_WELCOME_MESSAGE.getRoute(report.reportID))} shouldShowRightIcon /> )} diff --git a/src/pages/settings/Report/RoomNamePage.js b/src/pages/settings/Report/RoomNamePage.js index b8844a39c38b..42d7156660f9 100644 --- a/src/pages/settings/Report/RoomNamePage.js +++ b/src/pages/settings/Report/RoomNamePage.js @@ -86,7 +86,7 @@ function RoomNamePage(props) { Navigation.goBack(ROUTES.getReportSettingsRoute(report.reportID))} + onBackButtonPress={() => Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(report.reportID))} />
Navigation.goBack(ROUTES.getReportSettingsRoute(props.report.reportID))} + onBackButtonPress={() => Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(props.report.reportID))} /> Navigation.navigate(ROUTES.getWorkspaceSettingsRoute(policy.id)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_SETTINGS.getRoute(policy.id)), brickRoadIndicator: hasGeneralSettingsError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '', }, { translationKey: 'workspace.common.card', icon: Expensicons.ExpensifyCard, - action: () => Navigation.navigate(ROUTES.getWorkspaceCardRoute(policy.id)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_CARD.getRoute(policy.id)), }, { translationKey: 'workspace.common.reimburse', icon: Expensicons.Receipt, - action: () => Navigation.navigate(ROUTES.getWorkspaceReimburseRoute(policy.id)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_REIMBURSE.getRoute(policy.id)), error: hasCustomUnitsError, }, { translationKey: 'workspace.common.bills', icon: Expensicons.Bill, - action: () => Navigation.navigate(ROUTES.getWorkspaceBillsRoute(policy.id)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_BILLS.getRoute(policy.id)), }, { translationKey: 'workspace.common.invoices', icon: Expensicons.Invoice, - action: () => Navigation.navigate(ROUTES.getWorkspaceInvoicesRoute(policy.id)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_INVOICES.getRoute(policy.id)), }, { translationKey: 'workspace.common.travel', icon: Expensicons.Luggage, - action: () => Navigation.navigate(ROUTES.getWorkspaceTravelRoute(policy.id)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_TRAVEL.getRoute(policy.id)), }, { translationKey: 'workspace.common.members', icon: Expensicons.Users, - action: () => Navigation.navigate(ROUTES.getWorkspaceMembersRoute(policy.id)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_MEMBERS.getRoute(policy.id)), brickRoadIndicator: hasMembersError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '', }, { diff --git a/src/pages/workspace/WorkspaceInviteMessagePage.js b/src/pages/workspace/WorkspaceInviteMessagePage.js index fbab5dd93739..ce9cc730ddbe 100644 --- a/src/pages/workspace/WorkspaceInviteMessagePage.js +++ b/src/pages/workspace/WorkspaceInviteMessagePage.js @@ -82,7 +82,7 @@ class WorkspaceInviteMessagePage extends React.Component { componentDidMount() { if (_.isEmpty(this.props.invitedEmailsToAccountIDsDraft)) { - Navigation.goBack(ROUTES.getWorkspaceInviteRoute(this.props.route.params.policyID), true); + Navigation.goBack(ROUTES.WORKSPACE_INITIAL.getRoute(this.props.route.params.policyID), true); return; } this.focusWelcomeMessageInput(); @@ -123,7 +123,7 @@ class WorkspaceInviteMessagePage extends React.Component { Policy.setWorkspaceInviteMembersDraft(this.props.route.params.policyID, {}); // Pop the invite message page before navigating to the members page. Navigation.goBack(ROUTES.HOME); - Navigation.navigate(ROUTES.getWorkspaceMembersRoute(this.props.route.params.policyID)); + Navigation.navigate(ROUTES.WORKSPACE_MEMBERS.getRoute(this.props.route.params.policyID)); } /** diff --git a/src/pages/workspace/WorkspaceInvitePage.js b/src/pages/workspace/WorkspaceInvitePage.js index a61b26be8ab3..5e57968ab77a 100644 --- a/src/pages/workspace/WorkspaceInvitePage.js +++ b/src/pages/workspace/WorkspaceInvitePage.js @@ -177,7 +177,7 @@ function WorkspaceInvitePage(props) { invitedEmailsToAccountIDs[login] = Number(accountID); }); Policy.setWorkspaceInviteMembersDraft(props.route.params.policyID, invitedEmailsToAccountIDs); - Navigation.navigate(ROUTES.getWorkspaceInviteMessageRoute(props.route.params.policyID)); + Navigation.navigate(ROUTES.WORKSPACE_INVITE_MESSAGE.getRoute(props.route.params.policyID)); }; const [policyName, shouldShowAlertPrompt] = useMemo( @@ -217,7 +217,7 @@ function WorkspaceInvitePage(props) { guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_MEMBERS} onBackButtonPress={() => { Policy.clearErrors(props.route.params.policyID); - Navigation.goBack(ROUTES.getWorkspaceMembersRoute(props.route.params.policyID)); + Navigation.goBack(ROUTES.WORKSPACE_MEMBERS.getRoute(props.route.params.policyID)); }} /> { setSearchValue(''); - Navigation.navigate(ROUTES.getWorkspaceInviteRoute(props.route.params.policyID)); + Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(props.route.params.policyID)); }; /** @@ -356,7 +356,7 @@ function WorkspaceMembersPage(props) { subtitle={policyName} onBackButtonPress={() => { setSearchValue(''); - Navigation.goBack(ROUTES.getWorkspaceInitialRoute(policyID)); + Navigation.goBack(ROUTES.WORKSPACE_INITIAL.getRoute(policyID)); }} shouldShowGetAssistanceButton guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_MEMBERS} diff --git a/src/pages/workspace/WorkspacePageWithSections.js b/src/pages/workspace/WorkspacePageWithSections.js index ff2b27800fed..80c2db793ce7 100644 --- a/src/pages/workspace/WorkspacePageWithSections.js +++ b/src/pages/workspace/WorkspacePageWithSections.js @@ -114,7 +114,7 @@ function WorkspacePageWithSections({backButtonRoute, children, footer, guidesCal subtitle={policyName} shouldShowGetAssistanceButton guidesCallTaskID={guidesCallTaskID} - onBackButtonPress={() => Navigation.goBack(backButtonRoute || ROUTES.getWorkspaceInitialRoute(policyID))} + onBackButtonPress={() => Navigation.goBack(backButtonRoute || ROUTES.WORKSPACE_INITIAL.getRoute(policyID))} /> {shouldUseScrollView ? ( Navigation.navigate(ROUTES.getWorkspaceInitialRoute(policy.id)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(policy.id)), iconFill: themeColors.textLight, fallbackIcon: Expensicons.FallbackWorkspaceAvatar, brickRoadIndicator: reimbursementAccountBrickRoadIndicator || PolicyUtils.getPolicyBrickRoadIndicatorStatus(policy, allPolicyMembers), diff --git a/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js b/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js index eb96033ed3ef..66b104d89fb1 100644 --- a/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js +++ b/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js @@ -87,7 +87,7 @@ class WorkspaceRateAndUnitPage extends React.Component { submit(values) { this.saveUnitAndRate(values.unit, values.rate); Keyboard.dismiss(); - Navigation.goBack(ROUTES.getWorkspaceReimburseRoute(this.props.policy.id)); + Navigation.goBack(ROUTES.WORKSPACE_REIMBURSE.getRoute(this.props.policy.id)); } validate(values) { @@ -111,7 +111,7 @@ class WorkspaceRateAndUnitPage extends React.Component { route={this.props.route} guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_REIMBURSE} shouldSkipVBBACall - backButtonRoute={ROUTES.getWorkspaceReimburseRoute(this.props.policy.id)} + backButtonRoute={ROUTES.WORKSPACE_REIMBURSE.getRoute(this.props.policy.id)} > {() => ( Navigation.navigate(ROUTES.getWorkspaceRateAndUnitRoute(props.policy.id))} + onPress={() => Navigation.navigate(ROUTES.WORKSPACE_REIMBURSE.getRoute(props.policy.id))} wrapperStyle={[styles.mhn5, styles.wAuto]} brickRoadIndicator={(lodashGet(distanceCustomUnit, 'errors') || lodashGet(distanceCustomRate, 'errors')) && CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR} /> diff --git a/tests/actions/IOUTest.js b/tests/actions/IOUTest.js index 7372bb76b9e5..3df3b137bab3 100644 --- a/tests/actions/IOUTest.js +++ b/tests/actions/IOUTest.js @@ -2148,14 +2148,14 @@ describe('actions/IOU', () => { // Then we expect to navigate to the iou report - expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.getReportRoute(IOU_REPORT_ID)); + expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(IOU_REPORT_ID)); }); it('navigate the user correctly to the chat Report when appropriate', () => { // When we delete the money request and we should delete the IOU report IOU.deleteMoneyRequest(transaction.transactionID, createIOUAction, false); // Then we expect to navigate to the chat report - expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.getReportRoute(chatReport.reportID)); + expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(chatReport.reportID)); }); }); }); diff --git a/tests/e2e/ADDING_TESTS.md b/tests/e2e/ADDING_TESTS.md index 39cdb97ebed0..9704e4ea706d 100644 --- a/tests/e2e/ADDING_TESTS.md +++ b/tests/e2e/ADDING_TESTS.md @@ -37,7 +37,7 @@ that you might need to pass to the test running inside the app: ### Create the actual test -We created a new test file in `src/libs/E2E/tests/`. Typically, the +We created a new test file in `src/libs/E2E/tests/`. Typically, the tests ends on `.e2e.js`, so we can distinguish it from the other tests. Inside this test, we write logic that gets executed in the app. You can basically do @@ -61,9 +61,9 @@ import E2EClient from "./client.js"; const test = () => { const firstReportIDInList = // ... some logic to get a report - + performance.markStart("navigateToReport"); - Navigation.navigate(ROUTES.getReportRoute(firstReportIDInList)); + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(firstReportIDInList)); // markEnd will be called in the Screen's implementation performance.subscribeToMeasurements("navigateToReport", (measurement) => { @@ -73,7 +73,7 @@ const test = () => { duration: measurement.duration, }).then(E2EClient.submitTestDone) }); - + }; export default test; From 63b89f78c9591d02029ceb4470759b6473a68315 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Sat, 23 Sep 2023 09:51:37 +0800 Subject: [PATCH 2/6] Remove unnecessary utility method --- src/ROUTES.ts | 25 +++---------------------- src/libs/ReportUtils.js | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 09d237a6e2e9..b1156271dbc0 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -1,5 +1,4 @@ import {ValueOf} from 'type-fest'; -import * as Url from './libs/Url'; import CONST from './CONST'; /** @@ -35,6 +34,7 @@ export default { // when linking users from e.com in order to share a session in this app. ENABLE_PAYMENTS: 'enable-payments', WALLET_STATEMENT_WITH_DATE: 'statements/:yearMonth', + SIGN_IN_MODAL: 'sign-in-modal', BANK_ACCOUNT: 'bank-account', BANK_ACCOUNT_NEW: 'bank-account/new', @@ -154,25 +154,6 @@ export default { WORKSPACE_MEMBERS: { route: 'workspace/:policyID/members', getRoute: (policyID: string) => `workspace/${policyID}/members`}, // These are some on-off routes that will be removed once they're no longer needed (see GH issues for details) - SAASTR: 'saastr', - SBE: 'sbe', - - parseReportRouteParams: (route: string): ParseReportRouteParams => { - let parsingRoute = route; - if (parsingRoute.at(0) === '/') { - // remove the first slash - parsingRoute = parsingRoute.slice(1); - } - - if (!parsingRoute.startsWith(Url.addTrailingForwardSlash(REPORT))) { - return {reportID: '', isSubReportPageRoute: false}; - } - - const pathSegments = parsingRoute.split('/'); - return { - reportID: pathSegments[1], - isSubReportPageRoute: pathSegments.length > 2, - }; - }, - SIGN_IN_MODAL: 'sign-in-modal', + SAASTR: 'saastr', + SBE: 'sbe', } as const; diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index b32b9cbb666d..b477624142ba 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -15,6 +15,7 @@ import ROUTES from '../ROUTES'; import * as NumberUtils from './NumberUtils'; import * as ReportActionsUtils from './ReportActionsUtils'; import * as TransactionUtils from './TransactionUtils'; +import * as Url from './Url'; import Permissions from './Permissions'; import DateUtils from './DateUtils'; import linkingConfig from './Navigation/linkingConfig'; @@ -3146,13 +3147,35 @@ function getRouteFromLink(url) { return route; } +/** + * @param {String} route + * @returns {Object} + */ +function parseReportRouteParams(route) { + let parsingRoute = route; + if (parsingRoute.at(0) === '/') { + // remove the first slash + parsingRoute = parsingRoute.slice(1); + } + + if (!parsingRoute.startsWith(Url.addTrailingForwardSlash('r'))) { + return {reportID: '', isSubReportPageRoute: false}; + } + + const pathSegments = parsingRoute.split('/'); + return { + reportID: pathSegments[1], + isSubReportPageRoute: pathSegments.length > 2, + }; +} + /** * @param {String|null} url * @returns {String} */ function getReportIDFromLink(url) { const route = getRouteFromLink(url); - const {reportID, isSubReportPageRoute} = ROUTES.parseReportRouteParams(route); + const {reportID, isSubReportPageRoute} = parseReportRouteParams(route); if (isSubReportPageRoute) { // We allow the Sub-Report deep link routes (settings, details, etc.) to be handled by their respective component pages return ''; From 40358f6adf8ccb54b7ed079eae4265d48550a3f3 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Sat, 23 Sep 2023 09:52:41 +0800 Subject: [PATCH 3/6] Remove unused type --- src/ROUTES.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index b1156271dbc0..f602650706c8 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -5,11 +5,6 @@ import CONST from './CONST'; * This is a file containing constants for all of the routes we want to be able to go to */ -type ParseReportRouteParams = { - reportID: string; - isSubReportPageRoute: boolean; -}; - // prettier-ignore export default { HOME: '', @@ -39,7 +34,7 @@ export default { BANK_ACCOUNT: 'bank-account', BANK_ACCOUNT_NEW: 'bank-account/new', BANK_ACCOUNT_PERSONAL: 'bank-account/personal', - BANK_ACCOUNT_WITH_STEP_TO_OPEN: { route: 'bank-account/:stepToOpen?', getRoute: (stepToOpen = '', policyID = '', backTo = ''): string => { + BANK_ACCOUNT_WITH_STEP_TO_OPEN: { route: 'bank-account/:stepToOpen?', getRoute: (stepToOpen = '', policyID = '', backTo = ''): string => { const backToParam = backTo ? `&backTo=${encodeURIComponent(backTo)}` : ''; return `bank-account/${stepToOpen}?policyID=${policyID}${backToParam}`; }}, From 152524eed87ffbdaddec62cfbd8258868fd57768 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Sat, 23 Sep 2023 10:11:53 +0800 Subject: [PATCH 4/6] Fix a few mistakes --- src/libs/Navigation/linkingConfig.js | 8 ++++---- src/pages/iou/WaypointEditor.js | 8 ++++---- src/pages/workspace/reimburse/WorkspaceReimburseView.js | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index 1a3253bf424b..c1823f91a952 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -180,7 +180,7 @@ export default { path: ROUTES.WORKSPACE_REIMBURSE.route, }, Workspace_RateAndUnit: { - path: ROUTES.WORKSPACE_REIMBURSE.route, + path: ROUTES.WORKSPACE_RATE_AND_UNIT.route, }, Workspace_Bills: { path: ROUTES.WORKSPACE_BILLS.route, @@ -195,7 +195,7 @@ export default { path: ROUTES.WORKSPACE_MEMBERS.route, }, Workspace_Invite: { - path: ROUTES.WORKSPACE_INITIAL.route, + path: ROUTES.WORKSPACE_INVITE.route, }, Workspace_Invite_Message: { path: ROUTES.WORKSPACE_INVITE_MESSAGE.route, @@ -314,7 +314,7 @@ export default { exact: true, }, distance: { - path: ROUTES.WORKSPACE_MEMBERS.route, + path: ROUTES.MONEY_REQUEST_DISTANCE_TAB.route, exact: true, }, }, @@ -359,7 +359,7 @@ export default { }, Wallet_Statement: { screens: { - WalletStatement_Root: ROUTES.WALLET_STATEMENT_WITH_DATE.route, + WalletStatement_Root: ROUTES.WALLET_STATEMENT_WITH_DATE, }, }, Flag_Comment: { diff --git a/src/pages/iou/WaypointEditor.js b/src/pages/iou/WaypointEditor.js index 1e0622bc85ba..3397fa8701b6 100644 --- a/src/pages/iou/WaypointEditor.js +++ b/src/pages/iou/WaypointEditor.js @@ -147,13 +147,13 @@ function WaypointEditor({transactionID, route: {params: {iouType = '', waypointI } // Other flows will be handled by selecting a waypoint with selectWaypoint as this is mainly for the offline flow - Navigation.goBack(ROUTES.WORKSPACE_MEMBERS.getRoute(iouType)); + Navigation.goBack(ROUTES.MONEY_REQUEST_DISTANCE_TAB.getRoute(iouType)); }; const deleteStopAndHideModal = () => { Transaction.removeWaypoint(transactionID, waypointIndex); setIsDeleteStopModalOpen(false); - Navigation.goBack(ROUTES.WORKSPACE_MEMBERS.getRoute(iouType)); + Navigation.goBack(ROUTES.MONEY_REQUEST_DISTANCE_TAB.getRoute(iouType)); }; const selectWaypoint = (values) => { @@ -163,7 +163,7 @@ function WaypointEditor({transactionID, route: {params: {iouType = '', waypointI address: values.address, }; saveWaypoint(waypoint); - Navigation.goBack(ROUTES.WORKSPACE_MEMBERS.getRoute(iouType)); + Navigation.goBack(ROUTES.MONEY_REQUEST_DISTANCE_TAB.getRoute(iouType)); }; const focusAddressInput = () => { @@ -187,7 +187,7 @@ function WaypointEditor({transactionID, route: {params: {iouType = '', waypointI title={translate(wayPointDescriptionKey)} shouldShowBackButton onBackButtonPress={() => { - Navigation.goBack(ROUTES.WORKSPACE_MEMBERS.getRoute(iouType)); + Navigation.goBack(ROUTES.MONEY_REQUEST_DISTANCE_TAB.getRoute(iouType)); }} shouldShowThreeDotsButton={shouldShowThreeDotsButton} threeDotsAnchorPosition={styles.threeDotsPopoverOffset(windowWidth)} diff --git a/src/pages/workspace/reimburse/WorkspaceReimburseView.js b/src/pages/workspace/reimburse/WorkspaceReimburseView.js index d5a641cc43cb..5e7cf6d9baaa 100644 --- a/src/pages/workspace/reimburse/WorkspaceReimburseView.js +++ b/src/pages/workspace/reimburse/WorkspaceReimburseView.js @@ -168,7 +168,7 @@ function WorkspaceReimburseView(props) { title={currentRatePerUnit} description={translate('workspace.reimburse.trackDistanceRate')} shouldShowRightIcon - onPress={() => Navigation.navigate(ROUTES.WORKSPACE_REIMBURSE.getRoute(props.policy.id))} + onPress={() => Navigation.navigate(ROUTES.WORKSPACE_RATE_AND_UNIT.getRoute(props.policy.id))} wrapperStyle={[styles.mhn5, styles.wAuto]} brickRoadIndicator={(lodashGet(distanceCustomUnit, 'errors') || lodashGet(distanceCustomRate, 'errors')) && CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR} /> From 5d3fffcb27641ecf78c01cabb749714dbe08f879 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Sun, 24 Sep 2023 17:42:35 +0800 Subject: [PATCH 5/6] indent more routes --- src/ROUTES.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index f602650706c8..0def079ce2af 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -9,7 +9,7 @@ import CONST from './CONST'; export default { HOME: '', /** 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 */ - CONCIERGE: 'concierge', + CONCIERGE: 'concierge', FLAG_COMMENT: { route: 'flag/:reportID/:reportActionID', getRoute: (reportID: string, reportActionID: string) => `flag/${reportID}/${reportActionID}`}, SEARCH: 'search', DETAILS: { route: 'details', getRoute: (login: string) => `details?login=${encodeURIComponent(login)}`}, @@ -77,7 +77,7 @@ export default { NEW_CHAT: 'new/chat', NEW_ROOM: 'new/room', - REPORT: 'r', + REPORT: 'r', REPORT_WITH_ID: { route: 'r/:reportID?/:reportActionID?', getRoute: (reportID: string) => `r/${reportID}`}, EDIT_REQUEST: { route: 'r/:threadReportID/edit/:field', getRoute: (threadReportID: string, field: ValueOf) => `r/${threadReportID}/edit/${field}`}, EDIT_CURRENCY_REQUEST: { route: 'r/:threadReportID/edit/currency', getRoute: (threadReportID: string, currency: string, backTo: string) => `r/${threadReportID}/edit/currency?currency=${currency}&backTo=${backTo}`}, From d3b08423e01a477b81125a194e90ff6796717471 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Mon, 25 Sep 2023 08:57:09 +0800 Subject: [PATCH 6/6] Fix a couple of stragglers --- src/components/MoneyRequestConfirmationList.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 06e21f70c9d5..cdc5a787068d 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -463,7 +463,7 @@ function MoneyRequestConfirmationList(props) { shouldShowRightIcon={!props.isReadOnly && !props.isDistanceRequest} title={formattedAmount} description={translate('iou.amount')} - onPress={() => !props.isDistanceRequest && Navigation.navigate(ROUTES.getMoneyRequestAmountRoute(props.iouType, props.reportID))} + onPress={() => !props.isDistanceRequest && Navigation.navigate(ROUTES.MONEY_REQUEST_AMOUNT.getRoute(props.iouType, props.reportID))} style={[styles.moneyRequestMenuItem, styles.mt2]} titleStyle={styles.moneyRequestConfirmationAmount} disabled={didConfirm || props.isReadOnly} @@ -513,7 +513,7 @@ function MoneyRequestConfirmationList(props) { description={translate('common.distance')} style={[styles.moneyRequestMenuItem, styles.mb2]} titleStyle={styles.flex1} - onPress={() => Navigation.navigate(ROUTES.getMoneyRequestAddressRoute(props.iouType, props.reportID))} + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_ADDRESS.getRoute(props.iouType, props.reportID))} disabled={didConfirm || props.isReadOnly || !isTypeRequest} /> ) : (