import { Button, Checkbox, Link } from "@nextui-org/react"; import { Formik, Form, Field, ErrorMessage } from "formik"; import * as Yup from "yup"; import axios, { AxiosError } from "axios"; import config from "../config"; import NextUIFormikInput from "./NextUIFormikInput"; import { useNavigate } from "react-router-dom"; const validationSchema = Yup.object({ firstName: Yup.string() .trim() .min(1) .max(100) .required("First Name is required"), lastName: Yup.string() .trim() .min(1) .max(100) .required("Last Name is required"), email: Yup.string() .trim() .lowercase() .min(5) .max(69) .email("Invalid email format") .required("Email is required"), phoneNumber: Yup.string() .trim() .matches(/^[0-9]+$/, "Phone number must contain only numerical characters") .length(8, "Phone number must be 8 digits") .required("Phone number is required"), password: Yup.string() .trim() .min(8, "Password must be at least 8 characters") .max(69, "Password must be at most 69 characters") .matches( /^(?=.*[a-zA-Z])(?=.*[0-9]).{8,}$/, "Password needs to contain both letters and numbers" ) .required("Password is required"), terms: Yup.boolean().oneOf( [true], "You must accept the terms and conditions" ), }); export default function SignUpModule() { const navigate = useNavigate(); const initialValues = { firstName: "", lastName: "", email: "", phoneNumber: "", password: "", terms: false, }; const handleSubmit = async (values: any) => { try { const response = await axios.post( config.serverAddress + "/users/register", values ); console.log("User created successfully:", response.data); } catch (error) { throw ((error as AxiosError).response?.data as any).message; } }; return (
{({ isValid, dirty }) => (
+65

} />
I have read and agreed to the{" "} Terms and Services
)}

Already here before?

{ navigate("/signin"); }} > Sign in
); }