import { ErrorBoundary } from '../../components/error-boundary'; import { usePageTitle } from '../../lib/hooks/use-page-title'; import { Box } from '../../components/competitions/box'; import { useT } from '../../lib/use-t'; import { useVegaWallet, useVegaWalletDialogStore } from '@vegaprotocol/wallet'; import { Intent, Loader, Splash, TradingAnchorButton, VegaIcon, VegaIconNames, } from '@vegaprotocol/ui-toolkit'; import { RainbowButton } from '../../components/rainbow-button'; import { Link, Navigate, useParams } from 'react-router-dom'; import { Links } from '../../lib/links'; import { useReferralSetTransaction } from '../../lib/hooks/use-referral-set-transaction'; import { type FormFields, TeamForm, TransactionType } from './team-form'; import { useTeam } from '../../lib/hooks/use-team'; import { LayoutWithGradient } from '../../components/layouts-inner'; import { useEffect, useState } from 'react'; export const CompetitionsUpdateTeam = () => { const t = useT(); usePageTitle([t('Competitions'), t('Update a team')]); const { pubKey, isReadOnly } = useVegaWallet(); const openWalletDialog = useVegaWalletDialogStore( (store) => store.openVegaWalletDialog ); const { teamId } = useParams<{ teamId: string }>(); if (!teamId) { return ; } return (
{' '} {t('Go back to the team profile')}

{t('Update a team')}

{pubKey && !isReadOnly ? ( ) : ( <>

{t('Connect to update the details of your team.')}

{t('Connect wallet')} )}
); }; const UpdateTeamFormContainer = ({ teamId, pubKey, }: { teamId: string; pubKey: string; }) => { const t = useT(); const [refetching, setRefetching] = useState(false); const { team, loading, error, refetch } = useTeam(teamId, pubKey); const { err, status, onSubmit } = useReferralSetTransaction({ onSuccess: () => { // NOOP }, }); // refetch when saved useEffect(() => { if (refetch && status === 'confirmed') { refetch(); setRefetching(true); } }, [refetch, status]); if (loading && !refetching) { return ; } if (error) { return ( {t('Something went wrong.')} {t("Go back to the team's profile")} ); } const isMyTeam = team?.referrer === pubKey; if (!isMyTeam) { return ; } if (status === 'confirmed') { return (

{' '} {t('Changes successfully saved to your team.')}

{t('View team')}
); } const defaultValues: FormFields = { id: team.teamId, name: team.name, url: team.teamUrl, avatarUrl: team.avatarUrl, private: team.closed, allowList: team.allowList.join(','), }; return ( ); };