Skip to content

Commit 5b4e825

Browse files
authored
Merge pull request Expensify#81505 from software-mansion-labs/collectioneur/dynamic-routes-batch-6
2 parents a1e15a1 + a068424 commit 5b4e825

21 files changed

Lines changed: 709 additions & 42 deletions

src/ROUTES.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ type DynamicRoutes = Record<string, DynamicRouteConfig>;
8181
const DYNAMIC_ROUTES = {
8282
VERIFY_ACCOUNT: {
8383
path: 'verify-account',
84-
entryScreens: [],
84+
entryScreens: [SCREENS.SETTINGS.WALLET.ROOT],
8585
},
8686
} as const satisfies DynamicRoutes;
8787

@@ -359,7 +359,6 @@ const ROUTES = {
359359
SETTINGS_ABOUT: 'settings/about',
360360
SETTINGS_APP_DOWNLOAD_LINKS: 'settings/about/app-download-links',
361361
SETTINGS_WALLET: 'settings/wallet',
362-
SETTINGS_WALLET_VERIFY_ACCOUNT: `settings/wallet/${VERIFY_ACCOUNT}`,
363362
SETTINGS_WALLET_DOMAIN_CARD: {
364363
route: 'settings/wallet/card/:cardID?',
365364
getRoute: (cardID: string) => `settings/wallet/card/${cardID}` as const,

src/SCREENS.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ const SCREENS = {
178178

179179
WALLET: {
180180
ROOT: 'Settings_Wallet',
181-
VERIFY_ACCOUNT: 'Settings_Wallet_VerifyAccount',
182181
DOMAIN_CARD: 'Settings_Wallet_DomainCard',
183182
DOMAIN_CARD_CONFIRM_MAGIC_CODE: 'Settings_Wallet_DomainCard_ConfirmMagicCode',
184183
CARD_MISSING_DETAILS: 'Settings_Wallet_Card_MissingDetails',

src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
406406
[SCREENS.SETTINGS.CLOSE]: () => require<ReactComponentModule>('../../../../pages/settings/Security/CloseAccountPage').default,
407407
[SCREENS.SETTINGS.APP_DOWNLOAD_LINKS]: () => require<ReactComponentModule>('../../../../pages/settings/AppDownloadLinks').default,
408408
[SCREENS.SETTINGS.WALLET.CARDS_DIGITAL_DETAILS_UPDATE_ADDRESS]: () => require<ReactComponentModule>('../../../../pages/settings/Profile/PersonalDetails/PersonalAddressPage').default,
409-
[SCREENS.SETTINGS.WALLET.VERIFY_ACCOUNT]: () => require<ReactComponentModule>('../../../../pages/settings/Wallet/VerifyAccountPage').default,
410409
[SCREENS.SETTINGS.WALLET.DOMAIN_CARD]: () => require<ReactComponentModule>('../../../../pages/settings/Wallet/ExpensifyCardPage/index').default,
411410
[SCREENS.SETTINGS.WALLET.DOMAIN_CARD_CONFIRM_MAGIC_CODE]: () =>
412411
require<ReactComponentModule>('../../../../pages/settings/Wallet/ExpensifyCardPage/ExpensifyCardVerifyAccountPage').default,

src/libs/Navigation/helpers/getLastSuffixFromPath.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Log from '@libs/Log';
2+
import splitPathAndQuery from './splitPathAndQuery';
23

34
/**
45
* Extracts the last segment from a URL path, removing query parameters and trailing slashes.
@@ -7,16 +8,14 @@ import Log from '@libs/Log';
78
* @returns The last segment of the path as a string
89
*/
910
function getLastSuffixFromPath(path: string | undefined): string {
10-
const pathWithoutParams = path?.split('?').at(0);
11+
const [normalizedPath] = splitPathAndQuery(path ?? '');
1112

12-
if (!pathWithoutParams) {
13+
if (!normalizedPath) {
1314
Log.warn('[getLastSuffixFromPath.ts] Failed to parse the path, path is empty');
1415
return '';
1516
}
1617

17-
const pathWithoutTrailingSlash = pathWithoutParams.endsWith('/') ? pathWithoutParams.slice(0, -1) : pathWithoutParams;
18-
19-
const lastSuffix = pathWithoutTrailingSlash.split('/').pop() ?? '';
18+
const lastSuffix = normalizedPath.split('/').pop() ?? '';
2019

2120
return lastSuffix;
2221
}

src/libs/Navigation/helpers/getPathFromState.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import type {NavigationState, PartialState} from '@react-navigation/routers';
33
import {linkingConfig} from '@libs/Navigation/linkingConfig';
44
import {normalizedConfigs} from '@libs/Navigation/linkingConfig/config';
55
import {DYNAMIC_ROUTES} from '@src/ROUTES';
6+
import type {DynamicRouteSuffix} from '@src/ROUTES';
67
import type {Screen} from '@src/SCREENS';
78

89
type State = NavigationState | Omit<PartialState<NavigationState>, 'stale'>;
910

1011
const dynamicRouteEntries = Object.values(DYNAMIC_ROUTES);
12+
const dynamicRoutePaths = new Set(dynamicRouteEntries.map(({path}) => path));
1113

1214
/**
1315
* Checks if a screen name is a dynamic route screen
@@ -19,12 +21,7 @@ function isDynamicRouteScreen(screenName: Screen): boolean {
1921
return false;
2022
}
2123

22-
for (const {path} of dynamicRouteEntries) {
23-
if (screenPath === path) {
24-
return true;
25-
}
26-
}
27-
return false;
24+
return dynamicRoutePaths.has(screenPath as DynamicRouteSuffix);
2825
}
2926

3027
const getPathFromState = (state: State): string => {

src/libs/Navigation/helpers/splitPathAndQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* and the second element is the query string (if any).
66
*/
77
function splitPathAndQuery(fullPath: string | undefined): [string | undefined, string | undefined] {
8-
const [path, query] = fullPath?.split('?') ?? [undefined, undefined];
8+
const [path, query] = fullPath?.split('?', 2) ?? [undefined, undefined];
99
const normalizedPath = path?.endsWith('/') && path.length > 1 ? path.slice(0, -1) : path;
1010
return [normalizedPath, query];
1111
}

src/libs/Navigation/linkingConfig/RELATIONS/SETTINGS_TO_RHP.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ const SETTINGS_TO_RHP: Partial<Record<keyof SettingsSplitNavigatorParamList, str
3737
SCREENS.SETTINGS.WALLET.PERSONAL_CARD_DETAILS,
3838
SCREENS.SETTINGS.WALLET.PERSONAL_CARD_EDIT_NAME,
3939
SCREENS.SETTINGS.WALLET.PERSONAL_CARD_EDIT_TRANSACTION_START_DATE,
40-
SCREENS.SETTINGS.WALLET.VERIFY_ACCOUNT,
4140
SCREENS.SETTINGS.WALLET.TRANSFER_BALANCE,
4241
SCREENS.SETTINGS.WALLET.CHOOSE_TRANSFER_ACCOUNT,
4342
SCREENS.SETTINGS.WALLET.IMPORT_TRANSACTIONS,

src/libs/Navigation/linkingConfig/config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,6 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
241241
path: ROUTES.SETTINGS_WALLET_CARD_MISSING_DETAILS_CONFIRM_MAGIC_CODE.route,
242242
exact: true,
243243
},
244-
[SCREENS.SETTINGS.WALLET.VERIFY_ACCOUNT]: {
245-
path: ROUTES.SETTINGS_WALLET_VERIFY_ACCOUNT,
246-
exact: true,
247-
},
248244
[SCREENS.SETTINGS.WALLET.REPORT_VIRTUAL_CARD_FRAUD]: {
249245
path: ROUTES.SETTINGS_REPORT_FRAUD.route,
250246
exact: true,

src/libs/Navigation/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ type SettingsNavigatorParamList = {
197197
[SCREENS.WORKSPACE.WORKFLOWS_PAYER]: {
198198
policyID: string;
199199
};
200-
[SCREENS.SETTINGS.WALLET.VERIFY_ACCOUNT]: undefined;
201200
[SCREENS.SETTINGS.WALLET.TRANSFER_BALANCE]: undefined;
202201
[SCREENS.SETTINGS.WALLET.CHOOSE_TRANSFER_ACCOUNT]: undefined;
203202
[SCREENS.SETTINGS.WALLET.IMPORT_TRANSACTIONS]: undefined;

src/libs/actions/Welcome/OnboardingFlow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import CONST from '@src/CONST';
1313
import IntlStore from '@src/languages/IntlStore';
1414
import NAVIGATORS from '@src/NAVIGATORS';
1515
import ONYXKEYS from '@src/ONYXKEYS';
16-
import ROUTES from '@src/ROUTES';
1716
import type {Route} from '@src/ROUTES';
17+
import ROUTES from '@src/ROUTES';
1818
import {hasCompletedGuidedSetupFlowSelector} from '@src/selectors/Onboarding';
1919
import type {Locale, Onboarding} from '@src/types/onyx';
2020

0 commit comments

Comments
 (0)