Feat: 일정 찾기 페이지 카드, 필터링 로직 추가 - #51
Conversation
Choi-Jinwook
left a comment
There was a problem hiding this comment.
고생하셨습니다!! 코멘트 한 번 확인 부탁드릴게요!!
참고해서 저도 msw 사용해보도록 하겠습니다ㅎㅎ 감사합니다 :D
| const days = nights + 1; | ||
| if (nights === 0) return "(당일)"; | ||
| return `(${nights}박 ${days}일)`; | ||
| }; |
There was a problem hiding this comment.
아래 코드 패치에 대한 간단한 코드 리뷰를 도와드리겠습니다. 버그 위험 및 개선 제안에 대한 피드백을 드리겠습니다:
-
const startDate = new Date(start);와const endDate = new Date(end);는start와end를Date객체로 변환하는 데 사용됩니다. 하지만 이러한 변환 작업은 예외 처리가 필요할 수 있습니다. 날짜 형식이 잘못된 경우 또는 비어 있는 경우에 대한 검증과 오류 처리를 추가하는 것이 좋습니다. -
const timeDiff = endDate.getTime() - startDate.getTime();는 시작 날짜와 종료 날짜 사이의 밀리초 차이를 계산합니다. 이 방법은 보통 잘 작동하지만, 경계 조건에 주의해야 할 수도 있습니다. 해당 날짜와 시간 포맷의 정확성을 확인하고, 결과에 대한 예외 상황 처리를 고려하는 것이 좋습니다. -
const nights = timeDiff / (1000 * 60 * 60 * 24);는 날짜 차이를 계산하고 있습니다. 이 계산에서 숫자의 유효 범위 및 반올림 문제에 유의해야 합니다. 계산 결과가 소수점을 가질 수 있다는 점을 고려하여 적절한 반올림 로직을 추가하거나 결과 값을 정수로 변환하는 것이 좋습니다. -
const days = nights + 1;는 박과 일 수를 계산하기 위한 변수입니다. 예제에서는 종료 날짜를 포함하여 계산하고 있지만, 시작 날짜도 포함해야 할지 확인해야 합니다. 요구 사항에 따라 이 부분을 조정해야 합니다. -
if (nights === 0) return "(당일)";는 한 밤을 보내는 경우 당일 여행을 나타냅니다. 그러나 이 조건은 밤의 개수가 정확히 0일 경우에만 작동합니다. 기간이 24시간 미만인 등 다른 상황에 대한 고려가 필요할 수 있습니다. -
코드 자체는 간단하고 문제가 없어 보입니다. 그러나 실제 사용 시에 발생할 수 있는 예외 상황을 고려하여 추가적인 검증과 오류 처리를 구현하는 것이 좋습니다.
위의 제안을 참고하여 코드를 검토하고 개선해보세요.
NacreousCloud
left a comment
There was a problem hiding this comment.
리뷰를 해놓고 submit을 안하고있었네요 ㅋㅋㅋ; 확인했습니다! 여기있는 내용들은 인터페이스의 수정, 오타들입니다. 그 중하나는 스타일과 관련이 있으니 수정하시고 바로 머지해주세요! 고생하셨습니다!
|
|
||
| export const getServerSideProps: GetServerSideProps = async (context) => { | ||
| try { | ||
| const res = await axios.get( |
There was a problem hiding this comment.
| const res = await axios.get( | |
| const res = await axios.get<CardType[]>( |
[Lv1] axios 함수 제너릭으로 타입을 적어주면 res.data의 타입으로 사용할 수 있고 아래에 타입명시 (as CardType[]) 을 뺄수있습니다!
| }: CardType) => { | ||
| return ( | ||
| <div className="w-[260px] h-[420px] relative flex-col flex box-content transition-transform hover:-translate-y-1 m-auto"> | ||
| <div className={`w-full h-[170px] bg-stone-300 border-zinc-400 relatvie`}> |
There was a problem hiding this comment.
| <div className={`w-full h-[170px] bg-stone-300 border-zinc-400 relatvie`}> | |
| <div className={`w-full h-[170px] bg-stone-300 border-zinc-400 relative`}> |
| return ( | ||
| <div className="p-5 border-t"> | ||
| <CategoryTitle title="기간" /> | ||
| <div className="flex gap-x-[10px] flex-wrap mt-3"> |
There was a problem hiding this comment.
| <div className="flex gap-x-[10px] flex-wrap mt-3"> | |
| <div className="flex gap-x-2.5 flex-wrap mt-3"> |
|
|
||
| interface ExpenseTabProps { | ||
| expense: string; | ||
| handleExpenseChange: (e: React.ChangeEvent<HTMLInputElement>) => void; |
There was a problem hiding this comment.
| handleExpenseChange: (e: React.ChangeEvent<HTMLInputElement>) => void; | |
| handleExpenseChange: ChangeEventHandler<HTMLInputElement>; |
| import "react-calendar/dist/Calendar.css"; | ||
|
|
||
| interface InputCalenderProps { | ||
| date: Date | undefined; |
There was a problem hiding this comment.
| date: Date | undefined; | |
| date?: Date; |
| date: Date | undefined; | ||
| visible: boolean; | ||
| placeholder: string; | ||
| handleCalendarClick: () => void; |
There was a problem hiding this comment.
| handleCalendarClick: () => void; | |
| handleCalendarClick: VoidFunction; |
|
#58 PR에 comment 반영하였습니다! |
구현 사항
테스트
TODO
추가사항