Skip to content

feat: 알림(Notification) API 연동 - #37

Open
chiyyy wants to merge 4 commits into
developfrom
feature/notification-api-integration
Open

feat: 알림(Notification) API 연동#37
chiyyy wants to merge 4 commits into
developfrom
feature/notification-api-integration

Conversation

@chiyyy

@chiyyy chiyyy commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

요약

  • 알림 목록 조회(GET /api/notification), 읽음 처리(PATCH /api/notification/{notificationId}/read) API 연동 — 기존 MOCK_NOTIFICATIONS 목데이터 제거
  • 알림 화면 헤더의 설정 아이콘 탭 시 설정 화면으로 이동
  • 코드리뷰 반영: 목록 조회/읽음 처리 경합 시 낙관적 읽음 상태가 되돌아가는 문제 수정, 알림이 없을 때 안내 문구 표시

상세 변경

  • features/notification/api/notificationApi.ts(신규): getNotificationsApi, markNotificationReadApi
  • features/notification/model/useNotificationStore.ts(신규): 알림 목록 상태 관리 zustand 스토어
    • fetchNotifications에 in-flight 가드 추가 — 화면 재포커스마다 호출돼도 중복 요청이 안 나가도록 (useWardLocationStore와 동일 패턴)
    • markAsRead는 낙관적 업데이트(탭 즉시 읽음 표시 → PATCH 실패 시 롤백) + pendingReadIds로 그 사이 들어오는 목록 재조회 응답이 낙관적 읽음 상태를 덮어쓰지 않도록 보호
  • features/notification/model/types.ts: AppNotification(mock용) → 실 응답 스키마인 NotificationItem(notificationId, title, content, createdAt, isRead)으로 교체
  • features/notification/model/mockNotifications.ts 삭제 — 가이드 투어가 알림 화면/벨을 하이라이트하지 않아 mock 폴백 불필요함을 확인함
  • features/notification/ui/NotificationCard.tsx: 새 타입 반영, 안 읽은 알림에 표시 점 추가, onPress로 탭 시 읽음 처리
  • features/notification/utils/index.ts: createdAt(ISO) → YYYY.MM.DD HH:mm 포맷터 추가
  • screens/guardian/Notification/NotificationScreen.tsx: mock 배열 대신 스토어 연결, useFocusEffect로 재방문 시 재조회, 로딩/빈 목록 상태 UI 추가, 설정 아이콘 탭 시 Settings 화면으로 이동

참고

  • 스웨거 응답 예시에 read/isRead가 함께 노출돼 있는데, 기존 PillSchedule(active/isActive) 사례와 동일하게 백엔드 boolean getter 중복 노출로 보고 isRead 하나만 사용함
  • .env 등 민감 파일 변경 없음

테스트

  • tsc --noEmit 통과
  • ESLint 통과
  • 실기기에서 알림 목록 조회 / 카드 탭 읽음 처리 / 설정 아이콘 이동 확인

@chiyyy chiyyy self-assigned this Sep 1, 2026
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