51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
"use client";
|
|
import type { comCodeState } from "@/app/store/common/code";
|
|
import { getOverLayObj } from "@/components/lib/func/mapUtil";
|
|
import { Card } from "@common/business_components/ui/chart/lib/card";
|
|
import { useEffect, useState } from "react";
|
|
import WrOverLayTable from "./WrOverLayTable/WrOverLayTable";
|
|
import WrOverLayRuse from "./WrOverLayRuse/WrOverLayRuse";
|
|
|
|
export default function WrOverLay({
|
|
title,
|
|
data,
|
|
code,
|
|
}: {
|
|
title: string;
|
|
data: any;
|
|
code: Partial<comCodeState>;
|
|
}) {
|
|
const [newOverLayData, setNewOverLayData] = useState<Record<string, string>>(
|
|
{}
|
|
);
|
|
const [typeTitle, setTypeTitle] = useState<string>("");
|
|
|
|
useEffect(() => {
|
|
if (title !== "하수재이용시설" && data) {
|
|
const overRayData = getOverLayObj(title, data, code);
|
|
setTypeTitle(overRayData?.title ?? "");
|
|
setNewOverLayData(overRayData.newObj ?? {});
|
|
}
|
|
}, [title, data]);
|
|
|
|
return (
|
|
<>
|
|
<Card className="w-[320px] p-0 shadow-md rounded-xl overflow-hidden border border-slate-300">
|
|
{/* 파란 제목 바 */}
|
|
{title !== "하수재이용시설" ? (
|
|
<div className="bg-sky-600 text-white text-center font-semibold py-2 text-2xl">
|
|
{typeTitle + "(" + title + ")"}
|
|
</div>
|
|
) : (
|
|
<></>
|
|
)}
|
|
{title === "하수재이용시설" ? (
|
|
<WrOverLayRuse overLayData={data ?? []} />
|
|
) : (
|
|
<WrOverLayTable overLayData={newOverLayData} />
|
|
)}
|
|
</Card>
|
|
</>
|
|
);
|
|
}
|