Description
Current State:
- Navigation to verify-account routes uses direct route constants with
backTo parameters
- Example:
Navigation.navigate(ROUTES.SETTINGS_WALLET_VERIFY_ACCOUNT.getRoute(backTo))
- The
backTo parameter is embedded in the URL, creating complex nested URLs
Expected State:
- Add
createDynamicRoute() function to Navigation.ts
- Function should:
- Validate that the provided suffix exists in
DYNAMIC_ROUTES
- Get the current active route via
getActiveRoute()
- Separate the path from query parameters
- Append the dynamic suffix to the path
- Reattach query parameters
- Return the combined route
Implementation:
function createDynamicRoute(suffix: DynamicRouteSuffix): Route {
if (!isValidSuffix(suffix)) {
throw new Error(`Invalid dynamic route suffix: ${suffix}`);
}
const activePath = getActiveRoute();
return combinePathAndSuffix(activePath, suffix);
}
// Helper: Combines path and suffix while preserving query params
function combinePathAndSuffix(path: string, suffix: string): Route {
const [basePath, queryString] = path.split('?');
const newPath = `${basePath}/${suffix}`;
return queryString ? `${newPath}?${queryString}` : newPath;
}
Usage Example:
// Old way
Navigation.navigate(ROUTES.SETTINGS_WALLET_VERIFY_ACCOUNT.getRoute(backTo));
// New way
Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.VERIFY_ACCOUNT.path));
Scope
Files:
App/src/libs/Navigation/Navigation.ts - Add createDynamicRoute() and combinePathAndSuffix() functions
Dependencies:
Issue Owner
Current Issue Owner: @mallenexpensify
Description
Current State:
backToparametersNavigation.navigate(ROUTES.SETTINGS_WALLET_VERIFY_ACCOUNT.getRoute(backTo))backToparameter is embedded in the URL, creating complex nested URLsExpected State:
createDynamicRoute()function toNavigation.tsDYNAMIC_ROUTESgetActiveRoute()Implementation:
Usage Example:
Scope
Files:
App/src/libs/Navigation/Navigation.ts- AddcreateDynamicRoute()andcombinePathAndSuffix()functionsDependencies:
Issue Owner
Current Issue Owner: @mallenexpensify