"use client";

import ReportEngine, { ReportConfig } from "@/components/admin/report/ReportEngine";

const config: ReportConfig = {
  key: "inventory_report_v2",
  title: "재고 리포트",
  description: "재고 현황 다중 조건 비교 분석",
  apiEndpoint: "/report/inventory/data",
  metrics: [
    { id: "currentQty", name: "현재고", unit: "EA", color: "#3b82f6" },
    { id: "safetyQty", name: "안전재고", unit: "EA", color: "#10b981" },
    { id: "inQty", name: "입고수량", unit: "EA", color: "#f59e0b" },
    { id: "outQty", name: "출고수량", unit: "EA", color: "#ef4444" },
    { id: "turnover", name: "회전율", unit: "회", color: "#8b5cf6", isRate: true },
    { id: "stockValue", name: "재고금액", unit: "만원", color: "#ec4899" },
    { id: "shortageQty", name: "부족수량", unit: "EA", color: "#06b6d4" },
  ],
  groupByOptions: [
    { id: "item", name: "품목별" },
    { id: "warehouse", name: "창고별" },
    { id: "category", name: "카테고리별" },
    { id: "monthly", name: "월별" },
    { id: "quarterly", name: "분기별" },
    { id: "weekly", name: "주별" },
    { id: "daily", name: "일별" },
  ],
  defaultGroupBy: "item",
  defaultMetrics: ["currentQty"],
  thresholds: [
    { id: "safety", label: "안전재고 이하 경고", defaultValue: 0, unit: "EA" },
    { id: "turnover", label: "회전율 ≤", defaultValue: 2, unit: "회" },
  ],
  filterFieldDefs: [
    { id: "item", name: "품목", type: "select", optionKey: "items" },
    { id: "warehouse", name: "창고", type: "select", optionKey: "warehouses" },
    { id: "category", name: "카테고리", type: "select", optionKey: "categories" },
    { id: "currentQty", name: "현재고", type: "number" },
    { id: "turnover", name: "회전율", type: "number" },
  ],
  drilldownColumns: [
    { id: "date", name: "날짜", format: "date" },
    { id: "item", name: "품목" },
    { id: "warehouse", name: "창고" },
    { id: "currentQty", name: "현재고", align: "right", format: "number" },
    { id: "safetyQty", name: "안전재고", align: "right", format: "number" },
    { id: "inQty", name: "입고", align: "right", format: "number" },
    { id: "outQty", name: "출고", align: "right", format: "number" },
    { id: "shortageQty", name: "부족", align: "right", format: "number" },
  ],
  rawDataColumns: [
    { id: "date", name: "날짜", format: "date" },
    { id: "item_code", name: "품목코드" },
    { id: "item", name: "품목명" },
    { id: "warehouse", name: "창고" },
    { id: "category", name: "카테고리" },
    { id: "currentQty", name: "현재고", align: "right", format: "number" },
    { id: "safetyQty", name: "안전재고", align: "right", format: "number" },
    { id: "inQty", name: "입고", align: "right", format: "number" },
    { id: "outQty", name: "출고", align: "right", format: "number" },
  ],
  emptyMessage: "재고 데이터가 없습니다",
};

export default function InventoryReportPage() {
  return <ReportEngine config={config} />;
}
