[as] feat: 알림이력 페이지 구현
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type { PageResponse } from "@/shared/model";
|
||||
|
||||
import type { NotiAsUserResponseDto, NotiSearchDto, NotiService } from "../model/noti-interface";
|
||||
|
||||
const BASE = ENDPOINT.CMS_SERVICE.NOTI;
|
||||
|
||||
async function findMyAsNotiList(
|
||||
params: NotiSearchDto,
|
||||
): Promise<PageResponse<NotiAsUserResponseDto>> {
|
||||
const response = await client.get<PageResponse<NotiAsUserResponseDto>>(`${BASE}/as/my/list`, {
|
||||
params,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function readNoti(notiId: number): Promise<number> {
|
||||
const response = await client.put<number>(`${BASE}/${notiId}/read`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export const notiService = { findMyAsNotiList, readNoti } satisfies NotiService;
|
||||
@@ -0,0 +1,26 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
|
||||
import type { NotiSearchDto } from "../model/noti-interface";
|
||||
|
||||
import { notiService } from "./noti-service";
|
||||
|
||||
export const notiBaseKey = [ENDPOINT.CMS_SERVICE.NOTI] as const;
|
||||
|
||||
export function useFindMyAsNotiList(params: NotiSearchDto) {
|
||||
return useQuery({
|
||||
queryKey: [...notiBaseKey, "findMyAsNotiList", params],
|
||||
queryFn: () => notiService.findMyAsNotiList(params),
|
||||
});
|
||||
}
|
||||
|
||||
export function useReadNoti() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (notiId: number) => notiService.readNoti(notiId),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: notiBaseKey });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export { notiService } from "./api/noti-service";
|
||||
export { notiBaseKey, useFindMyAsNotiList, useReadNoti } from "./api/queries";
|
||||
export type { NotiAsUserResponseDto, NotiSearchDto, NotiService } from "./model/noti-interface";
|
||||
@@ -0,0 +1,41 @@
|
||||
import type { PageableParams, PageResponse } from "@/shared/model";
|
||||
|
||||
/** 백엔드 NotiAsUserResponseDto */
|
||||
export interface NotiAsUserResponseDto {
|
||||
notiId: number;
|
||||
recvUnqId: string;
|
||||
senderUnqId: string;
|
||||
notiType: string;
|
||||
notiTtl: string;
|
||||
notiCn?: string;
|
||||
notReadYn?: string;
|
||||
regDt?: string;
|
||||
notiUrl?: string;
|
||||
notiLnkgUnqNo?: string;
|
||||
docSeComCd?: string;
|
||||
docSeComNm?: string;
|
||||
notiIdntyDt?: string;
|
||||
notiIdntyYn?: string;
|
||||
notiPrcsCmptnYn?: string;
|
||||
notiPrcsCmptnDt?: string;
|
||||
}
|
||||
|
||||
/** 백엔드 NotiSearchDto + Pageable */
|
||||
export interface NotiSearchDto extends PageableParams {
|
||||
recvUnqId?: string;
|
||||
senderUnqId?: string;
|
||||
notiType?: string;
|
||||
notiTtlKeyword?: string;
|
||||
notiCnKeyword?: string;
|
||||
notReadYn?: string;
|
||||
delYn?: string;
|
||||
startDt?: string;
|
||||
endDt?: string;
|
||||
docSeComCd?: string;
|
||||
}
|
||||
|
||||
/** Controller public 메서드명·시그니처와 동일 */
|
||||
export interface NotiService {
|
||||
findMyAsNotiList(params: NotiSearchDto): Promise<PageResponse<NotiAsUserResponseDto>>;
|
||||
readNoti(notiId: number): Promise<number>;
|
||||
}
|
||||
Reference in New Issue
Block a user