/**
 * 입고 샘플 데이터 생성기
 */

import {
  randomPick,
  randomInt,
  randomRemark,
  today,
} from './index';

// ===== 상수 정의 =====

const SUPPLIERS = [
  '(주)대한철강', '삼성전자부품', '한국플라스틱', '글로벌전자',
  '동양화학', '한국볼트', '지오TNS (KG스틸)', 'SK이노베이션',
  '포스코', 'LG화학', '현대중공업', '한화솔루션',
];

const ITEMS = [
  { code: 'STEEL-001', name: 'SUS304 스테인리스 판재', spec: '1000x2000x3T', unit: 'EA' },
  { code: 'STEEL-002', name: '알루미늄 프로파일', spec: '40x40x2000L', unit: 'EA' },
  { code: 'ELEC-002', name: 'MCU 컨트롤러 IC', spec: 'STM32F103C8T6', unit: 'EA' },
  { code: 'ELEC-005', name: 'DC 모터 24V', spec: '24V 100RPM', unit: 'EA' },
  { code: 'ELEC-007', name: '커패시터 100uF', spec: '100uF 50V', unit: 'EA' },
  { code: 'PLAS-003', name: 'ABS 사출 케이스', spec: '150x100x50', unit: 'SET' },
  { code: 'CHEM-001', name: '에폭시 접착제', spec: '500ml', unit: 'EA' },
  { code: 'BOLT-001', name: 'SUS 볼트 M8x30', spec: 'M8x30 SUS304', unit: 'EA' },
  { code: '80008', name: '80008 egi1.55', spec: '1.55 * 1218 × 480', unit: 'EA' },
];

// ===== 타입 정의 =====

export interface ReceivingFormData {
  itemCode: string;
  itemName: string;
  specification: string;
  unit: string;
  supplier: string;
  receivingQty: number;
  receivingDate: string;
  status: string;
  remark: string;
}

// ===== 메인 생성 함수 =====

export function generateReceivingData(): ReceivingFormData {
  const item = randomPick(ITEMS);

  return {
    itemCode: item.code,
    itemName: item.name,
    specification: item.spec,
    unit: item.unit,
    supplier: randomPick(SUPPLIERS),
    receivingQty: randomInt(10, 500),
    receivingDate: today(),
    status: 'receiving_pending',
    remark: randomRemark(),
  };
}