extract signup component
parent
fee262be11
commit
c4ae545bcb
|
|
@ -0,0 +1,24 @@
|
||||||
|
"use client"
|
||||||
|
|
||||||
|
import { UserAuthForm } from "./user-auth-form"
|
||||||
|
import { useGraphQL } from "@/lib/hooks/use-graphql"
|
||||||
|
import { getIsAdminInitialized } from "@/lib/gql/request-documents"
|
||||||
|
|
||||||
|
export default function Signup() {
|
||||||
|
const { data } = useGraphQL(getIsAdminInitialized)
|
||||||
|
const title = data?.isAdminInitialized ? "Create an account" : "Create an admin account"
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-6 w-[350px]">
|
||||||
|
<div className="flex flex-col space-y-2 text-center">
|
||||||
|
<h1 className="text-2xl font-semibold tracking-tight">
|
||||||
|
{title}
|
||||||
|
</h1>
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
Enter your credentials below to create account
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<UserAuthForm />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -8,9 +8,11 @@ import { Button } from "@/components/ui/button"
|
||||||
import { Input } from "@/components/ui/input"
|
import { Input } from "@/components/ui/input"
|
||||||
import { Label } from "@/components/ui/label"
|
import { Label } from "@/components/ui/label"
|
||||||
|
|
||||||
interface UserAuthFormProps extends React.HTMLAttributes<HTMLDivElement> { }
|
interface UserAuthFormProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||||
|
invitationCode?: string
|
||||||
|
}
|
||||||
|
|
||||||
export function UserAuthForm({ className, ...props }: UserAuthFormProps) {
|
export function UserAuthForm({ className, invitationCode, ...props }: UserAuthFormProps) {
|
||||||
const [isLoading, setIsLoading] = React.useState<boolean>(false)
|
const [isLoading, setIsLoading] = React.useState<boolean>(false)
|
||||||
|
|
||||||
async function onSubmit(event: React.SyntheticEvent) {
|
async function onSubmit(event: React.SyntheticEvent) {
|
||||||
|
|
@ -26,13 +28,13 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) {
|
||||||
<div className={cn("grid gap-6", className)} {...props}>
|
<div className={cn("grid gap-6", className)} {...props}>
|
||||||
<form onSubmit={onSubmit}>
|
<form onSubmit={onSubmit}>
|
||||||
<div className="grid gap-2">
|
<div className="grid gap-2">
|
||||||
<div className="grid gap-1">
|
<div className="space-y-2">
|
||||||
<Label className="sr-only" htmlFor="email">
|
<Label htmlFor="email">
|
||||||
Email
|
Email
|
||||||
</Label>
|
</Label>
|
||||||
<Input
|
<Input
|
||||||
id="email"
|
id="email"
|
||||||
placeholder="name@example.com"
|
placeholder=""
|
||||||
type="email"
|
type="email"
|
||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
autoComplete="email"
|
autoComplete="email"
|
||||||
|
|
@ -40,17 +42,29 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) {
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid gap-1">
|
<div className="space-y-2">
|
||||||
<Label className="sr-only" htmlFor="email">
|
<Label htmlFor="password1">
|
||||||
Email
|
Password
|
||||||
</Label>
|
</Label>
|
||||||
<Input
|
<Input
|
||||||
id="password"
|
id="password1"
|
||||||
placeholder="password"
|
placeholder=""
|
||||||
type="password"
|
type="password"
|
||||||
|
disabled={isLoading}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Button disabled={isLoading}>
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="">
|
||||||
|
Confirm Password
|
||||||
|
</Label>
|
||||||
|
<Input
|
||||||
|
id="password2"
|
||||||
|
placeholder=""
|
||||||
|
type="password"
|
||||||
|
disabled={isLoading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Button className="mt-2" disabled={isLoading}>
|
||||||
{isLoading && (
|
{isLoading && (
|
||||||
<IconSpinner className="mr-2 h-4 w-4 animate-spin" />
|
<IconSpinner className="mr-2 h-4 w-4 animate-spin" />
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import { Metadata } from "next"
|
import { Metadata } from "next"
|
||||||
|
|
||||||
import { UserAuthForm } from "./components/user-auth-form"
|
import Signup from "./components/signup"
|
||||||
import { useGraphQL } from "@/lib/hooks/use-graphql"
|
|
||||||
import { getIsAdminInitialized } from "@/lib/gql/request-documents"
|
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Authentication",
|
title: "Authentication",
|
||||||
|
|
@ -12,17 +10,7 @@ export const metadata: Metadata = {
|
||||||
export default function AuthenticationPage() {
|
export default function AuthenticationPage() {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center flex-1">
|
<div className="flex flex-col items-center justify-center flex-1">
|
||||||
<div className="space-y-6 w-[350px]">
|
<Signup />
|
||||||
<div className="flex flex-col space-y-2 text-center">
|
|
||||||
<h1 className="text-2xl font-semibold tracking-tight">
|
|
||||||
Create an account
|
|
||||||
</h1>
|
|
||||||
<p className="text-sm text-muted-foreground">
|
|
||||||
Enter your credentials below to create admin account
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<UserAuthForm />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue