Skip to content

Conversation

@LeeCh0129
Copy link
Contributor

@LeeCh0129 LeeCh0129 commented Aug 4, 2025

📌 변경 사항 개요

체험 삭제 토스트 메시지 수정, 후기 작성 후 실시간 업데이트

📝 상세 내용

체험 삭제 토스트 메시지 수정, 후기 작성 후 실시간 업데이트(쿼리 키 추가)

🔗 관련 이슈

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

💡 참고 사항

Summary by CodeRabbit

  • 버그 수정

    • 활동 삭제 시 발생하는 오류 메시지가 보다 구체적으로 안내되도록 개선되었습니다. 오류 코드에 따라 상세한 안내 메시지가 표시됩니다.
  • 기타

    • 리뷰 작성 후 관련된 활동 정보가 최신 상태로 반영되도록 캐시가 자동으로 갱신됩니다.
    • 마이페이지 활동 선택 드롭다운이 더 직관적으로 개선되었습니다.
    • 드롭다운 컴포넌트가 라벨과 값을 모두 지원하도록 확장되어 사용자 선택이 명확해졌습니다.

@LeeCh0129 LeeCh0129 self-assigned this Aug 4, 2025
@LeeCh0129 LeeCh0129 added the 🐞 bug 버그관련 label Aug 4, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 4, 2025

Walkthrough

예약 리뷰 생성 및 체험 삭제와 관련된 캐시 무효화 및 에러 메시지 처리 로직이 개선되었습니다. 리뷰 생성 시 연관된 액티비티 쿼리 캐시를 무효화하도록 변경되었고, 체험 삭제 실패 시 HTTP 상태 코드에 따라 상세한 토스트 메시지가 표시되도록 수정되었습니다.

Changes

Cohort / File(s) Change Summary
예약 리뷰 및 캐시 무효화 로직 개선
src/app/(with-header)/mypage/reservations/page.tsx, src/hooks/useReservationQueries.ts
리뷰 생성 시 관련 액티비티 쿼리 캐시를 무효화하는 로직 추가 및 기존 리뷰 모달 상태 초기화 제거, invalidateActivityQueries 함수 신설 및 export, useCreateReview의 onSuccess 시그니처 변경
체험 삭제 에러 메시지 상세화
src/hooks/useMyActivitiesQueries.ts
체험 삭제 실패 시 HTTP 상태 코드별로 상세한 토스트 메시지 표시 로직으로 변경 (400, 401, 403, 404 등)
드롭다운 컴포넌트 및 관련 훅 개선
src/components/Dropdown.tsx, src/hooks/useActivityOptions.ts, src/app/(with-header)/mypage/dashboard/page.tsx, src/types/dropdownTypes.ts
드롭다운 컴포넌트에 optionData 추가로 라벨과 값을 가진 옵션 지원, 관련 훅과 페이지에서 드롭다운 옵션 처리 및 선택값 관리 로직 변경

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ReservationsPage
    participant ReservationQueriesHook
    participant ActivityQueriesHook
    participant QueryClient

    User->>ReservationsPage: 리뷰 작성 확인 (handleReviewConfirm)
    ReservationsPage->>ReservationQueriesHook: useCreateReview.mutate()
    ReservationQueriesHook-->>ReservationsPage: onSuccess
    ReservationsPage->>ActivityQueriesHook: invalidateActivityQueries(activityId)
    ActivityQueriesHook->>QueryClient: 관련 쿼리 invalidate
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
체험삭제 토스트 메시지 수정 (#139)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
리뷰 생성 시 캐시 무효화 로직 추가 및 관련 함수 신설 (src/app/(with-header)/mypage/reservations/page.tsx, src/hooks/useReservationQueries.ts) 이 변경은 체험 삭제 토스트 메시지 수정과 직접적인 관련이 없어, 이슈 #139의 범위를 벗어남.
드롭다운 컴포넌트 및 관련 훅 개선 (src/components/Dropdown.tsx, src/hooks/useActivityOptions.ts, src/app/(with-header)/mypage/dashboard/page.tsx, src/types/dropdownTypes.ts) 이 변경들은 체험 삭제 토스트 메시지 수정과 관련이 없으며, UI 컴포넌트 및 훅 개선 작업임.

Suggested labels

📬 API

Suggested reviewers

  • evaain706
  • minimo-9
  • 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/139

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 01659dd and 8206ed5.

📒 Files selected for processing (3)
  • src/app/(with-header)/mypage/reservations/page.tsx (2 hunks)
  • src/hooks/useMyActivitiesQueries.ts (2 hunks)
  • src/hooks/useReservationQueries.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/hooks/useReservationQueries.ts (1)
src/hooks/useDashboardQueries.ts (4)
  • queryClient (95-143)
  • _ (165-185)
  • updatedReservation (109-137)
  • queryClient (146-191)
src/app/(with-header)/mypage/reservations/page.tsx (1)
src/hooks/useReservationQueries.ts (1)
  • invalidateActivityQueries (91-108)
🔇 Additional comments (4)
src/hooks/useMyActivitiesQueries.ts (2)

13-13: 적절한 import 추가

AxiosError 타입을 올바르게 import하여 타입 안전성을 보장했습니다.


58-76: 체험 삭제 오류 처리 개선 완료

HTTP 상태 코드별로 구체적인 토스트 메시지를 제공하도록 개선되었습니다. 이는 PR 목표인 "체험 삭제 시 토스트 메시지 수정"과 정확히 일치합니다. 각 상태 코드에 대한 메시지가 사용자 친화적이고 명확합니다.

src/app/(with-header)/mypage/reservations/page.tsx (2)

8-8: 새로운 캐시 무효화 함수 import

후기 작성 후 실시간 업데이트를 위한 함수를 올바르게 import했습니다.


106-121: 후기 작성 후 캐시 무효화 로직 개선

후기 작성 성공 후 관련 액티비티 쿼리들을 무효화하여 실시간 업데이트를 제공하는 로직이 잘 구현되었습니다. 이는 PR 목표와 정확히 일치합니다.

다만 invalidateActivityQueries 함수의 설계 이슈로 인해 이 코드도 수정이 필요할 수 있습니다:

           onSuccess: () => {
             // 성공 후 추가 쿼리 무효화
             if (reservation?.activity.id) {
-              invalidateActivityQueries(reservation.activity.id);
+              invalidateActivityQueries(queryClient, reservation.activity.id);
             }
           },

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/components/Dropdown.tsx (1)

187-194: 접근성 개선이 필요합니다.

정적 분석 도구에서 지적한 대로, ul 요소에 listbox 역할을 부여하는 것은 접근성 표준에 맞지 않습니다.

다음과 같이 수정하는 것을 권장합니다:

-            <ul
-              role='listbox'
+            <div
+              role='listbox'
               className={cn(
                 'p-8',
                 disableScroll ? '' : 'max-h-240 overflow-auto',
                 listboxClassName,
               )}
             >
♻️ Duplicate comments (1)
src/hooks/useReservationQueries.ts (1)

91-108: React 훅 규칙 위반으로 인한 심각한 오류가 있습니다.

invalidateActivityQueries 함수가 React 컴포넌트나 커스텀 훅이 아닌 곳에서 useQueryClient를 호출하고 있어 런타임 오류가 발생합니다.

다음과 같이 수정하여 queryClient를 매개변수로 받도록 변경해주세요:

-export const invalidateActivityQueries = (activityId: number) => {
-  const queryClient = useQueryClient();
+export const invalidateActivityQueries = (queryClient: QueryClient, activityId: number) => {

그리고 이 함수를 호출하는 모든 곳에서 queryClient 인스턴스를 전달하도록 수정해야 합니다.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8206ed5 and d30b03c.

📒 Files selected for processing (5)
  • src/app/(with-header)/mypage/dashboard/page.tsx (3 hunks)
  • src/components/Dropdown.tsx (10 hunks)
  • src/hooks/useActivityOptions.ts (1 hunks)
  • src/hooks/useReservationQueries.ts (1 hunks)
  • src/types/dropdownTypes.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/hooks/useReservationQueries.ts (1)
src/hooks/useDashboardQueries.ts (5)
  • queryClient (95-143)
  • _ (165-185)
  • updatedReservation (109-137)
  • queryClient (146-191)
  • reservationId (157-160)
src/components/Dropdown.tsx (2)
src/hooks/useOutsideClick.ts (1)
  • useOutsideClick (21-49)
src/types/dropdownTypes.ts (1)
  • DropdownOption (3-6)
🪛 GitHub Actions: CI
src/hooks/useActivityOptions.ts

[warning] 3-3: Run autofix to sort these imports! (simple-import-sort/imports)

src/app/(with-header)/mypage/dashboard/page.tsx

[warning] 3-142: Run autofix to sort imports, fragments should contain more than one child, props sorting, callbacks ordering, and boolean attribute value must be omitted (simple-import-sort/imports, react/jsx-no-useless-fragment, react/jsx-sort-props, react/jsx-boolean-value)

src/hooks/useReservationQueries.ts

[error] 92-92: React Hook "useQueryClient" is called in function "invalidateActivityQueries" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use". (react-hooks/rules-of-hooks)

src/components/Dropdown.tsx

[warning] 3-205: Run autofix to sort imports, callbacks ordering, props sorting, and usage of array index in keys issues (simple-import-sort/imports, react/jsx-sort-props, react/no-array-index-key)

🪛 Biome (2.1.2)
src/components/Dropdown.tsx

[error] 196-196: The elements with this role can be changed to the following elements:
For examples and more information, see WAI-ARIA Roles (lint/a11y/useSemanticElements) [error] 196-196: The HTML element ul is non-interactive and should not have an interactive role. Replace ul with a div or a span. Unsafe fix: Remove the role attribute. (lint/a11y/noNoninteractiveElementToInteractiveRole) 🔇 Additional comments (11) src/types/dropdownTypes.ts (2) 3-6: 새로운 DropdownOption 인터페이스가 잘 정의되었습니다. 드롭다운 옵션에 대한 명확한 타입 정의를 제공하여 코드의 타입 안전성을 향상시킵니다. 24-24: optionData 속성 추가로 유연성이 향상되었습니다. 기존 options 배열과 함께 더 풍부한 옵션 데이터를 지원할 수 있게 되었습니다. src/hooks/useReservationQueries.ts (1) 77-81: 주석 업데이트가 적절합니다. 후기 작성 후 관련 쿼리 무효화에 대한 더 일반적인 설명으로 변경되었습니다. src/hooks/useActivityOptions.ts (2) 18-29: activityOptions 생성 로직이 잘 개선되었습니다. 더 일관된 구조로 변경되어 드롭다운 컴포넌트와의 통합이 개선되었습니다. 32-51: 활동 변경 시 캐시 무효화 로직이 적절합니다. 선택된 활동이 변경될 때 관련 쿼리들을 무효화하여 최신 데이터를 보장하는 로직이 잘 구현되었습니다. src/app/(with-header)/mypage/dashboard/page.tsx (3) 23-29: useActivityOptions 훅 사용법이 개선되었습니다. 더 간결하고 일관된 구조로 변경되어 코드 가독성이 향상되었습니다. 43-44: 선택된 활동 값 처리가 단순화되었습니다. 문자열 기반의 값 처리로 변경되어 더 직관적이고 일관된 로직이 되었습니다. 120-122: 드롭다운 컴포넌트 사용법이 새로운 구조에 맞게 업데이트되었습니다. optionData 속성을 사용하여 더 풍부한 옵션 데이터를 제공하도록 개선되었습니다. src/components/Dropdown.tsx (3) 31-31: optionData 지원 추가로 컴포넌트 유연성이 크게 향상되었습니다. 기존 options와의 호환성을 유지하면서 더 풍부한 옵션 데이터를 지원할 수 있게 되었습니다. Also applies to: 51-55 62-64: 표시 값 계산 로직이 잘 구현되었습니다. optionData 사용 여부에 따라 적절한 표시 텍스트를 선택하는 로직이 명확합니다. 73-82: 선택 핸들러가 새로운 구조에 맞게 잘 업데이트되었습니다. DropdownOption 객체를 받아 value를 추출하는 방식으로 일관된 처리가 가능해졌습니다.

return (
<li
key={option}
key={`${optionItem.value}-${index}`}
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

키 값으로 배열 인덱스 사용을 개선해주세요.

배열 인덱스를 키로 사용하면 성능 문제가 발생할 수 있습니다.

다음과 같이 수정하는 것을 권장합니다:

-                    key={`${optionItem.value}-${index}`}
+                    key={optionItem.value}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
key={`${optionItem.value}-${index}`}
key={optionItem.value}
🤖 Prompt for AI Agents
In src/components/Dropdown.tsx at line 201, avoid using the array index as part
of the key prop because it can cause performance issues. Instead, use a unique
and stable identifier from the optionItem itself, such as optionItem.value
alone, assuming it is unique. Update the key to use only optionItem.value or
another unique property without appending the index.

Copy link
Contributor

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

수정하시느라 고생 많으셨습니다!

@LeeCh0129 LeeCh0129 merged commit d7315cc into develop Aug 4, 2025
1 of 2 checks passed
@LeeCh0129 LeeCh0129 deleted the fix/139 branch August 4, 2025 14:33
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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d30b03c and da18261.

📒 Files selected for processing (2)
  • src/app/(with-header)/mypage/reservations/page.tsx (3 hunks)
  • src/hooks/useReservationQueries.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/app/(with-header)/mypage/reservations/page.tsx (1)
src/hooks/useReservationQueries.ts (1)
  • useInvalidateActivityQueries (91-110)
src/hooks/useReservationQueries.ts (1)
src/hooks/useDashboardQueries.ts (5)
  • _ (165-185)
  • queryClient (95-143)
  • updatedReservation (109-137)
  • queryClient (146-191)
  • activityId (64-92)
🔇 Additional comments (4)
src/hooks/useReservationQueries.ts (2)

77-77: 주석 개선이 적절합니다.

구체적인 내용에서 일반적인 설명으로 변경하여 더 명확해졌습니다.


91-110: 쿼리 무효화 훅이 잘 구현되었습니다.

새로운 useInvalidateActivityQueries 훅이 적절하게 구현되었습니다:

  • React 훅 컨텍스트 내에서 useQueryClient를 올바르게 사용하고 있습니다
  • 액티비티 관련 여러 쿼리 키를 체계적으로 무효화합니다
  • activityId 매개변수가 특정 액티비티 쿼리에 적절히 활용됩니다

이전 리뷰에서 지적된 React 훅 사용 문제가 해결되었습니다.

src/app/(with-header)/mypage/reservations/page.tsx (2)

8-8: 새로운 훅 임포트가 적절합니다.

useInvalidateActivityQueries 훅을 올바르게 임포트했습니다.


58-59: 훅 초기화가 올바릅니다.

쿼리 무효화 훅을 적절하게 초기화했습니다.

Comment on lines +109 to +123
const reservation = allReservations.find(
(r) => r.id === reviewModal.reservationId,
);

createReviewMutation.mutate(
{
reservationId: reviewModal.reservationId,
data: { rating, content },
},
{
onSuccess: () => {
setReviewModal({
isOpen: false,
reservationId: null,
activityTitle: null,
activityImage: null,
activityDate: null,
activityTime: null,
headCount: null,
totalPrice: null,
});
// 성공 후 추가 쿼리 무효화
if (reservation?.activity.id) {
invalidateActivityQueries(reservation.activity.id);
}
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

리뷰 생성 후 캐시 무효화 로직이 잘 구현되었습니다.

후기 작성 성공 시 관련 액티비티 쿼리들을 무효화하여 실시간 업데이트를 보장합니다. 예약 정보를 찾아 액티비티 ID를 전달하는 로직도 적절합니다.

다만 reservation을 찾지 못할 경우에 대한 방어 로직을 고려해보세요.

선택적 개선사항으로 다음과 같은 방어 로직을 추가할 수 있습니다:

  onSuccess: () => {
    // 성공 후 추가 쿼리 무효화
-   if (reservation?.activity.id) {
+   if (reservation?.activity?.id) {
      invalidateActivityQueries(reservation.activity.id);
+   } else {
+     console.warn('예약 정보를 찾을 수 없어 캐시 무효화를 건너뜁니다.');
    }
  },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const reservation = allReservations.find(
(r) => r.id === reviewModal.reservationId,
);
createReviewMutation.mutate(
{
reservationId: reviewModal.reservationId,
data: { rating, content },
},
{
onSuccess: () => {
setReviewModal({
isOpen: false,
reservationId: null,
activityTitle: null,
activityImage: null,
activityDate: null,
activityTime: null,
headCount: null,
totalPrice: null,
});
// 성공 후 추가 쿼리 무효화
if (reservation?.activity.id) {
invalidateActivityQueries(reservation.activity.id);
}
const reservation = allReservations.find(
(r) => r.id === reviewModal.reservationId,
);
createReviewMutation.mutate(
{
reservationId: reviewModal.reservationId,
data: { rating, content },
},
{
onSuccess: () => {
// 성공 후 추가 쿼리 무효화
if (reservation?.activity?.id) {
invalidateActivityQueries(reservation.activity.id);
} else {
console.warn('예약 정보를 찾을 수 없어 캐시 무효화를 건너뜁니다.');
}
},
},
);
🤖 Prompt for AI Agents
In src/app/(with-header)/mypage/reservations/page.tsx around lines 109 to 123,
the code finds a reservation by ID but lacks handling for the case when no
matching reservation is found. Add a defensive check to verify that reservation
exists before accessing its properties, such as reservation.activity.id, to
prevent runtime errors. If reservation is undefined, skip the cache invalidation
logic or handle the case appropriately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug 버그관련

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fix] 3차 QA 이슈

4 participants