vega-frontend-monorepo/libs/positions/src/lib/positions.tsx

51 lines
1.6 KiB
TypeScript
Raw Normal View History

feat: [console-lite] - abstract components for portfolio page (#1306) * feat: [console-lite] - abstract components for portfolio page * feat: [console-lite] - abstract components for portfolio page - improvements * feat: [console-lite] - use abstract list with accounts manager * feat: [console-lite] - use abstract list with positions * feat: [console-lite] - use abstract list with orders * feat: [console-lite] - use abstract list with fills * feat: [console-lite] - fix failings linters * feat: [console-lite] - fix failings e2e test * feat: [console-lite] - fix failings e2e test * feat: [console-lite] - improve some css * feat: [console-lite] - a bunch of fixes for positions * feat: [console-lite] - tweaks of columns confs, bunch of e2e tests * feat: [console-lite] - abstract components for portfolio page - after review feedback fixes * feat: [console-lite] - abstract components for portfolio page - after review feedback fixes * feat: [console-lite] - abstract components for portfolio page - add missing asset datails dialog * feat: [console-lite] - portfolio abstractions - add fills hook unit tests * feat: [console-lite] - portfolio abstractions - add orders hook unit tests * feat: [console-lite] - portfolio abstractions - fix lint error * feat: [console-lite] - abstract components for portfolio page -fix failings tests * feat: [console-lite] - abstract components for portfolio page -fix failings tests * feat: [console-lite] - abstract components for portfolio page - fix failings lint check * feat: [console-lite] - abstract components for portfolio page - next fix * feat: [console-lite] - abstract components for portfolio page - improve some int test Co-authored-by: maciek <maciek@vegaprotocol.io>
2022-09-22 11:09:12 +00:00
import { useRef, memo } from 'react';
feat(#840): update positions tab (#1101) * feat(#473): add positions metrics data provider * feat(#473) add positions stats * feat(#473) add positions stats * feat(#473): add positions stats * feat(#473): add positions stats * feat(#473): position metrics, test and refactoring * feat(#473): add unit tests to positions table * feat(#473): fix spelling, order positions by updated at desc * feat(#473): protect from division by 0 * feat(#473): fix trading positions e2e tests * feat(#473): fix e2e data mocks * feat(#473): post code review clean up * feat(#993): dependencies handling in data provider * feat(#993): fix e2e tests data mocks * feat(#993): remove position metrics mocks, add market data market id * feat(#993): add missing mocks, fix combine function * feat(#993): set loading initially to true, add unit tests * feat(#993): cleanup, add comments * feat(#993): remove undefined from client type * feat(#993): cosmetic changes * feat(#840): update positions tab * feat:(#993): pass informaton about update callback cause * feat(#840): update positions tab * feat(#840): update positions tab * feat(#840): update positions tab * chore: skip handles 5000 markets e2e test * feat(#840): update positions tab * feat(#840): rename assetDecimals to decimals * feat(#840): close position * feat(#993): notify about update * feat(#840): add use close position hook * feat(#840): do not show 0 volume positions, make liquidation price minimum 0 * feat(#840): post code review fixes and improvments * feat: fix fill-table spec
2022-09-02 20:53:00 +00:00
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
feat: [console-lite] - abstract components for portfolio page (#1306) * feat: [console-lite] - abstract components for portfolio page * feat: [console-lite] - abstract components for portfolio page - improvements * feat: [console-lite] - use abstract list with accounts manager * feat: [console-lite] - use abstract list with positions * feat: [console-lite] - use abstract list with orders * feat: [console-lite] - use abstract list with fills * feat: [console-lite] - fix failings linters * feat: [console-lite] - fix failings e2e test * feat: [console-lite] - fix failings e2e test * feat: [console-lite] - improve some css * feat: [console-lite] - a bunch of fixes for positions * feat: [console-lite] - tweaks of columns confs, bunch of e2e tests * feat: [console-lite] - abstract components for portfolio page - after review feedback fixes * feat: [console-lite] - abstract components for portfolio page - after review feedback fixes * feat: [console-lite] - abstract components for portfolio page - add missing asset datails dialog * feat: [console-lite] - portfolio abstractions - add fills hook unit tests * feat: [console-lite] - portfolio abstractions - add orders hook unit tests * feat: [console-lite] - portfolio abstractions - fix lint error * feat: [console-lite] - abstract components for portfolio page -fix failings tests * feat: [console-lite] - abstract components for portfolio page -fix failings tests * feat: [console-lite] - abstract components for portfolio page - fix failings lint check * feat: [console-lite] - abstract components for portfolio page - next fix * feat: [console-lite] - abstract components for portfolio page - improve some int test Co-authored-by: maciek <maciek@vegaprotocol.io>
2022-09-22 11:09:12 +00:00
import { t } from '@vegaprotocol/react-helpers';
feat(#840): update positions tab (#1101) * feat(#473): add positions metrics data provider * feat(#473) add positions stats * feat(#473) add positions stats * feat(#473): add positions stats * feat(#473): add positions stats * feat(#473): position metrics, test and refactoring * feat(#473): add unit tests to positions table * feat(#473): fix spelling, order positions by updated at desc * feat(#473): protect from division by 0 * feat(#473): fix trading positions e2e tests * feat(#473): fix e2e data mocks * feat(#473): post code review clean up * feat(#993): dependencies handling in data provider * feat(#993): fix e2e tests data mocks * feat(#993): remove position metrics mocks, add market data market id * feat(#993): add missing mocks, fix combine function * feat(#993): set loading initially to true, add unit tests * feat(#993): cleanup, add comments * feat(#993): remove undefined from client type * feat(#993): cosmetic changes * feat(#840): update positions tab * feat:(#993): pass informaton about update callback cause * feat(#840): update positions tab * feat(#840): update positions tab * feat(#840): update positions tab * chore: skip handles 5000 markets e2e test * feat(#840): update positions tab * feat(#840): rename assetDecimals to decimals * feat(#840): close position * feat(#993): notify about update * feat(#840): add use close position hook * feat(#840): do not show 0 volume positions, make liquidation price minimum 0 * feat(#840): post code review fixes and improvments * feat: fix fill-table spec
2022-09-02 20:53:00 +00:00
import type { AgGridReact } from 'ag-grid-react';
import PositionsTable from './positions-table';
import type { Position } from './positions-data-providers';
feat: [console-lite] - abstract components for portfolio page (#1306) * feat: [console-lite] - abstract components for portfolio page * feat: [console-lite] - abstract components for portfolio page - improvements * feat: [console-lite] - use abstract list with accounts manager * feat: [console-lite] - use abstract list with positions * feat: [console-lite] - use abstract list with orders * feat: [console-lite] - use abstract list with fills * feat: [console-lite] - fix failings linters * feat: [console-lite] - fix failings e2e test * feat: [console-lite] - fix failings e2e test * feat: [console-lite] - improve some css * feat: [console-lite] - a bunch of fixes for positions * feat: [console-lite] - tweaks of columns confs, bunch of e2e tests * feat: [console-lite] - abstract components for portfolio page - after review feedback fixes * feat: [console-lite] - abstract components for portfolio page - after review feedback fixes * feat: [console-lite] - abstract components for portfolio page - add missing asset datails dialog * feat: [console-lite] - portfolio abstractions - add fills hook unit tests * feat: [console-lite] - portfolio abstractions - add orders hook unit tests * feat: [console-lite] - portfolio abstractions - fix lint error * feat: [console-lite] - abstract components for portfolio page -fix failings tests * feat: [console-lite] - abstract components for portfolio page -fix failings tests * feat: [console-lite] - abstract components for portfolio page - fix failings lint check * feat: [console-lite] - abstract components for portfolio page - next fix * feat: [console-lite] - abstract components for portfolio page - improve some int test Co-authored-by: maciek <maciek@vegaprotocol.io>
2022-09-22 11:09:12 +00:00
import { AssetBalance } from '@vegaprotocol/accounts';
import { usePositionsData } from './use-positions-data';
feat(#840): update positions tab (#1101) * feat(#473): add positions metrics data provider * feat(#473) add positions stats * feat(#473) add positions stats * feat(#473): add positions stats * feat(#473): add positions stats * feat(#473): position metrics, test and refactoring * feat(#473): add unit tests to positions table * feat(#473): fix spelling, order positions by updated at desc * feat(#473): protect from division by 0 * feat(#473): fix trading positions e2e tests * feat(#473): fix e2e data mocks * feat(#473): post code review clean up * feat(#993): dependencies handling in data provider * feat(#993): fix e2e tests data mocks * feat(#993): remove position metrics mocks, add market data market id * feat(#993): add missing mocks, fix combine function * feat(#993): set loading initially to true, add unit tests * feat(#993): cleanup, add comments * feat(#993): remove undefined from client type * feat(#993): cosmetic changes * feat(#840): update positions tab * feat:(#993): pass informaton about update callback cause * feat(#840): update positions tab * feat(#840): update positions tab * feat(#840): update positions tab * chore: skip handles 5000 markets e2e test * feat(#840): update positions tab * feat(#840): rename assetDecimals to decimals * feat(#840): close position * feat(#993): notify about update * feat(#840): add use close position hook * feat(#840): do not show 0 volume positions, make liquidation price minimum 0 * feat(#840): post code review fixes and improvments * feat: fix fill-table spec
2022-09-02 20:53:00 +00:00
interface PositionsProps {
partyId: string;
assetSymbol: string;
onClose: (position: Position) => void;
}
export const Positions = memo(
({ partyId, assetSymbol, onClose }: PositionsProps) => {
const gridRef = useRef<AgGridReact | null>(null);
const { data, error, loading, getRows } = usePositionsData(
feat: [console-lite] - abstract components for portfolio page (#1306) * feat: [console-lite] - abstract components for portfolio page * feat: [console-lite] - abstract components for portfolio page - improvements * feat: [console-lite] - use abstract list with accounts manager * feat: [console-lite] - use abstract list with positions * feat: [console-lite] - use abstract list with orders * feat: [console-lite] - use abstract list with fills * feat: [console-lite] - fix failings linters * feat: [console-lite] - fix failings e2e test * feat: [console-lite] - fix failings e2e test * feat: [console-lite] - improve some css * feat: [console-lite] - a bunch of fixes for positions * feat: [console-lite] - tweaks of columns confs, bunch of e2e tests * feat: [console-lite] - abstract components for portfolio page - after review feedback fixes * feat: [console-lite] - abstract components for portfolio page - after review feedback fixes * feat: [console-lite] - abstract components for portfolio page - add missing asset datails dialog * feat: [console-lite] - portfolio abstractions - add fills hook unit tests * feat: [console-lite] - portfolio abstractions - add orders hook unit tests * feat: [console-lite] - portfolio abstractions - fix lint error * feat: [console-lite] - abstract components for portfolio page -fix failings tests * feat: [console-lite] - abstract components for portfolio page -fix failings tests * feat: [console-lite] - abstract components for portfolio page - fix failings lint check * feat: [console-lite] - abstract components for portfolio page - next fix * feat: [console-lite] - abstract components for portfolio page - improve some int test Co-authored-by: maciek <maciek@vegaprotocol.io>
2022-09-22 11:09:12 +00:00
partyId,
gridRef,
assetSymbol
);
feat: [console-lite] - abstract components for portfolio page (#1306) * feat: [console-lite] - abstract components for portfolio page * feat: [console-lite] - abstract components for portfolio page - improvements * feat: [console-lite] - use abstract list with accounts manager * feat: [console-lite] - use abstract list with positions * feat: [console-lite] - use abstract list with orders * feat: [console-lite] - use abstract list with fills * feat: [console-lite] - fix failings linters * feat: [console-lite] - fix failings e2e test * feat: [console-lite] - fix failings e2e test * feat: [console-lite] - improve some css * feat: [console-lite] - a bunch of fixes for positions * feat: [console-lite] - tweaks of columns confs, bunch of e2e tests * feat: [console-lite] - abstract components for portfolio page - after review feedback fixes * feat: [console-lite] - abstract components for portfolio page - after review feedback fixes * feat: [console-lite] - abstract components for portfolio page - add missing asset datails dialog * feat: [console-lite] - portfolio abstractions - add fills hook unit tests * feat: [console-lite] - portfolio abstractions - add orders hook unit tests * feat: [console-lite] - portfolio abstractions - fix lint error * feat: [console-lite] - abstract components for portfolio page -fix failings tests * feat: [console-lite] - abstract components for portfolio page -fix failings tests * feat: [console-lite] - abstract components for portfolio page - fix failings lint check * feat: [console-lite] - abstract components for portfolio page - next fix * feat: [console-lite] - abstract components for portfolio page - improve some int test Co-authored-by: maciek <maciek@vegaprotocol.io>
2022-09-22 11:09:12 +00:00
feat(#840): update positions tab (#1101) * feat(#473): add positions metrics data provider * feat(#473) add positions stats * feat(#473) add positions stats * feat(#473): add positions stats * feat(#473): add positions stats * feat(#473): position metrics, test and refactoring * feat(#473): add unit tests to positions table * feat(#473): fix spelling, order positions by updated at desc * feat(#473): protect from division by 0 * feat(#473): fix trading positions e2e tests * feat(#473): fix e2e data mocks * feat(#473): post code review clean up * feat(#993): dependencies handling in data provider * feat(#993): fix e2e tests data mocks * feat(#993): remove position metrics mocks, add market data market id * feat(#993): add missing mocks, fix combine function * feat(#993): set loading initially to true, add unit tests * feat(#993): cleanup, add comments * feat(#993): remove undefined from client type * feat(#993): cosmetic changes * feat(#840): update positions tab * feat:(#993): pass informaton about update callback cause * feat(#840): update positions tab * feat(#840): update positions tab * feat(#840): update positions tab * chore: skip handles 5000 markets e2e test * feat(#840): update positions tab * feat(#840): rename assetDecimals to decimals * feat(#840): close position * feat(#993): notify about update * feat(#840): add use close position hook * feat(#840): do not show 0 volume positions, make liquidation price minimum 0 * feat(#840): post code review fixes and improvments * feat: fix fill-table spec
2022-09-02 20:53:00 +00:00
return (
<AsyncRenderer loading={loading} error={error} data={data}>
<div className="flex justify-between items-center px-4 pt-3 pb-1">
<h4>
feat(#840): update positions tab (#1101) * feat(#473): add positions metrics data provider * feat(#473) add positions stats * feat(#473) add positions stats * feat(#473): add positions stats * feat(#473): add positions stats * feat(#473): position metrics, test and refactoring * feat(#473): add unit tests to positions table * feat(#473): fix spelling, order positions by updated at desc * feat(#473): protect from division by 0 * feat(#473): fix trading positions e2e tests * feat(#473): fix e2e data mocks * feat(#473): post code review clean up * feat(#993): dependencies handling in data provider * feat(#993): fix e2e tests data mocks * feat(#993): remove position metrics mocks, add market data market id * feat(#993): add missing mocks, fix combine function * feat(#993): set loading initially to true, add unit tests * feat(#993): cleanup, add comments * feat(#993): remove undefined from client type * feat(#993): cosmetic changes * feat(#840): update positions tab * feat:(#993): pass informaton about update callback cause * feat(#840): update positions tab * feat(#840): update positions tab * feat(#840): update positions tab * chore: skip handles 5000 markets e2e test * feat(#840): update positions tab * feat(#840): rename assetDecimals to decimals * feat(#840): close position * feat(#993): notify about update * feat(#840): add use close position hook * feat(#840): do not show 0 volume positions, make liquidation price minimum 0 * feat(#840): post code review fixes and improvments * feat: fix fill-table spec
2022-09-02 20:53:00 +00:00
{assetSymbol} {t('markets')}
</h4>
<div className="text-sm text-neutral-500 dark:text-neutral-300">
feat(#840): update positions tab (#1101) * feat(#473): add positions metrics data provider * feat(#473) add positions stats * feat(#473) add positions stats * feat(#473): add positions stats * feat(#473): add positions stats * feat(#473): position metrics, test and refactoring * feat(#473): add unit tests to positions table * feat(#473): fix spelling, order positions by updated at desc * feat(#473): protect from division by 0 * feat(#473): fix trading positions e2e tests * feat(#473): fix e2e data mocks * feat(#473): post code review clean up * feat(#993): dependencies handling in data provider * feat(#993): fix e2e tests data mocks * feat(#993): remove position metrics mocks, add market data market id * feat(#993): add missing mocks, fix combine function * feat(#993): set loading initially to true, add unit tests * feat(#993): cleanup, add comments * feat(#993): remove undefined from client type * feat(#993): cosmetic changes * feat(#840): update positions tab * feat:(#993): pass informaton about update callback cause * feat(#840): update positions tab * feat(#840): update positions tab * feat(#840): update positions tab * chore: skip handles 5000 markets e2e test * feat(#840): update positions tab * feat(#840): rename assetDecimals to decimals * feat(#840): close position * feat(#993): notify about update * feat(#840): add use close position hook * feat(#840): do not show 0 volume positions, make liquidation price minimum 0 * feat(#840): post code review fixes and improvments * feat: fix fill-table spec
2022-09-02 20:53:00 +00:00
{assetSymbol} {t('balance')}:
<span data-testid="balance" className="pl-1 font-mono">
feat(#840): update positions tab (#1101) * feat(#473): add positions metrics data provider * feat(#473) add positions stats * feat(#473) add positions stats * feat(#473): add positions stats * feat(#473): add positions stats * feat(#473): position metrics, test and refactoring * feat(#473): add unit tests to positions table * feat(#473): fix spelling, order positions by updated at desc * feat(#473): protect from division by 0 * feat(#473): fix trading positions e2e tests * feat(#473): fix e2e data mocks * feat(#473): post code review clean up * feat(#993): dependencies handling in data provider * feat(#993): fix e2e tests data mocks * feat(#993): remove position metrics mocks, add market data market id * feat(#993): add missing mocks, fix combine function * feat(#993): set loading initially to true, add unit tests * feat(#993): cleanup, add comments * feat(#993): remove undefined from client type * feat(#993): cosmetic changes * feat(#840): update positions tab * feat:(#993): pass informaton about update callback cause * feat(#840): update positions tab * feat(#840): update positions tab * feat(#840): update positions tab * chore: skip handles 5000 markets e2e test * feat(#840): update positions tab * feat(#840): rename assetDecimals to decimals * feat(#840): close position * feat(#993): notify about update * feat(#840): add use close position hook * feat(#840): do not show 0 volume positions, make liquidation price minimum 0 * feat(#840): post code review fixes and improvments * feat: fix fill-table spec
2022-09-02 20:53:00 +00:00
<AssetBalance partyId={partyId} assetSymbol={assetSymbol} />
</span>
</div>
feat(#840): update positions tab (#1101) * feat(#473): add positions metrics data provider * feat(#473) add positions stats * feat(#473) add positions stats * feat(#473): add positions stats * feat(#473): add positions stats * feat(#473): position metrics, test and refactoring * feat(#473): add unit tests to positions table * feat(#473): fix spelling, order positions by updated at desc * feat(#473): protect from division by 0 * feat(#473): fix trading positions e2e tests * feat(#473): fix e2e data mocks * feat(#473): post code review clean up * feat(#993): dependencies handling in data provider * feat(#993): fix e2e tests data mocks * feat(#993): remove position metrics mocks, add market data market id * feat(#993): add missing mocks, fix combine function * feat(#993): set loading initially to true, add unit tests * feat(#993): cleanup, add comments * feat(#993): remove undefined from client type * feat(#993): cosmetic changes * feat(#840): update positions tab * feat:(#993): pass informaton about update callback cause * feat(#840): update positions tab * feat(#840): update positions tab * feat(#840): update positions tab * chore: skip handles 5000 markets e2e test * feat(#840): update positions tab * feat(#840): rename assetDecimals to decimals * feat(#840): close position * feat(#993): notify about update * feat(#840): add use close position hook * feat(#840): do not show 0 volume positions, make liquidation price minimum 0 * feat(#840): post code review fixes and improvments * feat: fix fill-table spec
2022-09-02 20:53:00 +00:00
</div>
<PositionsTable
domLayout="autoHeight"
style={{ width: '100%' }}
ref={gridRef}
rowModelType={data?.length ? 'infinite' : 'clientSide'}
rowData={data?.length ? undefined : []}
datasource={{ getRows }}
onClose={onClose}
/>
</AsyncRenderer>
);
}
);