Skip to content

[Due for Payment meow][BT-002] Implement createDynamicRoute() Helper #80907

@mjasikowski

Description

@mjasikowski

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:
    1. Validate that the provided suffix exists in DYNAMIC_ROUTES
    2. Get the current active route via getActiveRoute()
    3. Separate the path from query parameters
    4. Append the dynamic suffix to the path
    5. Reattach query parameters
    6. 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 OwnerCurrent Issue Owner: @mallenexpensify

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2InternalRequires API changes or must be handled by Expensify staff

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions