mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-06 02:36:44 -05:00
users email duplicate check
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { addUser } from "@actions/userActions";
|
||||
import { addUser, getUserByEmail } from "@actions/userActions";
|
||||
import { users } from '@schemas/schema';
|
||||
export default function RegistrationForm() {
|
||||
const router = useRouter();
|
||||
const [error, setError] = useState("");
|
||||
@@ -18,15 +19,19 @@ export default function RegistrationForm() {
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
setError("");
|
||||
alert("in the submit");
|
||||
|
||||
alert(formData.password + ":" + formData.confirmPassword);
|
||||
if (formData.password !== formData.confirmPassword) {
|
||||
setError("Passwords do not match");
|
||||
console.log("password no match");
|
||||
alert("password no match");
|
||||
return;
|
||||
}
|
||||
|
||||
const existingUser : any = null;
|
||||
if((await getUserByEmail(formData.email)).length > 0){
|
||||
setError("Duplicate E-Mail Address");
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
addUser(
|
||||
formData.first_name,
|
||||
@@ -35,7 +40,6 @@ export default function RegistrationForm() {
|
||||
formData.email,
|
||||
formData.password
|
||||
);
|
||||
console.log("Form submitted:", formData);
|
||||
router.push("/signin"); // Redirect to login after successful registration
|
||||
} catch (err) {
|
||||
setError("Failed to register user");
|
||||
|
||||
Reference in New Issue
Block a user