[st] feat: 대시보드 공지사항 api 수정
This commit is contained in:
@@ -4,4 +4,5 @@ NEXT_PUBLIC_PROXY_HOST=http://localhost:3001
|
||||
SERVER_API_URL=http://192.168.0.102:8000
|
||||
NEXT_PUBLIC_SITE_ID=ST
|
||||
NEXT_PUBLIC_SUB_DOMAIN=http://localhost:3000
|
||||
NEXT_PUBLIC_TINY_API_KEY=t9nc4z6inquvvd5pq1vea8wcp7lb01qmqseh6egms9vpaju2
|
||||
NEXT_PUBLIC_TINY_API_KEY=t9nc4z6inquvvd5pq1vea8wcp7lb01qmqseh6egms9vpaju2
|
||||
NEXT_PUBLIC_ST_DASHBOARD_BBS_ID=13
|
||||
@@ -2,30 +2,14 @@ import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
|
||||
import type { RecentPostSearchParams } from "../model/post-interface";
|
||||
import type { UserPostSearchParams } from "../model/post-interface";
|
||||
|
||||
import { postApi } from "./post-service";
|
||||
|
||||
export function useRecentPostList(params?: RecentPostSearchParams) {
|
||||
export function useUserPostList(params?: UserPostSearchParams) {
|
||||
return useQuery({
|
||||
queryKey: createRecentPostListQueryKey(params),
|
||||
queryFn: () => postApi.getRecentPostList(params),
|
||||
queryKey: [ENDPOINT.BOARD_SERVICE.POSTS, params],
|
||||
queryFn: () => postApi.getUserPostList(params),
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
}
|
||||
|
||||
function createRecentPostListQueryKey(params?: RecentPostSearchParams) {
|
||||
return [
|
||||
ENDPOINT.BOARD_SERVICE.POSTS,
|
||||
"recentPosts",
|
||||
params?.page ?? "",
|
||||
params?.size ?? "",
|
||||
params?.sort ?? "",
|
||||
params?.keywordType ?? "",
|
||||
params?.keyword ?? "",
|
||||
params?.bbsId ?? "",
|
||||
params?.delYn ?? "",
|
||||
params?.frDateYmd ?? "",
|
||||
params?.toDateYmd ?? "",
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import { ENDPOINT, ST_DASHBOARD_BBS_ID } from "@/shared/config";
|
||||
|
||||
import type {
|
||||
PostService,
|
||||
RecentPostListResponse,
|
||||
RecentPostSearchParams,
|
||||
UserPostListResponse,
|
||||
UserPostSearchParams,
|
||||
} from "../model/post-interface";
|
||||
|
||||
async function getRecentPostList(
|
||||
params?: RecentPostSearchParams,
|
||||
): Promise<RecentPostListResponse> {
|
||||
const response = await client.get<RecentPostListResponse>(
|
||||
`${ENDPOINT.BOARD_SERVICE.POSTS}/recentPosts`,
|
||||
async function getUserPostList(
|
||||
params?: UserPostSearchParams,
|
||||
): Promise<UserPostListResponse> {
|
||||
const response = await client.get<UserPostListResponse>(
|
||||
`${ENDPOINT.BOARD_SERVICE.POSTS}/user/${ST_DASHBOARD_BBS_ID}`,
|
||||
{ params },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export const postApi: PostService = {
|
||||
getRecentPostList,
|
||||
getUserPostList,
|
||||
};
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
export { useRecentPostList } from "./api/post-queries";
|
||||
export { useUserPostList } from "./api/post-queries";
|
||||
export { postApi } from "./api/post-service";
|
||||
export {
|
||||
type PostService,
|
||||
type PstRecentListResponse,
|
||||
type RecentPostListResponse,
|
||||
type RecentPostSearchParams,
|
||||
} from "./model/post-interface";
|
||||
export { type PostService, type UserPost } from "./model/post-interface";
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import type { PageableList, PageableParams } from "@/shared/model";
|
||||
|
||||
export interface RecentPostSearchParams extends PageableParams {
|
||||
export interface UserPostSearchParams extends PageableParams {
|
||||
keywordType?: string;
|
||||
keyword?: string;
|
||||
bbsId?: number;
|
||||
delYn?: string;
|
||||
frDateYmd?: string;
|
||||
toDateYmd?: string;
|
||||
popupYn?: string;
|
||||
upndFixYn?: string;
|
||||
prdPstgYn?: string;
|
||||
siteId?: string;
|
||||
bbsTypeCd?: string;
|
||||
ansUseYn?: string;
|
||||
}
|
||||
|
||||
export interface PstRecentListResponse {
|
||||
export interface UserPost {
|
||||
rowNo: number;
|
||||
bbsId: number;
|
||||
pstNo: number;
|
||||
@@ -29,14 +31,12 @@ export interface PstRecentListResponse {
|
||||
regDt: string;
|
||||
rgtrNm: string;
|
||||
cmntCnt: number;
|
||||
bbsTypeCd: string;
|
||||
bbsNm: string;
|
||||
}
|
||||
|
||||
export type RecentPostListResponse = PageableList<PstRecentListResponse>;
|
||||
export type UserPostListResponse = PageableList<UserPost>;
|
||||
|
||||
export interface PostService {
|
||||
getRecentPostList(
|
||||
params?: RecentPostSearchParams,
|
||||
): Promise<RecentPostListResponse>;
|
||||
getUserPostList(
|
||||
params?: UserPostSearchParams,
|
||||
): Promise<UserPostListResponse>;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,9 @@ import { useRouter } from "next/navigation";
|
||||
import { createColumnHelper, getCoreRowModel } from "@tanstack/react-table";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
import { ST_DASHBOARD_BBS_ID } from "@/shared/config";
|
||||
import { useDataTable } from "@/shared/lib";
|
||||
import { type PstRecentListResponse, useRecentPostList } from "@/entities/post";
|
||||
import { type UserPost, useUserPostList } from "@/entities/post";
|
||||
import { Button } from "@common/components";
|
||||
|
||||
import { useDragHandle } from "../sortable-panel";
|
||||
@@ -15,25 +16,23 @@ export function NoticePanel() {
|
||||
const { dragHandleProps, isDragging } = useDragHandle();
|
||||
const router = useRouter();
|
||||
|
||||
const recentPostListQuery = useRecentPostList({
|
||||
const userPostListQuery = useUserPostList({
|
||||
page: 0,
|
||||
size: 4,
|
||||
keywordType: "bbsTypeCd",
|
||||
keyword: "BBSNOTICE",
|
||||
});
|
||||
|
||||
const handleRowClick = (post: PstRecentListResponse) => {
|
||||
router.push(
|
||||
`/cms/${post.bbsTypeCd.toLowerCase()}/${post.bbsId}/${post.pstNo}`,
|
||||
);
|
||||
const handleRowClick = (post: UserPost) => {
|
||||
router.push(`/cms/bbsnotice/${ST_DASHBOARD_BBS_ID}/${post.pstNo}`);
|
||||
};
|
||||
|
||||
const handleMoreClick = () => {
|
||||
router.push("/cms/bbsnotice/7");
|
||||
router.push(`/cms/bbsnotice/${ST_DASHBOARD_BBS_ID}`);
|
||||
};
|
||||
|
||||
const { tableComponent } = useDataTable({
|
||||
query: recentPostListQuery,
|
||||
query: userPostListQuery,
|
||||
tableOptions: {
|
||||
columns: noticeColumns,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
@@ -52,8 +51,11 @@ export function NoticePanel() {
|
||||
title="헤더를 드래그하여 패널 순서 변경"
|
||||
>
|
||||
<h3 className="text-2xl font-semibold">공지사항</h3>
|
||||
</div>
|
||||
<div className="py-2 text-right">
|
||||
<Button
|
||||
size="sm"
|
||||
color="white"
|
||||
className="!text-xl"
|
||||
onClick={handleMoreClick}
|
||||
>
|
||||
@@ -65,7 +67,7 @@ export function NoticePanel() {
|
||||
);
|
||||
}
|
||||
|
||||
const columnHelper = createColumnHelper<PstRecentListResponse>();
|
||||
const columnHelper = createColumnHelper<UserPost>();
|
||||
|
||||
const noticeColumns = [
|
||||
columnHelper.accessor("pstTtl", {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Client } from "@common/network";
|
||||
|
||||
import { BASE_URL, ST_SERVICE_BASE_URL } from "../config/api";
|
||||
import { SITE_ID } from "../config/env";
|
||||
import { setCookie } from "../lib";
|
||||
@@ -6,11 +7,11 @@ import { setCookie } from "../lib";
|
||||
setCookie("site-id-key", SITE_ID);
|
||||
|
||||
export const client = Client.getInstance({
|
||||
baseURL: BASE_URL,
|
||||
siteId: SITE_ID,
|
||||
baseURL: BASE_URL,
|
||||
siteId: SITE_ID,
|
||||
});
|
||||
|
||||
export const stClient = Client.getInstance({
|
||||
baseURL: ST_SERVICE_BASE_URL,
|
||||
siteId: SITE_ID,
|
||||
});
|
||||
baseURL: ST_SERVICE_BASE_URL,
|
||||
siteId: SITE_ID,
|
||||
});
|
||||
|
||||
@@ -14,3 +14,4 @@ export const AUTH_USER_ID = process.env.NEXT_PUBLIC_AUTH_USER_ID || "token-id";
|
||||
export const ST_SERVICE_URL =
|
||||
process.env.NEXT_PUBLIC_ST_SERVICE_URL || "http://localhost:8080";
|
||||
export const COOKIE_DOMAIN = process.env.NEXT_PUBLIC_COOKIE_DOMAIN;
|
||||
export const ST_DASHBOARD_BBS_ID = process.env.NEXT_PUBLIC_ST_DASHBOARD_BBS_ID;
|
||||
|
||||
Reference in New Issue
Block a user