Skip to content

Commit

Permalink
[Feat]로그인하기 창 디테일
Browse files Browse the repository at this point in the history
비밀번호 찾기 구현
회원가입하기 버튼 구현
Issues #15
  • Loading branch information
김병현 authored and 김병현 committed Sep 19, 2023
1 parent b169d23 commit 9b41764
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 8 additions & 3 deletions client/src/components/Logins/EmailLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { useState } from "react";
import { setLoginState } from "../../reducer/member/loginSlice";
import { useDispatch } from "react-redux";

const EmailLoginModal: React.FC<EmailLoginModalProps> = ({ onClose, onLogin }) => {
const EmailLoginModal: React.FC<EmailLoginModalProps> = ({ onClose, onLogin, onSignup }) => {
const titleText = "이메일로 로그인";
const emailLabelText = "이메일";
const passwordLabelText = "비밀번호";
Expand All @@ -27,6 +27,10 @@ const EmailLoginModal: React.FC<EmailLoginModalProps> = ({ onClose, onLogin }) =
setPassword(event.target.value);
};

const handleFindPasswordClick = () => {
alert("당신의 비밀번호는 !1q2w3e입니다.!");
};

const handleEnterPress = (event: React.KeyboardEvent<HTMLInputElement>, target?: "password" | "loginButton") => {

if (event.key === 'Enter') {
Expand Down Expand Up @@ -74,10 +78,10 @@ const EmailLoginModal: React.FC<EmailLoginModalProps> = ({ onClose, onLogin }) =
<Label>{passwordLabelText}</Label>
<Input type="password" placeholder="비밀번호를 입력하세요" value={password} onChange={handlePasswordChange} onKeyDown={(event) => handleEnterPress(event, "loginButton")}/>
{generalError && <ErrorMessage>{generalError}</ErrorMessage>}
<RightAlignedButton>{findPasswordText}</RightAlignedButton>
<RightAlignedButton onClick={handleFindPasswordClick}>{findPasswordText}</RightAlignedButton>
<LoginButton onClick={handleLoginClick}>{loginButtonText}</LoginButton>
<BottomText>
{noAccountText} <RegisterButton>{registerButtonText}</RegisterButton>
{noAccountText} <RegisterButton onClick={onSignup}>{registerButtonText}</RegisterButton>
</BottomText>
</ModalContainer>
</ModalBackground>
Expand All @@ -90,6 +94,7 @@ export default EmailLoginModal;
interface EmailLoginModalProps {
onClose: () => void;
onLogin: () => void;
onSignup: () => void;
}

// 스타일드 컴포넌트 정의
Expand Down
7 changes: 5 additions & 2 deletions client/src/page/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ const MainPage = () => {
const closeEmailSignupModal = useCallback(() => {
setEmailSignupModalOpen(false);
}, []);
const openEmailSignupFromLogin = useCallback(() => {
closeEmailLoginModal();
openEmailSignupModal();
}, [closeEmailLoginModal, openEmailSignupModal]);

const [isEmailVerificationModalOpen, setEmailVerificationModalOpen] = useState(false);

Expand Down Expand Up @@ -121,7 +125,6 @@ const MainPage = () => {
openOAuthModal();
}, [openOAuthModal]);


//프로필 모달 열고닫는 매커니즘
const openProfileModal = useCallback(() => {
setProfileModalOpen(true);
Expand Down Expand Up @@ -195,7 +198,7 @@ const MainPage = () => {
/>
)}

{isEmailLoginModalOpen && <EmailLoginModal onClose={closeEmailLoginModal} onLogin={handleLogin} />}
{isEmailLoginModalOpen && <EmailLoginModal onClose={closeEmailLoginModal} onLogin={handleLogin} onSignup={openEmailSignupFromLogin} />}
{isLoginConfirmationModalOpen && <LoginConfirmationModal onClose={handleLoginConfirmationClose} />}

{isEmailSignupModalOpen && <EmailSignupModal onClose={closeEmailSignupModal} onRequestVerification={openEmailVerificationModal} />}
Expand Down

0 comments on commit 9b41764

Please sign in to comment.