Files
frontend/packages/common/components/src/api/notice-user.ts
T

87 lines
1.7 KiB
TypeScript

import { ENDPOINT } from "../config";
import { getApiClient } from "./client";
interface PageableParams {
page?: number;
size?: number;
sort?: string[];
}
interface SortConfig {
empty: boolean;
sorted: boolean;
unsorted: boolean;
}
interface PageableConfig {
sort: SortConfig;
offset: number;
pageNumber: number;
pageSize: number;
paged: boolean;
unpaged: boolean;
}
interface PageableList<T> {
content: T[];
pageable: PageableConfig;
sort: SortConfig;
totalPages: number;
totalElements: number;
number: number;
numberOfElements: number;
size: number;
first: boolean;
last: boolean;
empty: boolean;
}
interface NoticeUserListParams extends PageableParams {
recvUnqId?: string;
senderUnqId?: string;
notiType?: string;
notiTtlKeyword?: string;
notiCnKeyword?: string;
notReadYn?: string;
delYn?: string;
}
interface NoticeUser {
notiId: number;
recvUnqId: string;
senderUnqId: string;
notiType: string;
notiTtl: string;
notReadYn: string;
regDt: string;
}
const client = getApiClient();
const getNoticeUserList = async (
recvUnqId: string,
params?: NoticeUserListParams,
) => {
const response = await client.get<PageableList<NoticeUser>>(
`${ENDPOINT.CMS_SERVICE.NOTICE_USER}/${recvUnqId}/list`,
{ params },
);
return response.data;
};
const getUnreadNoticeCount = async (recvUnqId: string) => {
const response = await client.get<number>(
`${ENDPOINT.CMS_SERVICE.NOTICE_USER}/${recvUnqId}/unread/count`,
);
return response.data;
};
const readNotice = async (notiId: number) => {
const response = await client.put(
`${ENDPOINT.CMS_SERVICE.NOTICE}/${notiId}/read`,
);
return response.data;
};
export { getNoticeUserList, getUnreadNoticeCount, readNotice };