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 { 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()
@ -39,14 +40,19 @@ export default function TwitchLandingPage() {
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.')
} finally {
setLoading(false)
}
}
return (
<Page>
@ -96,7 +102,7 @@ export default function TwitchLandingPage() {
</div>
</div>
) : isLoading ? (
<LoadingIndicator spinnerClassName="w-16 h-16" />
<LoadingIndicator spinnerClassName="!w-16 !h-16" />
) : (
<Button
size="2xl"