/**
 * 품목별 라우팅 관리 컴포넌트 타입 정의
 *
 * 3단계 계층: item_info → item_routing_version → item_routing_detail
 */

// 데이터 소스 설정
export interface ItemRoutingDataSource {
  itemTable: string;
  itemNameColumn: string;
  itemCodeColumn: string;
  routingVersionTable: string;
  routingVersionFkColumn: string; // item_routing_version에서 item_code를 가리키는 FK
  routingVersionNameColumn: string;
  routingDetailTable: string;
  routingDetailFkColumn: string; // item_routing_detail에서 routing_version_id를 가리키는 FK
  processTable: string;
  processNameColumn: string;
  processCodeColumn: string;
}

// 모달 연동 설정
export interface ItemRoutingModals {
  versionAddScreenId?: number;
  processAddScreenId?: number;
  processEditScreenId?: number;
}

// 공정 테이블 컬럼 정의
export interface ProcessColumnDef {
  name: string;
  label: string;
  width?: number;
  align?: "left" | "center" | "right";
}

// 전체 Config
export interface ItemRoutingConfig {
  dataSource: ItemRoutingDataSource;
  modals: ItemRoutingModals;
  processColumns: ProcessColumnDef[];
  splitRatio?: number;
  leftPanelTitle?: string;
  rightPanelTitle?: string;
  readonly?: boolean;
  autoSelectFirstVersion?: boolean;
  versionAddButtonText?: string;
  processAddButtonText?: string;
}

// 컴포넌트 Props
export interface ItemRoutingComponentProps {
  config: Partial<ItemRoutingConfig>;
  formData?: Record<string, any>;
  isPreview?: boolean;
  tableName?: string;
}

// 데이터 모델
export interface ItemData {
  id: string;
  [key: string]: any;
}

export interface RoutingVersionData {
  id: string;
  version_name: string;
  is_default?: boolean;
  [key: string]: any;
}

export interface RoutingDetailData {
  id: string;
  routing_version_id: string;
  seq_no: string;
  process_code: string;
  [key: string]: any;
}
