Skip to content

Conversation

@evaain706
Copy link
Contributor

@evaain706 evaain706 commented Aug 4, 2025

📌 변경 사항 개요

일정 검증로직 추가

📝 상세 내용

  • 체험 등록/수정 일정 검증로직 추가

🔗 관련 이슈

🖼️ 스크린샷(선택사항)

💡 참고 사항

Summary by CodeRabbit

  • 신규 기능

    • 일정 선택 및 편집 시 날짜와 시간 입력에 대한 유효성 검사가 추가되었습니다. 잘못된 입력 시 오류 메시지가 표시됩니다.
  • 스타일

    • 일부 버튼 및 컨테이너의 스타일 클래스 순서가 일관성 있게 정렬되었습니다. (기능 변화 없음)

@evaain706 evaain706 self-assigned this Aug 4, 2025
@evaain706 evaain706 added the 🔨 Refactor 코드 리팩토링 label Aug 4, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 4, 2025

Walkthrough

이 변경사항은 활동 일정 편집 기능에 대한 클라이언트 측 검증을 추가합니다. 일정 입력 폼에서 날짜와 시간의 유효성을 검사하는 로직이 도입되었고, 검증 실패 시 에러 메시지를 토스트로 사용자에게 안내합니다. 스타일 관련 클래스 순서도 일관성 있게 정렬되었습니다.

Changes

Cohort / File(s) Change Summary
일정 검증 유틸리티 추가
src/app/(with-header)/myactivity/utils/dateValidatoin.ts
validateSchedules 함수 추가. 일정 배열의 날짜, 시작/종료 시간 필수 입력 및 유효성(미래 날짜, 시간 순서) 검증 로직 구현.
폼 제출 검증 로직 추가
src/app/(with-header)/myactivity/[id]/hooks/useEditActivityForm.ts
handleSubmit 내에서 일정 검증(validateSchedules)을 수행하고, 실패 시 에러 토스트 및 제출 중단 처리 추가.
일정 선택 폼 입력 검증 및 스타일 정렬
src/app/(with-header)/myactivity/components/ScheduleSelectForm.tsx
날짜·시간 입력 시 과거 날짜 및 시간 순서 오류 검증, 에러 토스트 추가. 일부 className 순서 정렬.
일정 선택 컴포넌트 스타일 정렬
src/app/(with-header)/myactivity/components/ScheduleSelect.tsx
JSX 내 className 속성 순서 정렬. 기능적 변화 없음.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • minimo-9
  • LeeCh0129
  • BokyungCodes

Poem

🐰
시간표 검증, 토스트로 뿅!
과거는 안 돼요, 미래로 점프!
토끼는 일정 꼼꼼히 살펴
오늘도 에러 없이
깡총깡총 뛰어요!
🕒✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/156

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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: 파일명에 오타가 있고 시간 검증 로직을 개선해야 합니다.

  1. 파일명 오타: dateValidatoin.tsdateValidation.ts로 수정이 필요합니다.

  2. 시간 파싱에서 잘못된 형식에 대한 에러 처리가 없습니다. "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

📥 Commits

Reviewing files that changed from the base of the PR and between c0bbca2 and e25bad5.

📒 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

Comment on lines +57 to +79
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);
}}
Copy link

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.

Copy link
Contributor

@BokyungCodes BokyungCodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

끝나가네요 드디어ㅠㅠ 고생하셨습니다

Copy link
Contributor

@minimo-9 minimo-9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

마지막에 마지막까지 수정하시느라 고생 많으셨습니다!!!

@evaain706 evaain706 merged commit 044afb7 into develop Aug 4, 2025
2 checks passed
@evaain706 evaain706 deleted the fix/156 branch August 4, 2025 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 Refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants