-
Notifications
You must be signed in to change notification settings - Fork 1
Fix/156 일정 검증로직 추가 #157
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
Fix/156 일정 검증로직 추가 #157
Conversation
Walkthrough이 변경사항은 활동 일정 편집 기능에 대한 클라이언트 측 검증을 추가합니다. 일정 입력 폼에서 날짜와 시간의 유효성을 검사하는 로직이 도입되었고, 검증 실패 시 에러 메시지를 토스트로 사용자에게 안내합니다. 스타일 관련 클래스 순서도 일관성 있게 정렬되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ScheduleSelectForm
participant useEditActivityForm
participant validateSchedules
participant Toast
User->>ScheduleSelectForm: 날짜/시간 입력
ScheduleSelectForm->>ScheduleSelectForm: 입력값 검증 (isPastDate, isInvalidTimeRange)
alt 입력값 오류
ScheduleSelectForm->>Toast: 에러 토스트 표시
ScheduleSelectForm-->>User: 입력 중단
else 정상 입력
ScheduleSelectForm-->>User: 입력 반영
end
User->>useEditActivityForm: 폼 제출
useEditActivityForm->>validateSchedules: 일정 배열 검증
alt 검증 실패
useEditActivityForm->>Toast: 에러 토스트 표시
useEditActivityForm-->>User: 제출 중단
else 검증 통과
useEditActivityForm->>useEditActivityForm: 뮤테이션 실행
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Possibly related PRs
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
src/app/(with-header)/myactivity/utils/dateValidatoin.ts (1)
1-32: 파일명에 오타가 있고 시간 검증 로직을 개선해야 합니다.
파일명 오타:
dateValidatoin.ts→dateValidation.ts로 수정이 필요합니다.시간 파싱에서 잘못된 형식에 대한 에러 처리가 없습니다. "HH:MM" 형식이 아닌 경우 NaN이 발생할 수 있습니다.
다음 diff를 적용하여 시간 검증을 개선하세요:
const [startHour, startMinute] = startTime.split(':').map(Number); const [endHour, endMinute] = endTime.split(':').map(Number); + if (isNaN(startHour) || isNaN(startMinute) || isNaN(endHour) || isNaN(endMinute)) { + return `올바른 시간 형식을 입력해주세요!`; + } + + if (startHour < 0 || startHour > 23 || endHour < 0 || endHour > 23) { + return `시간은 00~23 사이여야 합니다!`; + } + + if (startMinute < 0 || startMinute > 59 || endMinute < 0 || endMinute > 59) { + return `분은 00~59 사이여야 합니다!`; + } const startMinutes = startHour * 60 + startMinute; const endMinutes = endHour * 60 + endMinute;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
src/app/(with-header)/myactivity/[id]/hooks/useEditActivityForm.ts(2 hunks)src/app/(with-header)/myactivity/components/ScheduleSelect.tsx(4 hunks)src/app/(with-header)/myactivity/components/ScheduleSelectForm.tsx(3 hunks)src/app/(with-header)/myactivity/utils/dateValidatoin.ts(1 hunks)
🔇 Additional comments (6)
src/app/(with-header)/myactivity/[id]/hooks/useEditActivityForm.ts (2)
12-12: 올바른 import 경로입니다.dateValidatoin.ts에서 validateSchedules 함수를 정확히 import했습니다.
212-216: 검증 로직이 적절히 추가되었습니다.폼 제출 전에 일정 검증을 수행하고, 검증 실패 시 사용자에게 에러 메시지를 표시하는 로직이 올바르게 구현되었습니다. early return으로 불필요한 mutation 실행을 방지하는 것도 좋습니다.
src/app/(with-header)/myactivity/components/ScheduleSelect.tsx (1)
31-33: CSS 클래스 정렬이 일관성 있게 개선되었습니다.className 속성의 클래스 순서가 일관성 있게 정렬되어 코드 가독성과 유지보수성이 향상되었습니다.
Also applies to: 42-42, 51-51, 63-63, 65-67
src/app/(with-header)/myactivity/components/ScheduleSelectForm.tsx (3)
3-3: 적절한 import 추가입니다.사용자 피드백을 위한 toast import가 올바르게 추가되었습니다.
18-27: 헬퍼 함수들이 잘 구현되었습니다.isPastDate와 isInvalidTimeRange 함수 모두 명확하고 재사용 가능한 형태로 잘 구현되었습니다.
38-38: CSS 클래스 정렬이 개선되었습니다.className 속성의 순서가 일관성 있게 정리되어 코드 품질이 향상되었습니다.
Also applies to: 43-43, 49-49
| onDateChange={(index, value) => { | ||
| if (isPastDate(value)) { | ||
| toast.error('오늘 이전 날짜는 선택할 수 없습니다.'); | ||
| return; | ||
| } | ||
| onDateChange(index, 'date', value); | ||
| }} | ||
| onStartTimeChange={(index, value) => { | ||
| const end = dates[index].endTime; | ||
| if (end && isInvalidTimeRange(value, end)) { | ||
| toast.error('시작 시간은 종료 시간보다 빨라야 합니다.'); | ||
| return; | ||
| } | ||
| onDateChange(index, 'startTime', value); | ||
| }} | ||
| onEndTimeChange={(index, value) => { | ||
| const start = dates[index].startTime; | ||
| if (start && isInvalidTimeRange(start, value)) { | ||
| toast.error('종료 시간은 시작 시간보다 늦어야 합니다.'); | ||
| return; | ||
| } | ||
| onDateChange(index, 'endTime', value); | ||
| }} |
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.
🧹 Nitpick (assertive)
실시간 검증 로직이 사용자 경험을 향상시킵니다.
각 입력 필드에서 즉시 검증을 수행하여 사용자에게 빠른 피드백을 제공하는 것이 좋습니다. 다만 validateSchedules 함수와 검증 로직의 일관성을 유지하는 것을 권장합니다.
중복을 줄이기 위해 isPastDate 로직을 validateSchedules와 통일하는 것을 고려해보세요:
function isPastDate(dateStr: string) {
- const selected = new Date(dateStr);
- const today = new Date();
- today.setHours(0, 0, 0, 0);
- return selected < today;
+ const selectedDate = new Date(dateStr);
+ const today = new Date();
+ today.setHours(0, 0, 0, 0);
+ return selectedDate < today;
}Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In src/app/(with-header)/myactivity/components/ScheduleSelectForm.tsx between
lines 57 and 79, the onDateChange, onStartTimeChange, and onEndTimeChange
handlers perform immediate validation but use logic that may differ from the
validateSchedules function. To fix this, refactor the validation checks in these
handlers to reuse or align with the validation logic defined in
validateSchedules, especially for the isPastDate check, to ensure consistency
and reduce duplication.
BokyungCodes
left a comment
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.
끝나가네요 드디어ㅠㅠ 고생하셨습니다
minimo-9
left a comment
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.
마지막에 마지막까지 수정하시느라 고생 많으셨습니다!!!
📌 변경 사항 개요
일정 검증로직 추가
📝 상세 내용
🔗 관련 이슈
🖼️ 스크린샷(선택사항)
💡 참고 사항
Summary by CodeRabbit
신규 기능
스타일