Skip to content

Commit

Permalink
[Account-v2] Shaheer / FEQ-1138 / Adds routing to account-v2 package (#…
Browse files Browse the repository at this point in the history
…13065)

* docs: text fix

* feat: adds routing for account v2

* fix: updates react router dom version
  • Loading branch information
shaheer-deriv authored Jan 22, 2024
1 parent 7a7322e commit e0584fa
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/account-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@types/css-modules": "^1.0.2",
"@types/react-dom": "^18.0.0",
"@types/react-modal": "^3.16.3",
"@types/react-router-dom": "^5.1.6",
"@types/webpack": "^5.28.5",
"@typescript-eslint/eslint-plugin": "5.45.0",
"@typescript-eslint/parser": "5.45.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/account-v2/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { FormProgress } from './components/form-progress';
import SignupWizard from './components/SignupWizard';
import { SignupWizardProvider, useSignupWizardContext } from './context/SignupWizardContext';
import { stepProgress } from './mocks/form-progress.mock';
import RouteLinks from './router/components/route-links/route-links';
import './index.scss';

const TriggerSignupWizardModal: React.FC = () => {
Expand All @@ -24,6 +25,7 @@ const App: React.FC = () => {
{/* [TODO]:Mock - Remove hardcoded initial value once isActive comes from Modal */}
<FormProgress activeStep={1} steps={stepProgress} />
</SignupWizardProvider>
<RouteLinks />
</BreakpointProvider>
</APIProvider>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

const DummyRoute = ({ path }: { path: string }) => (
<div className='text-body-lg'>
Component for path <span className='font-bold'>{path}</span>
</div>
);

export default DummyRoute;
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react';
import { BrowserRouter, NavLink, Redirect, Route, Switch } from 'react-router-dom';
import { defaultRoute, routes } from '../../constants/routesConfig';

const RouteLinks = () => (
<BrowserRouter>
<div className='p-800 border-solid border-200 border-solid-slate-75 grid grid-cols-[1fr_4fr]'>
<div className='p-400 flex flex-col bg-solid-slate-75 rounded-200'>
{routes.map(route => (
<NavLink
activeClassName='bg-solid-slate-100 border-solid border-l-200 border-l-solid-red-500 rounded-200 font-bold'
className='text-body-md p-400'
key={route.routePath}
to={route.routePath}
>
{route.routeName}
</NavLink>
))}
</div>
<div className='p-400'>
<Switch>
{routes.map(route => {
const Component = route.routeComponent;
return (
<Route
exact
key={route.routePath}
path={route.routePath}
render={() => <Component path={route.routePath} />}
/>
);
})}
<Redirect from='/' to={defaultRoute} />
</Switch>
</div>
</div>
</BrowserRouter>
);

export default RouteLinks;
86 changes: 86 additions & 0 deletions packages/account-v2/src/router/constants/routesConfig.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import DummyRoute from '../components/dummy-route/dummy-route';

export const routes = [
{
routeComponent: DummyRoute,
routeName: 'Personal details',
routePath: '/account-v2/personal_details',
},
{
routeComponent: DummyRoute,
routeName: 'Languages',
routePath: '/account-v2/languages',
},
{
routeComponent: DummyRoute,
routeName: 'Trading assessment',
routePath: '/account-v2/trading_assessment',
},
{
routeComponent: DummyRoute,
routeName: 'Financial assessment',
routePath: '/account-v2/financial_assessment',
},
{
routeComponent: DummyRoute,
routeName: 'Proof of identity',
routePath: '/account-v2/proof_of_identity',
},
{
routeComponent: DummyRoute,
routeName: 'Proof of address',
routePath: '/account-v2/proof_of_address',
},
{
routeComponent: DummyRoute,
routeName: 'Proof of ownership',
routePath: '/account-v2/proof_of_ownership',
},
{
routeComponent: DummyRoute,
routeName: 'Proof of income',
routePath: '/account-v2/proof_of_income',
},
{
routeComponent: DummyRoute,
routeName: 'Email and passwords',
routePath: '/account-v2/email_and_passwords',
},
{
routeComponent: DummyRoute,
routeName: 'Self exclusion',
routePath: '/account-v2/self_exclusion',
},
{
routeComponent: DummyRoute,
routeName: 'Account limits',
routePath: '/account-v2/account_limits',
},
{
routeComponent: DummyRoute,
routeName: 'Login history',
routePath: '/account-v2/login_history',
},
{
routeComponent: DummyRoute,
routeName: 'API token',
routePath: '/account-v2/api_token',
},
{
routeComponent: DummyRoute,
routeName: 'Connected apps',
routePath: '/account-v2/connected_apps',
},
{
routeComponent: DummyRoute,
routeName: 'Two-factor authentication',
routePath: '/account-v2/two_factor_authentication',
},
{
routeComponent: DummyRoute,
routeName: 'Close your account',
routePath: '/account-v2/close_your_account',
},
];

export const defaultRoute = routes[0].routePath;
2 changes: 1 addition & 1 deletion packages/core/src/App/Constants/routes-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const P2P_V2 = React.lazy(() =>
const Account_V2 = React.lazy(() =>
moduleLoader(() => {
// eslint-disable-next-line import/no-unresolved
return import(/* webpackChunkName: "p2p-v2" */ '@deriv/account-v2');
return import(/* webpackChunkName: "account-v2" */ '@deriv/account-v2');
})
);

Expand Down

1 comment on commit e0584fa

@vercel
Copy link

@vercel vercel bot commented on e0584fa Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

deriv-app – ./

deriv-app.binary.sx
binary.sx
deriv-app-git-master.binary.sx
deriv-app.vercel.app

Please sign in to comment.