diff --git a/src/components/savedAccounts/savedAccounts.test.js b/src/components/savedAccounts/savedAccounts.test.js
index 4617b0ca50..f265ff9b98 100644
--- a/src/components/savedAccounts/savedAccounts.test.js
+++ b/src/components/savedAccounts/savedAccounts.test.js
@@ -8,6 +8,7 @@ import PropTypes from 'prop-types';
import i18n from '../../i18n';
import networks from '../../constants/networks';
import SavedAccounts from './savedAccounts';
+import routes from '../../constants/routes';
const mountWithRouter = (node, options) => mount(
{node}, options);
const fakeStore = configureStore();
@@ -89,7 +90,7 @@ describe('SavedAccounts', () => {
it('should call props.accountSwitched on the "saved account card" click', () => {
wrapper.find('.saved-account-card').at(1).simulate('click');
expect(props.accountSwitched).to.have.been.calledWith(savedAccounts[1]);
- expect(props.history.push).to.have.been.calledWith('/main/dashboard/');
+ expect(props.history.push).to.have.been.calledWith(`${routes.main.path}${routes.dashboard.path}`);
});
it('should not call props.accountSwitched on the "saved account card" click if in "edit" mode', () => {
diff --git a/src/components/search/keyAction.js b/src/components/search/keyAction.js
index a3f0ea77ae..779a2c3f3f 100644
--- a/src/components/search/keyAction.js
+++ b/src/components/search/keyAction.js
@@ -13,17 +13,17 @@ const saveSearch = (search) => {
export const visit = (value, history) => {
if (value.match(regex.address)) {
- history.push(`${routes.account.long}/${value}`);
+ history.push(`${routes.explorer.path}${routes.account.path}/${value}`);
} else if (value.match(regex.transactionId)) {
- history.push(`${routes.transaction.long}/${value}`);
+ history.push(`${routes.explorer.path}${routes.transaction.path}/${value}`);
} else {
- history.push(`${routes.searchResult.long}/${value}`);
+ history.push(`${routes.explorer.path}${routes.searchResult.path}/${value}`);
}
};
export const visitAndSaveSearch = (value, history) => {
if (value.length === 0) {
- history.push(routes.search.long);
+ history.push(`${routes.explorer.path}${routes.search.path}`);
} else {
value = value.trim();
saveSearch(value);
diff --git a/src/components/search/keyAction.test.js b/src/components/search/keyAction.test.js
index 116307c95d..93c318043a 100644
--- a/src/components/search/keyAction.test.js
+++ b/src/components/search/keyAction.test.js
@@ -43,9 +43,9 @@ describe('Search KeyAction', () => {
];
const expectedHistory = [
- `${routes.account.long}/${testValues[0]}`,
- `${routes.transaction.long}/${testValues[1]}`,
- `${routes.searchResult.long}/${testValues[2]}`,
+ `${routes.explorer.path}${routes.account.path}/${testValues[0]}`,
+ `${routes.explorer.path}${routes.transaction.path}/${testValues[1]}`,
+ `${routes.explorer.path}${routes.searchResult.path}/${testValues[2]}`,
];
testValues.forEach((value) => {
diff --git a/src/components/searchBar/index.js b/src/components/searchBar/index.js
index 23a1e98ae0..db10dc817c 100644
--- a/src/components/searchBar/index.js
+++ b/src/components/searchBar/index.js
@@ -28,7 +28,7 @@ class Search extends React.Component {
shouldShowSearchBarOnMobile() {
const { pathname } = this.props.location;
- return pathname.includes('explorer') && !pathname.includes(routes.search.long);
+ return pathname.includes('explorer') && !pathname.includes(`${routes.explorer.path}${routes.search.path}`);
}
diff --git a/src/components/sendTo/index.js b/src/components/sendTo/index.js
index 2370dec4ea..fe2947b790 100644
--- a/src/components/sendTo/index.js
+++ b/src/components/sendTo/index.js
@@ -58,7 +58,7 @@ class SendTo extends React.Component {
${grid['middle-sm']}
${styles.sendButton}
`}>
-
+
{this.props.t('Send to this address')}
diff --git a/src/components/sendTo/sendTo.test.js b/src/components/sendTo/sendTo.test.js
index b420a11407..88509f7886 100644
--- a/src/components/sendTo/sendTo.test.js
+++ b/src/components/sendTo/sendTo.test.js
@@ -18,11 +18,11 @@ describe('SendTo Component', () => {
});
it('renders correct link', () => {
- expect(wrapper.find('Link').prop('to')).to.equal(`${routes.wallet.long}?address=${props.address}`);
+ expect(wrapper.find('Link').prop('to')).to.equal(`${routes.main.path}${routes.wallet.path}?address=${props.address}`);
});
it('updates when address changes', () => {
wrapper.setProps({ address: '9876L' });
- expect(wrapper.find('Link').prop('to')).to.equal(`${routes.wallet.long}?address=9876L`);
+ expect(wrapper.find('Link').prop('to')).to.equal(`${routes.main.path}${routes.wallet.path}?address=9876L`);
});
});
diff --git a/src/components/transactions/transactionDetailView.js b/src/components/transactions/transactionDetailView.js
index d290a0fe0b..0eda4cdfa0 100644
--- a/src/components/transactions/transactionDetailView.js
+++ b/src/components/transactions/transactionDetailView.js
@@ -36,7 +36,7 @@ const TransactionsDetailView = props => (
}
+ to={`${routes.explorer.path}${routes.account.path}/${props.value.senderId}`}>
{props.value.senderId}
@@ -53,7 +53,7 @@ const TransactionsDetailView = props => (
{
props.value.recipientId ?
+ to={`${routes.explorer.path}${routes.account.path}/${props.value.recipientId}`}>
{props.value.recipientId}
: '-'
}
diff --git a/src/constants/routes.js b/src/constants/routes.js
index aeeb4f9dc0..78a3106a86 100644
--- a/src/constants/routes.js
+++ b/src/constants/routes.js
@@ -1,10 +1,16 @@
export default {
- wallet: { long: '/main/transactions', short: '/transactions' },
- account: { long: '/explorer/accounts', short: '/accounts' },
- search: { long: '/explorer/search', short: '/search' },
- searchResult: { long: '/explorer/result', short: '/result' },
- transaction: { long: '/explorer/transactions', short: '/transactions' },
- login: { url: '/' },
- addAccount: { url: '/add-account' },
- register: { url: '/register' },
+ wallet: { path: '/transactions' },
+ account: { path: '/accounts' },
+ accountVisualDemo: { path: '/account-visual-demo' },
+ dashboard: { path: '/dashboard' },
+ search: { path: '/search' },
+ searchResult: { path: '/result' },
+ transaction: { path: '/transactions' },
+ login: { path: '/' },
+ addAccount: { path: '/add-account' },
+ register: { path: '/register' },
+ sidechains: { path: '/sidechains' },
+ voting: { path: '/voting' },
+ main: { path: '/main' },
+ explorer: { path: '/explorer' },
};
diff --git a/src/utils/externalLinks.test.js b/src/utils/externalLinks.test.js
index 3a75aa4681..106d864148 100644
--- a/src/utils/externalLinks.test.js
+++ b/src/utils/externalLinks.test.js
@@ -2,6 +2,7 @@ import { expect } from 'chai';
import { spy } from 'sinon';
import externalLinks from './externalLinks';
import history from '../history';
+import routes from '../constants/routes';
describe('externalLinks', () => {
const historyPush = spy(history, 'push');
@@ -28,6 +29,6 @@ describe('externalLinks', () => {
};
externalLinks.init();
callbacks.openUrl({}, 'lisk://register');
- expect(historyPush).to.have.been.calledWith('/register');
+ expect(historyPush).to.have.been.calledWith(routes.register.path);
});
});
diff --git a/src/utils/routes.js b/src/utils/routes.js
index 04eca951be..caaba26708 100644
--- a/src/utils/routes.js
+++ b/src/utils/routes.js
@@ -3,56 +3,56 @@ import routes from './../constants/routes';
export default [
{
regex: /\/main\/account-visual-demo(?:\/[^/]*)?$/,
- path: '/main/account-visual-demo/',
+ path: `${routes.main.path}${routes.accountVisualDemo.path}/`,
params: 'dialog',
name: 'account-visual-demo',
}, {
regex: /\/main\/dashboard(?:\/[^/]*)?$/,
- path: '/main/dashboard/',
+ path: `${routes.main.path}${routes.dashboard.path}/`,
params: 'dialog',
name: 'dashboard',
}, {
regex: /\/main\/transactions(?:\/[^/]*)?$/,
- path: `${routes.wallet.long}/`,
+ path: `${routes.main.path}${routes.wallet.path}/`,
params: 'dialog',
name: 'transactions',
}, {
regex: /\/main\/voting(?:\/[^/]*)?$/,
- path: '/main/voting/',
+ path: `${routes.main.path}${routes.voting.path}/`,
params: 'dialog',
name: 'voting',
}, {
regex: /\/main\/sidechains(?:\/[^/]*)?$/,
- path: '/main/sidechains/',
+ path: `${routes.main.path}${routes.sidechains.path}/`,
params: 'dialog',
name: 'sidechains',
}, {
regex: /\/add-account(?:\/[^/]*)?$/,
- path: '/add-account/',
+ path: `${routes.addAccount.path}/`,
params: 'dialog',
name: 'add-account',
}, {
regex: /\/explorer\/accounts\/\d{1,21}[L|l](?:\/[^/]*)?$/,
- path: new RegExp(`${routes.account.long}/\\d{1,21}[L|l]/`),
+ path: new RegExp(`${routes.explorer.path}${routes.account.path}/\\d{1,21}[L|l]/`),
params: 'address',
name: 'accounts',
}, {
regex: /\/explorer\/result\/([0-9]+|[a-z]+)(?:\/[^/]*)?$/,
- path: new RegExp(`${routes.searchResult.long}/([0-9]+|[a-z]+)/`),
+ path: new RegExp(`${routes.explorer.path}${routes.searchResult.path}/([0-9]+|[a-z]+)/`),
params: 'query',
name: 'result',
}, {
regex: /\/explorer\/search(?:\/[^/]*)?$/,
- path: `${routes.search.long}/`,
+ path: `${routes.explorer.path}${routes.search.path}/`,
name: 'explorer',
}, {
regex: /\/explorer\/transactions\/\d+(?:\/[^/]*)?$/,
- path: new RegExp(`${routes.transaction.long}/\\d+/`),
+ path: new RegExp(`${routes.explorer.path}${routes.transaction.path}/\\d+/`),
params: 'id',
name: 'explorer-transaction',
}, {
regex: /register(?:\/[^/]*)?$/,
- path: '/register/',
+ path: `${routes.register.path}/`,
params: 'dialog',
name: 'register',
}, {