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

feat: login 아이디 비번 불일치 시 로그인 실패 모달 #28

Merged
merged 1 commit into from
Jun 30, 2022
Merged
Changes from all commits
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
51 changes: 32 additions & 19 deletions frontend/src/components/pages/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { css } from "@emotion/react";
import axios from "axios";
import AuthFormContainer from "components/common/AuthFormContainer";
import Button from "components/common/Button";
import Modal from "components/common/Modal";
import useUser from "hooks/useUser";
import Link from "next/link";
import { useRouter } from "next/router";
import { FormEvent, useRef } from "react";
import { FormEvent, useRef, useState } from "react";

import { StyledA, StyledInput } from "./styles";

Expand All @@ -30,6 +31,7 @@ function Login() {

const router = useRouter();
const data: FormValue = { email: "", password: "" };
const [showModal, setShowModal] = useState(false);

async function loginRequest(data: FormValue) {
// TODO: password frontend hashing
Expand All @@ -42,6 +44,7 @@ function Login() {
router.push("/");
})
.catch((error) => {
setShowModal(true);
console.log(error);
});
return false;
Expand All @@ -67,24 +70,34 @@ function Login() {
};

return (
<AuthFormContainer>
<form onSubmit={handleListSubmit}>
<StyledInput ref={emailInputRef} type="text" placeholder="이메일" />
<StyledInput ref={passwordInputRef} type="password" placeholder="비밀번호" />
<Button
type="submit"
css={css`
margin-bottom: 10px;
width: 100%;
`}
>
로그인
</Button>
</form>
<Link href={"/register"}>
<StyledA>계정이 없으신가요? 회원가입하기 &gt;</StyledA>
</Link>
</AuthFormContainer>
<>
<Modal
title="로그인 실패"
buttonText="확인"
show={showModal}
onClose={() => setShowModal(false)}
>
아이디와 비밀번호를 확인하세요
</Modal>
<AuthFormContainer>
<form onSubmit={handleListSubmit}>
<StyledInput ref={emailInputRef} type="text" placeholder="이메일" />
<StyledInput ref={passwordInputRef} type="password" placeholder="비밀번호" />
<Button
type="submit"
css={css`
margin-bottom: 10px;
width: 100%;
`}
>
로그인
</Button>
</form>
<Link href={"/register"}>
<StyledA>계정이 없으신가요? 회원가입하기 &gt;</StyledA>
</Link>
</AuthFormContainer>
</>
);
}

Expand Down