배너 및 지원현황 추가

This commit is contained in:
2025-12-12 18:08:59 +09:00
parent 2ecb9811bd
commit b746db5638
10 changed files with 190 additions and 86 deletions
@@ -0,0 +1,42 @@
import { client } from "@/shared/api";
import { ENDPOINT } from "@/shared/config";
export interface Support {
total: number;
ongoing: number;
han: number;
youngsang: number;
geum: number;
nakdong: number;
type: string;
}
export const getSupportList = async () => {
const url = `/api/proxy${ENDPOINT.IC_SERVICE.GROUPING_STATISTICS}`;
console.log("[getSupportList] API 호출 시작 (프록시, 인증 없음):", url);
try {
const response = await fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
accept: "application/json",
},
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log("[getSupportList] API 응답 성공:", data);
return data;
} catch (error: any) {
console.error("[getSupportList] API 호출 실패:", {
url,
error,
status: error?.status,
message: error?.message,
});
throw error;
}
};
@@ -0,0 +1,49 @@
import type { ColumnDef } from "@tanstack/react-table";
import type { Support } from "../api/support";
const typeLabelMap: Record<string, string> = {
waterQuality: "수질",
flood: "침수",
technical: "기술지원",
};
const supportTableColumns: ColumnDef<Support>[] = [
{
accessorKey: "type",
header: "구분",
cell: ({ getValue }) => {
const value = getValue() as string;
return typeLabelMap[value] || value;
},
},
{
accessorKey: "total",
header: "합계",
},
{
accessorKey: "han",
header: "한강",
},
{
accessorKey: "nakdong",
header: "낙동강",
},
{
accessorKey: "geum",
header: "금강",
},
{
accessorKey: "youngsang",
header: "영산강",
},
{
accessorKey: "ongoing",
header: "진행중",
},
{
accessorKey: "completed",
header: "환료",
},
];
export { supportTableColumns };
@@ -3,7 +3,7 @@
import { useRef } from "react";
import { useQuery } from "@tanstack/react-query";
import { ENDPOINT } from "@/shared/config";
import { getImageUrlByAtflCd, getBannerList } from "../api/banner";
import { getImageUrlByAtflCd, getBannerList, type Banner } from "../api/banner";
import { getCookie } from "@/shared/lib";
import {
@@ -63,7 +63,7 @@ const BannerList: React.FC = () => {
</div>
);
};
const { data: bannerList, error: bannerError, isLoading: isLoadingBanners } = useQuery({
const { data: bannerList, error: bannerError, isLoading: isLoadingBanners } = useQuery<Banner[]>({
queryKey: [ENDPOINT.CMS_SERVICE.BANNERS, siteId],
queryFn: () => getBannerList(siteId),
enabled: !!siteId,
@@ -26,6 +26,7 @@ import ReuseChart from "./reuse-chart";
import ReuseStatus from "./reuse-status";
import NoticeList from "./notice-list";
import BannerList from "./banner-list";
import SupportList from "./support-list";
// Chart.js 등록
ChartJS.register(
@@ -183,13 +184,8 @@ function DashboardPage() {
{/* 두번째 라인 */}
<div className="grid grid-cols-4 gap-1">
<div className="card card-border" id="grouping-statistics">
<div className="card-header text-foreground">
<h3 className="text-2xl font-medium">지원현황</h3>
</div>
<div className="h-70 p-4">
</div>
<div className="card card-border">
<SupportList />
</div>
<div className="card card-border">
<div className="card-header text-foreground">
@@ -0,0 +1,43 @@
"use client";
import { useRouter } from "next/navigation";
import { useQuery } from "@tanstack/react-query";
import { getCoreRowModel } from "@tanstack/react-table";
import { ENDPOINT } from "@/shared/config";
import { useDataTable } from "@/shared/lib";
import {
supportTableColumns,
} from "../model/support-columns";
import { getSupportList } from "../api/support";
const SupportList: React.FC = () => {
const router = useRouter();
const supportQuery = useQuery({
queryKey: [ENDPOINT.BOARD_SERVICE.POSTS],
queryFn: () =>
getSupportList(),
});
const { tableComponent: supportTableComponent } = useDataTable({
query: supportQuery,
tableOptions: {
columns: supportTableColumns,
getCoreRowModel: getCoreRowModel(),
},
dataTableOptions: {
variant: "line",
},
});
return (
<div className="card card-border !p-0">
<div className="card-header !m-0 !border-none text-foreground">
<h3 className="text-2xl font-medium">지원현황</h3>
</div>
{supportTableComponent}
</div>
);
};
export default SupportList;
+1 -1
View File
@@ -82,7 +82,7 @@ export const ENDPOINT = {
REUSE_STATUS: "/operation-service/api/v1/dashBoard/main/reuse/status",
},
IC_SERVICE: {
GROUPING_STATISTICS: "/ic-service/api/v1/nti/grouping-statistics",
GROUPING_STATISTICS: "/ic-service/api/v1/support-status-summary",
},
DC_SERVICE: {
DATA_STATUS: "/dc-service/api/v1/dataStatus",