import classNames from 'classnames';
import {
ExternalLink,
Intent,
TradingAnchorButton,
TradingButton,
VegaIcon,
VegaIconNames,
} from '@vegaprotocol/ui-toolkit';
import { useVegaWallet, useDialogStore } from '@vegaprotocol/wallet-react';
import { Networks, useEnvironment } from '@vegaprotocol/environment';
import { useOnboardingStore } from '../../stores/onboarding';
import {
OnboardingStep,
useGetOnboardingStep,
} from '../../lib/hooks/use-get-onboarding-step';
import { Links, Routes } from '../../lib/links';
import { useGlobalStore } from '../../stores';
import { useSidebar, ViewType } from '../sidebar';
import { useT } from '../../lib/use-t';
import { Trans } from 'react-i18next';
interface Props {
lead?: string;
}
const GetStartedButton = ({ step }: { step: OnboardingStep }) => {
const t = useT();
const { VEGA_ENV } = useEnvironment();
const dismiss = useOnboardingStore((store) => store.dismiss);
const setDialog = useOnboardingStore((store) => store.setDialog);
const risk = useOnboardingStore((store) => store.risk);
const marketId = useGlobalStore((store) => store.marketId);
const setViews = useSidebar((store) => store.setViews);
const buttonProps = {
size: 'small' as const,
'data-testid': 'get-started-button',
intent: Intent.Info,
};
if (step <= OnboardingStep.ONBOARDING_CONNECT_STEP) {
return (
{
if (VEGA_ENV === Networks.MAINNET && risk !== 'accepted') {
setDialog('risk');
} else {
setDialog('connect');
}
}}
>
{t('Connect')}
);
} else if (step === OnboardingStep.ONBOARDING_DEPOSIT_STEP) {
return (
setDialog('inactive')}
>
{t('Deposit')}
);
} else if (step >= OnboardingStep.ONBOARDING_ORDER_STEP) {
const link = marketId ? Links.MARKET(marketId) : Links.HOME();
return (
{
setViews({ type: ViewType.Order }, Routes.MARKET);
dismiss();
}}
>
{t('Ready to trade')}
);
}
return (
setDialog('connect')}>
{t('Get started')}
);
};
export const GetStartedCheckList = () => {
const t = useT();
const { pubKey } = useVegaWallet();
const currentStep = useGetOnboardingStep();
return (
OnboardingStep.ONBOARDING_CONNECT_STEP || pubKey
)}
/>
OnboardingStep.ONBOARDING_DEPOSIT_STEP}
/>
OnboardingStep.ONBOARDING_ORDER_STEP}
/>
);
};
export const GetStarted = ({ lead }: Props) => {
const t = useT();
const { pubKey } = useVegaWallet();
const { VEGA_ENV, VEGA_NETWORKS } = useEnvironment();
const openVegaWalletDialog = useDialogStore((store) => store.open);
const currentStep = useGetOnboardingStep();
const dismissed = useOnboardingStore((store) => store.dismissed);
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 (!dismissed) {
return (
{lead &&
{lead}
}
{t('Get started')}
{VEGA_ENV === Networks.MAINNET && (
Fairground Testnet
,
]}
/>
)}
{VEGA_ENV === Networks.TESTNET && (
Switch to Mainnet
,
]}
/>
)}
);
}
if (!pubKey) {
return (
Vega wallet
,
]}
/>
{t('Connect wallet')}
);
}
return null;
};
const Step = ({
step,
text,
complete,
}: {
step: number;
text: string;
complete: boolean;
}) => {
return (
{complete ? : {step}.}
{text}
);
};
const Tick = () => {
return (
);
};