Skip to content

Commit

Permalink
[FEQ] P2P Ako/ add p2p-v2 base layout (#13173)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ali-hosseini-deriv authored Jan 26, 2024
1 parent 054804b commit 9ca2dbc
Show file tree
Hide file tree
Showing 10 changed files with 36,656 additions and 26,871 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ nx-cloud.env
test-results/
playwright-report/
playwright/.cache/
.nx
63,411 changes: 36,563 additions & 26,848 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/account-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"start": "rimraf dist && npm run test && npm run serve"
},
"dependencies": {
"@deriv-com/ui": "0.0.1-beta.7",
"@deriv-com/ui": "0.0.1-beta.8",
"@deriv/api": "^1.0.0",
"@deriv/library": "^1.0.0",
"@deriv/quill-design": "^1.3.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/p2p-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"start": "rimraf dist && npm run test && npm run serve"
},
"dependencies": {
"@deriv-com/ui": "0.0.1-beta.7",
"@deriv-com/ui": "0.0.1-beta.8",
"@deriv/api": "^1.0.0",
"@deriv/integration": "^1.0.0",
"@deriv/react-joyride": "^2.6.2",
Expand Down
14 changes: 9 additions & 5 deletions packages/p2p-v2/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import React from 'react';
import { APIProvider } from '@deriv/api';
import AppContent from './routes/AppContent';
import { Router } from './routes';
import './index.scss';

const App: React.FC = () => (
<APIProvider standalone>
<Router />
</APIProvider>
);
const App: React.FC = () => {
return (
<APIProvider standalone>
<Router />
<AppContent />
</APIProvider>
);
};
export default App;
19 changes: 19 additions & 0 deletions packages/p2p-v2/src/routes/AppContent/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.p2p-v2-tab {
&__items-wrapper {
& button {
padding: 0 3rem;
white-space: nowrap;
height: 40px;
@include mobile {
width: calc(100vw / 4);
}
}
}
&__wrapper {
width: fit-content;
@include mobile {
width: 100vw;
margin-top: 4rem;
}
}
}
50 changes: 50 additions & 0 deletions packages/p2p-v2/src/routes/AppContent/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react';
import { useHistory } from 'react-router-dom';
import { useActiveAccount } from '@deriv/api';
import { Loader } from '@deriv-com/ui/dist/components/Loader';
import { Tab, Tabs } from '@deriv-com/ui/dist/components/Tabs';
import { MobileCloseHeader } from '../../components';
import { useDevice } from '../../hooks';
import './index.scss';

export const routesConfiguration = [
{ Component: <div> Buy Sell Page </div>, path: 'buy-sell', title: 'Buy / Sell' },
{ Component: <div> Orders Page </div>, path: 'orders', title: 'Orders' },
{ Component: <div> My Ads Page </div>, path: 'my-ads', title: 'My Ads' },
{ Component: <div> My Profile Page </div>, path: 'my-profile', title: 'My Profile' },
];
const AppContent = () => {
const history = useHistory();
const { data: activeAccountData, isLoading } = useActiveAccount();
const { isMobile } = useDevice();
if (isLoading || !activeAccountData) return <Loader color='#85acb0' />;

// NOTE: Replace this with P2PBlocked component later and a custom hook useIsP2PEnabled, P2P is only available for USD accounts
if (activeAccountData?.currency !== 'USD') return <h1>P2P is only available for USD accounts.</h1>;

return (
<>
{isMobile && <MobileCloseHeader />}
<div className='p2p-v2-tab__wrapper'>
<Tabs
className='p2p-v2-tab__items-wrapper'
onChange={index => {
history.push(`/cashier/p2p-v2/${routesConfiguration[index].path}`);
}}
variant='secondary'
wrapperClassName='p2p-v2-tab__wrapper'
>
{routesConfiguration.map(({ Component, path, title }) => {
return (
<Tab key={path} title={title}>
{Component}
</Tab>
);
})}
</Tabs>
</div>
</>
);
};

export default AppContent;
11 changes: 0 additions & 11 deletions packages/p2p-v2/src/routes/Home/index.scss

This file was deleted.

15 changes: 11 additions & 4 deletions packages/p2p-v2/src/routes/Router.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Route, Switch } from 'react-router-dom';
import Home from './Home';
import { Route, Switch, useHistory } from 'react-router-dom';
import { routesConfiguration } from './AppContent';

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

Expand All @@ -13,10 +13,17 @@ declare module 'react-router-dom' {
}

const Router: React.FC = () => {
const history = useHistory();
if (history.location.pathname === prefix) {
history.push(`${prefix}/${routesConfiguration[0].path}`);
}
return (
<Switch>
<Route component={() => <Home path='Inner' />} exact path={`${prefix}/inner`} />
<Route component={() => <Home path='Root' />} exact path={`${prefix}/`} />
{routesConfiguration.map(({ Component, path }) => (
<Route key={path} path={path}>
{Component}
</Route>
))}
</Switch>
);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/tradershub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@deriv/library": "^1.0.0",
"@deriv/quill-design": "^1.3.2",
"@deriv/quill-icons": "^1.17.0",
"@deriv-com/ui": "0.0.1-beta.7",
"@deriv-com/ui": "0.0.1-beta.8",
"@deriv/react-joyride": "^2.6.2",
"@deriv/utils": "^1.0.0",
"@tanstack/react-table": "^8.10.3",
Expand Down

1 comment on commit 9ca2dbc

@vercel
Copy link

@vercel vercel bot commented on 9ca2dbc Jan 26, 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.vercel.app
deriv-app.binary.sx
deriv-app-git-master.binary.sx
binary.sx

Please sign in to comment.