tabby/ee/tabby-ui/app/auth/components/user-auth-form.tsx

77 lines
2.0 KiB
TypeScript
Raw Normal View History

2023-12-05 06:34:02 +00:00
"use client"
import * as React from "react"
import { cn } from "@/lib/utils"
import { IconSpinner } from "@/components/ui/icons"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
2023-12-05 07:52:57 +00:00
interface UserAuthFormProps extends React.HTMLAttributes<HTMLDivElement> {
invitationCode?: string
}
2023-12-05 06:34:02 +00:00
2023-12-05 07:52:57 +00:00
export function UserAuthForm({ className, invitationCode, ...props }: UserAuthFormProps) {
2023-12-05 06:34:02 +00:00
const [isLoading, setIsLoading] = React.useState<boolean>(false)
async function onSubmit(event: React.SyntheticEvent) {
event.preventDefault()
setIsLoading(true)
setTimeout(() => {
setIsLoading(false)
}, 3000)
}
return (
<div className={cn("grid gap-6", className)} {...props}>
<form onSubmit={onSubmit}>
<div className="grid gap-2">
2023-12-05 07:52:57 +00:00
<div className="space-y-2">
<Label htmlFor="email">
2023-12-05 06:34:02 +00:00
Email
</Label>
<Input
id="email"
2023-12-05 07:52:57 +00:00
placeholder=""
2023-12-05 06:34:02 +00:00
type="email"
autoCapitalize="none"
autoComplete="email"
autoCorrect="off"
disabled={isLoading}
/>
</div>
2023-12-05 07:52:57 +00:00
<div className="space-y-2">
<Label htmlFor="password1">
Password
</Label>
<Input
id="password1"
placeholder=""
type="password"
disabled={isLoading}
/>
</div>
<div className="space-y-2">
<Label htmlFor="">
Confirm Password
2023-12-05 06:34:02 +00:00
</Label>
<Input
2023-12-05 07:52:57 +00:00
id="password2"
placeholder=""
2023-12-05 06:34:02 +00:00
type="password"
2023-12-05 07:52:57 +00:00
disabled={isLoading}
2023-12-05 06:34:02 +00:00
/>
</div>
2023-12-05 07:52:57 +00:00
<Button className="mt-2" disabled={isLoading}>
2023-12-05 06:34:02 +00:00
{isLoading && (
<IconSpinner className="mr-2 h-4 w-4 animate-spin" />
)}
Sign In
</Button>
</div>
</form>
</div>
)
}