"use client"; import React from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Plus, Trash2 } from "lucide-react"; import { TableInfo, ColumnInfo } from "@/lib/api/dataflow"; import { DataSaveSettings } from "@/types/connectionTypes"; interface ActionFieldMappingsProps { action: DataSaveSettings["actions"][0]; actionIndex: number; settings: DataSaveSettings; onSettingsChange: (settings: DataSaveSettings) => void; availableTables: TableInfo[]; tableColumnsCache: { [tableName: string]: ColumnInfo[] }; } export const ActionFieldMappings: React.FC = ({ action, actionIndex, settings, onSettingsChange, availableTables, tableColumnsCache, }) => { const addFieldMapping = () => { const newActions = [...settings.actions]; newActions[actionIndex].fieldMappings.push({ sourceTable: "", sourceField: "", targetTable: "", targetField: "", defaultValue: "", transformFunction: "", }); onSettingsChange({ ...settings, actions: newActions }); }; const updateFieldMapping = (mappingIndex: number, field: string, value: string) => { const newActions = [...settings.actions]; (newActions[actionIndex].fieldMappings[mappingIndex] as any)[field] = value; onSettingsChange({ ...settings, actions: newActions }); }; const removeFieldMapping = (mappingIndex: number) => { const newActions = [...settings.actions]; newActions[actionIndex].fieldMappings = newActions[actionIndex].fieldMappings.filter((_, i) => i !== mappingIndex); onSettingsChange({ ...settings, actions: newActions }); }; return (
{action.fieldMappings.map((mapping, mappingIndex) => (
{/* 컴팩트한 매핑 표시 */}
{/* 소스 */}
{mapping.sourceTable && ( )} .
{/* 타겟 */}
.
{/* 기본값 (인라인) */} { updateFieldMapping(mappingIndex, "defaultValue", e.target.value); if (e.target.value.trim()) { updateFieldMapping(mappingIndex, "sourceTable", ""); updateFieldMapping(mappingIndex, "sourceField", ""); } }} disabled={!!mapping.sourceTable} className="h-6 w-20 text-xs" placeholder="기본값" /> {/* 삭제 버튼 */}
))}
); };