import { type ReactNode } from 'react'; import BigNumber from 'bignumber.js'; import countBy from 'lodash/countBy'; import { Pill, VegaIcon, VegaIconNames, Tooltip, } from '@vegaprotocol/ui-toolkit'; import { formatNumberRounded } from '@vegaprotocol/utils'; import { type TeamStats as ITeamStats, type Member, } from '../../lib/hooks/use-team'; import { useT } from '../../lib/use-t'; import { DispatchMetricLabels, type DispatchMetric } from '@vegaprotocol/types'; import classNames from 'classnames'; import { type TeamGame } from '../../lib/hooks/use-games'; export const TeamStats = ({ stats, members, games, }: { stats?: ITeamStats; members?: Member[]; games?: TeamGame[]; }) => { const t = useT(); return ( <> {games && games.length ? ( ) : null} ); }; const LatestResults = ({ games }: { games: TeamGame[] }) => { const t = useT(); const latestGames = games.slice(0, 5); return (
{t('gameCount', { count: latestGames.length })}
{latestGames.map((game) => { return ( {t('place', { count: game.team.rank, ordinal: true })} ); })}
); }; export const FavoriteGame = ({ games, noLabel = false, }: { games: TeamGame[]; noLabel?: boolean; }) => { const t = useT(); const rewardMetrics = games.map( (game) => game.team.rewardMetric as DispatchMetric ); const count = countBy(rewardMetrics); let favoriteMetric = ''; let mostOccurances = 0; for (const key in count) { if (count[key] > mostOccurances) { favoriteMetric = key; mostOccurances = count[key]; } } if (!favoriteMetric) return null; // rewardMetric is a string, should be typed as DispatchMetric const favoriteMetricLabel = DispatchMetricLabels[favoriteMetric as DispatchMetric]; return (
{t('Favorite game')}
{' '} {favoriteMetricLabel}
); }; export const StatSection = ({ children }: { children: ReactNode }) => { return (
{children}
); }; export const StatSectionSeparator = () => { return
; }; export const StatList = ({ children }: { children: ReactNode }) => { return (
{children}
); }; export const Stat = ({ value, label, tooltip, valueTestId, className, }: { value: ReactNode; label: ReactNode; tooltip?: string; valueTestId?: string; className?: classNames.Argument; }) => { return (
{value}
{tooltip ? ( {label} ) : ( label )}
); };