import type { ItemMasterField } from '@/contexts/ItemMasterContext'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { Plus, Edit, Trash2 } from 'lucide-react'; // 입력방식 옵션 (ItemMasterDataManagement에서 사용하는 상수) const INPUT_TYPE_OPTIONS = [ { value: 'textbox', label: '텍스트' }, { value: 'dropdown', label: '드롭다운' }, { value: 'checkbox', label: '체크박스' }, { value: 'number', label: '숫자' }, { value: 'date', label: '날짜' }, { value: 'textarea', label: '텍스트영역' } ]; // 변경 레코드 타입 (임시 - 나중에 공통 타입으로 분리) interface ChangeRecord { masterFields: Array<{ type: 'add' | 'update' | 'delete'; id: string; data?: any; }>; [key: string]: any; } interface MasterFieldTabProps { itemMasterFields: ItemMasterField[]; setIsMasterFieldDialogOpen: (open: boolean) => void; handleEditMasterField: (field: ItemMasterField) => void; handleDeleteMasterField: (id: number) => void; hasUnsavedChanges: boolean; pendingChanges: ChangeRecord; } export function MasterFieldTab({ itemMasterFields, setIsMasterFieldDialogOpen, handleEditMasterField, handleDeleteMasterField, hasUnsavedChanges, pendingChanges }: MasterFieldTabProps) { return (
마스터 항목 관리 재사용 가능한 항목 템플릿을 관리합니다
{/* 변경사항 배지 - 나중에 사용 예정으로 임시 숨김 */} {false && hasUnsavedChanges && pendingChanges.masterFields.length > 0 && ( {pendingChanges.masterFields.length}개 변경 )}
{itemMasterFields.length === 0 ? (

등록된 마스터 항목이 없습니다

항목 추가 버튼을 눌러 재사용 가능한 항목을 등록하세요.

) : (
{itemMasterFields.map((field) => (
{field.field_name} {INPUT_TYPE_OPTIONS.find(t => t.value === field.properties?.inputType)?.label} {field.properties?.required && ( 필수 )} {field.category} {(field.properties as any)?.attributeType && (field.properties as any).attributeType !== 'custom' && ( {(field.properties as any).attributeType === 'unit' ? '단위 연동' : (field.properties as any).attributeType === 'material' ? '재질 연동' : '표면처리 연동'} )}
ID: {field.id} {field.description && ( • {field.description} )}
{field.properties?.options && field.properties.options.length > 0 && (
옵션: {field.properties.options.join(', ')} {(field.properties as any)?.attributeType && (field.properties as any).attributeType !== 'custom' && ( (속성 탭 자동 동기화) )}
)}
))}
)}
); }