develop #1

Merged
gitadmin merged 12 commits from develop into master 2026-11-04 15:14:33 +09:00
15 changed files with 392 additions and 69 deletions

View File

@@ -1,4 +1,4 @@
NEXT_PUBLIC_ENV=development
ENV=development
API_SERVER=http://127.0.0.1:6107/api/v1
NEXT_PUBLIC_FILE_ORIGIN=http://127.0.0.1:6107
BACK_SERVER=http://127.0.0.1:6107

View File

@@ -1,4 +1,4 @@
NEXT_PUBLIC_ENV=local
ENV=local
API_SERVER=http://localhost:6107/api/v1
NEXT_PUBLIC_FILE_ORIGIN=http://localhost:6107
BACK_SERVER=http://localhost:6107

View File

@@ -1,4 +1,4 @@
NEXT_PUBLIC_ENV=production
ENV=production
API_SERVER=http://127.0.0.1:6107/api/v1
NEXT_PUBLIC_FILE_ORIGIN=http://127.0.0.1:6107
BACK_SERVER=http://127.0.0.1:6107

View File

@@ -251,6 +251,17 @@ When implementation is complete, report in Korean:
- Validate external data at runtime; a shared TypeScript type alone does not validate an API response or persisted value.
- Prefer named public exports and retain the consumer project's current module system and bundler conventions.
### React Compiler and Manual Memoization
- `createKriNextConfig` enables `reactCompiler: true` unless the project overrides it; confirm the effective configuration.
- When enabled, rely on React Compiler instead of adding `useMemo`, `useCallback`, or `React.memo` as a routine performance precaution.
- Use manual memoization only for required reference stability, an Effect or third-party contract, compiler-incompatible code, or a measured performance problem.
- Preserve existing memoization unless approved and verified for removal. Use `"use memo"` or `"use no memo"` only for a documented compiler boundary.
### Project Instruction Budget
- Keep `.agent/project.md` at or below 8 KiB (8,192 bytes) as the normal target. Do not delete material rules merely to meet the budget; move schemas, endpoint inventories, examples, and temporary issue history to linked project documentation, and keep concise read-routing instructions here.
### Change Safety
- Pin or constrain the package version according to the consumer repository's dependency policy and commit its lockfile changes.

View File

@@ -1,6 +1,20 @@
import type { NextConfig } from "next";
import { createKriNextConfig } from "@kri/common/config";
import {createEnv, createKriNextConfig, env} from "@kri/common/config";
const nextConfig = createKriNextConfig({}) satisfies NextConfig;
const nextEnv = createEnv({
API_SERVER: env.required("API_SERVER", process.env.API_SERVER),
BACK_SERVER: env.required("BACK_SERVER", process.env.BACK_SERVER),
});
const nextConfig = createKriNextConfig({
async rewrites() {
return [
{
source: "/files/:path*",
destination: `${nextEnv.BACK_SERVER}/files/:path*`,
},
];
},
}) satisfies NextConfig;
export default nextConfig;

View File

@@ -2,15 +2,24 @@
import { ChevronDown } from "lucide-react";
import { useParams, useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import { useEffect, useRef, useState } from "react";
import type { CSSProperties } from "react";
import { KriBarChart } from "@/components/chart";
import { AppPageTitle } from "@/components/app-shell/AppPageTitle";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { CHART_BAR_MAX_WIDTH, CHART_FONT_SIZE, CHART_HEIGHT } from "@/const/epolicy-dash.const";
import {
CHART_BAR_MAX_WIDTH,
CHART_FONT_DEFAULT,
CHART_FONT_SIZE,
CHART_GAP_MARKER_BG_COLOR,
CHART_GAP_MARKER_TEXT_COLOR,
CHART_HEIGHT, CHART_LEGEND_FONT_SIZE,
SUBITEM_NEGATIVE_COLOR,
} from "@/const/epolicy-dash.const";
import { cn } from "@/lib/utils";
import { toChartData } from "@/lib/chart-utils";
import { getGapPoints, getHighlightedIndexes, isNegativeCategory, toChartData } from "@/lib/chart-utils";
import { formatDecimal1, formatThousands, round1 } from "@/lib/format";
import { isSessionInvalid, resolveApiErrorMessage } from "@/lib/api-error-message";
import { usePartDetailQuery } from "@/query/waves";
@@ -26,6 +35,17 @@ function findAudienceColor(item: Item): string | undefined {
return undefined;
}
// 서브 탭 hover 배경처럼 색상에 알파를 입힌 은은한 톤이 필요한 곳에서 사용한다.
function hexToRgba(hex: string, alpha: number): string {
const normalized = hex.replace("#", "");
const isShorthand = normalized.length === 3;
const r = parseInt(isShorthand ? normalized[0] + normalized[0] : normalized.slice(0, 2), 16);
const g = parseInt(isShorthand ? normalized[1] + normalized[1] : normalized.slice(2, 4), 16);
const b = parseInt(isShorthand ? normalized[2] + normalized[2] : normalized.slice(4, 6), 16);
if ([r, g, b].some((channel) => Number.isNaN(channel))) return hex;
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
}
function seriesLegendName(label: string, baseCount: number | null) {
return baseCount === null ? label : `${label} (N=${formatThousands(baseCount)})`;
}
@@ -58,35 +78,146 @@ function buildHiddenCategoryNote(group: ResultGroup): string | null {
return `※ ${parts.join(isSingleSeries ? ", " : " | ")}`;
}
function ResultGroupChart({ group }: { group: ResultGroup }) {
// x축 카테고리 라벨 폭을 컨테이너 실측 폭 기준으로 계산한다(카테고리당 슬롯 폭에 여유를 둔 값).
// 고정값을 쓰면 화면이 넓을 때는 불필요하게 줄바꿈되고, 좁을 때는 라벨이 겹치는 문제가 생긴다.
const MIN_AXIS_LABEL_WIDTH = 48;
// echarts axisLabel의 overflow:'break'는 한글을 알파벳 "단어"로 인식하지 못해 음절 단위로 강제 개행한다
// (zrender wrapText의 isWordBreakChar가 비알파벳 문자를 전부 break 지점으로 취급함).
// 그래서 공백 기준으로 단어를 유지한 채 줄바꿈 문자열을 직접 만들고, 단어 하나가 라인 폭을 넘을 때만 강제로 자른다.
function wrapLabelByWord(value: string, maxWidth: number, charWidth: number) {
const maxChars = Math.max(1, Math.floor(maxWidth / charWidth));
const words = value.split(" ");
const lines: string[] = [];
let currentLine = "";
for (const word of words) {
const candidate = currentLine ? `${currentLine} ${word}` : word;
if (candidate.length > maxChars && currentLine) {
lines.push(currentLine);
currentLine = word;
} else {
currentLine = candidate;
}
while (currentLine.length > maxChars) {
lines.push(currentLine.slice(0, maxChars));
currentLine = currentLine.slice(maxChars);
}
}
if (currentLine) lines.push(currentLine);
return lines.join("\n");
}
function ResultGroupChart({ group, item }: { group: ResultGroup; item: Item }) {
const chartData = toChartData(group.categories, group.series);
const visibleCategories = group.categories.filter((category) => category.chartVisible);
const negativeMode = group.subItem === null ? item.negativeMode : group.subItem.negativeMode;
const negativeOrder = group.subItem === null ? item.negativeOrder : group.subItem.negativeOrder;
const hasChartData = chartData.categories.length > 0 && chartData.series.length > 0;
const chartWrapperRef = useRef<HTMLDivElement>(null);
const [axisLabelWidth, setAxisLabelWidth] = useState<number>();
useEffect(() => {
const el = chartWrapperRef.current;
if (!el || chartData.categories.length === 0) return;
const updateAxisLabelWidth = () => {
const width = (el.clientWidth / chartData.categories.length) * 0.85;
setAxisLabelWidth(Math.max(MIN_AXIS_LABEL_WIDTH, width));
};
updateAxisLabelWidth();
const observer = new ResizeObserver(updateAxisLabelWidth);
observer.observe(el);
return () => observer.disconnect();
}, [chartData.categories.length]);
if (!hasChartData) return null;
return (
<KriBarChart
categories={chartData.categories}
series={chartData.series.map((item) => ({
name: seriesLegendName(item.label, item.baseCount),
data: item.values.map(round1),
color: item.color,
option: {
label: {
show: true,
position: "top",
fontSize: CHART_FONT_SIZE,
formatter: (params: { value: number }) => formatDecimal1(params.value),
<div ref={chartWrapperRef}>
<KriBarChart
categories={chartData.categories}
series={chartData.series.map((series) => {
const highlightedIndexes = series.chartHighlightMode
? getHighlightedIndexes(group.categories, series)
: [];
const gapPoints = getGapPoints(group.categories, series);
return {
name: seriesLegendName(series.label, series.baseCount),
data: series.values.map((value, index) => {
const category = visibleCategories[index];
const isNegative = category ? isNegativeCategory(negativeMode, negativeOrder, category) : false;
const isHighlighted = highlightedIndexes.includes(index);
const color = isNegative
? isHighlighted
? series.negativeHighlightColor
: series.negativeColor
: isHighlighted
? series.highlightColor
: series.color;
return { value: round1(value), itemStyle: { color } };
}),
color: negativeMode === "NEGATIVE" ? series.negativeColor : series.color,
option: {
label: {
show: true,
position: "top",
...CHART_FONT_DEFAULT,
formatter: (params: { value: number }) => formatDecimal1(params.value),
},
...(gapPoints.length
? {
markPoint: {
// 점 마커 없이, 라운딩된 사각형 배경을 가진 라벨 자체를 도형처럼 사용한다.
symbol: "circle",
symbolSize: 0,
label: {
show: true,
position: "top",
// 막대 자체의 값 라벨(position:"top")과 겹치지 않도록 그 위로 띄운다.
distance: 30,
color: CHART_GAP_MARKER_TEXT_COLOR,
backgroundColor: CHART_GAP_MARKER_BG_COLOR,
borderRadius: 20,
padding: [10, 10, 7, 10],
fontWeight: "bold",
...CHART_FONT_DEFAULT,
formatter: ({ value }: { value: number }) =>
`${value >= 0 ? "▲" : "▼"} ${formatDecimal1(Math.abs(value))}%p`,
},
// ALL: 각 현재 막대 위치. LAST_VISIBLE: 마지막 표시 막대 위치에 표시한다.
data: gapPoints.map(({ index, value, gap }) => ({
coord: [index, value],
value: gap,
})),
},
}
: {}),
},
};
})}
legend={{ right: 0, top: 0, textStyle: { fontSize: CHART_LEGEND_FONT_SIZE } }}
grid={{ top: 85, right: 25, bottom: 5, left: 0, containLabel: true }}
xAxis={{
axisLabel: {
...CHART_FONT_DEFAULT,
interval: 0,
...(axisLabelWidth
? { formatter: (value: string) => wrapLabelByWord(value, axisLabelWidth, CHART_FONT_SIZE) }
: {}),
},
},
}))}
legend={{ left: 0, top: 0, textStyle: { fontSize: CHART_FONT_SIZE } }}
grid={{ top: 55, right: 25, bottom: 5, left: 0, containLabel: true }}
xAxis={{ axisLabel: { fontSize: CHART_FONT_SIZE, interval: 0 } }}
yAxis={{ min: 0, max: 100, interval: 25, axisLabel: { fontSize: CHART_FONT_SIZE } }}
barMaxWidth={CHART_BAR_MAX_WIDTH}
height={CHART_HEIGHT}
/>
}}
yAxis={{ min: 0, max: 100, interval: 25, axisLabel: { show: false } }}
barMaxWidth={CHART_BAR_MAX_WIDTH}
height={CHART_HEIGHT}
/>
</div>
);
}
@@ -135,11 +266,13 @@ function ItemCard({ item }: { item: Item }) {
const hasSubItems = item.resultGroups.some((group) => group.subItem !== null);
const activeGroup = item.resultGroups[activeGroupIndex] ?? item.resultGroups[0];
const hiddenCategoryNote = activeGroup ? buildHiddenCategoryNote(activeGroup) : null;
// subItem 코멘트가 있으면 그것을 우선 표시하고, 없으면 문항 공통 코멘트로 대체한다.
const activeComment = activeGroup?.subItem?.partItemSubComment || item.comment || null;
return (
<div id={`item-${item.partItemCd}`} className="rounded-lg border bg-card p-6 text-card-foreground shadow-sm">
<div className="flex flex-wrap items-center justify-between gap-2">
<p className="font-medium">{item.title}</p>
<p className="font-medium text-xl">{item.title}</p>
<div className="flex items-center gap-2">
<Badge
className={cn(
@@ -156,29 +289,52 @@ function ItemCard({ item }: { item: Item }) {
</Button>
</div>
</div>
{activeComment &&
<p className="mt-2 text-xs text-muted-foreground">{activeComment}</p>
}
{hasSubItems || activeComment ? (
<div className="mt-4 flex flex-wrap items-center gap-3">
{hasSubItems ? (
<div className="inline-flex shrink-0 rounded-md border p-1">
{item.resultGroups.map((group, index) => {
const isActive = index === activeGroupIndex;
const isNegativeSubItem = group.subItem?.negativeMode === "NEGATIVE";
{hasSubItems ? (
<div className="mt-4 flex justify-end">
<div className="inline-flex rounded-md border p-1">
{item.resultGroups.map((group, index) => (
<Button
key={group.subItem?.partItemSubCd ?? index}
type="button"
size="sm"
variant={index === activeGroupIndex ? "default" : "ghost"}
className="rounded-sm"
onClick={() => setActiveGroupIndex(index)}
>
{group.subItem?.title}
</Button>
))}
</div>
return (
<Button
key={group.subItem?.partItemSubCd ?? index}
type="button"
size="sm"
variant={isActive ? "default" : "ghost"}
className={cn(
"rounded-sm",
isNegativeSubItem &&
!isActive &&
"hover:bg-[var(--negative-hover-bg)] hover:text-[var(--negative-hover-text)]",
)}
style={
isNegativeSubItem
? ({
...(isActive ? { backgroundColor: SUBITEM_NEGATIVE_COLOR, color: "#fff" } : {}),
["--negative-hover-bg" as string]: hexToRgba(SUBITEM_NEGATIVE_COLOR, 0.12),
["--negative-hover-text" as string]: SUBITEM_NEGATIVE_COLOR,
} as CSSProperties)
: undefined
}
onClick={() => setActiveGroupIndex(index)}
>
{group.subItem?.title}
</Button>
);
})}
</div>
) : null}
</div>
) : null}
{activeGroup ? (
<div className="mt-4">
<ResultGroupChart group={activeGroup} />
<ResultGroupChart group={activeGroup} item={item} />
{hiddenCategoryNote ? <p className="mt-1 text-xs text-muted-foreground">{hiddenCategoryNote}</p> : null}
{showTable ? (
<div className="mt-6">
@@ -187,8 +343,6 @@ function ItemCard({ item }: { item: Item }) {
) : null}
</div>
) : null}
{item.comment ? <p className="mt-4 text-xs text-muted-foreground">{item.comment}</p> : null}
</div>
);
}
@@ -221,7 +375,7 @@ export default function PartDetailPage() {
}
return (
<div className="space-y-6">
<div className="space-y-6 px-50">
<AppPageTitle title={data.title} />
{data.items.map((item) => (

View File

@@ -48,14 +48,14 @@ export default function WaveOverviewPage() {
) : null}
{data.surveys.length ? (
<div className="grid gap-4 md:grid-cols-2">
<div className={`grid gap-4 ${data.surveys.length >= 3 ? "md:grid-cols-3" : "md:grid-cols-2"}`}>
{data.surveys.map((survey) => (
<div
key={survey.surveyCd}
className="rounded-lg border-2 bg-card p-6 text-card-foreground shadow-sm"
style={{ borderColor: survey.color }}
>
<p className="font-semibold" style={{ color: survey.color }}>{survey.title}</p>
<p className="font-semibold" style={{ color: survey.highlightColor }}>{survey.title}</p>
<dl className="mt-3 space-y-2">
{survey.items.map((item) => (
<div key={item.title} className="flex gap-3 text-sm">

View File

@@ -30,7 +30,7 @@ export function AppHeader({ menuOpen, showMenuButton, activeMenuId, topMenus, us
className="h-6 w-auto object-contain brightness-0 invert"
priority
/>
<span className="text-lg font-bold tracking-tight text-white">2026년 에너지 국민인식조사</span>
<span className="text-2xl font-bold tracking-tight text-white">2026년 에너지 국민인식조사</span>
</div>
}
menus={topMenus}

View File

@@ -36,7 +36,7 @@ export function KriSidebar({
<aside
className={cn(
'fixed top-20 left-0 z-30 flex h-[calc(100vh-5rem)] flex-col overflow-hidden border-r bg-background transition-all duration-300 lg:static lg:top-0 lg:h-full lg:translate-x-0',
isOpen ? 'w-80 translate-x-0' : 'w-80 -translate-x-full lg:w-0 lg:border-r-0',
isOpen ? 'w-130 translate-x-0' : 'w-130 -translate-x-full lg:w-0 lg:border-r-0',
className,
)}
>
@@ -56,7 +56,7 @@ export function KriSidebar({
type="button"
variant={active ? 'secondary' : 'ghost'}
className={cn(
'h-auto w-full justify-start rounded-md py-2 text-left whitespace-normal break-keep break-words',
'h-auto w-full justify-start rounded-md py-2 text-left whitespace-normal break-keep wrap-break-words',
active &&
'border-l-2 border-primary bg-primary/10 text-primary font-medium hover:bg-primary/15 hover:text-primary',
)}
@@ -85,7 +85,7 @@ export function KriSidebar({
onClick={() => item.path && onNavigate?.(item.path, item)}
>
{Icon ? <Icon className="size-4 shrink-0" /> : null}
<span className="min-w-0 flex-1">{item.label}</span>
<span className="min-w-0 flex-1 whitespace-normal break-keep break-words">{item.label}</span>
<span className="shrink-0 text-xs whitespace-nowrap text-muted-foreground">{questionCount}문항</span>
<ChevronDown className={cn('size-4 shrink-0 transition-transform', opened && 'rotate-180')} />
</Button>

View File

@@ -6,6 +6,25 @@ export const SCROLL_SPY_THRESHOLD_UP = 410;
export const SCROLL_SPY_BOTTOM_TOLERANCE = 8;
// Part 상세 차트 렌더링 설정. dashboard/[waveCd]/[partCd]/page.tsx에서 사용.
export const CHART_FONT_SIZE = 14;
export const CHART_FONT_SIZE = 16;
export const CHART_LEGEND_FONT_SIZE = 14;
// echarts는 canvas 렌더러라 font-family에 CSS var()를 못 쓴다(셔다워 값을 요소 cascade 없이 자체 파싱해서
// var()가 그대로 무시됨). 본문(html)에 적용되는 --default-font-family(Tailwind 기본 --font-sans)를
// 리터럴로 그대로 옮겨왔다 — globals.css에서 --font-sans를 바꾸면 이 값도 함께 갱신해야 한다.
export const CHART_FONT_FAMILY =
'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
export const CHART_FONT_DEFAULT = {
fontSize: CHART_FONT_SIZE,
fontFamily: CHART_FONT_FAMILY,
};
export const CHART_BAR_MAX_WIDTH = 100;
export const CHART_HEIGHT = 320;
// 서브 문항 탭(예: "감소 이유")의 부정적 의미 강조색. series.color는 surveyCd 구성에 따라 값이 들쭉날쭉해서
// (예: 전문가만 있는 응답군은 색이 달라짐) 탭 색상 기준으로 쓸 수 없어, primary(브랜드 블루)와 동일한 채도로
// 고정한 별도 색상을 쓴다.
export const SUBITEM_NEGATIVE_COLOR = "#F0475A";
// Gap markPoint(전분기 대비 증감) 배지 색상. 특정 시리즈 색과 섞이지 않도록 중립적인 회색조를 쓴다.
export const CHART_GAP_MARKER_BG_COLOR = "#E5E7EB";
export const CHART_GAP_MARKER_TEXT_COLOR = "#000000";

View File

@@ -1,9 +1,8 @@
import type { Category } from "@/types/wave";
import { round1 } from "@/lib/format";
import type { Category, Series } from "@/types/wave";
export function toChartData<T extends { values: number[] }>(categories: Category[], series: T[]) {
const visibleIndexes = categories
.map((category, index) => (category.chartVisible ? index : -1))
.filter((index) => index >= 0);
const visibleIndexes = getVisibleCategoryIndexes(categories);
return {
categories: visibleIndexes.map((index) => categories[index].label),
@@ -13,3 +12,109 @@ export function toChartData<T extends { values: number[] }>(categories: Category
})),
};
}
export function getVisibleCategoryIndexes(categories: Category[]): number[] {
return categories
.map((category, index) => (category.chartVisible ? index : -1))
.filter((index) => index >= 0);
}
export function isNegativeCategory(
mode: "DEFAULT" | "NEGATIVE" | "SPECIFIED",
negativeOrder: string | null,
category: Category,
): boolean {
if (mode === "NEGATIVE") return true;
if (mode !== "SPECIFIED") return false;
return parseOrderSet(negativeOrder).has(category.order);
}
function parseOrderSet(value: string | null): Set<number> {
return new Set(
(value ?? "")
.split(",")
.map((order) => Number(order.trim()))
.filter((order) => Number.isFinite(order)),
);
}
// chartVisible=true인 카테고리만 대상으로, 강조할 데이터 포인트의 인덱스를 계산한다.
// 반환되는 인덱스는 toChartData가 만든 필터링된(visible) 카테고리/값 배열 기준이다.
export function getHighlightedIndexes(
categories: Category[],
series: Pick<Series, "chartHighlightMode" | "chartHighlightValue" | "values">,
): number[] {
const visibleCategories = categories.filter((category) => category.chartVisible);
switch (series.chartHighlightMode) {
case "MAX_VALUE": {
const visibleValues = getVisibleCategoryIndexes(categories).map((index) => series.values[index]);
if (!visibleValues.length) return [];
const maxValue = Math.max(...visibleValues);
return visibleValues.flatMap((value, index) => (value === maxValue ? [index] : []));
}
case "LAST_VISIBLE": {
if (!visibleCategories.length) return [];
const maxOrder = Math.max(...visibleCategories.map((category) => category.order));
const index = visibleCategories.findIndex((category) => category.order === maxOrder);
return index >= 0 ? [index] : [];
}
case "SPECIFIED": {
const orders = parseOrderSet(series.chartHighlightValue);
return visibleCategories
.map((category, index) => (orders.has(category.order) ? index : -1))
.filter((index) => index >= 0);
}
default:
return [];
}
}
export type GapPoint = {
// index/previousIndex는 toChartData가 만든 필터링된(visible) 카테고리/값 배열 기준 인덱스다.
// ALL은 index 위치(현재 막대 위)에, LAST_VISIBLE은 index와 previousIndex의 중간(두 막대 사이)에 표시한다.
index: number;
previousIndex: number;
value: number;
previousValue: number;
gap: number;
};
// 같은 Series 안에서, chartVisible=true인 항목을 category.order 오름차순으로 정렬한 뒤
// 인접한 값끼리의 차이(현재 - 직전)를 계산한다. 값은 차트에 표시되는 값(round1)과 맞춘다.
// NONE 또는 알 수 없는 값은 방어적으로 NONE과 동일하게 처리한다(Gap 없음).
export function getGapPoints(
categories: Category[],
series: Pick<Series, "chartGapMode" | "values">,
): GapPoint[] {
if (series.chartGapMode !== "ALL" && series.chartGapMode !== "LAST_VISIBLE") return [];
const visiblePoints = categories
.map((category, originalIndex) => ({ category, originalIndex, value: round1(series.values[originalIndex]) }))
.filter((point) => point.category.chartVisible)
.sort((a, b) => a.category.order - b.category.order);
if (visiblePoints.length < 2) return [];
const displayIndexByOriginalIndex = new Map<number, number>();
let displayIndex = 0;
categories.forEach((category, originalIndex) => {
if (category.chartVisible) {
displayIndexByOriginalIndex.set(originalIndex, displayIndex);
displayIndex += 1;
}
});
const gapPoints = visiblePoints.slice(1).map((current, index) => {
const previous = visiblePoints[index];
return {
index: displayIndexByOriginalIndex.get(current.originalIndex) ?? index + 1,
previousIndex: displayIndexByOriginalIndex.get(previous.originalIndex) ?? index,
value: current.value,
previousValue: previous.value,
gap: round1(current.value - previous.value),
};
});
return series.chartGapMode === "LAST_VISIBLE" ? gapPoints.slice(-1) : gapPoints;
}

View File

@@ -5,5 +5,4 @@ export const clientEnv = createEnv({
API_BASE: env.required("NEXT_PUBLIC_API_BASE", process.env.NEXT_PUBLIC_API_BASE),
STORE_KEY: env.required("NEXT_PUBLIC_STORE_KEY", process.env.NEXT_PUBLIC_STORE_KEY),
STORE_IV: env.required("NEXT_PUBLIC_STORE_IV", process.env.NEXT_PUBLIC_STORE_IV),
FILE_ORIGIN: env.required("NEXT_PUBLIC_FILE_ORIGIN", process.env.NEXT_PUBLIC_FILE_ORIGIN),
});

View File

@@ -4,4 +4,5 @@ import { createEnv, env } from "@kri/common/config";
export const serverEnv = createEnv({
ENV: env.required("ENV", process.env.ENV),
API_SERVER: env.required("API_SERVER", process.env.API_SERVER),
BACK_SERVER: env.required("BACK_SERVER", process.env.BACK_SERVER),
});

View File

@@ -1,7 +1,6 @@
import { clientEnv } from "@/lib/env.client";
// 백엔드의 상대 파일 경로는 next.config.ts의 rewrite를 통해 프론트 origin에서 내려받는다.
export function toFileDownloadUrl(downloadUrl: string): string {
return `${clientEnv.FILE_ORIGIN}${downloadUrl}`;
return downloadUrl;
}
// 백엔드가 Content-Disposition: attachment를 내려주지 않아 PDF 등은 새 탭에 그냥 열려버린다.

View File

@@ -12,16 +12,35 @@ export interface Category {
}
export interface SubItem {
negativeMode: NegativeMode;
negativeOrder: string | null;
partItemSubCd: number;
partItemSubComment: string | null;
title: string;
}
export type ChartType = "BAR";
export type NegativeMode = "DEFAULT" | "NEGATIVE" | "SPECIFIED";
export type ChartHighlightMode = "MAX_VALUE" | "LAST_VISIBLE" | "SPECIFIED";
/** Backend가 설정 없음/DB 값 오류 시에도 항상 "NONE"으로 채워서 내려준다. */
export type ChartGapMode = "NONE" | "ALL" | "LAST_VISIBLE";
export interface Series {
baseCount: number | null;
/** DB에 저장된 원문 그대로. baseCount와 조합해 생성되는 값이 아니다 (예: "전국 만 18세 이상 성인 남녀"). */
baseText: string | null;
chartGapMode: ChartGapMode;
chartHighlightMode: ChartHighlightMode | null;
/** chartHighlightMode가 "SPECIFIED"일 때 강조할 category.order 목록 (쉼표 구분 문자열, 예: "1,3,5"). */
chartHighlightValue: string | null;
chartType: ChartType;
color: string;
highlightColor: string;
label: string;
negativeColor: string;
negativeHighlightColor: string;
surveyCd: number;
values: number[];
}
@@ -32,12 +51,11 @@ export interface ResultGroup {
subItem: SubItem | null;
}
export type ChartType = "BAR";
export interface Item {
audience: Audience;
chartType: ChartType;
comment: string;
negativeMode: NegativeMode;
negativeOrder: string | null;
order: number;
partItemCd: number;
resultGroups: ResultGroup[];
@@ -76,7 +94,10 @@ export interface SurveyItem {
export interface Survey {
alias: string;
color: string;
highlightColor: string;
items: SurveyItem[];
negativeColor: string;
negativeHighlightColor: string;
surveyCd: number;
title: string;
}