diff --git a/apps/cs/src/pages/dashboard/api/dashboard-service.ts b/apps/cs/src/pages/dashboard/api/dashboard-service.ts index 784f1df82..998215864 100644 --- a/apps/cs/src/pages/dashboard/api/dashboard-service.ts +++ b/apps/cs/src/pages/dashboard/api/dashboard-service.ts @@ -4,6 +4,8 @@ import type { Dashboard, DashboardService, NoticeUser, + Schedule, + ScheduleQueryParams, } from "../model/dashboard-interface"; import type { PageableList } from "@/shared/model"; @@ -23,6 +25,16 @@ export class DashboardApiService implements DashboardService { ); return response.data; } + + public async getScheduleList( + params?: ScheduleQueryParams, + ): Promise { + const response = await client.get( + ENDPOINT.CMS_SERVICE.SCHEDULES, + { params }, + ); + return response.data; + } } export const DashboardApi = new DashboardApiService(); diff --git a/apps/cs/src/pages/dashboard/model/dashboard-interface.ts b/apps/cs/src/pages/dashboard/model/dashboard-interface.ts index 77a4649cc..e2a01173d 100644 --- a/apps/cs/src/pages/dashboard/model/dashboard-interface.ts +++ b/apps/cs/src/pages/dashboard/model/dashboard-interface.ts @@ -39,7 +39,32 @@ export interface NoticeUser { regDt: string; } +export interface Schedule { + schdlBgngDt: string; + schdlEndDt: string; + actualDate: string; + schdlSn: number; + siteId: string; + schdlTtl: string; + schdlSeCd: string; + schdlCn: string; + reptYn: string; + commSchdlYn: string; + atflCd: string | null; +} + +export interface ScheduleQueryParams { + siteId?: string; + schdlTtl?: string; + schdlSeCd?: string; + schdlBgngYmd?: string; + schdlEndYmd?: string; + reptYn?: string; + commSchdlYn?: string; +} + export interface DashboardService { getDashboard(): Promise; getNoticeUserList(recvUnqId: string): Promise>; + getScheduleList(params?: ScheduleQueryParams): Promise; } diff --git a/apps/cs/src/pages/dashboard/ui/dashboard-page.tsx b/apps/cs/src/pages/dashboard/ui/dashboard-page.tsx index 32ea14966..d787a6ab7 100644 --- a/apps/cs/src/pages/dashboard/ui/dashboard-page.tsx +++ b/apps/cs/src/pages/dashboard/ui/dashboard-page.tsx @@ -18,7 +18,7 @@ import { } from "chart.js"; import { Bar, Line } from "react-chartjs-2"; import { PostApi, type RecentPost } from "@/entities/post"; -import { AUTH_USER_ID, ENDPOINT } from "@/shared/config"; +import { AUTH_USER_ID, ENDPOINT, SITE_ID } from "@/shared/config"; import { getCookie, useDataTable } from "@/shared/lib"; import { DashboardApi } from "../api/dashboard-service"; import { chartData } from "../model/chart-data"; @@ -53,6 +53,29 @@ function DashboardPage() { queryKey: [ENDPOINT.CMS_SERVICE.NOTICE_USER], queryFn: () => DashboardApi.getNoticeUserList(userId), enabled: !!userId, + select: (data) => { + // 오늘 ~ 한 달 전 사이의 일정 + const today = dayjs().endOf("day"); + const monthAgo = dayjs().subtract(1, "month").startOf("day"); + return data.content?.filter((item) => { + const regDt = dayjs(item.regDt); + return ( + (regDt.isSame(monthAgo) || regDt.isAfter(monthAgo)) && + (regDt.isSame(today) || regDt.isBefore(today)) + ); + }); + }, + }); + + const { data: scheduleList } = useQuery({ + queryKey: [ENDPOINT.CMS_SERVICE.SCHEDULES], + queryFn: () => + DashboardApi.getScheduleList({ + siteId: SITE_ID, + schdlBgngYmd: dayjs().format("YYYY-MM-DD"), + schdlEndYmd: dayjs().add(1, "month").format("YYYY-MM-DD"), + commSchdlYn: "Y", + }), }); const noticePostQuery = useQuery({ @@ -333,7 +356,7 @@ function DashboardPage() {
- {noticeUserList?.content?.map((item) => ( + {noticeUserList?.map((item) => (
-
- - {(3).toLocaleString()}월 정기 시스템 점검 - - 내일 -
-
- 서버 업데이트 예정 - {(3).toLocaleString()}일 후 -
-
- 백업 스케줄 - {(5).toLocaleString()}일 후 -
-
- 정기 보안 점검 - {(7).toLocaleString()}일 후 -
+ {scheduleList && scheduleList.length > 0 ? ( + scheduleList.map((schedule, index) => { + const today = dayjs(); + const scheduleDate = dayjs(schedule.actualDate); + const daysUntil = scheduleDate.diff(today, "day"); + + let timeText = ""; + if (daysUntil === 0) { + timeText = "오늘"; + } else if (daysUntil === 1) { + timeText = "내일"; + } else if (daysUntil > 1) { + timeText = `${daysUntil}일 후`; + } else { + timeText = scheduleDate.format("YYYY-MM-DD"); + } + + return ( +
+ + {schedule.schdlTtl} + + {timeText} +
+ ); + }) + ) : ( +
+ 예정된 일정이 없습니다. +
+ )}