From 62ecaaa9ceef8065a7cf8551946b21fb819ef68b Mon Sep 17 00:00:00 2001 From: Art Date: Wed, 20 Mar 2024 18:17:05 +0100 Subject: [PATCH] feat(trading): team profile improvements (#6054) Co-authored-by: Dariusz Majcherczyk --- .../competitions/competitions-team.tsx | 107 ++++++++++++++++-- .../client-pages/competitions/join-team.tsx | 41 ++++++- .../competitions/competitions-leaderboard.tsx | 2 +- apps/trading/e2e/tests/teams/test_teams.py | 9 +- libs/i18n/src/locales/en/trading.json | 9 +- 5 files changed, 153 insertions(+), 15 deletions(-) diff --git a/apps/trading/client-pages/competitions/competitions-team.tsx b/apps/trading/client-pages/competitions/competitions-team.tsx index e0fd44a79..37e1f53e9 100644 --- a/apps/trading/client-pages/competitions/competitions-team.tsx +++ b/apps/trading/client-pages/competitions/competitions-team.tsx @@ -9,6 +9,10 @@ import { Button, VegaIcon, VegaIconNames, + Tooltip, + TradingAnchorButton, + Intent, + CopyWithTooltip, } from '@vegaprotocol/ui-toolkit'; import { TransferStatus, type Asset } from '@vegaprotocol/types'; import classNames from 'classnames'; @@ -18,6 +22,7 @@ import { addDecimalsFormatNumberQuantum, formatNumber, getDateTimeFormat, + removePaginationWrapper, } from '@vegaprotocol/utils'; import { useTeam, @@ -52,6 +57,7 @@ import { ActiveRewardCard, DispatchMetricInfo, } from '../../components/rewards-container/reward-card'; +import { usePartyProfilesQuery } from '../../components/vega-wallet-connect-button/__generated__/PartyProfiles'; export const CompetitionsTeam = () => { const t = useT(); @@ -140,11 +146,25 @@ const TeamPage = ({ const t = useT(); const [showGames, setShowGames] = useState(true); + const createdAt = new Date(team.createdAt); + + const closedIndicator = team.closed ? ( +
+ + {t('Private')} +
+ ) : ( +
+ + {t('Public')} +
+ ); + return (
-
+

+ {team.teamUrl && team.teamUrl.length > 0 && ( + + + + + + + + )} + + + +

+
+ {closedIndicator} +
+ {t('Created at')}:{' '} + + {getDateTimeFormat().format(createdAt)} + {' '} + ({t('epoch')}: {team.createdAtEpoch}) +
@@ -331,13 +383,30 @@ const Games = ({ const Members = ({ members }: { members?: Member[] }) => { const t = useT(); + const partyIds = members?.map((m) => m.referee) || []; + const { data: profilesData } = usePartyProfilesQuery({ + variables: { + partyIds, + }, + skip: partyIds.length === 0, + }); + const profiles = removePaginationWrapper( + profilesData?.partiesProfilesConnection?.edges + ); + if (!members?.length) { return

{t('No members')}

; } const data = orderBy( members.map((m) => ({ - referee: , + referee: ( + + ), rewards: formatNumber(m.totalQuantumRewards), volume: formatNumber(m.totalQuantumVolume), gamesPlayed: formatNumber(m.totalGamesPlayed), @@ -351,7 +420,7 @@ const Members = ({ members }: { members?: Member[] }) => { return ( { const RefereeLink = ({ pubkey, isCreator, + profiles, }: { pubkey: string; isCreator: boolean; + profiles?: { partyId: string; alias: string }[]; }) => { const t = useT(); const linkCreator = useLinks(DApp.Explorer); const link = linkCreator(EXPLORER_PARTIES.replace(':id', pubkey)); + const alias = profiles?.find((p) => p.partyId === pubkey)?.alias; + return ( - <> +
- {truncateMiddle(pubkey)} - {' '} - {isCreator ? t('Owner') : ''} - + {alias || truncateMiddle(pubkey)} + + {!alias && ( + + + + )} + {alias && ( + {truncateMiddle(pubkey)} + )} + {isCreator && ( + + {t('Owner')} + + )} +
); }; diff --git a/apps/trading/client-pages/competitions/join-team.tsx b/apps/trading/client-pages/competitions/join-team.tsx index 156d52586..cec268331 100644 --- a/apps/trading/client-pages/competitions/join-team.tsx +++ b/apps/trading/client-pages/competitions/join-team.tsx @@ -70,6 +70,12 @@ export const JoinButton = ({ }) => { const t = useT(); + /** + * A team cannot be joined (closed) when set as such + * and the currently connected pubkey is not whitelisted. + */ + const isTeamClosed = team.closed && !team.allowList.includes(pubKey || ''); + if (!pubKey || isReadOnly) { return ( @@ -79,8 +85,9 @@ export const JoinButton = ({ ); } + // Party is the creator of a team - else if (partyTeam && partyTeam.referrer === pubKey) { + if (partyTeam && partyTeam.referrer === pubKey) { // Party is the creator of THIS team if (partyTeam.teamId === team.teamId) { return ( @@ -105,8 +112,24 @@ export const JoinButton = ({ ); } } + // Party is in a team, but not this one - else if (partyTeam && partyTeam.teamId !== team.teamId) { + if (partyTeam && partyTeam.teamId !== team.teamId) { + // This team is closed. + if (isTeamClosed) { + return ( + + + + ); + } + // This team is open. return ( ); } + // Joined. Current party is already in this team - else if (partyTeam && partyTeam.teamId === team.teamId) { + if (partyTeam && partyTeam.teamId === team.teamId) { return ( + + ); + } + // This team is open. return (