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

[2팀 송창엽] [Chapter 2-1] 클린코드와 리팩토링 #29

Open
wants to merge 69 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
bfefb4f
feat: eslint install & init
Songchangyeop Jan 5, 2025
22de851
feat: eslint, prettier 셋업
Songchangyeop Jan 5, 2025
4d4ab38
chore: main.basic 파일 ts로 확장자 변경
Songchangyeop Jan 5, 2025
e8dc23b
fix: 코드 포맷팅
Songchangyeop Jan 5, 2025
9f3cc8e
chore: 코드 분리를 위한 각 역할별 info 주석 추가
Songchangyeop Jan 5, 2025
5f28c5f
fix: main에서 카트로직 모두 분리하여 Cart 파일로 삽입
Songchangyeop Jan 6, 2025
810e3bd
fix: 상품 선택, 추가 UI와 로직을 ProductSelector파일에 분리
Songchangyeop Jan 6, 2025
b89e64a
fix: 총액 관련 UI, 로직 TotalPrice 파일에 분리
Songchangyeop Jan 6, 2025
aedcac4
fix: 카트 아이템 UI, 로직 CartItem 파일에 분리
Songchangyeop Jan 6, 2025
afaf5e8
feat: 카트에 의존적인 로직과 상태를 분리하기 위한 cartStore 생성
Songchangyeop Jan 6, 2025
e974bf2
feat: 팀원들과 함께 lint, prettier 세팅
Songchangyeop Jan 6, 2025
be1c7af
feat: ProductStore 추가하여 아이템 관리
Songchangyeop Jan 6, 2025
465206b
fix: CartItem 컴포넌트 분리하여 관련 로직 처리
Songchangyeop Jan 7, 2025
38d31f7
feat: basic 컴포넌트 렌더링 처리
Songchangyeop Jan 7, 2025
aa873d9
feat: createStore, createObserver를 생성하여 스토어 생성시 createStore를 적용하고 obs…
Songchangyeop Jan 7, 2025
8bc3458
feat: main.ts에서 Cart, Product 스토어 구독
Songchangyeop Jan 7, 2025
6a9a699
feat: createStore에 tsdoc 추가
Songchangyeop Jan 7, 2025
34e51bd
fix: CartStore의 addCartItem 로직 수정
Songchangyeop Jan 7, 2025
be28f51
feat: CartStore에서 총 금액을 받는 getTotalAmount 액션 함수 추가
Songchangyeop Jan 7, 2025
5493be3
fix: cart 컴포넌트 내부에 존재하던 calcCart 함수를 CartStore 내부로 분리 후 해당 함수에 파악을 위한…
Songchangyeop Jan 7, 2025
3847226
fix: calcCart 함수 내부에서 총액을 구하는 반복문 내부 카트의 아이템과 매치되는 프로덕트 아이템을 가져오는 로직 …
Songchangyeop Jan 7, 2025
bca1803
fix: 할인율 구하는 로직 함수로 분리
Songchangyeop Jan 7, 2025
f25c203
fix: calcCart 함수에서 재고개수, 총합, 할인총액 구하는 반복문을 함수로 분리
Songchangyeop Jan 8, 2025
e02629c
fix: cartCart 함수를 Store외부의 유틸함수 관리하는 폴더 내부로 이동해서 관리
Songchangyeop Jan 8, 2025
b5d6b6a
fix: CartStore에서 추가 삭제 될 경우 calculateCartPrice 함수 호출하여 할인률, 할인가 가져오도…
Songchangyeop Jan 8, 2025
5880222
fix: TotalPrice 컴포넌트의 할인율을 Store에서 받도록 처리
Songchangyeop Jan 8, 2025
e117fb1
fix: productSelector의 아이템을 productStore에서 가져오도록 처리
Songchangyeop Jan 8, 2025
5f41907
feat: TotalPrice에 포인트 엘리먼트 추가
Songchangyeop Jan 8, 2025
c3071f1
fix: CartItem의 이벤트 핸들러가 1번만 추가 되도록 처리
Songchangyeop Jan 8, 2025
94dfe5a
fix: productList를 분리
Songchangyeop Jan 8, 2025
8fcc619
fix: ProductSelector에서 아이템을 추가할 수 있도록 로직 수정
Songchangyeop Jan 8, 2025
edf73c3
feat: 심화 과제를 위한 리액트 설치 및 세팅
Songchangyeop Jan 8, 2025
ca6c083
feat: 카트 컴포넌트 생성
Songchangyeop Jan 9, 2025
05fd461
feat: TotalPrice 컴포넌트 생성
Songchangyeop Jan 9, 2025
5b129f1
feat: ProductSelector 컴포넌트 생성
Songchangyeop Jan 9, 2025
93deaf3
feat: Cart의 상태와 액션을 담당하는 CartProvider를 생성
Songchangyeop Jan 9, 2025
fbd778a
feat: 상품을 선택하고 장바구니로 담는 처리를 CartProvider를 통해 처리
Songchangyeop Jan 9, 2025
b1999e5
feat: 장바구니 아이템 클리어 버튼 CartProvider에서 처리
Songchangyeop Jan 9, 2025
aaebf3e
feat: 장바구니 아이템 내부에서 삭제, 추가 CartProvider에서 처리
Songchangyeop Jan 9, 2025
84c1d23
fix: CartItem에서 동일한 디자인의 버튼 컴포넌트 분리
Songchangyeop Jan 9, 2025
16dd4ad
feat: CartProvider에서 totalAmount 내려주도록 처리
Songchangyeop Jan 9, 2025
800a339
feat: CartProvider에서 수량에 변경이 생길 때 마다 calcurateCartPrice 유틸 함수 호출하여 할인…
Songchangyeop Jan 9, 2025
dd511d3
refactor: calculateCart 유틸 내부 함수 리팩토링
Songchangyeop Jan 9, 2025
5a73045
feat: calcurateCart에서 포인트 계산 로직 추가하여 CartProvider에서 관리
Songchangyeop Jan 9, 2025
5a72c6d
refactor: useCreateCartContext를 만들어 컨텍스트 생성시 호출하여 만들도록 처리
Songchangyeop Jan 9, 2025
d31cba9
feat: ProductProvider를 생성하여 상품 재고 수량 처리
Songchangyeop Jan 9, 2025
5926ff9
feat: CartProvider에서 clearCartItem이 호출되면 ProductList의 Quantity가 초기화 되…
Songchangyeop Jan 9, 2025
583286b
refactor: isQuantityCountOver에서 비교대상값인 compareTarget을 받아 공용으로 사용 할 수 …
Songchangyeop Jan 9, 2025
85750a6
feat: StockInfo 컴포넌트에서 재고 부족, 품절 제어 및 UI
Songchangyeop Jan 9, 2025
4502a5c
feat: 번개세일 로직을 담당하는 useFlashSale 훅을 만들어 ProductProvider에서 호출
Songchangyeop Jan 9, 2025
38fc178
feat: 추천상품 세일 로직 useRecommendProduct 훅 만들어서 ProductProvider에서 관리하도록 처리
Songchangyeop Jan 9, 2025
47cd679
refactor: useRecommandProduct 훅 변수 네이밍 정리 및 매직넘버 상수 처리
Songchangyeop Jan 9, 2025
6c26932
refactor: useFlashSale 훅 변수 네이밍 정리 및 매직넘버 상수 처리
Songchangyeop Jan 9, 2025
a32ce46
refactor: 매직넘버 상수 분리
Songchangyeop Jan 9, 2025
49c9056
refactor: ProductProvider, CartProvider에서 컨텍스트 관련 로직만 따로 분리
Songchangyeop Jan 9, 2025
4687d14
refactor: StockInfo 컴포넌트 내부 재고 넘버 상수를 객체로 변경하여 사용
Songchangyeop Jan 9, 2025
509de74
refactor: CartProvider 내부 반복되는 로직 재사용 함수로 분리
Songchangyeop Jan 9, 2025
9667a99
refactor: CartProvider 내부 아이템 추가 삭제시 Quantity 업데이트하는 로직 공통 함수로 분리
Songchangyeop Jan 9, 2025
94d1d9c
fix: Context 파일 분리하면서 생긴 import 경로 에러 처리
Songchangyeop Jan 9, 2025
1b28ff6
fix: component -> components 폴더명 변경
Songchangyeop Jan 9, 2025
9958789
fix: basic의 cartStore를 advanced의 CartProvider 로직과 동일하게 변경
Songchangyeop Jan 9, 2025
09861e0
fix: basic의 productStore를 advanced의 ProductProvider 로직과 동일하게 변경
Songchangyeop Jan 9, 2025
889fe28
fix: basic의 TotalPrice를 advanced의 TotalPrice와 동일하게 변경
Songchangyeop Jan 9, 2025
9197db2
fix: basic의 ProsuctSelector를 advanced의 ProductSelector 로직과 동일하게 변경
Songchangyeop Jan 9, 2025
e74c4af
fix: basic의 Cart, CartItem 로직을 advanced와 동일하게 변경
Songchangyeop Jan 9, 2025
3d24e58
fix: 이벤트 리스너 중독 등록되던 문제 처리
Songchangyeop Jan 9, 2025
c51cb40
fix: advanced TotalPrice 컴포넌트의 이름을 TotalCartPrice로 변경
Songchangyeop Jan 9, 2025
3cf95ea
fix: 가격을 나타내는 이름으로 amount, price 혼재되어 혼란을 야기해 price로 통일
Songchangyeop Jan 9, 2025
9048fe5
refactor: if 조건문에서 의미있는 조건 네이밍 처리
Songchangyeop Jan 9, 2025
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
101 changes: 101 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"root": true,
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended",
"plugin:prettier/recommended",
"plugin:import/recommended",
"plugin:import/typescript"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint", "react", "react-hooks", "jsx-a11y", "import", "prettier"],
"settings": {
"react": {
"version": "detect"
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true,
"project": "./tsconfig.json"
},
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
},
"rules": {
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
],
"@typescript-eslint/consistent-type-imports": [
"error",
{
"prefer": "type-imports",
"disallowTypeAnnotations": true
}
],
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"react/jsx-props-no-spreading": "warn",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"import/order": [
"error",
{
"groups": [["builtin", "external"], "internal", ["parent", "sibling"], "index", "type", "object"],
"newlines-between": "always",
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
],
"import/no-duplicates": "error",
"import/no-unresolved": "error",
"no-console": [
"warn",
{
"allow": ["warn", "error"]
}
],
"no-debugger": "error",
"prefer-const": "error",
"no-var": "error",
"no-multiple-empty-lines": [
"error",
{
"max": 1,
"maxEOF": 0,
"maxBOF": 0
}
],
"jsx-a11y/anchor-is-valid": [
"error",
{
"components": ["Link"],
"specialLink": ["to"]
}
],
"prettier/prettier": "error"
}
}
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"printWidth": 120
}
22 changes: 11 additions & 11 deletions index.advanced.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!DOCTYPE html>
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>장바구니</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 p-8">
<main id="app"></main>
<script type="module" src="./src/advanced/main.advanced.js"></script>
</body>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>장바구니</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 p-8">
<main id="app"></main>
<script type="module" src="./src/advanced/main.advanced.tsx"></script>
</body>
</html>
22 changes: 11 additions & 11 deletions index.basic.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!DOCTYPE html>
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>장바구니</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 p-8">
<main id="app"></main>
<script type="module" src="./src/basic/main.basic.js"></script>
</body>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>장바구니</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 p-8">
<main id="app"></main>
<script type="module" src="./src/basic/main.basic.ts"></script>
</body>
</html>
Loading
Loading