Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
a717af5
Initialize project using Create React App
May 22, 2023
5f9ba86
feat: 초기 환경 세팅
May 23, 2023
70f1fd6
chore: 불필요한 파일 삭제
May 23, 2023
cf58360
feat: 폼 유효성 확인하는 훅 추가
May 23, 2023
bdbb0e8
feat: input 관리하는 훅 추가
May 23, 2023
8224d89
feat: 로그인, 회원가입 폼 유효성 관리
May 23, 2023
af12a02
chore: type 추가
May 23, 2023
bd52821
feat: 라우터 추가
May 23, 2023
22a1505
chore: constants 추가
May 23, 2023
20357f6
feat: 메인 페이지 추가
May 23, 2023
b55e046
chore: string 관련 함수 모아놓음
May 23, 2023
cc5504c
Merge pull request #1 from Hooking-CEOS/feature/user
hyosin-Jang May 23, 2023
e13d0ba
style: 공통 color 추가
Jun 3, 2023
0e1f4cd
style: 스타일 초기화 및 전역 스타일 추가
Jun 3, 2023
2cbc95d
style: 헤더 있는 레이아웃 추가
Jun 3, 2023
c1cbb5c
chore: axios 기본 세팅 추가
Jun 3, 2023
718d4d9
feat: 헤더 추가
Jun 3, 2023
3de6e3c
feat: login mock api 연결
Jun 3, 2023
2b22ca3
feat: signup mock api 연결
Jun 3, 2023
e170999
chore: 피그마에서 내보낸 png 파일들 추가
Jun 3, 2023
0783bf4
Merge pull request #2 from Hooking-CEOS/feature/user
hyosin-Jang Jun 3, 2023
9e8ea39
chore: proxy 설정
Jun 27, 2023
e8ba716
feat: 임시 데모데이 페이지 추가
Jun 27, 2023
f235bcf
feat: 메인화면 추가
Jun 27, 2023
400bc49
feat: 파트장 투표 예시 코드 추가
Jun 27, 2023
e5f0298
feat: 로그인 회원가입 페이지 추가
Jun 27, 2023
c263b59
chore: form validation 문구 자세하게 수정
Jun 27, 2023
14280dc
feat: 임시 결과 페이지 추가
Jun 27, 2023
36d1bda
feat: privateRouter 추가 (투표 페이지는 로그인한 후에만 접근 가능)
Jun 27, 2023
7ad6783
feat: 로그아웃 버튼 추가
Jun 27, 2023
904a54c
chore: 메인 height 수정
Jun 27, 2023
13ad0fa
chore: images.d.ts 추가
Jun 27, 2023
c5eb38a
feat: userInfo, islogin atom 추가
Jun 27, 2023
5e7256f
chore: style, constants, api 수정
Jun 27, 2023
c429898
Merge pull request #3 from Hooking-CEOS/feature/user
hyosin-Jang Jun 27, 2023
6ac6d7c
feat: vote page wip
moong23 Jun 27, 2023
b6ea8fc
Merge branch 'develop' into feature/vote
moong23 Jun 27, 2023
7db65d5
Merge pull request #4 from Hooking-CEOS/feature/vote
moong23 Jun 27, 2023
79ec745
axios type added
moong23 Jun 28, 2023
160b0a7
assets added
moong23 Jun 28, 2023
9e2aaa1
part vote page implemented
moong23 Jun 28, 2023
e9e08ae
demo vote page implemented
moong23 Jun 28, 2023
4d16ad6
chore: commit for deployment
moong23 Jun 28, 2023
88564b6
Merge pull request #5 from Hooking-CEOS/develop
moong23 Jun 28, 2023
e4e8140
axios error modify via redirection
moong23 Jun 28, 2023
502856c
Merge pull request #6 from Hooking-CEOS/develop
moong23 Jun 28, 2023
acc7181
axios error modify via redirection
moong23 Jun 28, 2023
6268cb8
Merge branch 'develop'
moong23 Jun 28, 2023
1938c8b
axios error modified via cors
moong23 Jun 28, 2023
ec7cf64
axios error modified via cors
moong23 Jun 28, 2023
8c026c0
axios error modified via cors
moong23 Jun 28, 2023
eacc59e
chore: minor bug fix
moong23 Jun 28, 2023
a3f5e0a
chore: minor bug fix
moong23 Jun 28, 2023
b441c9e
chore: minor bug fix
moong23 Jun 28, 2023
ae0d098
demo result re-positioned by descending orders
moong23 Jun 29, 2023
c3c3bb8
fix: routing logic modified and vote result logic modified
moong23 Jun 29, 2023
fc34bf1
vote result re-positioned by descending orders
moong23 Jun 29, 2023
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
69 changes: 67 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@testing-library/user-event": "^13.5.0",
"axios": "^1.4.0",
"react": "^18.2.0",
"react-cookie": "^4.1.1",
"react-dom": "^18.2.0",
"react-hook-form": "^7.43.9",
"react-router-dom": "^6.11.2",
Expand Down
5 changes: 5 additions & 0 deletions src/api/post.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { POST } from "../utils/axios";

export const onLogin = async (body: any) => await POST("/login", body);

export const onSignUp = async (body: any) => await POST("/signup", body);
70 changes: 44 additions & 26 deletions src/pages/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,63 @@
import { useForm, SubmitHandler } from "react-hook-form";
import { ILoginFormInput } from "../utils/type";
import { Container, Box, Input, Button } from "@mui/material";
import { Cookies } from "react-cookie";
import { useForm, SubmitHandler } from "react-hook-form";
import styled from "styled-components";
import { onLogin } from "../api/post";
import { ILoginFormInput } from "../utils/type";

const Login = () => {
const cookies = new Cookies();
const {
register,
formState: { errors },
handleSubmit,
} = useForm<ILoginFormInput>({ mode: "onBlur" });
const onSubmit: SubmitHandler<ILoginFormInput> = (data: any) =>
console.log(data);
const onSubmit: SubmitHandler<ILoginFormInput> = async (data: any) => {
// console.log("[FE data]: ", data);

const result = await onLogin(data);
const { accessToken, refreshToken } = result;

localStorage.setItem("accessToken", accessToken);
cookies.set("refreshToken", refreshToken, { path: "/" });
};

Copy link

Choose a reason for hiding this comment

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

이렇게 할 수도 있군요,,! 배워갑니다,,

return (
<Container maxWidth="sm">
<form onSubmit={handleSubmit(onSubmit)}>
<Box sx={{ display: "flex", flexDirection: "column" }}>
<div>로그인</div>
<Input
{...register("id", {
required: "아이디를 입력해주세요",
})}
placeholder="아이디"
/>
<ErrorMessages>{errors?.id?.message}</ErrorMessages>
<Input
{...register("pw", {
required: "비밀번호를 입력해주세요",
})}
placeholder="비밀번호"
/>
<ErrorMessages>{errors?.pw?.message}</ErrorMessages>
<Button type="submit">로그인</Button>
</Box>
</form>
</Container>
<Wrapper>
<Container maxWidth="sm">
<form onSubmit={handleSubmit(onSubmit)}>
<Box sx={{ display: "flex", flexDirection: "column" }}>
<div>로그인</div>
<Input
{...register("id", {
required: "아이디를 입력해주세요",
})}
placeholder="아이디"
/>
<ErrorMessages>{errors?.id?.message}</ErrorMessages>
<Input
{...register("pw", {
required: "비밀번호를 입력해주세요",
})}
placeholder="비밀번호"
/>
<ErrorMessages>{errors?.pw?.message}</ErrorMessages>
<Button type="submit">로그인</Button>
</Box>
</form>
</Container>
</Wrapper>
);
};

export default Login;

const Wrapper = styled.div`
width: 100%;
margin-top: 5rem;
padding: 0 3rem;
`;

const ErrorMessages = styled.div`
color: red;
font-size: 12px;
Expand Down