import { useState } from 'react' import { Page } from 'web/components/page' import { Col } from 'web/components/layout/col' import { ManifoldLogo } from 'web/components/nav/manifold-logo' import { useSaveReferral } from 'web/hooks/use-save-referral' import { SEO } from 'web/components/SEO' import { Spacer } from 'web/components/layout/spacer' import { firebaseLogin, getUserAndPrivateUser } from 'web/lib/firebase/users' import { track } from 'web/lib/service/analytics' import { Row } from 'web/components/layout/row' import { Button } from 'web/components/button' import { useTracking } from 'web/hooks/use-tracking' import { linkTwitchAccountRedirect } from 'web/lib/twitch/link-twitch-account' import { usePrivateUser, useUser } from 'web/hooks/use-user' import { LoadingIndicator } from 'web/components/loading-indicator' import toast from 'react-hot-toast' export default function TwitchLandingPage() { useSaveReferral() useTracking('view twitch landing page') const user = useUser() const privateUser = usePrivateUser() const twitchUser = privateUser?.twitchInfo?.twitchName const callback = user && privateUser ? () => linkTwitchAccountRedirect(user, privateUser) : async () => { const result = await firebaseLogin() const userId = result.user.uid const { user, privateUser } = await getUserAndPrivateUser(userId) if (!user || !privateUser) return await linkTwitchAccountRedirect(user, privateUser) } const [isLoading, setLoading] = useState(false) const getStarted = async () => { try { setLoading(true) const promise = callback() track('twitch page button click') await promise } catch (e) { console.error(e) toast.error('Failed to sign up. Please try again later.') setLoading(false) } } return (

Bet {' '} on your favorite streams

Get more out of Twitch with play-money betting markets.{' '} {!twitchUser && 'Click the button below to link your Twitch account.'}
{twitchUser ? (
Twitch account linked
{twitchUser}
) : isLoading ? ( ) : ( )}
) }