chatbot-template/components/login-button.tsx

33 lines
748 B
TypeScript
Raw Normal View History

2023-06-13 18:14:06 +04:00
'use client'
import * as React from 'react'
2023-06-16 20:38:13 +04:00
import { signIn } from 'next-auth/react'
2023-06-13 18:14:06 +04:00
import { cn } from '@/lib/utils'
import { Button, type ButtonProps } from '@/components/ui/button'
2023-06-16 20:38:13 +04:00
import { IconSpinner } from '@/components/ui/icons'
2023-06-13 18:14:06 +04:00
interface LoginButtonProps extends ButtonProps {
text?: string
}
2023-06-16 20:38:13 +04:00
export function LoginButton({ className, ...props }: LoginButtonProps) {
2023-06-13 18:14:06 +04:00
const [isLoading, setIsLoading] = React.useState(false)
return (
<Button
2023-06-16 20:38:13 +04:00
variant="link"
2023-06-13 18:14:06 +04:00
onClick={() => {
setIsLoading(true)
2023-06-16 11:49:14 -04:00
signIn('github')
2023-06-13 18:14:06 +04:00
}}
disabled={isLoading}
className={cn(className)}
{...props}
>
2023-06-16 20:38:13 +04:00
{isLoading && <IconSpinner className="mr-2 animate-spin" />}
Login
2023-06-13 18:14:06 +04:00
</Button>
)
}