Skip to content

Feature/signup kkm #69

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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions components/signup/SignupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ interface SignupFormProps {
export default function SignupForm(props: SignupFormProps) {
const { register, errors, keyData, keyIndex, isAgree, isDirty, onToggleIsAgreeCondition } = props;

const linkOfCondition = referralLinkLIst[0].href;

const PasswordForm = (
<>
<StEmailFixed>{LocalStorage.getItem("booktez-email")}</StEmailFixed>
Expand All @@ -36,11 +38,9 @@ export default function SignupForm(props: SignupFormProps) {
</>
);

const linkOfCondition = referralLinkLIst[0].href;

const AgreeConditionBox = (
<StAgreeConditionBox htmlFor="signupAgree" onClick={onToggleIsAgreeCondition}>
<StIcSignupChecking isagree={isAgree} />
<StAgreeConditionBox htmlFor="signupAgree">
<StIcSignupChecking isagree={isAgree} onClick={onToggleIsAgreeCondition} />
<a href={linkOfCondition} target="_blank" rel="noopener noreferrer">
κ°œμΈμ •λ³΄ μˆ˜μ§‘ 및 이용 약관에 λ™μ˜ν•©λ‹ˆλ‹€.
</a>
Expand All @@ -56,9 +56,7 @@ export default function SignupForm(props: SignupFormProps) {
<Input {...register(keyIndex, errorPatterns[keyIndex])} placeholder={`${keyData[keyIndex]}을 μž…λ ₯ν•΄ μ£Όμ„Έμš”`} />
)}
{errors[keyIndex]?.message && <AlertLabel message={errors[keyIndex].message} />}

{keyIndex === "email" && AgreeConditionBox}

<StNextStepBtn disabled={!isDirty || !isAgree} type="submit">
λ‹€μŒ 계단
</StNextStepBtn>
Expand Down
49 changes: 28 additions & 21 deletions pages/signup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -97,34 +97,41 @@ export default function Signup() {
return "submit";
});

setValue(formDataKeyIndex, "");
setValue(formDataKeyIndex, "", { shouldDirty: true });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘πŸ‘

Copy link
Contributor

Choose a reason for hiding this comment

The 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];

console.log(inputValue);

// λΉ„λ°€λ²ˆν˜Έ μž…λ ₯κΉŒμ§€ 마치면 μžλ™ 둜그인
if (formDataKeyIndex === "password") {
if (loginFormData["password"] === loginFormData["password2"]) {
autoLoginAfterSignup(key);
} else {
setError("password", { type: "server", message: "λΉ„λ°€λ²ˆν˜Έκ°€ μΌμΉ˜ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€." });
autoLoginAfterSignup(inputValue);

return;
}
} 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"]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

λ‘œμ»¬μŠ€ν† λ¦¬μ§€ ν‚€λ₯Ό μƒμˆ˜λ‚˜ νƒ€μž…μœΌλ‘œ μ •μ˜ν•΄λ‘λ©΄ (λ‚˜μ€‘μ— μ½”λ“œλ₯Ό κ³ μΉ  λˆ„κ΅°κ°€κ°€ νŽΈν•΄μ§ˆ 것 κ°™μ•„μ„œ)쒋을 것 κ°™λ‹€λŠ” 생각이 λ“œλŠ”λ°, ν•„μˆ˜λŠ” μ•„λ‹™λ‹ˆλ‹Ή(근데 ν•΄μ£Όλ©΄ 쒋을 것 같은 λŠλ‚Œμ •λ„)

}

return;
}
setError(formDataKeyIndex, { type: "server", message });
Comment on lines +123 to +132
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μš”ν˜Έ μ΄λ ‡κ²Œ λ˜μ—ˆκ΅°μš”!!
이것도 μ’‹μ§€λ§Œ, μœ„μ—μ„œ 말 ν•œ κ²ƒμ²˜λŸΌ μ—λŸ¬ 체킹을 μœ„λ‘œ 올리면, if 의 λŽμŠ€κ°€ κΉŠμ–΄μ§€μ§€ μ•Šμ„ 수 μžˆμ„ 것 κ°™μ•„μš”

};

const handleToggleIsAgreeCondition = () => {
Expand Down