-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : 알림페이지 api 연동 및 알림 타입 변경 (#359)
- Loading branch information
1 parent
a7fd03a
commit 353bc7c
Showing
8 changed files
with
98 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { getNotifications } from '@/service/notification/getNotifiations'; | ||
|
||
export const useGetNotifications = () => { | ||
return useQuery({ | ||
queryKey: ['notifications'], | ||
queryFn: getNotifications | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { updateNotificationStatus } from '@/service/notification/updateNotificationStatus'; | ||
|
||
export const useUpdateNotificationStatus = () => { | ||
return useMutation({ | ||
mutationFn: updateNotificationStatus | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defaultApi } from '@/service/api'; | ||
import { NotificationResponseType } from '@/types/notification'; | ||
|
||
export const getNotifications = async (): Promise<NotificationResponseType> => { | ||
const api = defaultApi(); | ||
|
||
const response = await api.patch('/notification'); | ||
return response.data; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defaultApi } from '@/service/api'; | ||
import { NotificationResponseType } from '@/types/notification'; | ||
|
||
export const updateNotificationStatus = async ( | ||
isRead: boolean | ||
): Promise<NotificationResponseType> => { | ||
const api = defaultApi(); | ||
|
||
const response = await api.patch('/notification', { isRead }); | ||
return response.data; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
export type NotificationType = | ||
| 'NEW_LETTER' | ||
| 'TARGET_LETTER' | ||
| 'REPLY_LETTER' | ||
| 'KEYWORD_REPLY' | ||
| 'MAP_REPLY' | ||
| 'WARNING' | ||
| 'BAN'; | ||
|
||
export type NotificationProps = { | ||
export type NotificationItemItemProps = { | ||
type: NotificationType; | ||
createdAt: string; | ||
letterId: number; | ||
isRead: boolean; | ||
label: string; | ||
}; | ||
|
||
export type NotificationResponseType = { | ||
isSuccess: boolean; | ||
code: string; | ||
message: string; | ||
result: { | ||
id: string; | ||
type: NotificationType; | ||
receiver: number; | ||
createdAt: string; | ||
letterId: number; | ||
isRead: boolean; | ||
label: string; | ||
}[]; | ||
}; |