import classNames from 'classnames'; import { t } from '@vegaprotocol/i18n'; import { ExternalLink, Intent, TradingButton, VegaIcon, VegaIconNames, } from '@vegaprotocol/ui-toolkit'; import { GetWalletButton, useVegaWallet, useVegaWalletDialogStore, } from '@vegaprotocol/wallet'; import { Networks, useEnvironment } from '@vegaprotocol/environment'; import { useLocalStorage } from '@vegaprotocol/react-helpers'; import { useNavigate } from 'react-router-dom'; import { OnboardingStep, useGetOnboardingStep, } from './use-get-onboarding-step'; import { Links, Routes } from '../../pages/client-router'; import { useGlobalStore } from '../../stores'; import { useSidebar, ViewType } from '../sidebar'; import * as constants from '../constants'; interface Props { lead?: string; } const GetStartedButton = ({ step }: { step: OnboardingStep }) => { const navigate = useNavigate(); const [, setOnboardingViewed] = useLocalStorage( constants.ONBOARDING_VIEWED_KEY ); const update = useGlobalStore((store) => store.update); const marketId = useGlobalStore((store) => store.marketId); const link = marketId ? Links[Routes.MARKET](marketId) : Links[Routes.HOME](); const openVegaWalletDialog = useVegaWalletDialogStore( (store) => store.openVegaWalletDialog ); const setView = useSidebar((store) => store.setView); let buttonText = t('Get started'); let onClickHandle = () => { openVegaWalletDialog(); }; if (step === OnboardingStep.ONBOARDING_WALLET_STEP) { return ; } else if (step === OnboardingStep.ONBOARDING_CONNECT_STEP) { buttonText = t('Connect'); } else if (step === OnboardingStep.ONBOARDING_DEPOSIT_STEP) { buttonText = t('Deposit'); onClickHandle = () => { navigate(link); setView({ type: ViewType.Deposit }); update({ onBoardingDismissed: true }); }; } else if (step === OnboardingStep.ONBOARDING_ORDER_STEP) { buttonText = t('Dismiss'); onClickHandle = () => { navigate(link); setView({ type: ViewType.Order }); setOnboardingViewed('true'); }; } return ( {buttonText} ); }; export const GetStarted = ({ lead }: Props) => { const { pubKey } = useVegaWallet(); const { VEGA_ENV, VEGA_NETWORKS } = useEnvironment(); const CANONICAL_URL = VEGA_NETWORKS[VEGA_ENV] || 'https://console.vega.xyz'; const [onBoardingViewed] = useLocalStorage(constants.ONBOARDING_VIEWED_KEY); const currentStep = useGetOnboardingStep(); const openVegaWalletDialog = useVegaWalletDialogStore( (store) => store.openVegaWalletDialog ); const getStartedNeeded = onBoardingViewed !== 'true' && currentStep && currentStep < OnboardingStep.ONBOARDING_COMPLETE_STEP; const wrapperClasses = classNames( 'flex flex-col py-4 px-6 gap-4 rounded', 'bg-vega-blue-300 dark:bg-vega-blue-700', 'border border-vega-blue-350 dark:border-vega-blue-650', { 'mt-8': !lead } ); if (getStartedNeeded) { return (
{lead &&

{lead}

}

{t('Get started')}

    OnboardingStep.ONBOARDING_WALLET_STEP} /> OnboardingStep.ONBOARDING_CONNECT_STEP || pubKey )} /> OnboardingStep.ONBOARDING_DEPOSIT_STEP} /> OnboardingStep.ONBOARDING_ORDER_STEP} />
{VEGA_ENV === Networks.MAINNET && (

{t('Experiment for free with virtual assets on')}{' '} {t('Fairground Testnet')}

)} {VEGA_ENV === Networks.TESTNET && (

{t('Ready to trade with real funds?')}{' '} {t('Switch to Mainnet')}

)}
); } if (!pubKey) { return (

You need a{' '} Vega wallet {' '} to start trading in this market.

{t('Connect wallet')}
); } return null; }; const Step = ({ step, text, complete, }: { step: number; text: string; complete: boolean; }) => { return (
  • {complete ? : {step}.}
    {text}
  • ); }; const Tick = () => { return ( ); };