import { useEffect } from 'react' import { useHistory, useLocation } from 'react-router-dom' import { Row, Col, Card } from 'antd' import WelcomeSlide from './welcomeSlide' import SocialButton from './socialButton' import WalletConnection from 'view/wallet/login/walletConnection' import { useRootSelector, RootState } from 'store' import { useWalletAddress } from 'hooks/useWallet' import { useAppIds } from 'hooks/useAppIds' import { isAddress } from 'shared/util' import { useWidth } from 'hooks/useUI' import './index.os.less' const Welcome = () => { const history = useHistory() const { search } = useLocation() const loading = useRootSelector(({ flags }: RootState) => flags.loading) const walletAddress = useWalletAddress() const appIds = useAppIds() const width = useWidth() // Redirect callback useEffect(() => { const params = new URLSearchParams(search) const fallback = appIds.length ? `/app/${appIds[0]}` : '/store' const redirect = decodeURIComponent(params.get('redirect') || fallback) if (isAddress(walletAddress) && !loading) history.replace(redirect) }, [walletAddress, history, search, appIds, loading]) return ( {width >= 992 && ( )} ) } export default Welcome