import { useSearchParams } from 'react-router-dom'; import { Intent, TradingAnchorButton } from '@vegaprotocol/ui-toolkit'; import { useVegaWallet, useVegaWalletDialogStore } from '@vegaprotocol/wallet'; import { addDecimalsFormatNumber } from '@vegaprotocol/utils'; import { useT } from '../../lib/use-t'; import { useReferralSetTransaction } from '../../lib/hooks/use-referral-set-transaction'; import { DApp, TokenStaticLinks, useLinks } from '@vegaprotocol/environment'; import { RainbowButton } from '../../components/rainbow-button'; import { usePageTitle } from '../../lib/hooks/use-page-title'; import { ErrorBoundary } from '../../components/error-boundary'; import { Box } from '../../components/competitions/box'; import { LayoutWithGradient } from '../../components/layouts-inner'; import { Links } from '../../lib/links'; import { TeamForm, TransactionType } from './team-form'; export const CompetitionsCreateTeam = () => { const [searchParams] = useSearchParams(); const isSolo = Boolean(searchParams.get('solo')); const t = useT(); usePageTitle(t('Create a team')); const { isReadOnly, pubKey } = useVegaWallet(); const openWalletDialog = useVegaWalletDialogStore( (store) => store.openVegaWalletDialog ); return (

{isSolo ? t('Create solo team') : t('Create a team')}

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

{t( 'Create a team to participate in team based rewards as well as access the discount benefits of the current referral program.' )}

{t('Connect wallet')} )}
); }; const CreateTeamFormContainer = ({ isSolo }: { isSolo: boolean }) => { const t = useT(); const createLink = useLinks(DApp.Governance); const { err, status, code, isEligible, requiredStake, onSubmit } = useReferralSetTransaction({ onSuccess: (code) => { // For some reason team creation takes a long time, too long even to make // polling viable, so its not feasible to navigate to the team page // after creation // // navigate(Links.COMPETITIONS_TEAM(code)); }, }); if (status === 'confirmed') { return (

{t('Team creation transaction successful')}

{code && ( <>

Your team ID is:{' '} {code}

{t('View team')} )}
); } if (!isEligible) { return (
{requiredStake !== undefined && (

{t( 'You need at least {{requiredStake}} VEGA staked to generate a referral code and participate in the referral program.', { requiredStake: addDecimalsFormatNumber( requiredStake.toString(), 18 ), } )}

)} {t('Stake some $VEGA now')}
); } return ( ); };