daphnis/auth/components/signup/signup.tsx

106 lines
2.7 KiB
TypeScript
Raw Normal View History

2024-06-29 05:22:22 +00:00
"use client";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import Link from "next/link";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Label } from "@/components/ui/label";
2024-06-29 19:25:43 +00:00
import { toast } from "@/components/ui/use-toast";
2024-06-29 05:22:22 +00:00
import { signUp } from "./action";
export default function SignUpForm() {
const submit = async (data: FormData) => {
const { error } = await signUp(data);
if (error) {
toast({
title: "Error",
description: error,
});
} else {
toast({
title: "Success",
description: "Account created successfully",
});
}
};
return (
<Card className="mx-auto max-w-sm">
<CardHeader>
<CardTitle className="text-2xl">Sign up</CardTitle>
<CardDescription>
Enter your info below to create your account
</CardDescription>
</CardHeader>
<CardContent>
<form action={submit} className="grid gap-4">
<div className="grid gap-2">
<Label htmlFor="username">Username</Label>
<Input name="username" type="text" placeholder="clotho" required />
</div>
<div className="grid gap-2">
<Label htmlFor="email">Email</Label>
<Input
name="email"
type="email"
placeholder="clotho@fates.com"
required
/>
</div>
<div className="grid gap-2">
<Label htmlFor="accessCode">Access Code</Label>
<Input
name="accessCode"
type="text"
placeholder="*******************"
required
/>
</div>
<div className="grid gap-2">
<Label htmlFor="password">Password</Label>
<Input
name="password"
type="password"
placeholder="********"
required
/>
</div>
<div className="grid gap-2">
<Label htmlFor="confirmPassword">Confirm Password</Label>
<Input
name="confirmPassword"
type="password"
placeholder="********"
required
/>
</div>
<Button type="submit" className="w-full">
Sign up
</Button>
</form>
<div className="mt-4 text-center text-sm">
Already have an account?{" "}
<Link href="/" className="underline">
Sign in
</Link>
</div>
</CardContent>
</Card>
);
}
export { SignUpForm };