-
Notifications
You must be signed in to change notification settings - Fork 1
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
[FE] 날짜 필터 기능 구현 완료 #57
Conversation
- react-dates 모달 안에 나타나게 기본 설정 적용
- 달력 한글화
- 구조 분해 할당을 하니, 리셋하는 경우에는 별도의 payload가 없어 버그가 발생했다. 분해할당을 없애니 제대로 동작함.
- type을 받는 함수를 별도로 리턴하도록 변경
- 버튼 텍스트를 월, 일로 바꿔주는 함수 - 쿼리에 적합한 형식으로 날짜를 바꿔주는 함수
- endDate가 없을 경우, startDate의 다음 날짜로 데이터를 요청하도록 변경. - startDate가 있을 경우에만 데이터를 요청하도록 변경
- 날짜가 아예 선택되지 않았을 경우라도, 이전의 조건문에서는 !endDate 분기처리로 들어가게 됨 - startDate가 있을 경우로 !endDate 경우를 감싸서 해결
- 데이터가 없을 경우 checkin, checkout 을 빈 문자열로 초기화
- actions 를 개별 action 파일로 분리 - 개별 action 파일에서는 type이 포함된 액션 함수를 리턴해서 쉽게 외부에서 사용할 수 있게 - 게스트 모달에서 사용되는 유틸함수들을 util 파일로 이동
- 다른 필터들과 같이 일관적으로 순서 맞추기 위함
- utils 폴더 내부에 url 파일을 만들어, 거기서 dotenv로 가져온 url을 사용하도록 변경 - filter 컴포넌트 내부의 긴 url을 작성할 필요없이, url 파일 내부에서 구조분해할당으로 사용하도록 변경
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.
중간중간 리팩토링도 진행하면서 빠르게 작업하셨네요!
멋져요 @sungik-choi !!
FE/src/utils/urls.js
Outdated
@@ -0,0 +1,4 @@ | |||
export const initURL = `${process.env.API_KEY}`; | |||
|
|||
export const filterURL = ({ checkin, checkout, adults, children, infants, priceMin, priceMax }) => |
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.
변수를 인자로 전달받아서 url을 리턴하도록 유틸함수를 만든 아이디어가 좋네요!
- 네이밍 ─
filterURL
이라고 하니 'URL을 필터링 하는 함수'로 오해할 수 있을 것 같아요. 함수의 역할에 적합한 다른 이름이면 좋을 것 같아요. filterURL
함수 내부에서${process.env.API_KEY}
대신에initURL
을 쓸 순 없을까요?
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.
filteringDataURL
, initDataURL
어때요?
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.
2번은 수정하겠습니다
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.
filteringDataURL
,initDataURL
어때요?
음.. 함수의 역할이 필터링/검색을 위한 url을 만드는 거니까 generateFilteringURL
또는 generateSearchURL
은 어떤가요?
네이밍 어렵다..
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.
참고로 '생성하다' 라는 의미를 전달하고 싶을때 create 과 generate 중 무엇을 써야 할지 정리한 포스팅이 있어서 공유해보아요.
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.
filteringDataURL
,initDataURL
어때요?음.. 함수의 역할이 필터링/검색을 위한 url을 만드는 거니까
generateFilteringURL
또는generateSearchURL
은 어떤가요?네이밍 어렵다..
제너레이트 좋은데요? 뒤에 링크 내용도 좋네요
dispatch: cardListDispatch, | ||
actionType: { | ||
success: fetchActions.FETCH_SUCCESS, | ||
error: fetchActions.FETCH_ERROR, | ||
success: fetchSuccess, |
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.
dispatch에 전달할 인자를 함수의 리턴값으로 반환하다보니 코드가 좀 더 깔끔해졌네요👍
|
||
export const largerThanMaxNum = (maxNum, num) => maxNum <= num; | ||
|
||
export const getTotalNumOfValue = obj => |
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.
유틸 함수를 적극적으로 활용해서 코드의 재사용성을 높인 점이 좋습니다!👍
구현 내용
Airbnb react-dates
라이브러리를 사용해 날짜 필터 기능을 구현했습니다리팩토링
actions.js
파일을 별도의 액션 파일들로 분리했습니다type
이 포함된 액션 함수들 또한 export해서, 컴포넌트 내부에서 더 쉽게 dispatch 할 수 있도록 했습니다Guest Modal
컴포넌트 내부의 유틸 함수들을 유틸 파일 내부로 이동했습니다urls.js
파일을 만들어 import해서 사용하도록 했습니다. 컴포넌트 내부에선 url에 대한 정보가 변수로만 보이도록 했습니다