chore(trading): referrals stats tweaks (#5160)

This commit is contained in:
Matthew Russell 2023-11-01 03:06:36 -07:00 committed by GitHub
parent 6421cf87c6
commit 4af9979a21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 37 deletions

View File

@ -71,7 +71,7 @@ export const useReferral = (args: UseReferralArgs) => {
variables: { variables: {
code: referralSet?.id as string, code: referralSet?.id as string,
aggregationEpochs: aggregationEpochs:
args.aggregationEpochs != null args.aggregationEpochs !== null
? args.aggregationEpochs ? args.aggregationEpochs
: DEFAULT_AGGREGATION_DAYS, : DEFAULT_AGGREGATION_DAYS,
}, },

View File

@ -3,6 +3,8 @@ import {
VegaIcon, VegaIcon,
VegaIconNames, VegaIconNames,
truncateMiddle, truncateMiddle,
ExternalLink,
Tooltip,
} from '@vegaprotocol/ui-toolkit'; } from '@vegaprotocol/ui-toolkit';
import { useVegaWallet } from '@vegaprotocol/wallet'; import { useVegaWallet } from '@vegaprotocol/wallet';
@ -28,6 +30,7 @@ import { useCurrentEpochInfoQuery } from './hooks/__generated__/Epoch';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import maxBy from 'lodash/maxBy'; import maxBy from 'lodash/maxBy';
import { DocsLinks } from '@vegaprotocol/environment';
export const ReferralStatistics = () => { export const ReferralStatistics = () => {
const { pubKey } = useVegaWallet(); const { pubKey } = useVegaWallet();
@ -201,7 +204,7 @@ export const Statistics = ({
'Total commission (last %s epochs)', 'Total commission (last %s epochs)',
(details?.windowLength || DEFAULT_AGGREGATION_DAYS).toString() (details?.windowLength || DEFAULT_AGGREGATION_DAYS).toString()
)} )}
description={t('(qUSD)')} description={<QUSDTooltip />}
> >
{getNumberFormat(0).format(Number(totalCommissionValue))} {getNumberFormat(0).format(Number(totalCommissionValue))}
</StatTile> </StatTile>
@ -233,7 +236,12 @@ export const Statistics = ({
<StatTile title={t('Discount')}>{discountFactorValue * 100}%</StatTile> <StatTile title={t('Discount')}>{discountFactorValue * 100}%</StatTile>
); );
const runningVolumeTile = ( const runningVolumeTile = (
<StatTile title={t('Combined volume')}> <StatTile
title={t(
'Combined volume (last %s epochs)',
details?.windowLength.toString()
)}
>
{compactNumFormat.format(runningVolumeValue)} {compactNumFormat.format(runningVolumeValue)}
</StatTile> </StatTile>
); );
@ -241,24 +249,14 @@ export const Statistics = ({
<StatTile title={t('Epochs in set')}>{epochsValue}</StatTile> <StatTile title={t('Epochs in set')}>{epochsValue}</StatTile>
); );
const nextTierVolumeTile = ( const nextTierVolumeTile = (
<StatTile <StatTile title={t('Volume to next tier')}>
title={t(
'Volume to next tier %s',
nextBenefitTierValue?.tier ? `(${nextBenefitTierValue.tier})` : ''
)}
>
{nextBenefitTierVolumeValue <= 0 {nextBenefitTierVolumeValue <= 0
? '0' ? '0'
: compactNumFormat.format(nextBenefitTierVolumeValue)} : compactNumFormat.format(nextBenefitTierVolumeValue)}
</StatTile> </StatTile>
); );
const nextTierEpochsTile = ( const nextTierEpochsTile = (
<StatTile <StatTile title={t('Epochs to next tier')}>
title={t(
'Epochs to next tier %s',
nextBenefitTierValue?.tier ? `(${nextBenefitTierValue.tier})` : ''
)}
>
{nextBenefitTierEpochsValue <= 0 ? '0' : nextBenefitTierEpochsValue} {nextBenefitTierEpochsValue <= 0 ? '0' : nextBenefitTierEpochsValue}
</StatTile> </StatTile>
); );
@ -339,11 +337,16 @@ export const Statistics = ({
}, },
{ {
name: 'commission', name: 'commission',
displayName: t( displayName: (
'Commission earned (last %s epochs)', <>
( {t('Commission earned in')} <QUSDTooltip />{' '}
details?.windowLength || DEFAULT_AGGREGATION_DAYS {t(
).toString() '(last %s epochs)',
(
details?.windowLength || DEFAULT_AGGREGATION_DAYS
).toString()
)}
</>
), ),
}, },
]} ]}
@ -373,3 +376,25 @@ export const Statistics = ({
</> </>
); );
}; };
export const QUSDTooltip = () => (
<Tooltip
description={
<>
<p className="mb-1">
{t(
'qUSD provides a rough USD equivalent of balances across all assets using the value of "Quantum" for that asset'
)}
</p>
{DocsLinks && (
<ExternalLink href={DocsLinks.QUANTUM}>
{t('Find out more')}
</ExternalLink>
)}
</>
}
underline={true}
>
<span>{t('qUSD')}</span>
</Tooltip>
);

View File

@ -1,10 +1,10 @@
import { Tooltip, VegaIcon, VegaIconNames } from '@vegaprotocol/ui-toolkit'; import { Tooltip, VegaIcon, VegaIconNames } from '@vegaprotocol/ui-toolkit';
import classNames from 'classnames'; import classNames from 'classnames';
import { forwardRef, type HTMLAttributes } from 'react'; import { forwardRef, type ReactNode, type HTMLAttributes } from 'react';
import { BORDER_COLOR, GRADIENT } from './constants'; import { BORDER_COLOR, GRADIENT } from './constants';
type TableColumnDefinition = { type TableColumnDefinition = {
displayName?: string; displayName?: ReactNode;
name: string; name: string;
tooltip?: string; tooltip?: string;
className?: string; className?: string;
@ -46,7 +46,7 @@ export const Table = forwardRef<
INNER_BORDER_STYLE INNER_BORDER_STYLE
)} )}
> >
<span className="flex flex-row gap-2 items-center"> <span className="flex flex-row items-center gap-2">
<span>{displayName}</span> <span>{displayName}</span>
{tooltip ? ( {tooltip ? (
<Tooltip description={tooltip}> <Tooltip description={tooltip}>
@ -102,17 +102,14 @@ export const Table = forwardRef<
key={`${i}-${name}`} key={`${i}-${name}`}
> >
{/** display column name in mobile view */} {/** display column name in mobile view */}
{!noCollapse && {!noCollapse && !noHeader && displayName && (
!noHeader && <span
displayName && aria-hidden
displayName.length > 0 && ( className="px-0 font-mono text-xs md:hidden text-vega-clight-100 dark:text-vega-cdark-100"
<span >
aria-hidden {displayName}
className="md:hidden font-mono text-xs px-0 text-vega-clight-100 dark:text-vega-cdark-100" </span>
> )}
{displayName}
</span>
)}
<span>{d[name]}</span> <span>{d[name]}</span>
</td> </td>
))} ))}

View File

@ -29,7 +29,7 @@ export const Tile = ({
type StatTileProps = { type StatTileProps = {
title: string; title: string;
description?: string; description?: ReactNode;
children?: ReactNode; children?: ReactNode;
}; };
export const StatTile = ({ title, description, children }: StatTileProps) => { export const StatTile = ({ title, description, children }: StatTileProps) => {
@ -67,11 +67,11 @@ export const CodeTile = ({
title={t('Your referral code')} title={t('Your referral code')}
description={createdAt ? t('(Created at: %s)', createdAt) : undefined} description={createdAt ? t('(Created at: %s)', createdAt) : undefined}
> >
<div className="flex gap-2 items-center justify-between"> <div className="flex items-center justify-between gap-2">
<Tooltip <Tooltip
description={ description={
<div className="break-all"> <div className="break-all">
<span className="text-xl bg-rainbow bg-clip-text text-transparent"> <span className="text-xl text-transparent bg-rainbow bg-clip-text">
{code} {code}
</span> </span>
</div> </div>

View File

@ -84,6 +84,7 @@ export const DocsLinks = VEGA_DOCS_URL
ETH_DATA_SOURCES: `${VEGA_DOCS_URL}/concepts/trading-on-vega/data-sources#ethereum-data-sources`, ETH_DATA_SOURCES: `${VEGA_DOCS_URL}/concepts/trading-on-vega/data-sources#ethereum-data-sources`,
ICEBERG_ORDERS: `${VEGA_DOCS_URL}/concepts/trading-on-vega/orders#iceberg-order`, ICEBERG_ORDERS: `${VEGA_DOCS_URL}/concepts/trading-on-vega/orders#iceberg-order`,
POST_REDUCE_ONLY: `${VEGA_DOCS_URL}/concepts/trading-on-vega/orders#conditional-order-parameters`, POST_REDUCE_ONLY: `${VEGA_DOCS_URL}/concepts/trading-on-vega/orders#conditional-order-parameters`,
QUANTUM: `${VEGA_DOCS_URL}/concepts/assets/asset-framework#quantum`,
} }
: undefined; : undefined;