From 4af9979a21236738a851a6045225338f4df198b3 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Wed, 1 Nov 2023 03:06:36 -0700 Subject: [PATCH] chore(trading): referrals stats tweaks (#5160) --- .../referrals/hooks/use-referral.ts | 2 +- .../referrals/referral-statistics.tsx | 63 +++++++++++++------ apps/trading/client-pages/referrals/table.tsx | 25 ++++---- apps/trading/client-pages/referrals/tile.tsx | 6 +- libs/environment/src/hooks/use-links.ts | 1 + 5 files changed, 60 insertions(+), 37 deletions(-) diff --git a/apps/trading/client-pages/referrals/hooks/use-referral.ts b/apps/trading/client-pages/referrals/hooks/use-referral.ts index 28deb09f5..67f471bad 100644 --- a/apps/trading/client-pages/referrals/hooks/use-referral.ts +++ b/apps/trading/client-pages/referrals/hooks/use-referral.ts @@ -71,7 +71,7 @@ export const useReferral = (args: UseReferralArgs) => { variables: { code: referralSet?.id as string, aggregationEpochs: - args.aggregationEpochs != null + args.aggregationEpochs !== null ? args.aggregationEpochs : DEFAULT_AGGREGATION_DAYS, }, diff --git a/apps/trading/client-pages/referrals/referral-statistics.tsx b/apps/trading/client-pages/referrals/referral-statistics.tsx index 7a89288d1..69e10d30c 100644 --- a/apps/trading/client-pages/referrals/referral-statistics.tsx +++ b/apps/trading/client-pages/referrals/referral-statistics.tsx @@ -3,6 +3,8 @@ import { VegaIcon, VegaIconNames, truncateMiddle, + ExternalLink, + Tooltip, } from '@vegaprotocol/ui-toolkit'; import { useVegaWallet } from '@vegaprotocol/wallet'; @@ -28,6 +30,7 @@ import { useCurrentEpochInfoQuery } from './hooks/__generated__/Epoch'; import BigNumber from 'bignumber.js'; import { t } from '@vegaprotocol/i18n'; import maxBy from 'lodash/maxBy'; +import { DocsLinks } from '@vegaprotocol/environment'; export const ReferralStatistics = () => { const { pubKey } = useVegaWallet(); @@ -201,7 +204,7 @@ export const Statistics = ({ 'Total commission (last %s epochs)', (details?.windowLength || DEFAULT_AGGREGATION_DAYS).toString() )} - description={t('(qUSD)')} + description={} > {getNumberFormat(0).format(Number(totalCommissionValue))} @@ -233,7 +236,12 @@ export const Statistics = ({ {discountFactorValue * 100}% ); const runningVolumeTile = ( - + {compactNumFormat.format(runningVolumeValue)} ); @@ -241,24 +249,14 @@ export const Statistics = ({ {epochsValue} ); const nextTierVolumeTile = ( - + {nextBenefitTierVolumeValue <= 0 ? '0' : compactNumFormat.format(nextBenefitTierVolumeValue)} ); const nextTierEpochsTile = ( - + {nextBenefitTierEpochsValue <= 0 ? '0' : nextBenefitTierEpochsValue} ); @@ -339,11 +337,16 @@ export const Statistics = ({ }, { name: 'commission', - displayName: t( - 'Commission earned (last %s epochs)', - ( - details?.windowLength || DEFAULT_AGGREGATION_DAYS - ).toString() + displayName: ( + <> + {t('Commission earned in')} {' '} + {t( + '(last %s epochs)', + ( + details?.windowLength || DEFAULT_AGGREGATION_DAYS + ).toString() + )} + ), }, ]} @@ -373,3 +376,25 @@ export const Statistics = ({ ); }; + +export const QUSDTooltip = () => ( + +

+ {t( + 'qUSD provides a rough USD equivalent of balances across all assets using the value of "Quantum" for that asset' + )} +

+ {DocsLinks && ( + + {t('Find out more')} + + )} + + } + underline={true} + > + {t('qUSD')} +
+); diff --git a/apps/trading/client-pages/referrals/table.tsx b/apps/trading/client-pages/referrals/table.tsx index f0f424642..8094607ea 100644 --- a/apps/trading/client-pages/referrals/table.tsx +++ b/apps/trading/client-pages/referrals/table.tsx @@ -1,10 +1,10 @@ import { Tooltip, VegaIcon, VegaIconNames } from '@vegaprotocol/ui-toolkit'; import classNames from 'classnames'; -import { forwardRef, type HTMLAttributes } from 'react'; +import { forwardRef, type ReactNode, type HTMLAttributes } from 'react'; import { BORDER_COLOR, GRADIENT } from './constants'; type TableColumnDefinition = { - displayName?: string; + displayName?: ReactNode; name: string; tooltip?: string; className?: string; @@ -46,7 +46,7 @@ export const Table = forwardRef< INNER_BORDER_STYLE )} > - + {displayName} {tooltip ? ( @@ -102,17 +102,14 @@ export const Table = forwardRef< key={`${i}-${name}`} > {/** display column name in mobile view */} - {!noCollapse && - !noHeader && - displayName && - displayName.length > 0 && ( - - {displayName} - - )} + {!noCollapse && !noHeader && displayName && ( + + {displayName} + + )} {d[name]} ))} diff --git a/apps/trading/client-pages/referrals/tile.tsx b/apps/trading/client-pages/referrals/tile.tsx index 3fe4bbbe1..fc2a9966e 100644 --- a/apps/trading/client-pages/referrals/tile.tsx +++ b/apps/trading/client-pages/referrals/tile.tsx @@ -29,7 +29,7 @@ export const Tile = ({ type StatTileProps = { title: string; - description?: string; + description?: ReactNode; children?: ReactNode; }; export const StatTile = ({ title, description, children }: StatTileProps) => { @@ -67,11 +67,11 @@ export const CodeTile = ({ title={t('Your referral code')} description={createdAt ? t('(Created at: %s)', createdAt) : undefined} > -
+
- + {code}
diff --git a/libs/environment/src/hooks/use-links.ts b/libs/environment/src/hooks/use-links.ts index 1e3c8b58a..f099b07c6 100644 --- a/libs/environment/src/hooks/use-links.ts +++ b/libs/environment/src/hooks/use-links.ts @@ -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`, 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`, + QUANTUM: `${VEGA_DOCS_URL}/concepts/assets/asset-framework#quantum`, } : undefined;