fix(trading): check for batch proposal in trading mode tooltip (#5895)
This commit is contained in:
parent
28b4593a1d
commit
2d821700bd
@ -1,11 +1,7 @@
|
||||
import { useMemo } from 'react';
|
||||
import { parseISO, isValid, isAfter } from 'date-fns';
|
||||
import classNames from 'classnames';
|
||||
import {
|
||||
useProposalOfMarketQuery,
|
||||
type ProposalOfMarketQuery,
|
||||
type SingleProposal,
|
||||
} from '@vegaprotocol/proposals';
|
||||
import { useProposalOfMarketQuery } from '@vegaprotocol/proposals';
|
||||
import { DocsLinks } from '@vegaprotocol/environment';
|
||||
import { getDateTimeFormat } from '@vegaprotocol/utils';
|
||||
import * as Schema from '@vegaprotocol/types';
|
||||
@ -40,15 +36,21 @@ export const TradingModeTooltip = ({
|
||||
marketTradingMode,
|
||||
});
|
||||
|
||||
// We only fetch Proposals (and not BatchProposals)
|
||||
const proposal = proposalData?.proposal as SingleProposal<
|
||||
ProposalOfMarketQuery['proposal']
|
||||
>;
|
||||
|
||||
if (!market || !marketData) {
|
||||
return null;
|
||||
}
|
||||
const enactmentDate = parseISO(proposal?.terms.enactmentDatetime);
|
||||
|
||||
let enactmentDate;
|
||||
const proposal = proposalData?.proposal;
|
||||
|
||||
if (proposal?.__typename === 'Proposal') {
|
||||
enactmentDate = parseISO(proposal.terms.enactmentDatetime);
|
||||
} else if (proposal?.__typename === 'BatchProposal') {
|
||||
const change = proposal.batchTerms?.changes.find(
|
||||
(c) => c?.change.__typename === 'NewMarket'
|
||||
);
|
||||
enactmentDate = change ? parseISO(change.enactmentDatetime) : undefined;
|
||||
}
|
||||
|
||||
const compiledGrid =
|
||||
!skipGrid && compileGridData(t, market, marketData, onSelect);
|
||||
@ -67,14 +69,16 @@ export const TradingModeTooltip = ({
|
||||
return (
|
||||
<section data-testid="trading-mode-tooltip">
|
||||
<p
|
||||
className={classNames('flex flex-col', {
|
||||
className={classNames('flex flex-col items-start gap-2', {
|
||||
'mb-4': Boolean(compiledGrid),
|
||||
})}
|
||||
>
|
||||
{isValid(enactmentDate) && isAfter(new Date(), enactmentDate) ? (
|
||||
{enactmentDate &&
|
||||
isValid(enactmentDate) &&
|
||||
isAfter(new Date(), enactmentDate) ? (
|
||||
<>
|
||||
<span
|
||||
className="justify-center font-bold my-2"
|
||||
className="justify-center font-bold"
|
||||
data-testid="opening-auction-sub-status"
|
||||
>
|
||||
{`${Schema.MarketTradingModeMapping[marketTradingMode]}: ${t(
|
||||
@ -91,7 +95,7 @@ export const TradingModeTooltip = ({
|
||||
<>
|
||||
{isValid(enactmentDate) && (
|
||||
<span
|
||||
className="justify-center font-bold my-2"
|
||||
className="justify-center font-bold"
|
||||
data-testid="opening-auction-sub-status"
|
||||
>
|
||||
{`${
|
||||
@ -109,10 +113,7 @@ export const TradingModeTooltip = ({
|
||||
</>
|
||||
)}
|
||||
{DocsLinks && (
|
||||
<ExternalLink
|
||||
href={DocsLinks.AUCTION_TYPE_OPENING}
|
||||
className="ml-1"
|
||||
>
|
||||
<ExternalLink href={DocsLinks.AUCTION_TYPE_OPENING}>
|
||||
{t('Find out more')}
|
||||
</ExternalLink>
|
||||
)}
|
||||
|
@ -45,6 +45,19 @@ query ProposalOfMarket($marketId: ID!) {
|
||||
enactmentDatetime
|
||||
}
|
||||
}
|
||||
... on BatchProposal {
|
||||
id
|
||||
batchTerms {
|
||||
changes {
|
||||
enactmentDatetime
|
||||
change {
|
||||
... on NewMarket {
|
||||
__typename
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ export type ProposalOfMarketQueryVariables = Types.Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type ProposalOfMarketQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal' } | { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', enactmentDatetime?: any | null } } | null };
|
||||
export type ProposalOfMarketQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal', id?: string | null, batchTerms?: { __typename?: 'BatchProposalTerms', changes: Array<{ __typename?: 'BatchProposalTermsChange', enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } | null> } | null } | { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', enactmentDatetime?: any | null } } | null };
|
||||
|
||||
export type SuccessorMarketProposalDetailsQueryVariables = Types.Exact<{
|
||||
proposalId: Types.Scalars['ID'];
|
||||
@ -152,6 +152,19 @@ export const ProposalOfMarketDocument = gql`
|
||||
enactmentDatetime
|
||||
}
|
||||
}
|
||||
... on BatchProposal {
|
||||
id
|
||||
batchTerms {
|
||||
changes {
|
||||
enactmentDatetime
|
||||
change {
|
||||
... on NewMarket {
|
||||
__typename
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
2
libs/types/src/__generated__/types.ts
generated
2
libs/types/src/__generated__/types.ts
generated
@ -256,6 +256,8 @@ export type AggregatedLedgerEntry = {
|
||||
toAccountPartyId?: Maybe<Scalars['ID']>;
|
||||
/** Account type, if query was grouped by receiver account type - else null */
|
||||
toAccountType?: Maybe<AccountType>;
|
||||
/** Transfer ID associated with this aggregated ledger entry */
|
||||
transferId: Scalars['ID'];
|
||||
/** Type of the transfer for this ledger entry */
|
||||
transferType?: Maybe<TransferType>;
|
||||
/** RFC3339Nano time from at which this ledger entries records were relevant */
|
||||
|
Loading…
Reference in New Issue
Block a user