Skip to content

Conversation

@yulrang
Copy link
Contributor

@yulrang yulrang commented Nov 19, 2024

🔖 Issue Ticket

#132

✍️ Description

✅ Checklist

PR

  • Branch Convention 확인

    feat/ 피쳐, fix/ 버그 수정, refactor/ 개선

  • Base Branch 확인
  • 적절한 Label 지정
  • Assignee 및 Reviewer 지정

Test

  • 로컬 작동 확인

Summary by CodeRabbit

  • 새로운 기능

    • CalendarFilter 컴포넌트가 추가 속성을 수용하도록 수정되었습니다.
    • DateTimePickeronChange 콜백이 Date 객체 대신 문자열을 수용하도록 변경되었습니다.
    • PopOverCalendar 컴포넌트가 외부 클릭 시 닫히도록 개선되었습니다.
  • 버그 수정

    • 날짜 선택 시 KST 형식의 ISO 문자열을 반환하도록 DateTimePickeronChange 기능이 업데이트되었습니다.
  • 문서화

    • 내부 로직 변경 사항이 문서화되었습니다.

@coderabbitai
Copy link

coderabbitai bot commented Nov 19, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

이 변경 사항은 CalendarFilter, DateTimePicker, 및 PopOverCalendar 컴포넌트에 대한 여러 수정 사항을 포함합니다. CalendarFilter는 추가 props를 수용할 수 있도록 변경되었으며, DateTimePickeronChange 콜백의 데이터 타입을 Date에서 string으로 변경했습니다. PopOverCalendar는 새로운 상태 관리 및 이벤트 핸들링 기능을 도입하여 외부 클릭 시 팝오버를 닫는 기능을 추가했습니다. 각 컴포넌트의 내부 로직은 대체로 유지되며, 기능적 변화가 주를 이루고 있습니다.

Changes

파일 경로 변경 요약
src/components/common/input/calendar-filter/index.tsx CalendarFilter 컴포넌트가 추가 props를 수용할 수 있도록 ...rest를 사용하여 함수 시그니처가 업데이트됨.
src/components/common/input/date-time-picker/index.tsx onChange 콜백의 타입이 Date에서 string으로 변경됨. ISO 문자열 형식으로 날짜를 전달하도록 수정됨.
src/components/common/input/pop-over-calendar/index.tsx useEffect, useRef를 사용하여 팝오버의 상태 관리 및 클릭 외부 시 닫기 기능 추가. 이벤트 핸들러 수정됨.
src/components/common/input/date-time-picker/date-time-picker.stories.tsx DateTimePickeronChange prop이 newValueDate 객체로 변환하여 상태를 업데이트하도록 변경됨.

Possibly related PRs

Suggested labels

api, design

Suggested reviewers

  • HaeJungg
  • Rangbyeolang

🐇 변화의 기쁨을 노래해요,
캘린더가 더 똑똑해졌어요!
날짜를 선택하고, 클릭을 막고,
팝오버가 열리면 모두가 즐거워요!
새로운 기능이 우리를 기다려요,
함께 뛰어놀며 기쁨을 나눠요! 🌼

Warning

Rate limit exceeded

@yulrang has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 46 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 8d1fb76 and 05d2b1d.

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/components/common/input/date-time-picker/date-time-picker.stories.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't determine the plugin "react-hooks" uniquely.

  • /node_modules/eslint-plugin-react-hooks/index.js (loaded in ".eslintrc.js")
  • /node_modules/eslint-config-next/node_modules/eslint-plugin-react-hooks/index.js (loaded in ".eslintrc.js » eslint-config-next/core-web-vitals » /node_modules/eslint-config-next/index.js » plugin:react-hooks/recommended")

Please remove the "plugins" setting from either config or remove either plugin installation.

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.


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 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.

@github-actions
Copy link

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: 5

🧹 Outside diff range and nitpick comments (2)
src/components/common/input/pop-over-calendar/index.tsx (2)

14-18: 불필요한 상태 관리 개선 필요

inputTheme을 상태로 관리하는 대신 opened 값에서 직접 계산하는 것이 더 효율적일 것 같습니다.

다음과 같이 수정하는 것을 제안합니다:

-const [inputTheme, setInputTheme] = useState(opened ? 'dark' : 'light');
+const inputTheme = opened ? 'dark' : 'light';

58-58: 날짜 표시 형식 개선 필요

현재 날짜 표시 형식이 단순합니다. 더 읽기 좋은 형식으로 개선하면 좋을 것 같습니다.

날짜 포맷팅을 위해 date-fns 라이브러리를 사용하거나 별도의 포맷터 함수를 만드는 것을 제안합니다:

-<span>{date ? `${date.getMonth() + 1}월 ${date.getDate()}일` : '날짜 선택'}</span>
+<span>{date ? format(date, 'yyyy년 M월 d일') : '날짜 선택'}</span>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1ea8adb and 8d1fb76.

📒 Files selected for processing (3)
  • src/components/common/input/calendar-filter/index.tsx (2 hunks)
  • src/components/common/input/date-time-picker/index.tsx (2 hunks)
  • src/components/common/input/pop-over-calendar/index.tsx (2 hunks)
🔇 Additional comments (2)
src/components/common/input/calendar-filter/index.tsx (1)

77-77: rest props 사용에 대한 주의가 필요합니다.

{...rest}를 통해 전달되는 props가 기존 Calendar 컴포넌트의 중요한 props를 덮어쓸 수 있습니다. 특히 getDayProps, renderDay, styles 등의 주요 기능에 영향을 줄 수 있으므로 주의가 필요합니다.

src/components/common/input/pop-over-calendar/index.tsx (1)

42-47: 접근성과 사용성이 잘 고려된 구현입니다

포털 사용, 키보드 접근성, 외부 클릭 처리 등이 적절하게 구현되어 있습니다.

Comment on lines +15 to +20
export default function CalendarFilter({
value,
toDoDates,
onChange,
...rest
}: CalendarFilterProps) {
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Props 타입 정의 개선이 필요합니다.

CalendarFilterProps 인터페이스에 추가된 rest props의 타입이 정의되어 있지 않습니다. 타입 안정성을 위해 다음과 같은 개선이 필요합니다.

export interface CalendarFilterProps {
  value: Date;
  toDoDates: Date[] | null;
  onChange: (date: Date) => void;
+ // Calendar 컴포넌트의 props 타입을 확장
+ extends Omit<CalendarProps, 'value' | 'onChange'>;
}

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +36 to +39
useEffect(() => {
document.addEventListener('click', handleOutsideClick);
return () => document.removeEventListener('click', handleOutsideClick);
}, []);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

의존성 배열 개선 필요

useEffect의 의존성 배열에 close 함수가 누락되어 있어 스테일 클로저 문제가 발생할 수 있습니다.

다음과 같이 수정하는 것을 제안합니다:

useEffect(() => {
  document.addEventListener('click', handleOutsideClick);
  return () => document.removeEventListener('click', handleOutsideClick);
-}, []);
+}, [close]);

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +20 to +35
e.stopPropagation();
setDate(new Date());
onChange(new Date());
close();
};
const handleSubmit = () => {
const handleSubmit = (e: React.MouseEvent<HTMLButtonElement>) => {
e.stopPropagation();
onChange(date);
close();
};

const handleOutsideClick = (e: MouseEvent) => {
if (popOver.current && !popOver.current.contains(e.target as Node)) {
close();
}
};
useEffect(() => {
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

초기화 동작 개선 필요

handleClear 함수에서 현재 날짜로 초기화하는 것보다 날짜를 완전히 비우는 것이 사용자 경험에 더 적합할 것 같습니다.

다음과 같이 수정하는 것을 제안합니다:

const handleClear = (e: React.MouseEvent<HTMLButtonElement>) => {
  e.stopPropagation();
-  setDate(new Date());
-  onChange(new Date());
+  setDate(null);
+  onChange(null);
  close();
};

이를 위해 PopOverProps 인터페이스도 수정이 필요합니다:

export interface PopOverProps {
-  value: Date;
+  value: Date | null;
-  onChange: (date: Date) => void;
+  onChange: (date: Date | null) => void;
}

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +29 to +39
const newDate = new Date(selected);

newDate.setHours(Number(hour));
newDate.setMinutes(Number(minute));

const kstDate = new Date(newDate.getTime() - newDate.getTimezoneOffset() * 60000).toISOString();

setSelected(newDate);
onChange(newDate);

// KST 기준 ISO 문자열 전달
onChange(kstDate);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

시간대 처리 로직 개선이 필요합니다.

현재 구현에서 몇 가지 개선이 필요한 부분이 있습니다:

  1. 수동으로 KST 변환하는 대신 dayjs를 활용하면 더 안전하게 처리할 수 있습니다.
  2. 자정 근처에서 날짜가 변경될 수 있는 엣지 케이스 처리가 필요합니다.

다음과 같이 개선하는 것을 제안드립니다:

-    const newDate = new Date(selected);
-
-    newDate.setHours(Number(hour));
-    newDate.setMinutes(Number(minute));
-
-    const kstDate = new Date(newDate.getTime() - newDate.getTimezoneOffset() * 60000).toISOString();
-
-    setSelected(newDate);
-
-    // KST 기준 ISO 문자열 전달
-    onChange(kstDate);
+    const newDate = dayjs(selected)
+      .hour(Number(hour))
+      .minute(Number(minute))
+      .tz('Asia/Seoul');
+    
+    setSelected(newDate.toDate());
+    onChange(newDate.toISOString());

이렇게 수정하면:

  • dayjs의 타임존 기능을 활용하여 더 안정적인 시간 처리가 가능합니다
  • 날짜 변경선 근처에서의 엣지 케이스도 자동으로 처리됩니다

Committable suggestion skipped: line range outside the PR's diff.

export interface DateTimePickerProps {
fullDate: Date;
onChange: (date: Date) => void;
onChange: (date: string) => void;
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Date 타입 변경으로 인한 영향도가 확인되었습니다

현재 DateTimePicker 컴포넌트를 사용하는 두 곳에서 모두 Date 객체를 사용하고 있습니다:

  • date-time-picker.stories.tsx: useState<Date>() 사용
  • create-gathering-form/index.tsx: new Date()를 fullDate prop으로 전달

이 변경으로 인해 다음 작업이 필요합니다:

  • stories 파일의 state 타입과 예제 코드 수정
  • create-gathering-form의 date 처리 로직 수정
🔗 Analysis chain

인터페이스 변경에 대한 마이그레이션 가이드가 필요합니다.

onChange 콜백의 타입을 Date에서 string으로 변경하는 것은 Breaking Change입니다. 이 컴포넌트를 사용하는 모든 곳에서 수정이 필요할 것 같습니다.

다음 스크립트로 영향을 받는 컴포넌트들을 확인해보겠습니다:


Let me check the actual usage of DateTimePicker in these files to understand the impact.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# DateTimePicker 컴포넌트의 사용처를 검색
rg -l "DateTimePicker" src/

Length of output: 249


Script:

#!/bin/bash
# Check how DateTimePicker is being used in the stories and actual implementation
rg "DateTimePicker" src/components/common/input/date-time-picker/date-time-picker.stories.tsx -A 5
rg "DateTimePicker" src/app/\(crew\)/crew/detail/\[id\]/_components/create-gathering/create-gathering-form/index.tsx -A 5

Length of output: 1473

@github-actions
Copy link

Copy link
Contributor

@ChoYenii ChoYenii left a comment

Choose a reason for hiding this comment

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

수고많으셨습니다!!

@yulrang yulrang merged commit cf27bbb into develop Nov 19, 2024
@yulrang yulrang linked an issue Nov 19, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

약속 생성/수정하기 API 연결

4 participants