-
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
[Feat] 클래스 카드 공통 컴포넌트 제작 #87
Conversation
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.
수고하셨습니다! 공통 컴포넌트로 두는 것에 대해 고민하신 것도 정말 잘 하신 것 같고 분기 처리도 상황에 맞게 잘 하신 것 같아요! 삼항 연산자 중첩 관련은 단순히 가독성 측면에서 참고 정도로 말씀 드린 거라 한번 더 생각해보시면 좋을 것 같습니다 수고하셨어요~
src/components/ClassCard/index.tsx
Outdated
<Text tag="b4" color={status === 'completed' ? 'gray8' : 'black'}> | ||
{isReservation | ||
? status === 'upcoming' | ||
? '수강예정' | ||
: status === 'ongoing' | ||
? '수강중' | ||
: '수강완료' | ||
: status === 'upcoming' | ||
? '모집중' | ||
: '모집완료'} | ||
</Text> |
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
문 혹은 switch
문을 사용하시는 것도 좋은 방법이 될 것 같습니다!
switch문 예시
let text;
if (isReservation) {
switch (status) {
case 'upcoming':
text = '수강예정';
break;
case 'ongoing':
text = '수강중';
break;
case 'completed':
text = '수강완료';
break;
default:
text = '';
}
} else {
switch (status) {
case 'upcoming':
text = '모집중';
break;
case 'completed':
text = '모집완료';
break;
default:
text = '';
}
}
<Text tag="b4" color={status === 'completed' ? 'gray8' : 'black'}>
{text}
</Text>
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.
반영완~
src/components/ClassCard/index.tsx
Outdated
interface classCardProps { | ||
lessonId?: string; | ||
reservationId?: string; | ||
lessonName: string; | ||
lessonImageUrl: string; | ||
lessonGenre: string; | ||
lessonLevel: string; | ||
lessonLocation: string; | ||
lessonStartDateTime: string; | ||
lessonEndDateTime: string; | ||
isReservation?: boolean; | ||
children?: React.ReactNode; | ||
} |
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.
interface는 PascalCase를 사용해주세요!
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.
고생하셨습니다! 뚝딱뚝딱 잘만드시네요👍
src/components/ClassCard/index.tsx
Outdated
interface classCardProps { | ||
lessonId?: string; | ||
reservationId?: string; | ||
lessonName: string; | ||
lessonImageUrl: string; | ||
lessonGenre: string; | ||
lessonLevel: string; | ||
lessonLocation: string; | ||
lessonStartDateTime: string; | ||
lessonEndDateTime: string; | ||
isReservation?: boolean; | ||
children?: React.ReactNode; | ||
} |
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.
Type이 많이 길어진거 같은데 분리해서 사용하는 것은 어떨까요?
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.
고생하셨습니다! 코멘트 하나 확인해주세요!
|
||
if (currentTime < startTime) { | ||
// 수강 예정 상태 | ||
const remainingDays = Math.ceil((startTime.getTime() - currentTime.getTime()) / (1000 * 60 * 60 * 24)); |
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.
지금 날짜와 수강 시작 날짜를 비교할때
currentTime.setHours(0, 0, 0, 0);
startTime.setHours(0, 0, 0, 0);
이렇게 시간,분,초를 0으로 맞추고 비교해줘야지 정확하게 날짜만 계산이 됩니다!
아닌 경우에는 날짜로는 하루가 차이나도 실제 시간은 12시간정도의 차이면 0.xxx 로 계산되어서 정확한 디데이가 안나오는 경우가 있습니다!
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.
반영했습니다 !!
📌 Related Issues
✅ 체크 리스트
📄 Tasks
⭐ PR Point (To Reviewer)
(completed)
, 수강 중 상태인지(ongoing)
, 수강예정 상태(upcominc)
인지 반환합니다.remainigDays
에 저장했습니다.ongoing
또는completed
두 가지의 경우만 갖게 됩니다.(수강 예정, 수강중, 수강완료)
의 상태와문의하기 >
버튼이 있고, 강사가 개설한 클래스 관리 페이지에서는(모집중, 모집완료)
의 상태와 문의하기 버튼이 없기 때문에 둘을 구분하기 위해 isReservtion이라는 prop을 추가했습니다.📷 Screenshot
<기본, children 없음>
<children 있음>
<lesson 카드일때>
<수강예정 카드일때>
🔔 ETC