Skip to content

fix: 학습 알림톡 시간 저장 연결#679

Merged
Hyeonjun0527 merged 1 commit into
developfrom
fix/my-class-notification-setting
May 22, 2026
Merged

fix: 학습 알림톡 시간 저장 연결#679
Hyeonjun0527 merged 1 commit into
developfrom
fix/my-class-notification-setting

Conversation

@Hyeonjun0527

@Hyeonjun0527 Hyeonjun0527 commented May 22, 2026

Copy link
Copy Markdown
Member

요약

  • 마이 클래스 알림톡 시간 조회/저장 상태를 백엔드 B-02/B-03 API와 연결
  • 저장 성공 시 notification-setting 캐시 즉시 반영 및 재조회
  • 저장 중 중복 클릭 방지와 조회 loading/error 문구 연결

검증

  • yarn typecheck
  • scoped ESLint: my-class page/modal + notification hook
  • scoped Biome format: my-class page/modal + notification hook
  • git diff --check

범위

  • 알림톡 시간 설정만 포함
  • 무료수강신청 CTA 로컬 변경은 포함하지 않음

Summary by CodeRabbit

릴리스 노트

  • 개선사항
    • 알림 설정 저장 중 "저장 중..." 텍스트와 함께 저장 버튼을 비활성화하여 사용자 혼동 방지
    • 알림 설정 로딩 및 오류 상태를 화면에 표시하여 사용자 경험 개선
    • 알림 시간 표시 로직을 안정화하여 더 정확한 상태 정보 제공

Review Change Stack

@vercel

vercel Bot commented May 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
study-platform-client-dev Ready Ready Preview, Comment May 22, 2026 5:35pm

@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

알림 설정 쿼리 훅의 타입과 쿼리 키를 공개하고, 캐시 갱신 방식을 setQueryData + invalidateQueries 조합으로 개선합니다. 모달은 mutation 상태를 활용해 저장 진행 중 버튼을 비활성화하고, 페이지는 로딩·에러 상태를 AlarmCard에 전파하여 상태별 메시지를 표시합니다.

Changes

알림 설정 상태 관리 및 로딩 상태 반영

Layer / File(s) Summary
쿼리 훅 기반 개선: 타입 공개 및 캐시 갱신
src/hooks/queries/notification/use-notification-setting.ts
NotificationSettingResponse, NotificationSettingUpdateRequest 타입과 NOTIFICATION_SETTING_QUERY_KEY 상수를 export하고, 업데이트 완료 시 먼저 setQueryData로 캐시를 즉시 갱신한 뒤 invalidateQueries를 호출합니다.
모달 로딩 상태 반영: mutation 객체 사용 및 버튼 비활성화
src/app/(service)/(my)/my-class/_components/learning-notification-modal.tsx
전체 mutation 객체를 사용하여 isPending 상태를 추적하고, 저장 진행 중 버튼을 비활성화하며 텍스트를 "저장 중..."으로 표시합니다.
페이지 상태 전파: 로딩·에러 분리 및 AlarmCard 업데이트
src/app/(service)/(my)/my-class/page.tsx
useGetNotificationSetting()의 반환값을 notificationSetting, isLoading, isError로 분리하여 AlarmCard에 전달하고, 로딩/에러 상태를 우선 메시지로, 정상 시 시간을 number 타입으로 검증해 표시합니다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

🐛 bug, release:patch

Poem

🐰 알림의 상태를 명확히 하니,
로딩 중일 땐 "기다려요" 하고,
에러 났으면 "도움이 필요해요" 하고,
캐시도 빠르게 갱신되고,
사용자 손가락은 이제 더 이상 헷갈리지 않는다네! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경 사항의 주요 목적을 명확하게 나타냄: 학습 알림톡 시간 저장 기능의 백엔드 API 연동.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/my-class-notification-setting

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/hooks/queries/notification/use-notification-setting.ts`:
- Around line 39-43: The onSuccess currently replaces the whole cache via
queryClient.setQueryData(NOTIFICATION_SETTING_QUERY_KEY, data) which can
overwrite optional/partial fields and cause UI flicker; instead, in the
onSuccess handler for useNotificationSetting merge incoming data with existing
cache (read existing via
queryClient.getQueryData(NOTIFICATION_SETTING_QUERY_KEY) or use setQueryData(old
=> ...)) and shallow-merge/assign only provided fields (e.g., merge isEnabled
and other optional properties) before writing back, then call
queryClient.invalidateQueries for NOTIFICATION_SETTING_QUERY_KEY if needed;
update the onSuccess in use-notification-setting.ts to perform this merge logic
so partial responses don’t clobber missing fields.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3fcb0779-6f0d-4bb8-8b5a-f374f52905c4

📥 Commits

Reviewing files that changed from the base of the PR and between 98f92ed and 313245f.

📒 Files selected for processing (3)
  • src/app/(service)/(my)/my-class/_components/learning-notification-modal.tsx
  • src/app/(service)/(my)/my-class/page.tsx
  • src/hooks/queries/notification/use-notification-setting.ts

Comment on lines +39 to +43
onSuccess: async (data) => {
queryClient.setQueryData(NOTIFICATION_SETTING_QUERY_KEY, data);
await queryClient.invalidateQueries({
queryKey: NOTIFICATION_SETTING_QUERY_KEY,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "1) notification-setting 관련 타입/사용처 확인"
rg -n --type=ts -C3 "NotificationSettingResponse|isEnabled|saved|members/me/notification-setting|setQueryData\\(|useGetNotificationSetting\\("

echo
echo "2) OpenAPI/Swagger 산출물(있다면)에서 notification-setting 응답 스키마 확인"
fd -i "openapi|swagger" .

Repository: code-zero-to-one/study-platform-client

Length of output: 39137


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== 1) use-notification-setting.ts 관련 코드 ==="
sed -n '1,120p' src/hooks/queries/notification/use-notification-setting.ts

echo
echo "=== 2) my-class page.tsx에서 notificationSetting 소비부 ==="
sed -n '1,220p' src/app/(service)/(my)/my-class/page.tsx

echo
echo "=== 3) learning-notification-modal.tsx에서 소비부 ==="
sed -n '1,200p' "src/app/(service)/(my)/my-class/_components/learning-notification-modal.tsx"

echo
echo "=== 4) notification-setting 관련 API/스키마(가능하면) 추가 탐색 ==="
rg -n "notification-setting" src | head -n 50

echo
echo "=== 5) NotificationSettingResponse/saved 사용처 ==="
rg -n "NotificationSettingResponse|\\.saved\\b|isEnabled\\b" src/app src/features src/hooks/queries/notification | head -n 80

Repository: code-zero-to-one/study-platform-client

Length of output: 1626


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== 1) use-notification-setting.ts 관련 코드 ==="
sed -n '1,120p' src/hooks/queries/notification/use-notification-setting.ts

echo
echo "=== 2) my-class page.tsx에서 notificationSetting 소비부 ==="
sed -n '1,220p' src/app/(service)/(my)/my-class/page.tsx

echo
echo "=== 3) learning-notification-modal.tsx에서 소비부 ==="
sed -n '1,200' "src/app/(service)/(my)/my-class/_components/learning-notification-modal.tsx"

echo
echo "=== 4) notification-setting 관련 API/스키마(가능하면) 추가 탐색 ==="
rg -n "notification-setting" src | head -n 50

echo
echo "=== 5) NotificationSettingResponse/saved 사용처 ==="
rg -n "NotificationSettingResponse|\\.saved\\b|isEnabled\\b" src/app src/features src/hooks/queries/notification | head -n 80

Repository: code-zero-to-one/study-platform-client

Length of output: 1626


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== 1) my-class page.tsx에서 notificationSetting 소비부 핵심 ==="
sed -n '1,90p' "src/app/(service)/(my)/my-class/page.tsx"

echo
echo "=== 2) learning-notification-modal.tsx에서 notificationSetting 소비부 핵심 ==="
sed -n '1,140p' "src/app/(service)/(my)/my-class/_components/learning-notification-modal.tsx"

echo
echo "=== 3) NotificationSettingResponse(타입) 직접 사용/필드 접근 추가 탐색 ==="
rg -n "NotificationSettingResponse|notificationSetting\\?\\.isEnabled|\\bisEnabled\\b|\\bsaved\\b" \
  "src/app/(service)/(my)/my-class" src/features/mentoring src/hooks/queries/notification

echo
echo "=== 4) notification-setting query key 사용처(캐시 참조) ==="
rg -n "NOTIFICATION_SETTING_QUERY_KEY|notification-setting" src/hooks src/app

Repository: code-zero-to-one/study-platform-client

Length of output: 11114


src/hooks/queries/notification/use-notification-setting.ts 캐시 업데이트를 부분 응답에 대비해 병합하세요

onSuccess에서 queryClient.setQueryData(NOTIFICATION_SETTING_QUERY_KEY, data)로 통째 교체하면 NotificationSettingResponse가 optional 필드(isEnabled 등)만 부분 포함하는 경우, my-class/page.tsx에서 notificationSetting?.isEnabled ?? false 때문에 토글 상태가 잠깐 잘못(깜빡임) 표시될 수 있습니다.

🔧 제안 수정안
-    onSuccess: async (data) => {
-      queryClient.setQueryData(NOTIFICATION_SETTING_QUERY_KEY, data);
+    onSuccess: async (data) => {
+      queryClient.setQueryData(
+        NOTIFICATION_SETTING_QUERY_KEY,
+        (prev?: NotificationSettingResponse) => ({
+          ...prev,
+          ...data,
+        }),
+      );
       await queryClient.invalidateQueries({
         queryKey: NOTIFICATION_SETTING_QUERY_KEY,
       });
     },
📝 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
onSuccess: async (data) => {
queryClient.setQueryData(NOTIFICATION_SETTING_QUERY_KEY, data);
await queryClient.invalidateQueries({
queryKey: NOTIFICATION_SETTING_QUERY_KEY,
});
onSuccess: async (data) => {
queryClient.setQueryData(
NOTIFICATION_SETTING_QUERY_KEY,
(prev?: NotificationSettingResponse) => ({
...prev,
...data,
}),
);
await queryClient.invalidateQueries({
queryKey: NOTIFICATION_SETTING_QUERY_KEY,
});
},
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/hooks/queries/notification/use-notification-setting.ts` around lines 39 -
43, The onSuccess currently replaces the whole cache via
queryClient.setQueryData(NOTIFICATION_SETTING_QUERY_KEY, data) which can
overwrite optional/partial fields and cause UI flicker; instead, in the
onSuccess handler for useNotificationSetting merge incoming data with existing
cache (read existing via
queryClient.getQueryData(NOTIFICATION_SETTING_QUERY_KEY) or use setQueryData(old
=> ...)) and shallow-merge/assign only provided fields (e.g., merge isEnabled
and other optional properties) before writing back, then call
queryClient.invalidateQueries for NOTIFICATION_SETTING_QUERY_KEY if needed;
update the onSuccess in use-notification-setting.ts to perform this merge logic
so partial responses don’t clobber missing fields.

@Hyeonjun0527 Hyeonjun0527 merged commit 0085ad0 into develop May 22, 2026
16 checks passed
@Hyeonjun0527 Hyeonjun0527 deleted the fix/my-class-notification-setting branch May 22, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant