Skip to main content

Route definition

Proposed change

This is a way of accessing language-based routes across applications without having to construct the route every time.

How it looks now

let accountCardPath;

if (getLang() === 'en-GB') {
accountCardPath = '/accounts/71322459536/cards/TMMERAPSI7489TVO';
} else {
accountCardPath = '/kontoer/71322459536/kort/TMMERAPSI7489TVO';
}

navigateTo(accountCardPath);

Alternative

Using types routes, we can access the route path based on the user's language.

import { accountRoutes } from '@pm-netbank/routes';

const accountCardPath = accountRoutes.accountCard('71322459536', 'TMMERAPSI7489TVO');
navigateTo(accountCardPath);

Motivation

The codebase is growing, and the number of apps is increasing. We're finding ourselves needing to navigate between apps, and soon we'll have to support using different routes depending on the user's language.

We're currently hardcoding all routes, so if one route changes, it will have to be edited everywhere it's being used - this could lead to user error. Doing it like this would decrease potential issues and provide a neat way of seeing all available routes in an application.

Used alongside the dynamic routing library, this can standardise the way we're using routes in our apps.

Other info about the proposal

Within the library, we'll check the current language settings and return routes corresponding to that language.