Skip to content

Commit 9ca2dbc

Browse files
[FEQ] P2P Ako/ add p2p-v2 base layout (#13173)
* ci: add nx cache dir to the gitignore * build: update ui lib * feat: add app content tab * feat: use app content in app module * feat: add p2p routes to router module * build: update package-lock json file
1 parent 054804b commit 9ca2dbc

File tree

10 files changed

+36656
-26871
lines changed

10 files changed

+36656
-26871
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ nx-cloud.env
2727
test-results/
2828
playwright-report/
2929
playwright/.cache/
30+
.nx

package-lock.json

Lines changed: 36563 additions & 26848 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/account-v2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"start": "rimraf dist && npm run test && npm run serve"
1212
},
1313
"dependencies": {
14-
"@deriv-com/ui": "0.0.1-beta.7",
14+
"@deriv-com/ui": "0.0.1-beta.8",
1515
"@deriv/api": "^1.0.0",
1616
"@deriv/library": "^1.0.0",
1717
"@deriv/quill-design": "^1.3.2",

packages/p2p-v2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"start": "rimraf dist && npm run test && npm run serve"
1313
},
1414
"dependencies": {
15-
"@deriv-com/ui": "0.0.1-beta.7",
15+
"@deriv-com/ui": "0.0.1-beta.8",
1616
"@deriv/api": "^1.0.0",
1717
"@deriv/integration": "^1.0.0",
1818
"@deriv/react-joyride": "^2.6.2",

packages/p2p-v2/src/App.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import React from 'react';
22
import { APIProvider } from '@deriv/api';
3+
import AppContent from './routes/AppContent';
34
import { Router } from './routes';
45
import './index.scss';
56

6-
const App: React.FC = () => (
7-
<APIProvider standalone>
8-
<Router />
9-
</APIProvider>
10-
);
7+
const App: React.FC = () => {
8+
return (
9+
<APIProvider standalone>
10+
<Router />
11+
<AppContent />
12+
</APIProvider>
13+
);
14+
};
1115
export default App;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.p2p-v2-tab {
2+
&__items-wrapper {
3+
& button {
4+
padding: 0 3rem;
5+
white-space: nowrap;
6+
height: 40px;
7+
@include mobile {
8+
width: calc(100vw / 4);
9+
}
10+
}
11+
}
12+
&__wrapper {
13+
width: fit-content;
14+
@include mobile {
15+
width: 100vw;
16+
margin-top: 4rem;
17+
}
18+
}
19+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React from 'react';
2+
import { useHistory } from 'react-router-dom';
3+
import { useActiveAccount } from '@deriv/api';
4+
import { Loader } from '@deriv-com/ui/dist/components/Loader';
5+
import { Tab, Tabs } from '@deriv-com/ui/dist/components/Tabs';
6+
import { MobileCloseHeader } from '../../components';
7+
import { useDevice } from '../../hooks';
8+
import './index.scss';
9+
10+
export const routesConfiguration = [
11+
{ Component: <div> Buy Sell Page </div>, path: 'buy-sell', title: 'Buy / Sell' },
12+
{ Component: <div> Orders Page </div>, path: 'orders', title: 'Orders' },
13+
{ Component: <div> My Ads Page </div>, path: 'my-ads', title: 'My Ads' },
14+
{ Component: <div> My Profile Page </div>, path: 'my-profile', title: 'My Profile' },
15+
];
16+
const AppContent = () => {
17+
const history = useHistory();
18+
const { data: activeAccountData, isLoading } = useActiveAccount();
19+
const { isMobile } = useDevice();
20+
if (isLoading || !activeAccountData) return <Loader color='#85acb0' />;
21+
22+
// NOTE: Replace this with P2PBlocked component later and a custom hook useIsP2PEnabled, P2P is only available for USD accounts
23+
if (activeAccountData?.currency !== 'USD') return <h1>P2P is only available for USD accounts.</h1>;
24+
25+
return (
26+
<>
27+
{isMobile && <MobileCloseHeader />}
28+
<div className='p2p-v2-tab__wrapper'>
29+
<Tabs
30+
className='p2p-v2-tab__items-wrapper'
31+
onChange={index => {
32+
history.push(`/cashier/p2p-v2/${routesConfiguration[index].path}`);
33+
}}
34+
variant='secondary'
35+
wrapperClassName='p2p-v2-tab__wrapper'
36+
>
37+
{routesConfiguration.map(({ Component, path, title }) => {
38+
return (
39+
<Tab key={path} title={title}>
40+
{Component}
41+
</Tab>
42+
);
43+
})}
44+
</Tabs>
45+
</div>
46+
</>
47+
);
48+
};
49+
50+
export default AppContent;

packages/p2p-v2/src/routes/Home/index.scss

Lines changed: 0 additions & 11 deletions
This file was deleted.

packages/p2p-v2/src/routes/Router.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
2-
import { Route, Switch } from 'react-router-dom';
3-
import Home from './Home';
2+
import { Route, Switch, useHistory } from 'react-router-dom';
3+
import { routesConfiguration } from './AppContent';
44

55
const prefix = '/cashier/p2p-v2';
66

@@ -13,10 +13,17 @@ declare module 'react-router-dom' {
1313
}
1414

1515
const Router: React.FC = () => {
16+
const history = useHistory();
17+
if (history.location.pathname === prefix) {
18+
history.push(`${prefix}/${routesConfiguration[0].path}`);
19+
}
1620
return (
1721
<Switch>
18-
<Route component={() => <Home path='Inner' />} exact path={`${prefix}/inner`} />
19-
<Route component={() => <Home path='Root' />} exact path={`${prefix}/`} />
22+
{routesConfiguration.map(({ Component, path }) => (
23+
<Route key={path} path={path}>
24+
{Component}
25+
</Route>
26+
))}
2027
</Switch>
2128
);
2229
};

packages/tradershub/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@deriv/library": "^1.0.0",
1919
"@deriv/quill-design": "^1.3.2",
2020
"@deriv/quill-icons": "^1.17.0",
21-
"@deriv-com/ui": "0.0.1-beta.7",
21+
"@deriv-com/ui": "0.0.1-beta.8",
2222
"@deriv/react-joyride": "^2.6.2",
2323
"@deriv/utils": "^1.0.0",
2424
"@tanstack/react-table": "^8.10.3",

0 commit comments

Comments
 (0)