-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/signup kkm #69
base: develop
Are you sure you want to change the base?
Changes from 4 commits
172015d
debe830
18b0881
837cafe
ecbc132
ecf7fd8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
import styled from "@emotion/styled"; | ||
import { AnimatePresence, motion } from "framer-motion"; | ||
import { useRouter } from "next/router"; | ||
import { useState } from "react"; | ||
import { useEffect, useState } from "react"; | ||
import { useForm } from "react-hook-form"; | ||
|
||
import { NavHeader } from "../../components/common"; | ||
|
@@ -78,13 +78,13 @@ export default function Signup() { | |
}; | ||
|
||
// λ€μ λ¨κ³λ‘ μ΄λνλ ν¨μ | ||
const setNextStep = (key: string) => { | ||
const setNextStep = (inputValue: string) => { | ||
setUserData((current) => { | ||
const formData = { ...current }; | ||
const userData = { ...current }; | ||
|
||
formData[formDataKeyIndex] = key; | ||
userData[formDataKeyIndex] = inputValue; | ||
|
||
return formData; | ||
return userData; | ||
}); | ||
|
||
setFormDataKeyIndex((current) => { | ||
|
@@ -97,48 +97,59 @@ export default function Signup() { | |
return "submit"; | ||
}); | ||
|
||
setValue(formDataKeyIndex, ""); | ||
setValue(formDataKeyIndex, "", { shouldDirty: true }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ππ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ππππ |
||
}; | ||
|
||
// νΌ μ μΆ μλ¬κ° μλμ§ νμΈ | ||
const submitForm = async (loginFormData: UseFormDataType) => { | ||
const key = loginFormData[formDataKeyIndex]; | ||
const inputValue = loginFormData[formDataKeyIndex]; | ||
|
||
// λΉλ°λ²νΈ μ λ ₯κΉμ§ λ§μΉλ©΄ μλ λ‘κ·ΈμΈ | ||
if (formDataKeyIndex === "password") { | ||
if (loginFormData["password"] === loginFormData["password2"]) { | ||
autoLoginAfterSignup(key); | ||
} else { | ||
setError("password", { type: "server", message: "λΉλ°λ²νΈκ° μΌμΉνμ§ μμ΅λλ€." }); | ||
autoLoginAfterSignup(inputValue); | ||
|
||
return; | ||
} | ||
} else { | ||
// μ΄λ©μΌ μ λ ₯μ κ°μΈμ 보 μ·¨κΈ λ°©μΉ¨ λμλ₯Ό λ¨Όμ μ λ | ||
if (formDataKeyIndex === "email" && !isAgreeCondition) { | ||
setError(formDataKeyIndex, { | ||
type: "agreeCondition", | ||
message: "κ°μΈμ 보 μμ§ λ° μ΄μ© μ½κ΄μ λμν΄μ£ΌμκΈ° λ°λλλ€.", | ||
}); | ||
} else { | ||
// μλ²λ‘ λ°μ΄ν°λ₯Ό 보λ΄μ μ ν¨μ± κ²μ¬ | ||
// return: μ ν¨νμ§(isValid) && μλ¬ λ©μμ§(message) | ||
const { isValid, message } = await checkIsValid(formDataKeyIndex, key); | ||
|
||
if (isValid) { | ||
setNextStep(key); | ||
if (formDataKeyIndex === "email") { | ||
LocalStorage.setItem("booktez-email", loginFormData["email"]); | ||
} | ||
} else { | ||
setError(formDataKeyIndex, { type: "server", message }); | ||
} | ||
setError("password", { type: "server", message: "λΉλ°λ²νΈκ° μΌμΉνμ§ μμ΅λλ€." }); | ||
|
||
return; | ||
} | ||
|
||
// μλ²λ‘ λ°μ΄ν°λ₯Ό 보λ΄μ μ ν¨μ± κ²μ¬ | ||
// return: μ ν¨νμ§(isValid) && μλ¬ λ©μμ§(message) | ||
const { isValid, message } = await checkIsValid(formDataKeyIndex, inputValue); | ||
|
||
if (isValid) { | ||
setNextStep(inputValue); | ||
|
||
if (formDataKeyIndex === "email") { | ||
LocalStorage.setItem("booktez-email", loginFormData["email"]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. λ‘컬μ€ν λ¦¬μ§ ν€λ₯Ό μμλ νμ μΌλ‘ μ μν΄λλ©΄ (λμ€μ μ½λλ₯Ό κ³ μΉ λκ΅°κ°κ° νΈν΄μ§ κ² κ°μμ)μ’μ κ² κ°λ€λ μκ°μ΄ λλλ°, νμλ μλλλΉ(κ·Όλ° ν΄μ£Όλ©΄ μ’μ κ² κ°μ λλμ λ) |
||
} | ||
|
||
return; | ||
} | ||
setError(formDataKeyIndex, { type: "server", message }); | ||
Comment on lines
+123
to
+132
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μνΈ μ΄λ κ² λμκ΅°μ!! |
||
}; | ||
|
||
const handleToggleIsAgreeCondition = () => { | ||
setIsAgreeCondition(!isAgreeCondition); | ||
}; | ||
|
||
useEffect(() => { | ||
if (formDataKeyIndex == "nickname" || formDataKeyIndex == "password") { | ||
const prevFormDataKeyIndex = formDataKeyIndex == "password" ? "nickname" : "email"; | ||
|
||
history.pushState(null, "", ""); | ||
window.onpopstate = () => { | ||
setFormDataKeyIndex(prevFormDataKeyIndex); | ||
}; | ||
} else { | ||
window.onpopstate = () => { | ||
// μ΄κΈ°ν | ||
}; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. switchλ¬Έ μ¬μ©νλ κ² μ’ λ μμ보기 μ¬μ°λ €λ μΆλ€μ! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (κΆμ₯) if-elseμ, μΌνμ°μ°κΉμ§ μμΌλ μ΄λ€ μ½λμΈμ§ λͺ
νν μ μλΏλ κ² κ°μμ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μ¬κΈ°μλ μ§μ§ λ³κ±° μλλ°, |
||
}, [setFormDataKeyIndex]); | ||
|
||
return ( | ||
<> | ||
<NavHeader logoColor={theme.colors.gray100} /> | ||
|
@@ -155,7 +166,13 @@ export default function Signup() { | |
<StFormWrapper> | ||
<StSignupImage src={imgList[formDataKeyIndex]} alt="νμκ°μ 첫 λ¨κ³" /> | ||
<StSignupHeading2>λλ§μ μμ¬λ₯Ό λ§λλ μ€μ΄μμ!</StSignupHeading2> | ||
<StSignupParagraph>λΉμ μ {formDataKeyData[formDataKeyIndex]}μ μ λ ₯ν΄ μ£ΌμΈμ.</StSignupParagraph> | ||
|
||
{formDataKeyData[formDataKeyIndex] == "λλ€μ" ? ( | ||
<StSignupParagraph>μ κ° μ¬λ¬λΆμ μ΄λ»κ² λΆλ₯΄λ©΄ λ κΉμ?</StSignupParagraph> | ||
) : ( | ||
<StSignupParagraph>λΉμ μ {formDataKeyData[formDataKeyIndex]}μ μ λ ₯ν΄ μ£ΌμΈμ.</StSignupParagraph> | ||
)} | ||
|
||
<StForm onSubmit={handleSubmit(submitForm)}> | ||
<SignupForm | ||
register={register} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
const EMAIL_REGEX = | ||
/^(([^<>()\].,;:\s@"]+(\.[^<>()\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i; | ||
|
||
const NICKNAME_REGEX = /^(?=.*[a-z0-9κ°-ν£])[a-z0-9κ°-ν£]{2,10}$/i; | ||
|
||
Comment on lines
+4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ππ |
||
const INVALID_PWD_CHAR_LIST: { [key: string]: string } = { | ||
",": "λ°μ (,)", | ||
'"': 'μλ°μ΄ν(")', | ||
|
@@ -34,6 +36,10 @@ const nicknameErrorPatterns: ErrorCondition = { | |
value: true, | ||
message: "λλ€μμ μ λ ₯ν΄μ£ΌμΈμ.", | ||
}, | ||
pattern: { | ||
value: NICKNAME_REGEX, | ||
message: "2-10μ μ΄λ΄μ μλ¬Έ/νκΈ/μ«μλ‘ μ λ ₯ν΄μ£ΌμΈμ.", | ||
}, | ||
}; | ||
|
||
export const passwordErrorPatterns: ErrorCondition = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ κ° νΌκ·Έλ§λ₯Ό νμΈνμ§λ λͺ»νλλ°, νΉμ μ΄ νμκ°
κ°μΈμ 보 μμ§ λ° μ΄μ© μ½κ΄μ λμν©λλ€.
μ μ²΄κ° μλκ°μΈμ 보 μμ§ λ° μ΄μ© μ½κ΄
μλ§ ν΄λΉλλ κ²μ μλκ°μ₯?