-
Notifications
You must be signed in to change notification settings - Fork 35
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
[도리] 1주차 pr요청 #6
Conversation
- fe/be 폴더 생성 - eslint - prettier
commit 96b47b2d281891c886b3730e9fe86413d65018bd Author: yunho <kimyouknow@naver.com> Date: Mon May 9 22:15:36 2022 +0900 Chore: 스타일링 라이브러리 추가 - material ui - styled-components commit 870086d311f418d9016c6a2b9cb4d9f13b58ff8c Author: yunho <kimyouknow@naver.com> Date: Mon May 9 13:48:05 2022 +0900 Chore: eslint파일 확장자 변경
commit 5066297ece066179c550ae7529e4d39d63da2394 Author: yunho <kimyouknow@naver.com> Date: Mon May 9 23:43:50 2022 +0900 Chore: mock데이터 변수명 변경 pruduct_name -> product_name commit 32da444d15e2e9336f6496e8450f405e7617f28e Author: yunho <kimyouknow@naver.com> Date: Mon May 9 23:43:21 2022 +0900 Chore: prop-types 라이브러리 추가 commit c5506d665f4a090cebd2e9b539554b78153baca5 Author: yunho <kimyouknow@naver.com> Date: Mon May 9 23:32:15 2022 +0900 Chore: drinks, snacks mock데이터 추가
commit 606a497fe17c9533eb491bc179315ca3097c85a0 Author: yunho <kimyouknow@naver.com> Date: Tue May 10 23:43:51 2022 +0900 Refactor: layout구조 변경 react-router-v6에서 사용하는 outlet과 index path 활용 commit d8eda42128bcda44e8338d543e562f2dcdbb228d Author: yunho <kimyouknow@naver.com> Date: Tue May 10 17:45:16 2022 +0900 Chore: App.jsx src/로 위치변경 commit 50d9afcce3757b1e29379294d9ea7fd95d185732 Author: yunho <kimyouknow@naver.com> Date: Tue May 10 17:00:34 2022 +0900 Feat: 잔고에 따른 입력 값 수정 로직 commit 592463491a4705173a3cf6f0234191d733ee0338 Author: yunho <kimyouknow@naver.com> Date: Tue May 10 16:20:49 2022 +0900 Rename: ChangeUnitsContainer -> ChangesUnitsContainer commit 4c52a27693b7adec3979ce53b46fa008eed9ba32 Author: yunho <kimyouknow@naver.com> Date: Tue May 10 16:12:58 2022 +0900 Chore: setKoreanLocaleMoney 반환 값에 "원" 단위 제거 commit ea69187b304beb06ab6c886bcbd6a830ba985bd8 Merge: a78432d 5981d05 Author: yunho <kimyouknow@naver.com> Date: Tue May 10 15:57:44 2022 +0900 Merge branch 'vm-ui-tester' into vm-ui commit 5981d05e7d4b803212701646120eba4e05f5b945 Author: yunho <kimyouknow@naver.com> Date: Tue May 10 15:43:33 2022 +0900 Feat: Insert Money에 따라 살 수 있는 제품들 ui표시 commit 15bde89eba2c2a256d76dd4deba74f42d1e84fcf Author: yunho <kimyouknow@naver.com> Date: Tue May 10 15:26:13 2022 +0900 Rename: ChangeInput -> InsertMoneyForm commit cdba1f15ec64ad0384dc9ba7d66d84194a57bff8 Author: yunho <kimyouknow@naver.com> Date: Tue May 10 15:22:51 2022 +0900 Feat: 사용자 돈 입력값 validation - 숫자만 받기 commit ce0d830b1e378d1c31ddb0498e418c66a16fc4de Author: yunho <kimyouknow@naver.com> Date: Tue May 10 14:21:31 2022 +0900 Feat: 유닛 버튼을 눌렀을 때 잔고 감소 commit dcab3280426f1a53e5b3fcc4ef1959c731ecb0d0 Author: yunho <kimyouknow@naver.com> Date: Tue May 10 12:33:00 2022 +0900 Feat: 현재가지고 있는 돈을 단위별로 분류 commit 64b06e48c28f7a64f8618a2fba7d680c859cdec5 Author: yunho <kimyouknow@naver.com> Date: Tue May 10 11:39:16 2022 +0900 Design: VM 레이아웃 설정 - ProductsContainer: grid - ProductCard: 타입에 따른 border색깔 변경 commit 6d6794acb6dacbffc4a4863112ff89eb70c97dfb Author: yunho <kimyouknow@naver.com> Date: Tue May 10 11:24:42 2022 +0900 Feat: 앱 전체 레이아웃 설정 - main - header commit 8ffb74a7116979bfd93d94033066bd427a430933 Author: yunho <kimyouknow@naver.com> Date: Mon May 9 23:44:23 2022 +0900 Feat: Product 컴포넌트 drink, snack 객체를 렌더링 commit e61a40d30feb0385ea220d1f5b478f9ecdb0905c Author: yunho <kimyouknow@naver.com> Date: Mon May 9 23:43:50 2022 +0900 Chore: mock데이터 변수명 변경 pruduct_name -> product_name commit 9c7ac1b87b906f44a0f8a61d6bb7ee35ca3ea08f Author: yunho <kimyouknow@naver.com> Date: Mon May 9 23:43:21 2022 +0900 Chore: prop-types 라이브러리 추가 commit 9e88a2419ba627ae4ce3f53fe6edd947d56cff26 Author: yunho <kimyouknow@naver.com> Date: Mon May 9 23:32:15 2022 +0900 Chore: drinks, snacks mock데이터 추가 commit 36f784ca5175283763d341368c958136850861c0 Author: yunho <kimyouknow@naver.com> Date: Mon May 9 23:31:55 2022 +0900 Chore: eslint 절대경로 에러 수정
commit c91009ac462cfd6a8810cc89f91abc613daa18ba Author: yunho <kimyouknow@naver.com> Date: Wed May 11 14:44:55 2022 +0900 Refactor: ChangesUnit컴포넌트 VMmangement 페이지로 분리 commit fcd4ec54b4b516a1c07ab878b3b8776bfce12f91 Author: yunho <kimyouknow@naver.com> Date: Wed May 11 14:44:21 2022 +0900 Feat: GNB
commit 40812ef2ec9ec56055e30bcb91faf90d543a5639 Author: yunho <kimyouknow@naver.com> Date: Wed May 11 15:31:20 2022 +0900 Design: product 색깔 변수 theme 적용 commit bb54f7c6a18ecd140c1e9bbd9c5955446c573dd7 Author: yunho <kimyouknow@naver.com> Date: Wed May 11 15:29:13 2022 +0900 Design: theme color 추가 commit 1ef3fe5d2e4197ed27ea02832ad8c9bf73cef8bf Author: yunho <kimyouknow@naver.com> Date: Wed May 11 15:26:36 2022 +0900 Design: GBN Tabs commit 788f890a6b20f16b00f13c2bf52c9cd45858cd8d Author: yunho <kimyouknow@naver.com> Date: Wed May 11 15:01:54 2022 +0900 Design: Header와 Main 가운데 정렬 commit e0f6d647eea7a099a43b0adbc2bcda3cc8c983d3 Author: yunho <kimyouknow@naver.com> Date: Wed May 11 14:54:20 2022 +0900 Design: global style 세팅
commit 8da9a64b76017a97e41e137a91eec4a7ea0e9e37 Author: yunho <kimyouknow@naver.com> Date: Wed May 11 16:38:25 2022 +0900 Bug: GNB 버그 주석 추가 url과 상관없이 활성화탭이 기본 값으로 됨. commit 99310e0f6431c41ef11ca67cd93e143a464613bd Author: yunho <kimyouknow@naver.com> Date: Wed May 11 16:34:00 2022 +0900 Feat: VMmangement페이지에 Products 컴포넌트 추가 commit 378c7ffa1c933f38da570b66ee0ec99fc11e721e Author: yunho <kimyouknow@naver.com> Date: Wed May 11 16:33:38 2022 +0900 Refactor: VendingMachine 페이지와 VMContext연결 commit a701919177bf90116aee4457213f450724f37ae6 Author: yunho <kimyouknow@naver.com> Date: Wed May 11 16:33:05 2022 +0900 Feat: Products 컴포넌트 분리 commit 1538afb7cd8115c8645df529b13f4f00f762313a Author: yunho <kimyouknow@naver.com> Date: Wed May 11 16:18:47 2022 +0900 Feat: VMContext commit ac89f2a1d418e602b8ce00bf02666be13de9e6e5 Author: yunho <kimyouknow@naver.com> Date: Wed May 11 16:06:45 2022 +0900 Refactor: 재고관리 잔돈 누를시 줄어드는 로직 제거
* chore: 프로젝트 초기 셋팅 (#2) * feat:VendingMachine, Wallet 라우팅 (#5) * Wallet Component - Markup (#6) * update: money data * design: Coin Component * design: Balance Component * design: Wallet Component * VendingMachine Component - Markup (#9) * update: product data * design: VendProduct Component * design: VendController Component * design: HistoryBox Component * design: VendingMachine Component * design: ChangeOutlet Component * design: InsertCoin Component * refactor: VendController Component의 하위컴포넌트 분리 * chore: update yarn.lock * Common Components 분리(1) (#10) * feat: Button Component 구현 * feat: InsertCoin, BrandLabel, Unit에 Button Component 적용 * chore: polished 라이브러리 설치 * refactor: Nav를 NavLink 적용하여 리팩토링 * chore: gh-pages 라이브러리 설치
// FIXME: 새로 고침했을 때 URL과 상관없이 활성화탭이 0번으로 되는 버그 | ||
function GlobalNavigation() { | ||
const [value, setValue] = useState(0); | ||
const handleChange = (event, newValue) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어떤 change를 handling 하는 건지 더 구체적으로 네이밍 해보면 좋을 것 같네요~
|
||
// FIXME: 새로 고침했을 때 URL과 상관없이 활성화탭이 0번으로 되는 버그 | ||
function GlobalNavigation() { | ||
const [value, setValue] = useState(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 state도 어떤 상태인지 알 수 있도록 구체적으로 네이밍 해보는게 어떨까요?
const divideBalance = useCallback(() => { | ||
const resetUnit = getRestUnit(changesUnits, totalBalance); | ||
console.log('resetUnit', resetUnit); | ||
VMdispatch({ type: 'setRestUnit', value: resetUnit }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
action도 상수화 해볼 수 있을 것 같아요!
.sort((prev, cur) => cur.unit - prev.unit) | ||
.reduce( | ||
({ rest, resultArr }, cur) => { | ||
const taretCount = Math.floor(rest / cur.unit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
targetCount..?
return targetUnit?.unit; | ||
}; | ||
|
||
function VendingMachine(props) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
컴포넌트 정의할 때는 함수 선언문을 사용하시는데, 함수 선언문과 표현식을 사용을 결정하는 도리만의 규칙이 있는지 궁금하네요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
컴포넌트는 함수 선언문으로 사용했고, 컴포넌트 내부 함수나 기타 함수들은 표현식으로 사용하고 있습니다. 일관성을 위해 통일하는 것이 더 좋을까요?
(+ 컴포넌트 내부 함수의 경우 useCallback 같은 hooks를 쓸 때, 표현식만 가능하다고 알고 있는 맞을까요? )
@@ -0,0 +1,2 @@ | |||
/* eslint-disable import/prefer-default-export */ | |||
export const setKoreanLocaleMoney = number => `${number.toLocaleString('ko-KR')}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
숫자를 가져와 천 단위 콤마를 찍어 리턴하는 유틸함수이군요.
값을 리턴하는 함수명에 set이 들어가니 조금 어색하게 느껴지네요!
if (substractAbs < acc) { | ||
return acc; | ||
} | ||
return unit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
삼항 연산자 사용해서 한 줄로 작성해도 괜찮을 것 같네요!
if (!existUnits) { | ||
alert('잔돈이 없어요'); | ||
} | ||
const targetUnit = findTargetUnit(existUnits, submitOnlyNumber); | ||
console.log('targetUnit :>> ', targetUnit); | ||
if (!targetUnit) { | ||
const closestUnit = findClosestUnit(existUnits, submitOnlyNumber); | ||
if (!closestUnit) { | ||
alert('가까운 돈도 없어요'); | ||
} | ||
console.log('target :>> ', closestUnit); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
잔돈 처리하는 로직에 처리해야할 case가 많아 보이는데요. 이 부분 로직 분리해도 괜찮을 것 같네요.
안녕하세요 도리. 리뷰를 맡은 Daisy입니다~ 2주간 잘 부탁드려요! 또 styled components import 할 때 S라는 이름으로 import 해서 쓰는 컨벤션은 저도 전에 사용해본 적이있는데, 질문에 답변을 드리자면,
개인적으로 저는 컴포넌트 안에서 사용되는 함수는 다 해당 컴포넌트 안에서 정의하는 걸 선호합니다. 컴포넌트가 리렌더링 될 때 함수가 새로 생성 되어 퍼포먼스 측면에서 좋지 않을 거라는 우려하시는 부분은 리액트 공식문서에 따르면
따라서 이를 참고하셔서 컴포넌트 내부에 |
const decideBorderColor = (type, color) => { | ||
switch (type) { | ||
case 'drink': | ||
return color.orange; | ||
case 'snack': | ||
return color.mint; | ||
default: | ||
return 'black'; | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
단순히 case 따라 color값을 리턴하는 거라면 함수가 아니라 객체로 정의해도 괜찮을 것 같은데 어떠신가요?
mainWidth: '1280px', | ||
}; | ||
|
||
const theme = { color, layout }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theme 사용 너무 좋네요 👍
targetPrice => { | ||
return targetPrice <= insertMoney; | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
brace 없이 바로 return 하도록 해도 되겠네요!
@damilog 자세한 답변 감사해요😄. useCallback이 의존성이 바뀌지 않으면 무조건 함수가 새로 생성되지 않는다고 알고 있었는데 설명해주신 내용과 함께 걸어주신 링크를 참고해서 다시 찾아봐야겠네요! 그 외에 코멘트 남겨주신 부분들도 고려해서 다음 pr에 반영해보겠습니다. |
commit 53fb74cecd3f7ed68a891e74df7cfe2f528c6514 Author: yunho <kimyouknow@naver.com> Date: Fri May 13 11:54:37 2022 +0900 Chore: 주석삭제 및 notFound 페이지 commit 7cd0f236c7839fb9d5c4e72f8fa2aac05c174998 Author: yunho <kimyouknow@naver.com> Date: Fri May 13 11:48:30 2022 +0900 Chore: 1번 째 pr 피드백반영 - codesquad-members-2022#6 commit ed659eed47de2dd5ea0f2cd18fe79326881e6c72 Author: yunho <kimyouknow@naver.com> Date: Fri May 13 11:38:06 2022 +0900 Fix: 새로고침시 tab ui path에 맞게 활성화
* chore: 프로젝트 초기 셋팅 (#2) * feat:VendingMachine, Wallet 라우팅 (#5) * Wallet Component - Markup (#6) * update: money data * design: Coin Component * design: Balance Component * design: Wallet Component * VendingMachine Component - Markup (#9) * update: product data * design: VendProduct Component * design: VendController Component * design: HistoryBox Component * design: VendingMachine Component * design: ChangeOutlet Component * design: InsertCoin Component * refactor: VendController Component의 하위컴포넌트 분리 * chore: update yarn.lock * Common Components 분리(1) (#10) * feat: Button Component 구현 * feat: InsertCoin, BrandLabel, Unit에 Button Component 적용 * chore: polished 라이브러리 설치 * refactor: Nav를 NavLink 적용하여 리팩토링 * chore: gh-pages 라이브러리 설치 * Display Mode(dark/light) (#13) * [DOTORI] 1주차 첫번째 PR (#25) * chore: 프로젝트 초기 셋팅 (#2) * feat:VendingMachine, Wallet 라우팅 (#5) * Wallet Component - Markup (#6) * update: money data * design: Coin Component * design: Balance Component * design: Wallet Component * VendingMachine Component - Markup (#9) * update: product data * design: VendProduct Component * design: VendController Component * design: HistoryBox Component * design: VendingMachine Component * design: ChangeOutlet Component * design: InsertCoin Component * refactor: VendController Component의 하위컴포넌트 분리 * chore: update yarn.lock * Common Components 분리(1) (#10) * feat: Button Component 구현 * feat: InsertCoin, BrandLabel, Unit에 Button Component 적용 * chore: polished 라이브러리 설치 * refactor: Nav를 NavLink 적용하여 리팩토링 * chore: gh-pages 라이브러리 설치 * feat: useDisplay 커스텀 훅 생성 * feat: AppLayout, ToggleDisplay Component 구현 * feat: DisplayProvider 구현 displayMode를 전역 상태로 관리한다. * design: title font 변경, change outlet title 대문자로 변경 * PR1 Refactoring (#16) * refactor: components 디렉토리 구조 변경 * feat: common components - Nav 구현 * refactor: 라우터 모듈 분리 * refactor: 사용하지 않는 styled-components 제거, div->span, strong 태그 변경 * refactor: CoinContainer, VendProductContainer Component 분리 * Wallet Component - 동전 투입 기능 (#17) * feat: 금액 버튼 클릭시 해당 금액 개수 감소 렌더링 useCoin 커스텀 훅 사용 * feat: 금액 버튼 클릭시 잔고 금액 감소 렌더링 useBalance 커스텀 훅 사용 * feat: CoinProvider 생성 outlet 상위 컴포넌트에 생성하여 라우팅에 따른 상태 초기화 방지 * feat: InsertCoinProvider 구현 지갑에서 선택한 금액을 자판기에 투입된 금액으로 렌더링 * rename: components 디렉토리 구조 수정 * remove: merge로 생성된 중복 파일 제거 * rename: 컴포넌트 디렉토리명 대문자로 변경 * refactor: balance state 제거, useBalance삭제 coin state로 연산할 수 있는 balance state를 제거
- export default는 바로, export는 젤 하단에서로 통일 - 대문자로 시작한 변수 소문자로 변경 issue #6
* Refactor: contextApi+useReducer (action, reducer, type) commit 66fb291f8ba4bfa708819fda01b4babcff98740a Author: yunho <kimyouknow@naver.com> Date: Thu May 12 11:41:00 2022 +0900 Feat: NotFound 페이지 commit 5046ef9f881018c4ae70ec38d6325d1f46459d08 Author: yunho <kimyouknow@naver.com> Date: Thu May 12 11:11:55 2022 +0900 Refactor: vmContext폴더 action,type,reducer 분리 * Feat: msw 및 api 요청 세팅 commit 5bca16798f4bf60ddf33d085dcd3e39e6e9e38bf Author: yunho <kimyouknow@naver.com> Date: Thu May 12 12:01:50 2022 +0900 Feat: api 및 route 세팅 commit 6c15f4792e8d77265de775e5e46fe8d93a60f3c7 Author: yunho <kimyouknow@naver.com> Date: Thu May 12 11:54:01 2022 +0900 Feat: msw * Feat:VMContext에서 async-action추가 및 관심사 분리 - action, type, reducer 분리 commit 8f603b02b29fc2c94bc3d2422a846366111729db Author: yunho <kimyouknow@naver.com> Date: Thu May 12 16:05:12 2022 +0900 Chore: 모킹 데이터 msw 폴더에서 관리 - 기존 mock폴더 삭제 commit b7b2e8e6beee9636bd495080154b5e7312a7e30c Author: yunho <kimyouknow@naver.com> Date: Thu May 12 16:00:20 2022 +0900 Feat: Products컴포넌트에 products 데이터 가져오는 비동기 요청 commit 9495e81deb8ec28c38a03f7123ff27f204149e5b Author: yunho <kimyouknow@naver.com> Date: Thu May 12 15:59:49 2022 +0900 Refactor: context에서 action분리해서 생긴 오류 해결 commit 4efb19c662fe2e801a83572dbb950ebcb93fe460 Author: yunho <kimyouknow@naver.com> Date: Thu May 12 15:59:19 2022 +0900 Refactor: InsertMoneyForm에 React.memo 추가 - 순수함수여서 추가함 commit 428a6c3e786ff8ef8ea88f187f55f5a2f5738f6c Author: yunho <kimyouknow@naver.com> Date: Thu May 12 15:58:39 2022 +0900 Chore: VendingMachine컴포넌트 외부함수 위치 조정 - 컴포넌트 외부에서 사용하는 함수 컴포넌트 아래로 위치 조정 commit 0f6627ca3aa2ce8aee71702478f819212e1f7711 Author: yunho <kimyouknow@naver.com> Date: Thu May 12 15:57:44 2022 +0900 Refactor: VMContext에서 action과 type분리 commit 72463e3c3cc0a3d1423ecebe135ed9e7659d8363 Author: yunho <kimyouknow@naver.com> Date: Thu May 12 15:57:07 2022 +0900 Feat: GET products 요청 commit bed5911215ea51b2345cab087c8346c8c44a2df3 Author: yunho <kimyouknow@naver.com> Date: Thu May 12 15:56:26 2022 +0900 Fix: axios instance config 배열에서 객체로 수정 * Feat: 매니저 로직 (재고 및 잔돈 관리) - 상품 추가 및 제거 - 잔돈 추가 및 제거 commit 6814690b6e4feecceff49266bb51d778d0307e5f Author: yunho <kimyouknow@naver.com> Date: Fri May 13 11:18:36 2022 +0900 Chore: 주석 정리 commit 0a1f5d13436d98297cd8d119969e29119aeca018 Author: yunho <kimyouknow@naver.com> Date: Fri May 13 11:16:46 2022 +0900 Refator: msw/controller/manger - 단위 찾는 로직 분리 getNewUnitsAndTargetInfo() commit d93ac77a7612692e5dd5efacc6a53ae0ee5f09ca Author: yunho <kimyouknow@naver.com> Date: Fri May 13 10:46:54 2022 +0900 Refator: msw/controller/manger - 상품찾는 로직 분리 getNewProductsAndTargetInfo() commit f116edf164566f483dda20d3e128255e18e51f2b Author: yunho <kimyouknow@naver.com> Date: Fri May 13 10:40:30 2022 +0900 Refactor: msw - updateProduct()함수 분리 및 controller분리 commit 707e304c591149c188411f4ed42259874cf89cab Author: yunho <kimyouknow@naver.com> Date: Fri May 13 10:29:33 2022 +0900 Refactor: VMcontext위치 index.js -> layout commit 87abed929cd2ed7649b393aab7d86cf4b0f9a162 Author: yunho <kimyouknow@naver.com> Date: Fri May 13 10:29:14 2022 +0900 Feat: msw- 선택한 잔고 count가 0이하면 에러 반환 commit b9e0ef667cc1368f1aa8cad956dfa85304b62b3b Author: yunho <kimyouknow@naver.com> Date: Fri May 13 09:45:08 2022 +0900 Refactor: 선택된 상품이 업데이트 되었을 때 targetProduct도 업데이트 commit 8b14f9d06044b619338f6b0f43aeb0f29d6e1757 Author: yunho <kimyouknow@naver.com> Date: Fri May 13 09:36:32 2022 +0900 Refactor: vmReducer - 새로운 제품 업데이트 하는 함수 commit 1f77f34375bfdff0853911321021edf74f513d0e Author: yunho <kimyouknow@naver.com> Date: Fri May 13 09:31:10 2022 +0900 Feat: 상품 재고 +,- api 연결 commit 15942f34a6bbd8691845aab24a4e3210c7b0de1c Author: yunho <kimyouknow@naver.com> Date: Fri May 13 09:12:08 2022 +0900 Refactor: msw의 addTargetUnit()을 subStractTargetUnit()과 같은 로직으로 변경 commit c60677cc7aa9b5a625180c28fd3abc8dc4e5b871 Author: yunho <kimyouknow@naver.com> Date: Fri May 13 08:51:09 2022 +0900 Rename: productApi -> globalApi commit 88bbeedbe6bed34988239b27678b01f1e66cedab Author: yunho <kimyouknow@naver.com> Date: Fri May 13 08:43:47 2022 +0900 Rename: handleClickProduct -> handleSelectProduct commit 7eaa7d41c5f31b5383c9871d8218b80630f24d7a Author: yunho <kimyouknow@naver.com> Date: Fri May 13 08:32:21 2022 +0900 Feat: 관리자가 잔고 빼는 로직 msw commit 8afeb647cbed2036b937575abeb67ad9b9f1450b Author: yunho <kimyouknow@naver.com> Date: Thu May 12 23:12:47 2022 +0900 Feat: msw 잔고 +,- 로직 commit 5141f04ac86a05d60246bdbed8f00ec928e762fc Author: yunho <kimyouknow@naver.com> Date: Thu May 12 22:42:32 2022 +0900 Feat: 잔고 돈 단위 별 추가 및 삭제 요청 - msw commit 66e25cfcd77116e1535cd5a46e330a808d40c532 Author: yunho <kimyouknow@naver.com> Date: Thu May 12 22:12:03 2022 +0900 Feat: 잔고 가져오는 mangerApi commit 827609a85e82b5098bcf838b580d93c0a38a1f01 Author: yunho <kimyouknow@naver.com> Date: Thu May 12 21:52:07 2022 +0900 Chore: msw 실행 Npm 스크립트 변경 commit 249ad04ba092b223ac641bffb585f768030388a7 Author: yunho <kimyouknow@naver.com> Date: Thu May 12 16:38:09 2022 +0900 Feat: 재고관리 - 선택된 상품 별도로 UI에 표시 * Refactor: pr요청 전 주석 처리 및 1번 째 pr피드백 반영 commit 53fb74cecd3f7ed68a891e74df7cfe2f528c6514 Author: yunho <kimyouknow@naver.com> Date: Fri May 13 11:54:37 2022 +0900 Chore: 주석삭제 및 notFound 페이지 commit 7cd0f236c7839fb9d5c4e72f8fa2aac05c174998 Author: yunho <kimyouknow@naver.com> Date: Fri May 13 11:48:30 2022 +0900 Chore: 1번 째 pr 피드백반영 - #6 commit ed659eed47de2dd5ea0f2cd18fe79326881e6c72 Author: yunho <kimyouknow@naver.com> Date: Fri May 13 11:38:06 2022 +0900 Fix: 새로고침시 tab ui path에 맞게 활성화 * Feat: 상품 주문하면 수량 감소 TODO: 잔고관리 로직 추가하기 commit ca7c728b29f64855a06adc5bfa1044030776f78c Author: yunho <kimyouknow@naver.com> Date: Fri May 13 14:43:26 2022 +0900 Feat: 상품 주문하면 수량 감소하는 로직 commit ad268096f4f79650844daab4b4ec6a75e9d565bd Author: yunho <kimyouknow@naver.com> Date: Fri May 13 14:38:17 2022 +0900 Feat: 주문하기 api 연결 commit f6108b61d100b2815afa793213e4c4a5377e6fc2 Author: yunho <kimyouknow@naver.com> Date: Fri May 13 14:31:12 2022 +0900 Feat: 상품 주문하기 버튼 추가 commit b13d7980906e333461446240bcfdc8fe6f7b4eee Author: yunho <kimyouknow@naver.com> Date: Fri May 13 14:24:19 2022 +0900 Rename: handleSubmitInsertMoney -> handleReturnChanges commit 0fd7642422e5d2364cb24f1e37d8f15d41cb929f Author: yunho <kimyouknow@naver.com> Date: Fri May 13 14:24:00 2022 +0900 Feat: 선택한 상품에 주문하기 버튼 보여주기
* chore: 프로젝트 초기 셋팅 (#2) * feat:VendingMachine, Wallet 라우팅 (#5) * Wallet Component - Markup (#6) * update: money data * design: Coin Component * design: Balance Component * design: Wallet Component * VendingMachine Component - Markup (#9) * update: product data * design: VendProduct Component * design: VendController Component * design: HistoryBox Component * design: VendingMachine Component * design: ChangeOutlet Component * design: InsertCoin Component * refactor: VendController Component의 하위컴포넌트 분리 * chore: update yarn.lock * Common Components 분리(1) (#10) * feat: Button Component 구현 * feat: InsertCoin, BrandLabel, Unit에 Button Component 적용 * chore: polished 라이브러리 설치 * refactor: Nav를 NavLink 적용하여 리팩토링 * chore: gh-pages 라이브러리 설치 * Display Mode(dark/light) (#13) * [DOTORI] 1주차 첫번째 PR (#25) * chore: 프로젝트 초기 셋팅 (#2) * feat:VendingMachine, Wallet 라우팅 (#5) * Wallet Component - Markup (#6) * update: money data * design: Coin Component * design: Balance Component * design: Wallet Component * VendingMachine Component - Markup (#9) * update: product data * design: VendProduct Component * design: VendController Component * design: HistoryBox Component * design: VendingMachine Component * design: ChangeOutlet Component * design: InsertCoin Component * refactor: VendController Component의 하위컴포넌트 분리 * chore: update yarn.lock * Common Components 분리(1) (#10) * feat: Button Component 구현 * feat: InsertCoin, BrandLabel, Unit에 Button Component 적용 * chore: polished 라이브러리 설치 * refactor: Nav를 NavLink 적용하여 리팩토링 * chore: gh-pages 라이브러리 설치 * feat: useDisplay 커스텀 훅 생성 * feat: AppLayout, ToggleDisplay Component 구현 * feat: DisplayProvider 구현 displayMode를 전역 상태로 관리한다. * design: title font 변경, change outlet title 대문자로 변경 * PR1 Refactoring (#16) * refactor: components 디렉토리 구조 변경 * feat: common components - Nav 구현 * refactor: 라우터 모듈 분리 * refactor: 사용하지 않는 styled-components 제거, div->span, strong 태그 변경 * refactor: CoinContainer, VendProductContainer Component 분리 * Wallet Component - 동전 투입 기능 (#17) * feat: 금액 버튼 클릭시 해당 금액 개수 감소 렌더링 useCoin 커스텀 훅 사용 * feat: 금액 버튼 클릭시 잔고 금액 감소 렌더링 useBalance 커스텀 훅 사용 * feat: CoinProvider 생성 outlet 상위 컴포넌트에 생성하여 라우팅에 따른 상태 초기화 방지 * feat: InsertCoinProvider 구현 지갑에서 선택한 금액을 자판기에 투입된 금액으로 렌더링 * rename: components 디렉토리 구조 수정 * remove: merge로 생성된 중복 파일 제거 * rename: 컴포넌트 디렉토리명 대문자로 변경 * refactor: balance state 제거, useBalance삭제 coin state로 연산할 수 있는 balance state를 제거 * PR2 Refactoring (#21) * refactor: setCoin 로직 변경 배열의 카피본에서 같은 값을 갖는 인덱스 요소의 객체를 변경 -> map 사용 * refactor: grid repeat 함수 적용 * refactor: Coin Component useMemo 적용, setProvider 분리 Coin Component 클릭시 금액의 변동사항이 있는 컴포넌트만 리렌더링 된다. * feat: 지갑에서 금액을 투입하면 알림 문구가 뜬다. (#23) useReducer 적용
* name 데이터 추가 * 일부 데이터 가격 수정 Related to: #6
* MDN font-weight 참고 Related to: #6
* chore: 프로젝트 초기 셋팅 (#2) * feat:VendingMachine, Wallet 라우팅 (#5) * Wallet Component - Markup (#6) * update: money data * design: Coin Component * design: Balance Component * design: Wallet Component * VendingMachine Component - Markup (#9) * update: product data * design: VendProduct Component * design: VendController Component * design: HistoryBox Component * design: VendingMachine Component * design: ChangeOutlet Component * design: InsertCoin Component * refactor: VendController Component의 하위컴포넌트 분리 * chore: update yarn.lock * Common Components 분리(1) (#10) * feat: Button Component 구현 * feat: InsertCoin, BrandLabel, Unit에 Button Component 적용 * chore: polished 라이브러리 설치 * refactor: Nav를 NavLink 적용하여 리팩토링 * chore: gh-pages 라이브러리 설치 * Display Mode(dark/light) (#13) * [DOTORI] 1주차 첫번째 PR (#25) * chore: 프로젝트 초기 셋팅 (#2) * feat:VendingMachine, Wallet 라우팅 (#5) * Wallet Component - Markup (#6) * update: money data * design: Coin Component * design: Balance Component * design: Wallet Component * VendingMachine Component - Markup (#9) * update: product data * design: VendProduct Component * design: VendController Component * design: HistoryBox Component * design: VendingMachine Component * design: ChangeOutlet Component * design: InsertCoin Component * refactor: VendController Component의 하위컴포넌트 분리 * chore: update yarn.lock * Common Components 분리(1) (#10) * feat: Button Component 구현 * feat: InsertCoin, BrandLabel, Unit에 Button Component 적용 * chore: polished 라이브러리 설치 * refactor: Nav를 NavLink 적용하여 리팩토링 * chore: gh-pages 라이브러리 설치 * feat: useDisplay 커스텀 훅 생성 * feat: AppLayout, ToggleDisplay Component 구현 * feat: DisplayProvider 구현 displayMode를 전역 상태로 관리한다. * design: title font 변경, change outlet title 대문자로 변경 * PR1 Refactoring (#16) * refactor: components 디렉토리 구조 변경 * feat: common components - Nav 구현 * refactor: 라우터 모듈 분리 * refactor: 사용하지 않는 styled-components 제거, div->span, strong 태그 변경 * refactor: CoinContainer, VendProductContainer Component 분리 * Wallet Component - 동전 투입 기능 (#17) * feat: 금액 버튼 클릭시 해당 금액 개수 감소 렌더링 useCoin 커스텀 훅 사용 * feat: 금액 버튼 클릭시 잔고 금액 감소 렌더링 useBalance 커스텀 훅 사용 * feat: CoinProvider 생성 outlet 상위 컴포넌트에 생성하여 라우팅에 따른 상태 초기화 방지 * feat: InsertCoinProvider 구현 지갑에서 선택한 금액을 자판기에 투입된 금액으로 렌더링 * rename: components 디렉토리 구조 수정 * remove: merge로 생성된 중복 파일 제거 * rename: 컴포넌트 디렉토리명 대문자로 변경 * refactor: balance state 제거, useBalance삭제 coin state로 연산할 수 있는 balance state를 제거 * PR2 Refactoring (#21) * refactor: setCoin 로직 변경 배열의 카피본에서 같은 값을 갖는 인덱스 요소의 객체를 변경 -> map 사용 * refactor: grid repeat 함수 적용 * refactor: Coin Component useMemo 적용, setProvider 분리 Coin Component 클릭시 금액의 변동사항이 있는 컴포넌트만 리렌더링 된다. * feat: 지갑에서 금액을 투입하면 알림 문구가 뜬다. (#23) useReducer 적용 * 자판기 - 금액 투입, 상품 선택기능 (#25) * feat: 지갑에서 금액을 투입하면 알림 문구가 뜬다. useReducer 적용 * feat: 자판기에 투입된 금액 자동보정 기능 구현 * design: historyBox list margin, 자판기 margin-top * feat: 자판기에서 금액을 투입하면 알림 문구가 뜬다. * refactor: 투입 금액 보정 함수 수정 재귀함수로 리팩토링 * feat: 자판기 투입 최소, 최대 금액 설정 0원이면 early return, 잔고보다 큰 금액이면 잔고를 return * feat: 최대금액 입력시 지갑 잔고 관리 잔고와 동전의 개수는 0으로 초기화된다. * feat: history provider 분리로 렌더링 최적화 * feat: SelectButton 구현 inputCoin과 stocked에 따라 선택 가능한 상품에 초록불을 렌더한다. * feat: 선택 가능한 상품을 누를 때 상품명, 잔돈 알림 문구 구현 * feat: 돈을 투입하고 5초간 입력이 없으면 잔돈 자동반환 * feat: 투입금액이 추가 발생하면 타이머 초기화 디바운싱을 이용하여 타이머를 초기화한다. * rename: setTimer -> setDebounce * 자판기 - 상품 선택 기능(2) (#26) * feat: 지갑에서 금액을 투입하면 알림 문구가 뜬다. useReducer 적용 * feat: 자판기에 투입된 금액 자동보정 기능 구현 * design: historyBox list margin, 자판기 margin-top * feat: 자판기에서 금액을 투입하면 알림 문구가 뜬다. * refactor: 투입 금액 보정 함수 수정 재귀함수로 리팩토링 * feat: 자판기 투입 최소, 최대 금액 설정 0원이면 early return, 잔고보다 큰 금액이면 잔고를 return * feat: 최대금액 입력시 지갑 잔고 관리 잔고와 동전의 개수는 0으로 초기화된다. * feat: history provider 분리로 렌더링 최적화 * feat: SelectButton 구현 inputCoin과 stocked에 따라 선택 가능한 상품에 초록불을 렌더한다. * feat: 선택 가능한 상품을 누를 때 상품명, 잔돈 알림 문구 구현 * feat: 돈을 투입하고 5초간 입력이 없으면 잔돈 자동반환 * feat: 투입금액이 추가 발생하면 타이머 초기화 디바운싱을 이용하여 타이머를 초기화한다. * rename: setTimer -> setDebounce * remove: vendProductOutlet Component 삭제 * refactor: 투입 금액 보정 로직 변경 잔고가 있는 돈의 배열을 재귀로 돌면서 투입금액에 가까이 누적시킨다. * feat: 지갑과 자판기에서 금액을 투입하면 선택 시간 3초 초기화 provider에서 useEffect를 사용하여 wallet, vm 컴포넌트에서 insertCoin의 sideEffect를 감지 * refactor: 화살표 함수 컨벤션 통일 * refactor: 중복 코드를 하나의 객체로 변경 * refactor: styled component 분리
* 💄 Route 이동 간 animation 적용 - framer-motion 라이브러리 설치 - route 간 이동 시 애니메이션 적용 * ✨ Error 페이지 수정 * 🚚 utils calc -> calculate 이름 수정
* ✨ 사용자가 임의의 금액을 입력해서 충전하는 기능 추가 * ♻️ 코인 금액으로 Target인지 확인하는 로직으로 변경 수정전에는 코인의 Index로 확인하고 있었다. * ✨ 요청된 금액에 정확하게 충전되지 않으면 에러 메세지 표시 * ✨ 투입된 금액이 만족되면 구매 가능한 상품 테두리 색상 빨간색으로 변경 * ✨ 상품을 선택해서 받는 기능 추가 - 상품이 없으면 품절 메세지 띄우고 비활성화 - 상품 클릭하면 재고 및 현재 충전된 돈 업데이트 * ✨ 상품 클릭하면 상품이 2초 뒤에 배출하는 기능 추가 - 상품 클릭시 로딩 컴포넌트 랜더링 closed #6 * ♻️ Loading 컴포넌트 App 에서 Home 에서 랜더링하도록 수정 * ✨ 유저가 돈 충전, 상품 구매하면 이벤트 로그에 표시하는 기능 추가 * ✨ 구매할 수 없는 상품 배경색 변경 * ✨ 각 이벤트에 해당하는 글귀를 이벤트 로그에 표시 * ♻️ 반환담당 핸들러 MoneyContext에서 관리 * ♻️ UnModifiableInput 컴포넌트 밖으로 분리
안녕하세요 Daisy! 프론트엔드 도리입니다. 1주차 첫 번재 리뷰 요청합니다~
진행상황
1. 자판기 구성
2. 상태관리
궁금한점
1. 컴포넌트 상단에 순수함수를 선언
컴포넌트 내부에서 선언한 함수가 길어져서 분리할 때, 컴포넌트 상단에 순수함수로 분리해 컴포넌트가 리렌더링되어도 함수는 그대로 사용할 수 있게 해봤습니다.
모든 함수를 useCallback으로 감싸고 컴포넌트 내부에 선언하는 방법이 가독성이 더 좋을까요?
2. 스타일 컨벤션
styled-componet를 사용할 때 react 컴포넌트와 styled컴포넌트가 구분되지 않아 구분하는 방법으로 다음과 같은 방법을 고려해봤습니다.
3. 상태관리
이번 미션에서는 context api + useReducer를 합친
context 컴포넌트
를 만들어서 상태를 관리하는 방법을 시도하고 있습니다. 이전에 react-redux를 사용해본 적이 있는데 형태가 비슷해보여서 비교해 볼 계획입니다.