260206_07_ENH: 필터 아이콘 추가 및 api통신에 캐시 기능 추가, LIFE_STAGE_COLUMNS에 미혼, 독립 시니어 rowspan 적용

This commit is contained in:
2026-02-06 16:30:29 +09:00
parent 17d75e3f3a
commit b7282bd07d
4 changed files with 23 additions and 6 deletions

View File

@@ -15,7 +15,7 @@ import ExcelDownloadButton from "./ExcelDownloadButton";
import {LayoutFilterProvider} from "./LayoutFilterContext";
import {LAST_YEAR, PRODUCTS_FILTER_ITEM} from "@/const/lgConst";
import {ProductsFilterItem} from "@/types/lg";
import {ArrowUp} from "lucide-react";
import {ArrowUp, Filter} from "lucide-react";
type MainLayoutProps = {
children: ReactNode;
@@ -141,6 +141,7 @@ const MainLayout = ({ children }: MainLayoutProps) => {
"select-none"
)}
>
<Filter className="h-4 w-4 fill-[hsl(var(--lg-gray-500))] stroke-[hsl(var(--lg-gray-500))]" />
필터 <span className="text-sm leading-none">{isFilterOpen ? "▲" : "▼"}</span>
</button>
{isTotal && (

View File

@@ -1,6 +1,7 @@
"use client";
import {bannerType} from "@/components/lge-dashboard/types";
import {Filter} from "lucide-react";
type BannerButtonsProps = {
banners: bannerType[];
@@ -15,7 +16,10 @@ const BannerButtons = ({
}: BannerButtonsProps) => {
return (
<div className="flex flex-col gap-1.5">
<div className="text-center font-bold p-1">구분 필터</div>
<div className="flex items-center justify-center font-bold p-1">
<Filter className="h-4 w-4 -ml-2 mr-1 fill-[hsl(var(--lg-gray-500))] stroke-[hsl(var(--lg-gray-500))]" />
구분 필터
</div>
{banners.map((banner) => (
<button
key={banner.variable}

View File

@@ -88,14 +88,14 @@ export const LIFE_STAGE_COLUMNS: GaugeColumn<LifeStageRow>[] = [
{ key: "item", header: "", headRowSpan:2, rowHead: true, render: (r) => r.item },
{ key: "total", header: "전체", headRowSpan:2, max: 100, align: "left", cellType:"number"},
{ key: "single", header: "미혼", max: 100 , align: "left"},
{ key: "single", header: "미혼" , headRowSpan:2, max: 100 , align: "left"},
{ key: "noKids", header: "무자녀", group: "기혼", max: 100 , align: "left"},
{ key: "preschoolKids", header: "미취학", group: "기혼", max: 100 , align: "left"},
{ key: "schoolKids", header: "취학자녀", group: "기혼", max: 100 , align: "left"},
{ key: "adultKids", header: "성인자녀", group: "기혼", max: 100 , align: "left"},
{ key: "independentSenior", header: "독립\n시니어", max: 100 , align: "left"},
{ key: "independentSenior", header: "독립\n시니어", headRowSpan:2, max: 100 , align: "left"},
];
export const LIFE_STAGE_GROUPS = [

View File

@@ -33,6 +33,11 @@ export type QueryValue = string | string[] | undefined;
export type Query = Record<string, QueryValue>;
export type PathParams = Record<string, string | number | boolean>;
export type NextFetchOptions = {
revalidate?: number;
tags?: string[];
};
export type RequestOptions = {
method?: HttpMethod;
pathParams?: PathParams;
@@ -47,6 +52,8 @@ export type RequestOptions = {
autoLogoutOnAuthError?: boolean;
expectText?: boolean;
expectBinary?: boolean;
cache?: RequestCache; // "force-cache" | "no-store" | ...
next?: NextFetchOptions; // Next 서버 fetch 확장 옵션
};
export type HttpClientOptions = {
@@ -140,12 +147,17 @@ export const createHttpClient = (baseURL: string, opts: HttpClientOptions = {})
const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), options.timeoutMs ?? defaultTimeoutMs);
const isServer = typeof window === "undefined";
const cacheMode: RequestCache = options.cache ?? (isServer && options.next ? "force-cache" : "no-store");
const nextOpt = isServer ? options.next : undefined;
try {
const res = await fetch(url.toString(), {
method: options.method ?? (body ? "POST" : "GET"),
headers,
body,
cache: "no-store",
cache: cacheMode,
...(nextOpt ? ({ next: nextOpt } as any) : {}),
signal: controller.signal,
});
@@ -292,4 +304,4 @@ export const createHttpClient = (baseURL: string, opts: HttpClientOptions = {})
return { request, get, post, put, patch, del, postForm, putForm };
};
export const nextApi = createHttpClient(clientEnv.API_BASE);
export const nextApi = createHttpClient(clientEnv.API_BASE);