Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] 83 fix signup error #84

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
31 changes: 19 additions & 12 deletions src/app/auth/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ const SignUpPage = () => {
checkStudentIdDuplicate,
} = AuthService();


// μ—”ν„°ν‚€λ₯Ό λˆ„λ₯Ό λ•Œ κΈ°λ³Έ λ™μž‘μ„ λ°©μ§€ν•˜λŠ” ν•¨μˆ˜
const handleKeyDown = (e) => {
if (e.key === "Enter") {
e.preventDefault(); // μ—”ν„°ν‚€μ˜ κΈ°λ³Έ λ™μž‘ 방지
}
};

// 이메일 쀑볡 및 ν˜•μ‹ 검사
const handleEmailBlur = async (e: React.FocusEvent<HTMLInputElement>) => {
const email = e.target.value;
Expand Down Expand Up @@ -272,11 +280,12 @@ const SignUpPage = () => {
<input
className="w-full max-w-md rounded-lg border-2 border-gray-300 p-2"
type="text"
placeholder="아이디λ₯Ό μž…λ ₯ν•΄μ£Όμ„Έμš”"
placeholder="이메일 ν˜•μ‹μœΌλ‘œ μž…λ ₯ν•΄μ£Όμ„Έμš”"
{...register("email", {
required: "아이디λ₯Ό μž…λ ₯ν•΄μ£Όμ„Έμš”",
})}
onBlur={handleEmailBlur}
onKeyDown={handleKeyDown}
/>
{errors.email && (
<p className="text-error">{errors.email.message}</p>
Expand Down Expand Up @@ -305,6 +314,7 @@ const SignUpPage = () => {
"λΉ„λ°€λ²ˆν˜Έλ₯Ό 8~16자둜 영문, 숫자, 특수기호λ₯Ό μ‘°ν•©ν•΄μ„œ μ‚¬μš©ν•˜μ„Έμš”. ",
},
})}
onKeyDown={handleKeyDown}
/>
<button
type="button"
Expand All @@ -329,16 +339,6 @@ const SignUpPage = () => {
placeholder="8자리 이상, μ˜μ–΄/숫자/특수 문자 μ‘°ν•©"
{...register("pwConfirm", {
required: "λΉ„λ°€λ²ˆν˜Έλ₯Ό μž…λ ₯ν•΄μ£Όμ„Έμš”",
minLength: {
value: 8,
message: "8κΈ€μž 이상 μž…λ ₯ν•΄μ£Όμ„Έμš”",
},
pattern: {
value:
/^(?=.*[a-zA-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,16}$/,
message:
"λΉ„λ°€λ²ˆν˜Έλ₯Ό 8~16자둜 영문, 숫자, 특수기호λ₯Ό μ‘°ν•©ν•΄μ„œ μ‚¬μš©ν•˜μ„Έμš”. ",
},
validate: {
check: (val) => {
if (getValues("password") !== val) {
Expand All @@ -347,6 +347,7 @@ const SignUpPage = () => {
},
},
})}
onKeyDown={handleKeyDown}
/>
<button
type="button"
Expand Down Expand Up @@ -376,6 +377,7 @@ const SignUpPage = () => {
{...register("name", {
required: "이름을 μž…λ ₯ν•΄μ£Όμ„Έμš”",
})}
onKeyDown={handleKeyDown}
/>
<p className="text-error">{errors?.name?.message}</p>
</div>
Expand All @@ -394,6 +396,7 @@ const SignUpPage = () => {
required: "λ‹‰λ„€μž„μ„ μž…λ ₯ν•΄μ£Όμ„Έμš”",
})}
onBlur={handleNicknameBlur}
onKeyDown={handleKeyDown}
/>
{errors.nickname && (
<p className="text-error">{errors.nickname.message}</p>
Expand All @@ -409,6 +412,7 @@ const SignUpPage = () => {
{...register("admissionYearString", {
required: "μž…ν•™ 년도λ₯Ό μ„ νƒν•΄μ£Όμ„Έμš”",
})}
onKeyDown={handleKeyDown}
>
<option value="">-μ„ νƒν•΄μ£Όμ„Έμš”-</option>
{yearOptions.map((option) => (
Expand All @@ -434,6 +438,7 @@ const SignUpPage = () => {
required: "ν•™λ²ˆμ„ μž…λ ₯ν•΄μ£Όμ„Έμš”",
})}
onBlur={handleStudentIdBlur}
onKeyDown={handleKeyDown}
/>
<p className="text-error">{errors?.studentId?.message}</p>
</div>
Expand All @@ -449,6 +454,7 @@ const SignUpPage = () => {
{...register("major", {
required: "ν•™λΆ€/ν•™κ³Όλ₯Ό μž…λ ₯ν•΄μ£Όμ„Έμš”",
})}
onKeyDown={handleKeyDown}
/>
<p className="text-error">{errors?.major?.message}</p>
</div>
Expand All @@ -468,6 +474,7 @@ const SignUpPage = () => {
message: "μ „ν™”λ²ˆν˜Έ ν˜•μ‹μ΄ μ•„λ‹™λ‹ˆλ‹€.",
},
})}
onKeyDown={handleKeyDown}
/>
<p className="text-error">{errors?.phoneNumberHyphen?.message}</p>
</div>
Expand All @@ -487,7 +494,7 @@ const SignUpPage = () => {

<label htmlFor="terms">
<label
className="cursor-pointer text-lg text-gray-700"
className="cursor-pointer text-lg text-gray-700 underline"
onClick={openModal}
>
μ•½κ΄€ 읽고 λ™μ˜ν•˜κΈ°
Expand Down