import { useEffect } from 'react';
import { matchPath, useLocation } from 'react-router-dom';
import { Dialog, Intent } from '@vegaprotocol/ui-toolkit';
import {
ConnectionStatus,
useConnect,
useWallet,
Links,
RiskAck,
ConnectionOptionRecord,
ConnectionOptionDefault,
} from '@vegaprotocol/wallet-react';
import { ConnectorErrors } from '@vegaprotocol/wallet';
import { ensureSuffix } from '@vegaprotocol/utils';
import { useT } from '../../lib/use-t';
import { Routes } from '../../lib/links';
import { WelcomeDialogContent } from './welcome-dialog-content';
import {
useOnboardingStore,
type OnboardingDialog,
} from '../../stores/onboarding';
import { RiskAckContent } from '../risk-ack-content';
/**
* A list of paths on which the welcome dialog should be omitted.
*/
const OMIT_ON_LIST = [ensureSuffix(Routes.REFERRALS, '/*')];
export const WelcomeDialog = () => {
const { pathname } = useLocation();
const dismissed = useOnboardingStore((store) => store.dismissed);
const dialog = useOnboardingStore((store) => store.dialog);
const dismiss = useOnboardingStore((store) => store.dismiss);
const setDialog = useOnboardingStore((store) => store.setDialog);
useEffect(() => {
const shouldOmit = OMIT_ON_LIST.map((path) =>
matchPath(path, pathname)
).some((m) => !!m);
if (dismissed || shouldOmit) return;
setDialog('intro');
}, [dismissed, pathname, setDialog]);
const onClose = () => {
if (dialog === 'connect' || dialog === 'risk') {
setDialog('intro');
} else {
setDialog('inactive');
dismiss();
}
};
return (
);
};
const DialogStepSwitch = ({
dialog,
onConnect,
}: {
dialog: OnboardingDialog;
onConnect: () => void;
}) => {
const accept = useOnboardingStore((store) => store.acceptRisk);
const reject = useOnboardingStore((store) => store.rejectRisk);
const setDialog = useOnboardingStore((store) => store.setDialog);
if (dialog === 'intro') {
return
{error.message}
)} Dont have a wallet?