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

Feature/signup kkm #69

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
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
20 changes: 16 additions & 4 deletions pages/signup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -99,13 +99,10 @@ export default function Signup() {

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

// 폼 제좜 μ—λŸ¬κ°€ μ—†λŠ”μ§€ 확인
const submitForm = async (loginFormData: UseFormDataType) => {
const inputValue = loginFormData[formDataKeyIndex];

console.log(inputValue);

// λΉ„λ°€λ²ˆν˜Έ μž…λ ₯κΉŒμ§€ 마치면 μžλ™ 둜그인
if (formDataKeyIndex === "password") {
if (loginFormData["password"] === loginFormData["password2"]) {
Expand Down Expand Up @@ -138,6 +135,21 @@ export default function Signup() {
setIsAgreeCondition(!isAgreeCondition);
};

useEffect(() => {
if (formDataKeyIndex == "nickname" || formDataKeyIndex == "password") {
const prevFormDataKeyIndex = formDataKeyIndex == "password" ? "nickname" : "email";

history.pushState(null, "", "");
window.onpopstate = () => {
setFormDataKeyIndex(prevFormDataKeyIndex);
};
} else {
window.onpopstate = () => {
// μ΄ˆκΈ°ν™”
};
}
Copy link
Member

Choose a reason for hiding this comment

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

switchλ¬Έ μ‚¬μš©ν•˜λŠ” 게 μ’€ 더 μ•Œμ•„λ³΄κΈ° μ‰¬μš°λ €λ‚˜ μ‹Άλ„€μš”!

Copy link
Member

@joohaem joohaem Jan 31, 2023

Choose a reason for hiding this comment

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

(ꢌμž₯) if-else에, μ‚Όν•­μ—°μ‚°κΉŒμ§€ μžˆμœΌλ‹ˆ μ–΄λ–€ μ½”λ“œμΈμ§€ λͺ…ν™•νžˆ μ•ˆ μ™€λ‹ΏλŠ” 것 κ°™μ•„μš”
formDataKeyIndex κ°’μœΌλ‘œ switch λ¬Έ ν™œμš©ν•˜λ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹·

Copy link
Contributor

Choose a reason for hiding this comment

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

μ—¬κΈ°μ„œλŠ” μ§„μ§œ 별거 μ•„λ‹Œλ°, === κ°€ μ•„λ‹Œ == 인 μ΄μœ κ°€ μžˆλ‚˜μš€?

}, [setFormDataKeyIndex]);

return (
<>
<NavHeader logoColor={theme.colors.gray100} />
Expand Down