-
Notifications
You must be signed in to change notification settings - Fork 0
[Fix] 알림페이지 디자인 반영 / 버그 일부 수정 #269
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
Changes from 9 commits
3d13185
622a1dc
3badeea
9e42a09
e03f9de
85949d6
ddcf88c
cbce84d
0660dac
b383606
76c89d6
bf54014
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,14 +2,29 @@ | |||||||||||||||||||||||||||||||||
| import { useRouter } from 'next/navigation'; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| import { Icon } from '@/components/icon'; | ||||||||||||||||||||||||||||||||||
| import { useUpdateNotificationReadAll } from '@/hooks/use-notification'; | ||||||||||||||||||||||||||||||||||
| import { cn } from '@/lib/utils'; | ||||||||||||||||||||||||||||||||||
| import { useNotification } from '@/providers'; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| export const NotificationHeader = () => { | ||||||||||||||||||||||||||||||||||
| const router = useRouter(); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const { unReadCount } = useNotification(); | ||||||||||||||||||||||||||||||||||
| const { mutateAsync } = useUpdateNotificationReadAll(); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const handleHistoryBackClick = () => { | ||||||||||||||||||||||||||||||||||
| router.back(); | ||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const handleReadAllClick = () => { | ||||||||||||||||||||||||||||||||||
| if (unReadCount === 0) return; | ||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||
| mutateAsync(); | ||||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||||
| alert('요청 처리에 실패했습니다.'); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
| const handleReadAllClick = () => { | |
| if (unReadCount === 0) return; | |
| try { | |
| mutateAsync(); | |
| } catch { | |
| alert('요청 처리에 실패했습니다.'); | |
| } | |
| }; | |
| const handleReadAllClick = async () => { | |
| if (unReadCount === 0) return; | |
| try { | |
| await mutateAsync(); | |
| } catch { | |
| alert('요청 처리에 실패했습니다.'); | |
| } | |
| }; |
🤖 Prompt for AI Agents
In src/components/pages/notification/notification-header/index.tsx around lines
19 to 26, the handler calls mutateAsync() without awaiting it so the try/catch
won't catch rejected promises; make the handler async and await mutateAsync()
(or return the promise and handle .catch) so errors are properly caught, and
keep the existing alert inside the catch block to show failure.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,7 @@ export const useConnectSSE = () => { | |
| console.log('SSE 수신 성공:', data); | ||
| setReceivedNewNotification(true); | ||
| queryClient.invalidateQueries({ queryKey: notificationKeys.unReadCount() }); | ||
| queryClient.invalidateQueries({ queryKey: notificationKeys.list() }); | ||
| // TODO: 알림 타입별 처리 추가 예정 | ||
| } catch (error) { | ||
| console.error('SSE 데이터 파싱 실패:', error); | ||
|
|
@@ -62,6 +63,7 @@ export const useConnectSSE = () => { | |
| es.onerror = (_error) => { | ||
| console.log('SSE 오류 발생:'); | ||
| // todo: 재 연결 로직 추가 필요 | ||
| accessToken.value = null; | ||
| }; | ||
|
|
||
| // SSE Cleanup | ||
|
|
@@ -70,7 +72,7 @@ export const useConnectSSE = () => { | |
| es.close(); | ||
| eventSourceRef.current = null; | ||
| }; | ||
| }, [accessToken.value, queryClient]); | ||
| }, [accessToken, queryClient]); | ||
|
||
|
|
||
| return { receivedNewNotification }; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ import { GetNotificationListQueryParams } from '@/types/service/notification'; | |
|
|
||
| export const useGetNotificationsInfinite = (params?: GetNotificationListQueryParams) => { | ||
| return useInfiniteQuery({ | ||
| queryKey: notificationKeys.list(params), | ||
| queryKey: notificationKeys.list(), | ||
|
||
| queryFn: ({ pageParam }) => API.notificationService.getList({ ...params, cursor: pageParam }), | ||
| initialPageParam: params?.cursor, | ||
| getNextPageParam: (lastPage) => lastPage.nextCursor, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,5 @@ | ||
| import { GetNotificationListQueryParams } from '@/types/service/notification'; | ||
|
|
||
| export const notificationKeys = { | ||
| all: ['notifications'] as const, | ||
| list: (params?: GetNotificationListQueryParams) => [ | ||
| 'notifications', | ||
| 'list', | ||
| ...(params ? [params] : []), | ||
| ], | ||
| list: () => ['notifications', 'list'], | ||
| unReadCount: () => [...notificationKeys.all, 'unread-count'], | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,7 @@ | |
| button { | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| button:disabled { | ||
| cursor: not-allowed; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: WeGo-Together/WeGo_FrontEnd
Length of output: 656
🏁 Script executed:
Repository: WeGo-Together/WeGo_FrontEnd
Length of output: 1367
🏁 Script executed:
Repository: WeGo-Together/WeGo_FrontEnd
Length of output: 2186
🏁 Script executed:
Repository: WeGo-Together/WeGo_FrontEnd
Length of output: 1533
logout()호출이 에러 처리 없이 사용자 리다이렉션을 차단할 수 있습니다.logout()은 API 요청을 수행하며 예외를 던질 수 있습니다. 현재 코드에서 이 호출이 try-catch로 보호되지 않으면, 예외 발생 시 60-69번 줄의 리다이렉션 로직이 실행되지 않아 사용자가 로그인 페이지로 이동하지 못합니다.try-catch로 감싸서 안전하게 처리하세요:
🤖 Prompt for AI Agents