"use client";

import React from "react";
import { NumberingRuleDesigner } from "@/components/numbering-rule/NumberingRuleDesigner";
import { NumberingRuleComponentConfig } from "./types";

interface NumberingRuleWrapperProps {
  config: NumberingRuleComponentConfig;
  onChange?: (config: NumberingRuleComponentConfig) => void;
  isPreview?: boolean;
  tableName?: string; // 현재 화면의 테이블명
  menuObjid?: number; // 🆕 메뉴 OBJID
}

export const NumberingRuleWrapper: React.FC<NumberingRuleWrapperProps> = ({
  config,
  onChange,
  isPreview = false,
  tableName,
  menuObjid,
}) => {
  console.log("📋 NumberingRuleWrapper: 테이블명 + menuObjid 전달", { 
    tableName, 
    menuObjid,
    hasMenuObjid: !!menuObjid,
    config 
  });
  
  return (
    <div className="h-full w-full">
      <NumberingRuleDesigner
        maxRules={config.maxRules || 6}
        isPreview={isPreview}
        className="h-full"
        currentTableName={tableName} // 테이블명 전달
        menuObjid={menuObjid} // 🆕 메뉴 OBJID 전달
      />
    </div>
  );
};

export const NumberingRuleComponent = NumberingRuleWrapper;
