diff --git a/src/front/src/routes/Signup.jsx b/src/front/src/routes/Signup.jsx index c8c8dfb..b1999e4 100644 --- a/src/front/src/routes/Signup.jsx +++ b/src/front/src/routes/Signup.jsx @@ -1,6 +1,107 @@ +import { useContext, useState } from "react"; +import { useNavigate } from "react-router-dom"; +import { GlobalContext } from ".."; +import { Link } from "react-router-dom"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Select, SelectTrigger, SelectValue, SelectContent, SelectGroup } from "@/components/ui/select"; +import LabelSection from "@/components/Layout/LabelSection"; +import { correctRegxEmail, correctRegxPwd } from "@/utils/common"; + const Signup = () =>{ + //라우팅 네비게이터 + const nevigate = useNavigate(); + + const [passwordQuestions, setPasswordQuestions] = useState([]); + const [pwdQVal, setPwdQVal] = useState(); + // 유저정보 + const [email, setEmail] = useState(""); + const [username, setUsername] = useState(""); + const [pwd, setPwd] = useState(""); + const [pwdConfirm, setPwdConfirm] = useState(""); + + //메서드 + const doSignup = () =>{ + if(!username){ + alert("유저명을 입력해주세요"); + return ; + } + + if(!email){ + alert("이메일을 입력해주세요"); + return ; + } + + if(!pwd || !pwdConfirm || pwd != pwdConfirm){ + alert("비밀번호, 비밀번호 입력을 확인해주세요"); + return ; + } + + if(!correctRegxEmail(tBox_email.value)){ + alert("이메일 형식이 올바르지 않습니다."); + return ; + } + + if(!correctRegxPwd(tBox_password.value)){ + alert("비밀번호는 영어 대문자,소문자,특수기호,숫자를 반드시 포함한 8 ~ 16자리 문자여야합니다."); + return ; + } + + if(!pwdQVal){ + alert("비밀번호 찾기 질문을 선택해주세요."); + return ; + } + + // signup API 호출 + nevigate("/"); + } + return ( -
+
+
+

logo

+

가입을 통해 자소서 첨삭과 전문가 매칭 서비스를 누려보세요

+ + setUsername(ev.target.value)}> + + + setEmail(ev.target.value)}> + + + setPwd(ev.target.value)}> + + + setPwdConfirm(ev.target.value)}> + + + + + +
+
+ 또는 +
+
+
+ 비밀번호를 잊으셨나요? +
+
+
); }; diff --git a/src/front/src/utils/common.js b/src/front/src/utils/common.js new file mode 100644 index 0000000..4c9d167 --- /dev/null +++ b/src/front/src/utils/common.js @@ -0,0 +1,31 @@ +/** + * @brief 이메일 정규식 형태가 일치하는지 확인합니다. + * The email couldn't start or finish with a dot + * The email shouldn't contain spaces into the string + * The email shouldn't contain special chars (<:, *,ecc) + * The email could contain dots in the middle of mail address before the @ + * The email could contain a double doman ( '.de.org' or similar rarity) + * @param {String} inputString + * @returns boolean + */ +export function correctRegxEmail(inputString){ + const emailRegx = new RegExp(/^((?!\.)[\w\-_.]*[^.])(@\w+)(\.\w+(\.\w+)?[^.\W])$/gm); + return emailRegx.test(inputString) +} + +/** + * @brief 비밀번호 정규식 형태가 일치하는지 확인합니다. + * 형태는 + * password must contain 1 number (0-9) + * password must contain 1 uppercase letters + * password must contain 1 lowercase letters + * password must contain 1 non-alpha numeric number + * password is 8-16 characters with no space + * @param {String} inputString + * @returns boolean + */ +export function correctRegxPwd(inputString){ + const pwdRegx = new RegExp(/^(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[^\w\d\s:])([^\s]){8,16}$/gm); + return pwdRegx.test(inputString); +} +