sign up to login
This commit is contained in:
@@ -3,7 +3,6 @@ import { IconMail, IconLock } from "@tabler/icons-react";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
import http from "../http";
|
import http from "../http";
|
||||||
import { useNavigate } from "react-router-dom";
|
|
||||||
|
|
||||||
export default function SignupView({
|
export default function SignupView({
|
||||||
onLogin,
|
onLogin,
|
||||||
@@ -21,8 +20,6 @@ export default function SignupView({
|
|||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
const [confirmPassword, setConfirmPassword] = useState("");
|
const [confirmPassword, setConfirmPassword] = useState("");
|
||||||
|
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
const validatePassword = (password: string): boolean => {
|
const validatePassword = (password: string): boolean => {
|
||||||
const passwordComplexityRegex =
|
const passwordComplexityRegex =
|
||||||
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{12,}$/;
|
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{12,}$/;
|
||||||
@@ -78,8 +75,9 @@ export default function SignupView({
|
|||||||
throw new Error("Failed to sign up");
|
throw new Error("Failed to sign up");
|
||||||
}
|
}
|
||||||
|
|
||||||
toast.success("User signed up successfully");
|
toast.success("Welcome to Ace Job, " + firstName + "!", {
|
||||||
navigate("/");
|
onClose: onLogin,
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error((error as any).response?.data || "Error during signup");
|
toast.error((error as any).response?.data || "Error during signup");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user