/**
 * Reference 필드 소스 프리셋
 *
 * ReferenceField가 properties.source 값을 키로 조회하여
 * API URL, 표시 필드, 검색 컬럼 등을 자동 결정
 *
 * 확장: 새 소스 추가 = 이 파일에 객체 1개 추가
 */

import type { ReferenceSourcePreset } from '../types';

export const REFERENCE_SOURCES: Record<string, ReferenceSourcePreset> = {
  // ===== 공통 =====
  vendors: {
    apiUrl: '/api/proxy/vendors',
    displayField: 'name',
    valueField: 'id',
    searchFields: ['name', 'code'],
    columns: [
      { key: 'code', label: '거래처 코드', width: '120px' },
      { key: 'name', label: '거래처명' },
      { key: 'contact_person', label: '담당자', width: '100px' },
    ],
  },
  items: {
    apiUrl: '/api/proxy/items',
    displayField: 'name',
    valueField: 'id',
    searchFields: ['name', 'code'],
    columns: [
      { key: 'code', label: '품목코드', width: '120px' },
      { key: 'name', label: '품목명' },
      { key: 'spec', label: '규격', width: '120px' },
    ],
  },
  customers: {
    apiUrl: '/api/proxy/customers',
    displayField: 'name',
    valueField: 'id',
    searchFields: ['name', 'code'],
    columns: [
      { key: 'code', label: '고객 코드', width: '120px' },
      { key: 'name', label: '고객명' },
    ],
  },
  employees: {
    apiUrl: '/api/proxy/employees',
    displayField: 'name',
    valueField: 'id',
    searchFields: ['name'],
    columns: [
      { key: 'name', label: '직원명' },
      { key: 'department', label: '부서', width: '120px' },
    ],
  },
  warehouses: {
    apiUrl: '/api/proxy/warehouses',
    displayField: 'name',
    valueField: 'id',
    searchFields: ['name', 'code'],
    columns: [
      { key: 'code', label: '창고코드', width: '120px' },
      { key: 'name', label: '창고명' },
    ],
  },

  // ===== 제조 =====
  processes: {
    apiUrl: '/api/proxy/processes',
    displayField: 'name',
    valueField: 'id',
    searchFields: ['name', 'code'],
    columns: [
      { key: 'code', label: '공정코드', width: '120px' },
      { key: 'name', label: '공정명' },
    ],
  },
  equipment: {
    apiUrl: '/api/proxy/equipment',
    displayField: 'name',
    valueField: 'id',
    searchFields: ['name', 'code'],
    columns: [
      { key: 'code', label: '설비코드', width: '120px' },
      { key: 'name', label: '설비명' },
    ],
  },

  // ===== 공사 =====
  sites: {
    apiUrl: '/api/proxy/construction-sites',
    displayField: 'name',
    valueField: 'id',
    searchFields: ['name', 'address'],
    columns: [
      { key: 'name', label: '현장명' },
      { key: 'address', label: '주소' },
    ],
  },

  // ===== 물류 =====
  vehicles: {
    apiUrl: '/api/proxy/vehicles',
    displayField: 'plate_number',
    valueField: 'id',
    searchFields: ['plate_number', 'driver_name'],
    columns: [
      { key: 'plate_number', label: '차량번호', width: '120px' },
      { key: 'driver_name', label: '기사명' },
    ],
  },
};
