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

[4주차 기본/공유 과제] 🔗 로그인, 회원가입 구현해보기 #6

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a8ff1a0
init: 라이브러리 설치, 필요없는 파일 삭제
se0jinYoon May 8, 2024
26b3fd5
init: 스타일 초기세팅
se0jinYoon May 8, 2024
b64624a
init: 라우터 설정
se0jinYoon May 8, 2024
ad755ba
feat: 재사용 버튼 구현
se0jinYoon May 8, 2024
faf7426
feat: main페이지 구현
se0jinYoon May 8, 2024
ceffe47
feat: 회원가입 라우팅 연결, wrapper구현
se0jinYoon May 8, 2024
ca97cf6
feat: 회원가입 뷰 구현
se0jinYoon May 9, 2024
1571030
feat: 회원가입 뷰 비밀번호, 전화번호 안내 문구
se0jinYoon May 9, 2024
d66025d
feat: 로그인 뷰 구현
se0jinYoon May 9, 2024
813614e
feat: 마이페이지 뷰 구현
se0jinYoon May 9, 2024
ec2b2f3
feat: 라우터 연결
se0jinYoon May 9, 2024
57abc88
feat: axios instance 생성
se0jinYoon May 9, 2024
9b68c9d
refactor: 회원가입 인풋 상수데이터로 렌더링, 값 입력 reducer
se0jinYoon May 9, 2024
27899be
fix: client 객체 baseURL 변경
se0jinYoon May 9, 2024
79691c4
feat: 회원가입 api 연결
se0jinYoon May 10, 2024
19fc7a1
feat: 로그인 api 연결
se0jinYoon May 10, 2024
e8ca510
feat: 유저 정보 가져오기
se0jinYoon May 10, 2024
6a398f0
feat: 비밀번호 변경 로직 연결
se0jinYoon May 10, 2024
a101c42
feat: 홈에서 마이페이지 연결
se0jinYoon May 10, 2024
4dee0f9
chore: 안쓰는 state 삭제
se0jinYoon May 10, 2024
b8792a4
refactor: api 함수 커스텀 훅으로 분리
se0jinYoon May 10, 2024
65a56c5
style: 버튼 theme prop 정리, 코드 개행
se0jinYoon May 10, 2024
1235172
refactor: 비밀번호 변경 함수 로직 변경
se0jinYoon May 10, 2024
4e55974
chore: import 순서 변경
se0jinYoon May 10, 2024
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
1 change: 1 addition & 0 deletions 4주차과제/loginSignup/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_APP_BASE_URL = http://34.64.233.12:8080
21 changes: 21 additions & 0 deletions 4주차과제/loginSignup/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react/jsx-no-target-blank': 'off',
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
24 changes: 24 additions & 0 deletions 4주차과제/loginSignup/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
8 changes: 8 additions & 0 deletions 4주차과제/loginSignup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# React + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
12 changes: 12 additions & 0 deletions 4주차과제/loginSignup/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>👩🏻‍💻 로그인/회원가입 👩🏻‍💻</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
33 changes: 33 additions & 0 deletions 4주차과제/loginSignup/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "loginsignup",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.5.2",
"@fortawesome/free-solid-svg-icons": "^6.5.2",
"@fortawesome/react-fontawesome": "^0.2.0",
"axios": "^1.6.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.23.0",
"styled-components": "^6.1.10",
"styled-reset": "^4.5.2"
},
"devDependencies": {
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.57.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"vite": "^5.2.0"
}
}
1 change: 1 addition & 0 deletions 4주차과제/loginSignup/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions 4주차과제/loginSignup/src/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import styled from 'styled-components';
import Router from './Router';

function App() {
return (
<DesktopWrapper>
<Router />
</DesktopWrapper>
);
}

export default App;

const DesktopWrapper = styled.div`
display: flex;
justify-content: center;
align-items: center;

width: 100vw;
height: 100vh;
`;
22 changes: 22 additions & 0 deletions 4주차과제/loginSignup/src/Router.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-disable react/prop-types */
import { BrowserRouter, Route, Routes } from 'react-router-dom';

import Main from './pages/main/Main';
import Signup from './pages/signup/Signup';
import Login from './pages/login/Login';
import MyPage from './pages/myPage/MyPage';

const Router = () => {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<Main />} />
<Route path="/signup" element={<Signup />} />
<Route path="/login" element={<Login />} />
<Route path="/mypage/:userId" element={<MyPage />} />
</Routes>
</BrowserRouter>
);
};

export default Router;
6 changes: 6 additions & 0 deletions 4주차과제/loginSignup/src/apis/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import axios from 'axios';

export const client = axios.create({
baseURL: import.meta.env.VITE_APP_BASE_URL,
headers: { 'Content-Type': 'application/json' },
});
Copy link

Choose a reason for hiding this comment

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

p5) axios.create로 axios 인스턴스를 만들고 불러와서 사용할수 있네요!! 배워갑니다..

9 changes: 9 additions & 0 deletions 4주차과제/loginSignup/src/apis/getUserInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { client } from './client';

export const getUserInfo = (userId) => {
return client.get(`/member/info`, {
headers: {
memberId: userId,
},
});
};
10 changes: 10 additions & 0 deletions 4주차과제/loginSignup/src/apis/patchChangePw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { client } from './client';

export const patchChangePw = (body, userId) => {
return client.patch(`/member/password`, body, {
headers: {
...client.defaults.headers,
memberId: userId,
},
});
};
5 changes: 5 additions & 0 deletions 4주차과제/loginSignup/src/apis/postLogin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { client } from './client';

export const postLogin = (body) => {
return client.post(`/member/login`, body);
};
5 changes: 5 additions & 0 deletions 4주차과제/loginSignup/src/apis/postSignup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { client } from './client';

export const postSignup = (body) => {
return client.post(`/member/join`, body);
};
35 changes: 35 additions & 0 deletions 4주차과제/loginSignup/src/assets/constants/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const SIGNUP_LABEL = [
{ label: 'ID', detailExist: false },
{
label: 'PW',
detailExist: true,
detail: '비밀번호 형식은 8자이상, 숫자, 특수문자, 영어 알파벳이 포함되어야 합니다.',
},
{ label: '닉네임', detailExist: false },
{ label: '전화번호', detailExist: true, detail: '전화번호 형식은 010-****-**** 입니다.' },
];

const LOGIN_LABEL = [{ label: 'ID' }, { label: 'PW' }];

const MYPAGE_LABEL = [
{
label: 'ID',
content: 'authenticationId',
},
{
label: '닉네임',
content: 'nickname',
},
{
label: '전화번호',
content: 'phone',
},
];

const CHANGE_PW_LABEL = [
{ label: '기존 비밀번호', id: 'previousPassword' },
{ label: '새로운 비밀번호', id: 'newPassword' },
{ label: '비밀번호 확인', id: 'newPasswordVerification' },
];

export { SIGNUP_LABEL, LOGIN_LABEL, MYPAGE_LABEL, CHANGE_PW_LABEL };
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions 4주차과제/loginSignup/src/commons/Button.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* eslint-disable react/prop-types */
import styled, { css } from 'styled-components';

const Button = (props) => {
const { content, onClick } = props;
return (
<ButtonWrapper {...props} onClick={onClick}>

Choose a reason for hiding this comment

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

스프레드 연산자로 prop의 모든 값을 한번에 넘겨줄 수도 있군요! 서진님 덕분에 새롭게 배워가요!!!
이렇게 {...props}를 작성할 경우 {...props}를 작성하지 않은 코드와 어떤 차이점이 있는지 잘 감이 오지 않는데 해당 부분 여쭤봐도 될까요?!

{content}
</ButtonWrapper>
);
};

export default Button;

const ButtonWrapper = styled.button`
display: flex;
justify-content: center;
align-items: center;

width = auto;
height = auto;

padding: 0.5rem 0.8rem;

border: 1px solid ${({ theme }) => theme.colors.white};
border-radius: 0.3rem;

font-size: 1.2rem;
cursor: pointer;

${({
theme,
$marginTop = '',
$buttonColor = 'skyblue',
$fontColor = 'white',
$hoverFontColor = 'white',
$hoverColor = 'blue',
}) => css`
margin-top: ${$marginTop};
Copy link

Choose a reason for hiding this comment

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

p5) 혹시 여기서만 css 로 css 설정을 해주신 이유가 있을까요??


background-color: ${theme.colors[$buttonColor]};
color: ${theme.colors[$fontColor]};

&:hover {
border: 1px solid ${({ theme }) => theme.colors.blue};

color: ${theme.colors[$hoverFontColor]};
background-color: ${theme.colors[$hoverColor]};
}
`}
`;
16 changes: 16 additions & 0 deletions 4주차과제/loginSignup/src/commons/ButtonWrapper.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-disable react/prop-types */
import styled from 'styled-components';

const ButtonWrapper = (props) => {
const { children } = props;
return <BtnWrapper>{children}</BtnWrapper>;
};

export default ButtonWrapper;

const BtnWrapper = styled.div`
display: flex;
justify-content: center;
align-items: center;
gap: 2rem;
`;
52 changes: 52 additions & 0 deletions 4주차과제/loginSignup/src/commons/Input.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* eslint-disable react/prop-types */
import styled from 'styled-components';

const Input = (props) => {
const { label, children, onChangeHandler } = props;

return (
<InputWrapper>
<InputContainer>
<InputLabel>{label}</InputLabel>
<StyledInput id={label} onChange={onChangeHandler} />
</InputContainer>
{children}
</InputWrapper>
);
};

export default Input;

const InputWrapper = styled.div`
position: relative;
`;

const InputContainer = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
gap: 2rem;

width: 28rem;
`;

const InputLabel = styled.label`
color: ${({ theme }) => theme.colors.white};

font-size: 1.2rem;
font-weight: bolder;
`;

const StyledInput = styled.input`
width: 17rem;

padding: 0.5rem 0.7rem;

border: none;
border-radius: 0.5rem;

background-color: ${({ theme }) => theme.colors.white};

font-size: 1.1rem;
font-family: ${({ theme }) => theme.font.fontFamily};
`;
39 changes: 39 additions & 0 deletions 4주차과제/loginSignup/src/commons/LoginSignupWrapper.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* eslint-disable react/prop-types */
import styled from 'styled-components';

const LoginSignupWrapper = (props) => {
const { title, children } = props;
return (
<LoginSignupWrp>
<Title>{title}</Title>
{children}
</LoginSignupWrp>
);
};

export default LoginSignupWrapper;

const LoginSignupWrp = styled.section`
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
gap: 2.7rem;

width: 35rem;

padding: 2.5rem 1rem 4rem 1rem;

border: 1px solid ${({ theme }) => theme.colors.white};
border-radius: 0.5rem;

color: ${({ theme }) => theme.colors.black};
background-color: ${({ theme }) => theme.colors.lightSkyblue};
`;

const Title = styled.h1`
color: ${({ theme }) => theme.colors.white};

font-size: 1.7rem;
font-weight: bolder;
`;
Loading