manifold/web/components/sign-in-button.tsx

25 lines
561 B
TypeScript
Raw Normal View History

2022-08-28 20:56:35 +00:00
import React from 'react'
import { useRouter } from 'next/router'
2022-08-28 21:14:44 +00:00
import { firebaseLogin } from 'web/lib/firebase/users'
2022-08-28 20:56:35 +00:00
import { Button } from './button'
2022-08-28 21:38:59 +00:00
export const SignInButton = () => {
2022-08-28 20:56:35 +00:00
const router = useRouter()
return (
<Button
2022-08-28 21:15:31 +00:00
size="lg"
color="gray"
2022-08-28 20:56:35 +00:00
onClick={async () => {
// login, and then reload the page, to hit any SSR redirect (e.g.
// redirecting from / to /home for logged in users)
await firebaseLogin()
router.replace(router.asPath)
}}
>
Sign in
</Button>
)
}