Skip to content
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: #301 프로젝트 생성 & 할 일 생성 날짜 종료일 수정 #307

Merged
merged 5 commits into from
Dec 25, 2024

Conversation

ice-bear98
Copy link
Contributor

@ice-bear98 ice-bear98 commented Dec 20, 2024

PR Type

What kind of change does this PR introduce?

  • [Fix] 버그를 수정했어요.

Related Issues

What does this PR do?

  • 프로젝트와 할일 목록 종료일 구별을 위한 props 추가
  • 프로젝트 종료일 토글 비 활성화시 null 값 추가

Other information

@ice-bear98 ice-bear98 added the 💉 Fix 에러 혹은 버그를 수정했어요 label Dec 20, 2024
@ice-bear98 ice-bear98 self-assigned this Dec 20, 2024
Copy link

coderabbitai bot commented Dec 20, 2024

개요

Walkthrough

이 변경 사항은 PeriodDateInput 컴포넌트의 날짜 동기화 동작을 제어하는 새로운 enableEndDateSync 속성을 도입합니다. 이 속성은 시작 날짜와 종료 날짜 간의 동기화 방식을 세밀하게 조정할 수 있게 해줍니다. 주요 변경 사항은 폼 컴포넌트와 유효성 검사 규칙에 걸쳐 있으며, 날짜 입력의 유연성을 향상시킵니다.

Changes

파일 변경 요약
src/components/common/PeriodDateInput.tsx enableEndDateSync 속성 추가, 날짜 동기화 로직 업데이트
src/components/modal/project/ModalProjectForm.tsx PeriodDateInputenableEndDateSync 속성 추가
src/components/modal/project/UpdateModalProject.tsx PeriodDateInputenableEndDateSync 속성 추가
src/components/modal/task/ModalTaskForm.tsx PeriodDateInputenableEndDateSync 속성 추가
src/components/modal/task/UpdateModalTask.tsx enableEndDateSyncfalse로 설정
src/constants/formValidationRules.ts 날짜 유효성 검사 함수 시그니처 및 로직 업데이트

Sequence Diagram

sequenceDiagram
    participant User
    participant PeriodDateInput
    participant Validation

    User->>PeriodDateInput: 시작 날짜 선택
    alt enableEndDateSync is true
        PeriodDateInput->>PeriodDateInput: 종료 날짜 자동 동기화
    else enableEndDateSync is false
        User->>PeriodDateInput: 종료 날짜 직접 선택
    end
    PeriodDateInput->>Validation: 날짜 유효성 검사
Loading

Poem

🐰 날짜의 춤, 토끼의 마법
시작과 끝, 자유롭게 흐르네
동기화의 스위치를 켜고 끄며
유연한 시간, 내 발걸음처럼
🌈 코드의 리듬이 춤을 추네!

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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. (Beta)
  • @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: 0

🧹 Nitpick comments (4)
src/components/common/PeriodDateInput.tsx (2)

47-55: useEffect 로직을 더 명확하게 개선할 수 있습니다.

현재 조건문이 중첩되어 있어 코드의 가독성이 떨어집니다. 다음과 같이 개선해보는 것은 어떨까요?

- if (enableEndDateSync && !hasDeadline) {
-   setValue(endDateFieldName, null);
- } else {
-   const startDate = startDateStr ? DateTime.fromISO(startDateStr).startOf('day') : null;
-   const endDate = endDateStr ? DateTime.fromISO(endDateStr).startOf('day') : null;
-   if (startDate && endDate) {
-     setHasDeadline(startDate < endDate);
-   }
- }
+ if (enableEndDateSync && !hasDeadline) {
+   setValue(endDateFieldName, null);
+   return;
+ }
+ 
+ const startDate = startDateStr ? DateTime.fromISO(startDateStr).startOf('day') : null;
+ const endDate = endDateStr ? DateTime.fromISO(endDateStr).startOf('day') : null;
+ 
+ if (startDate && endDate) {
+   setHasDeadline(startDate < endDate);
+ }

59-69: handleDeadlineToggle 함수를 더 간단하게 리팩토링할 수 있습니다.

현재 코드에서 clearErrors 호출이 중복되어 있고, 조건문 구조가 복잡합니다.

- if (hasDeadline === false) {
-   if (enableEndDateSync) {
-     setValue(endDateFieldName, null);
-   } else {
-     setValue(endDateFieldName, getValues(startDateFieldName));
-   }
-   clearErrors(endDateFieldName);
- } else {
-   setValue(endDateFieldName, getValues(startDateFieldName));
-   clearErrors(endDateFieldName);
- }
+ const newEndDate = (!hasDeadline && enableEndDateSync)
+   ? null
+   : getValues(startDateFieldName);
+ 
+ setValue(endDateFieldName, newEndDate);
+ clearErrors(endDateFieldName);
src/components/modal/task/ModalTaskForm.tsx (1)

165-165: 명시적인 값 설정을 권장합니다.

기본값을 사용하는 대신 enableEndDateSync={true}로 명시적으로 설정하면 코드의 의도가 더 명확해질 것 같습니다.

-          enableEndDateSync
+          enableEndDateSync={true}
src/components/modal/task/UpdateModalTask.tsx (1)

179-179: 동작 방식 차이에 대한 설명 추가를 제안합니다.

작업 생성 시와 수정 시의 날짜 동기화 동작이 다른 이유를 설명하는 주석을 추가하면 좋을 것 같습니다.

+                  // 작업 수정 시에는 시작일과 종료일을 독립적으로 설정할 수 있도록 동기화를 비활성화합니다.
                   enableEndDateSync={false}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 596df76 and c8c79f7.

📒 Files selected for processing (6)
  • src/components/common/PeriodDateInput.tsx (4 hunks)
  • src/components/modal/project/ModalProjectForm.tsx (1 hunks)
  • src/components/modal/project/UpdateModalProject.tsx (1 hunks)
  • src/components/modal/task/ModalTaskForm.tsx (1 hunks)
  • src/components/modal/task/UpdateModalTask.tsx (1 hunks)
  • src/constants/formValidationRules.ts (2 hunks)
🔇 Additional comments (7)
src/components/common/PeriodDateInput.tsx (2)

17-17: 타입 정의가 명확하고 적절합니다!

enableEndDateSync 프로퍼티가 불리언 타입으로 잘 정의되어 있습니다.


31-31: 기본값 설정이 적절합니다!

enableEndDateSync의 기본값을 true로 설정한 것은 기존 동작과의 호환성을 유지하는 좋은 접근입니다.

src/constants/formValidationRules.ts (2)

11-11: 매개변수 타입 변경이 적절합니다!

referenceDate 매개변수에 null 타입을 추가한 것은 enableEndDateSync 기능과 잘 어울립니다.


202-206: 종료일 유효성 검사 로직이 잘 구현되었습니다!

enableEndDateSync 매개변수를 활용하여 종료일 유효성 검사를 조건부로 처리하는 방식이 깔끔합니다.

src/components/modal/project/ModalProjectForm.tsx (1)

160-160: PeriodDateInput 컴포넌트 사용이 적절합니다!

enableEndDateSync 프로퍼티를 추가하여 프로젝트의 날짜 동기화 동작을 명확하게 제어할 수 있게 되었습니다.

src/components/modal/project/UpdateModalProject.tsx (1)

149-149: 프로젝트 날짜 동기화 기능이 적절히 구현되었습니다.

기본값(true)을 사용하여 프로젝트의 시작일과 종료일이 자동으로 동기화되도록 설정되었습니다.

src/components/modal/task/UpdateModalTask.tsx (1)

179-179: 날짜 동기화 비활성화가 적절히 구현되었습니다.

작업 수정 시 시작일과 종료일을 독립적으로 설정할 수 있도록 구현되었습니다.

Copy link
Contributor

@Seok93 Seok93 left a comment

Choose a reason for hiding this comment

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

코드 수정 확인했습니다. 리뷰 내용 확인하시고 궁금한 점 있으면 말씀해주세요.

src/components/common/PeriodDateInput.tsx Outdated Show resolved Hide resolved
src/components/common/PeriodDateInput.tsx Outdated Show resolved Hide resolved
src/constants/formValidationRules.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@Seok93 Seok93 left a comment

Choose a reason for hiding this comment

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

LGTM😄 작업하시느라 고생하셨습니다.

@ice-bear98 ice-bear98 merged commit 58f082e into develop Dec 25, 2024
1 check passed
@ice-bear98 ice-bear98 deleted the feature/#301-project-create-date-fix branch December 25, 2024 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💉 Fix 에러 혹은 버그를 수정했어요
Projects
None yet
Development

Successfully merging this pull request may close these issues.

프로젝트 생성 시 날짜 설정 오류 수정
2 participants