Added clean error handling in case of Twitch link fail.

This commit is contained in:
Phil 2022-09-03 17:08:35 +01:00
parent 6eb4286053
commit 1b8dff909f

View File

@ -14,6 +14,7 @@ import { useTracking } from 'web/hooks/use-tracking'
import { linkTwitchAccount } from 'web/lib/twitch/link-twitch-account' import { linkTwitchAccount } from 'web/lib/twitch/link-twitch-account'
import { usePrivateUser, useUser } from 'web/hooks/use-user' import { usePrivateUser, useUser } from 'web/hooks/use-user'
import { LoadingIndicator } from 'web/components/loading-indicator' import { LoadingIndicator } from 'web/components/loading-indicator'
import toast from 'react-hot-toast'
export default function TwitchLandingPage() { export default function TwitchLandingPage() {
useSaveReferral() useSaveReferral()
@ -39,14 +40,19 @@ export default function TwitchLandingPage() {
const [isLoading, setLoading] = useState(false) const [isLoading, setLoading] = useState(false)
const getStarted = async () => { const getStarted = async () => {
try {
setLoading(true) setLoading(true)
const promise = callback() const promise = callback()
track('twitch page button click') track('twitch page button click')
await promise await promise
} catch (e) {
console.error(e)
toast.error('Failed to sign up. Please try again later.')
} finally {
setLoading(false) setLoading(false)
} }
}
return ( return (
<Page> <Page>
@ -96,7 +102,7 @@ export default function TwitchLandingPage() {
</div> </div>
</div> </div>
) : isLoading ? ( ) : isLoading ? (
<LoadingIndicator spinnerClassName="w-16 h-16" /> <LoadingIndicator spinnerClassName="!w-16 !h-16" />
) : ( ) : (
<Button <Button
size="2xl" size="2xl"