260319_01_ENH: 17일자 수정사항 적용

This commit is contained in:
2026-03-19 14:05:19 +09:00
parent c66b51ca53
commit b2cf1b846f
13 changed files with 115 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
"use client";
import {ReactNode, useEffect, useRef, useState} from "react";
import {ReactNode, useEffect, useMemo, useRef, useState} from "react";
import {usePathname, useRouter} from "next/navigation";
import {cn} from "@/lib/utils";
import {SelectedMap} from "@/types/common";
@@ -16,6 +16,7 @@ import {LayoutFilterProvider} from "./LayoutFilterContext";
import {LAST_YEAR, PRODUCTS_FILTER_ITEM} from "@/const/lgConst";
import {ProductsFilterItem} from "@/types/lg";
import {ArrowUp, Filter} from "lucide-react";
import {Button} from "@/components/ui/button";
type MainLayoutProps = {
children: ReactNode;
@@ -103,6 +104,21 @@ const MainLayout = ({ children }: MainLayoutProps) => {
scrollRef.current?.scrollTo({ top: 0, behavior: "smooth" });
};
const isDefaultTotalFilter = useMemo(() => {
if(!isTotal) return false;
return Object.values(totalValue).every(value => value === "0");
},[isTotal, totalValue])
const setDefaletTotalFilter = () => {
if(isTotal && !isDefaultTotalFilter){
setTotalValue(prev =>
Object.fromEntries(
Object.keys(prev).map(key => [key, "0"])
)
);
}
}
useEffect(() => {
const prevIsTotal = prevIsTotalRef.current;
@@ -161,8 +177,17 @@ const MainLayout = ({ children }: MainLayoutProps) => {
필터 <span className="text-sm leading-none mb-1">{isFilterOpen ? "▲" : "▼"}</span>
</button>
{isTotal && (
<div className={"ml-5 content-text-sm"} dangerouslySetInnerHTML={{__html: totalPartDescription}}>
</div>
<>
<Button
variant={isDefaultTotalFilter ? "secondary" : "default"}
onClick={setDefaletTotalFilter}
className="h-6 rounded-sm px-3 ml-3 text-sm font-semibold content-text-sm"
>
초기화
</Button>
<div className={"ml-5 content-text-sm"} dangerouslySetInnerHTML={{__html: totalPartDescription}}>
</div>
</>
)}
</div>
<ExcelDownloadButton/>