vega-frontend-monorepo/apps/trading/pages/portfolio/index.page.tsx

99 lines
3.0 KiB
TypeScript
Raw Normal View History

import { Web3Container } from '../../components/web3-container';
import { t } from '@vegaprotocol/react-helpers';
import { PositionsContainer } from '@vegaprotocol/positions';
Chore/657 refactor wallet and orders libs (#709) * feat: 470 edit orders hook and @vegaprotocol/vegawallet-service-api-client@0.4.14 * fix: 470 add methods for dialog intent and title * fix: #657 rename order-list lib to orders * chore: #657 move hooks to orders lib * chore: #657 vega tx dialog used for order cancellation and order submission * chore: #657 use client subscribe and unsubscribe on reset, refactor vegatxdialog * fix: #657 revert script src=./env-config.js ending * fix: #657 format project.json * Update project.json * fix: #657 cancel all subs and async tasks in useffect cleanup function * feat: #657 styling updates on vega order dialog * fix: #657 rename set dialog open and awaiting confirmation dialog update * fix: #657 updates on cancel order id check * fix: #657 fix vega tx dialog test * fix: #657 fix cypress trading-deal-tciket test * fix: #657 fix data-testid market test * Update libs/orders/README.md Co-authored-by: Dexter Edwards <dexter.edwards93@gmail.com> * Update libs/wallet/src/vega-order-transaction-dialog/vega-order-transaction-dialog.tsx Co-authored-by: Dexter Edwards <dexter.edwards93@gmail.com> * Update libs/wallet/src/vega-transaction-dialog/vega-transaction-dialog.tsx Co-authored-by: Dexter Edwards <dexter.edwards93@gmail.com> * Update libs/wallet/src/vega-order-transaction-dialog/vega-order-transaction-dialog.tsx Co-authored-by: Dexter Edwards <dexter.edwards93@gmail.com> * Update libs/wallet/src/vega-order-transaction-dialog/vega-order-transaction-dialog.tsx Co-authored-by: Dexter Edwards <dexter.edwards93@gmail.com> * fix: #657 remove the magic string and use the ordertype enum from types package * fix: #657 guarantee that order.id is present at this point or we need to determine the id of the order * fix: #657 fix translation in dialog * fix: #657 rename wallet types, delete ticket query, set finalized order null in submit * fix: #657 fix deal ticket steps test * fix: #657 remove settings.json * fix: #657 use order submit in orders lib * fix: #463 final modal links to block explorer * fix: #745 long/short instead of buy/sell * fix: #657 use only one vega tx dialog * fix: #657 keep ref of subscription and unsubscribe * fix: #657 hide cancelled orders * fix: #657 sub only when id set * fix: WIP: trying to unsub when order updated * fix: #745 long/short instead of buy/sell * fix: ensure observable defined * fix: #657 remove redundant test * Update libs/orders/src/lib/order-hooks/use-order-submit.ts * fix: failing test due to resizeobserver loop limit exceeded * fix: lint * fix: #657 fix test resize observer loop limit exceeded Co-authored-by: Dexter Edwards <dexter.edwards93@gmail.com> Co-authored-by: Matthew Russell <mattrussell36@gmail.com> Co-authored-by: Joe <joe@vega.xyz>
2022-07-13 14:23:46 +00:00
import { OrderListContainer } from '@vegaprotocol/orders';
import { AccountsContainer } from '@vegaprotocol/accounts';
feat(#447): 447 - UI toolkit and theme updates * feat: 447 Refactored 'progress' intent to be 'prompt' as now white. Added yellow 'selected' intent * feat: 447 Colour consolidation * feat: 447 Colour consolidation extra renaming * feat: 447 Fixing specified red colours * feat: 447 Removed unused darker red * feat: 447 Documenting additional colours in storybook * feat: 447 Buttons updated (except 'accent', which will probably get removed when navs built) * feat: 447 Text inputs updated * feat:frontend-monorepo-447: Trading nav * feat:frontend-monorepo-447: Updated toggle button colours * feat:frontend-monorepo-447: Custom checkboxes * feat:frontend-monorepo-447: Tweaks to radio buttons * feat:frontend-monorepo-447: Input dates get dark color scheme in dark mode * feat:frontend-monorepo-447: Dropdown updates * feat:frontend-monorepo-447: Icon menu * feat:frontend-monorepo-447: Focus visual styles moved to focus-visible for radios and toggle * feat:frontend-monorepo-447: Tweak to focus styles for text input and textarea * feat:frontend-monorepo-447: Labeled input * feat:frontend-monorepo-447: Labeled input description red when in error * feat:frontend-monorepo-447: Tooltip visual update * feat:frontend-monorepo-447: Added disabled state to checkbox * feat:frontend-monorepo-447: Custom select with radix * feat:frontend-monorepo-447: Reverted back to native Select for a11y concerns * feat:frontend-monorepo-447: Added visual cue for dropdown items when multiple can be selected * feat:frontend-monorepo-447: Removed shadow from buttons in Explorer where it looked wrong * feat:frontend-monorepo-447: Added box shadow classes into tailwind theme * feat:frontend-monorepo-447: Colour primitives documentation updated * feat:frontend-monorepo-447: Cleaning up box shadow use further * feat:frontend-monorepo-447: Intents util updated * feat:frontend-monorepo-447: Dialog component updated * feat:frontend-monorepo-447: Callout component updated * feat:frontend-monorepo-447: Adjusted apps to handle toolkit changes * feat:frontend-monorepo-447: Moved tabs to ui-toolkit and styled * feat:frontend-monorepo-447: Fixed ui-toolkit tests * feat:frontend-monorepo-447: Token eth wallet made dark to support new buttons * feat:frontend-monorepo-447: Ran prettier * frontend-monorepo-447: Simplified button class functions and exported for use on other elements * frontend-monorepo-447: Used newly exported button classes on Link elements in eth-wallet * frontend-monorepo-447: Moved trading nav from ui-toolkit to trading app * frontend-monorepo-447: Simplified intents and updated stories * frontend-monorepo-447: Using classnames in requested spot * frontend-monorepo-447: Removed unnecessary 'asChild' prop on dropdown triggers * frontend-monorepo-447: Made use of the XPrimitive Radix naming convention * frontend-monorepo-447: Simplified types in 'getButtonClasses' * frontend-monorepo-447: Added 'asChild' to dropdown trigger to avoid nested buttons * frontend-monorepo-447: Moved input label and description into Formgroup component. Refactored based on tweaked structure * frontend-monorepo-447: Externally linked input label * frontend-monorepo-447: Adding correct text colours to Intent.None backgrounds * frontend-monorepo-447: Improved intent function name * frontend-monorepo-447: Removed new navbar until implementation ticket is picked up * frontend-monorepo-447: using testing-library/user-event for tab click unit tests * frontend-monorepo-447: Removed unused button import * frontend-monorepo-447: Little extra use of classnames in form-group.tsx * feat: make navbar pink for light mode * fix: problem with theme not switching when dependent in js on theme value * fix: bg of row hover * fix: dont use vega pink for sell red * fix: type error in generate orders func * fix: lint Co-authored-by: Matthew Russell <mattrussell36@gmail.com>
2022-06-24 03:16:01 +00:00
import { AnchorButton, Tab, Tabs } from '@vegaprotocol/ui-toolkit';
import { WithdrawalsContainer } from './withdrawals/withdrawals-container';
import { FillsContainer } from '@vegaprotocol/fills';
import classNames from 'classnames';
import type { ReactNode } from 'react';
2022-02-17 05:03:46 +00:00
const Portfolio = () => {
const wrapperClasses = classNames(
'h-full max-h-full',
'grid gap-4 grid-rows-[1fr_300px]',
'bg-black-10 dark:bg-white-10',
'text-ui'
);
const tabContentClassName = 'h-full grid gap-4 grid-rows-[min-content_1fr]';
2022-02-17 05:03:46 +00:00
return (
<div className={wrapperClasses}>
<PortfolioGridChild>
<Tabs>
<Tab id="positions" name={t('Positions')}>
<div className={tabContentClassName}>
<h4 className="text-h4 text-black dark:text-white p-8">
{t('Positions')}
</h4>
<div>
<PositionsContainer />
</div>
</div>
</Tab>
<Tab id="orders" name={t('Orders')}>
<div className={tabContentClassName}>
<h4 className="text-h4 text-black dark:text-white p-8">
{t('Orders')}
</h4>
<div>
<OrderListContainer />
</div>
</div>
</Tab>
<Tab id="fills" name={t('Fills')}>
<div className={tabContentClassName}>
<h4 className="text-h4 text-black dark:text-white p-8">
{t('Fills')}
</h4>
<div>
<FillsContainer />
</div>
</div>
</Tab>
</Tabs>
</PortfolioGridChild>
<PortfolioGridChild>
<Tabs>
<Tab id="collateral" name={t('Collateral')}>
<AccountsContainer />
</Tab>
<Tab id="deposits" name={t('Deposits')}>
<div className={tabContentClassName}>
<div className="p-8">
<AnchorButton data-testid="deposit" href="/portfolio/deposit">
{t('Deposit')}
</AnchorButton>
</div>
</div>
</Tab>
<Tab id="withdrawals" name={t('Withdrawals')}>
<Web3Container>
<WithdrawalsContainer />
</Web3Container>
</Tab>
</Tabs>
</PortfolioGridChild>
</div>
2022-02-17 05:03:46 +00:00
);
};
Portfolio.getInitialProps = () => ({
page: 'portfolio',
});
2022-02-17 05:03:46 +00:00
export default Portfolio;
interface PortfolioGridChildProps {
children: ReactNode;
className?: string;
}
const PortfolioGridChild = ({
children,
className,
}: PortfolioGridChildProps) => {
const gridChildClasses = classNames('bg-white dark:bg-black', className);
return <section className={gridChildClasses}>{children}</section>;
};