Skip to content

Commit e0584fa

Browse files
[Account-v2] Shaheer / FEQ-1138 / Adds routing to account-v2 package (#13065)
* docs: text fix * feat: adds routing for account v2 * fix: updates react router dom version
1 parent 7a7322e commit e0584fa

File tree

6 files changed

+139
-1
lines changed

6 files changed

+139
-1
lines changed

packages/account-v2/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"@types/css-modules": "^1.0.2",
3636
"@types/react-dom": "^18.0.0",
3737
"@types/react-modal": "^3.16.3",
38+
"@types/react-router-dom": "^5.1.6",
3839
"@types/webpack": "^5.28.5",
3940
"@typescript-eslint/eslint-plugin": "5.45.0",
4041
"@typescript-eslint/parser": "5.45.0",

packages/account-v2/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { FormProgress } from './components/form-progress';
55
import SignupWizard from './components/SignupWizard';
66
import { SignupWizardProvider, useSignupWizardContext } from './context/SignupWizardContext';
77
import { stepProgress } from './mocks/form-progress.mock';
8+
import RouteLinks from './router/components/route-links/route-links';
89
import './index.scss';
910

1011
const TriggerSignupWizardModal: React.FC = () => {
@@ -24,6 +25,7 @@ const App: React.FC = () => {
2425
{/* [TODO]:Mock - Remove hardcoded initial value once isActive comes from Modal */}
2526
<FormProgress activeStep={1} steps={stepProgress} />
2627
</SignupWizardProvider>
28+
<RouteLinks />
2729
</BreakpointProvider>
2830
</APIProvider>
2931
);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
3+
const DummyRoute = ({ path }: { path: string }) => (
4+
<div className='text-body-lg'>
5+
Component for path <span className='font-bold'>{path}</span>
6+
</div>
7+
);
8+
9+
export default DummyRoute;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from 'react';
2+
import { BrowserRouter, NavLink, Redirect, Route, Switch } from 'react-router-dom';
3+
import { defaultRoute, routes } from '../../constants/routesConfig';
4+
5+
const RouteLinks = () => (
6+
<BrowserRouter>
7+
<div className='p-800 border-solid border-200 border-solid-slate-75 grid grid-cols-[1fr_4fr]'>
8+
<div className='p-400 flex flex-col bg-solid-slate-75 rounded-200'>
9+
{routes.map(route => (
10+
<NavLink
11+
activeClassName='bg-solid-slate-100 border-solid border-l-200 border-l-solid-red-500 rounded-200 font-bold'
12+
className='text-body-md p-400'
13+
key={route.routePath}
14+
to={route.routePath}
15+
>
16+
{route.routeName}
17+
</NavLink>
18+
))}
19+
</div>
20+
<div className='p-400'>
21+
<Switch>
22+
{routes.map(route => {
23+
const Component = route.routeComponent;
24+
return (
25+
<Route
26+
exact
27+
key={route.routePath}
28+
path={route.routePath}
29+
render={() => <Component path={route.routePath} />}
30+
/>
31+
);
32+
})}
33+
<Redirect from='/' to={defaultRoute} />
34+
</Switch>
35+
</div>
36+
</div>
37+
</BrowserRouter>
38+
);
39+
40+
export default RouteLinks;
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import DummyRoute from '../components/dummy-route/dummy-route';
2+
3+
export const routes = [
4+
{
5+
routeComponent: DummyRoute,
6+
routeName: 'Personal details',
7+
routePath: '/account-v2/personal_details',
8+
},
9+
{
10+
routeComponent: DummyRoute,
11+
routeName: 'Languages',
12+
routePath: '/account-v2/languages',
13+
},
14+
{
15+
routeComponent: DummyRoute,
16+
routeName: 'Trading assessment',
17+
routePath: '/account-v2/trading_assessment',
18+
},
19+
{
20+
routeComponent: DummyRoute,
21+
routeName: 'Financial assessment',
22+
routePath: '/account-v2/financial_assessment',
23+
},
24+
{
25+
routeComponent: DummyRoute,
26+
routeName: 'Proof of identity',
27+
routePath: '/account-v2/proof_of_identity',
28+
},
29+
{
30+
routeComponent: DummyRoute,
31+
routeName: 'Proof of address',
32+
routePath: '/account-v2/proof_of_address',
33+
},
34+
{
35+
routeComponent: DummyRoute,
36+
routeName: 'Proof of ownership',
37+
routePath: '/account-v2/proof_of_ownership',
38+
},
39+
{
40+
routeComponent: DummyRoute,
41+
routeName: 'Proof of income',
42+
routePath: '/account-v2/proof_of_income',
43+
},
44+
{
45+
routeComponent: DummyRoute,
46+
routeName: 'Email and passwords',
47+
routePath: '/account-v2/email_and_passwords',
48+
},
49+
{
50+
routeComponent: DummyRoute,
51+
routeName: 'Self exclusion',
52+
routePath: '/account-v2/self_exclusion',
53+
},
54+
{
55+
routeComponent: DummyRoute,
56+
routeName: 'Account limits',
57+
routePath: '/account-v2/account_limits',
58+
},
59+
{
60+
routeComponent: DummyRoute,
61+
routeName: 'Login history',
62+
routePath: '/account-v2/login_history',
63+
},
64+
{
65+
routeComponent: DummyRoute,
66+
routeName: 'API token',
67+
routePath: '/account-v2/api_token',
68+
},
69+
{
70+
routeComponent: DummyRoute,
71+
routeName: 'Connected apps',
72+
routePath: '/account-v2/connected_apps',
73+
},
74+
{
75+
routeComponent: DummyRoute,
76+
routeName: 'Two-factor authentication',
77+
routePath: '/account-v2/two_factor_authentication',
78+
},
79+
{
80+
routeComponent: DummyRoute,
81+
routeName: 'Close your account',
82+
routePath: '/account-v2/close_your_account',
83+
},
84+
];
85+
86+
export const defaultRoute = routes[0].routePath;

packages/core/src/App/Constants/routes-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const P2P_V2 = React.lazy(() =>
8888
const Account_V2 = React.lazy(() =>
8989
moduleLoader(() => {
9090
// eslint-disable-next-line import/no-unresolved
91-
return import(/* webpackChunkName: "p2p-v2" */ '@deriv/account-v2');
91+
return import(/* webpackChunkName: "account-v2" */ '@deriv/account-v2');
9292
})
9393
);
9494

0 commit comments

Comments
 (0)