feat(trading): adjust layout for funding payments (#5034)

This commit is contained in:
Bartłomiej Głownia 2023-10-16 11:19:08 +02:00 committed by GitHub
parent 6044b86ff4
commit 1791b3ca6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 10 deletions

View File

@ -73,10 +73,19 @@ const MainGrid = memo(
{market && {market &&
market.tradableInstrument.instrument.product.__typename === market.tradableInstrument.instrument.product.__typename ===
'Perpetual' ? ( 'Perpetual' ? (
<Tab id="funding" name={t('Funding')}> <Tab id="funding-history" name={t('Funding history')}>
<TradingViews.funding.component marketId={marketId} /> <TradingViews.funding.component marketId={marketId} />
</Tab> </Tab>
) : null} ) : null}
{market &&
market.tradableInstrument.instrument.product.__typename ===
'Perpetual' ? (
<Tab id="funding-payments" name={t('Funding payments')}>
<TradingViews.fundingPayments.component
marketId={marketId}
/>
</Tab>
) : null}
</Tabs> </Tabs>
</TradeGridChild> </TradeGridChild>
</ResizableGridPanel> </ResizableGridPanel>
@ -139,9 +148,6 @@ const MainGrid = memo(
<Tab id="fills" name={t('Fills')}> <Tab id="fills" name={t('Fills')}>
<TradingViews.fills.component /> <TradingViews.fills.component />
</Tab> </Tab>
<Tab id="funding-payments" name={t('Funding payments')}>
<TradingViews.fundingPayments.component />
</Tab>
<Tab <Tab
id="accounts" id="accounts"
name={t('Collateral')} name={t('Collateral')}

View File

@ -9,7 +9,11 @@ import type { DataGridSlice } from '../../stores/datagrid-store-slice';
import { createDataGridSlice } from '../../stores/datagrid-store-slice'; import { createDataGridSlice } from '../../stores/datagrid-store-slice';
import { useMarketClickHandler } from '../../lib/hooks/use-market-click-handler'; import { useMarketClickHandler } from '../../lib/hooks/use-market-click-handler';
export const FundingPaymentsContainer = () => { export const FundingPaymentsContainer = ({
marketId,
}: {
marketId?: string;
}) => {
const onMarketClick = useMarketClickHandler(true); const onMarketClick = useMarketClickHandler(true);
const { pubKey } = useVegaWallet(); const { pubKey } = useVegaWallet();
@ -33,6 +37,7 @@ export const FundingPaymentsContainer = () => {
return ( return (
<FundingPaymentsManager <FundingPaymentsManager
partyId={pubKey} partyId={pubKey}
marketId={marketId}
onMarketClick={onMarketClick} onMarketClick={onMarketClick}
gridProps={gridStoreCallbacks} gridProps={gridStoreCallbacks}
/> />

View File

@ -6,8 +6,12 @@ fragment FundingPaymentFields on FundingPayment {
timestamp timestamp
} }
query FundingPayments($partyId: ID!, $pagination: Pagination) { query FundingPayments($partyId: ID!, $pagination: Pagination, $marketId: ID) {
fundingPayments(partyId: $partyId, pagination: $pagination) { fundingPayments(
partyId: $partyId
pagination: $pagination
marketId: $marketId
) {
edges { edges {
node { node {
...FundingPaymentFields ...FundingPaymentFields

View File

@ -8,6 +8,7 @@ export type FundingPaymentFieldsFragment = { __typename?: 'FundingPayment', mark
export type FundingPaymentsQueryVariables = Types.Exact<{ export type FundingPaymentsQueryVariables = Types.Exact<{
partyId: Types.Scalars['ID']; partyId: Types.Scalars['ID'];
pagination?: Types.InputMaybe<Types.Pagination>; pagination?: Types.InputMaybe<Types.Pagination>;
marketId?: Types.InputMaybe<Types.Scalars['ID']>;
}>; }>;
@ -23,8 +24,8 @@ export const FundingPaymentFieldsFragmentDoc = gql`
} }
`; `;
export const FundingPaymentsDocument = gql` export const FundingPaymentsDocument = gql`
query FundingPayments($partyId: ID!, $pagination: Pagination) { query FundingPayments($partyId: ID!, $pagination: Pagination, $marketId: ID) {
fundingPayments(partyId: $partyId, pagination: $pagination) { fundingPayments(partyId: $partyId, pagination: $pagination, marketId: $marketId) {
edges { edges {
node { node {
...FundingPaymentFields ...FundingPaymentFields
@ -55,6 +56,7 @@ export const FundingPaymentsDocument = gql`
* variables: { * variables: {
* partyId: // value for 'partyId' * partyId: // value for 'partyId'
* pagination: // value for 'pagination' * pagination: // value for 'pagination'
* marketId: // value for 'marketId'
* }, * },
* }); * });
*/ */

View File

@ -8,12 +8,14 @@ import { fundingPaymentsWithMarketProvider } from './funding-payments-data-provi
interface FundingPaymentsManagerProps { interface FundingPaymentsManagerProps {
partyId: string; partyId: string;
marketId?: string;
onMarketClick?: (marketId: string, metaKey?: boolean) => void; onMarketClick?: (marketId: string, metaKey?: boolean) => void;
gridProps: ReturnType<typeof useDataGridEvents>; gridProps: ReturnType<typeof useDataGridEvents>;
} }
export const FundingPaymentsManager = ({ export const FundingPaymentsManager = ({
partyId, partyId,
marketId,
onMarketClick, onMarketClick,
gridProps, gridProps,
}: FundingPaymentsManagerProps) => { }: FundingPaymentsManagerProps) => {
@ -27,7 +29,7 @@ export const FundingPaymentsManager = ({
} }
return false; return false;
}, },
variables: { partyId }, variables: { partyId, marketId },
}); });
return ( return (