"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, Save, Trash2 } from "lucide-react"; import { TableInfo, ColumnInfo } from "@/lib/api/dataflow"; import { DataSaveSettings as DataSaveSettingsType } from "@/types/connectionTypes"; import { ActionConditionsSection } from "./ActionConditionsSection"; import { ActionFieldMappings } from "./ActionFieldMappings"; import { ActionSplitConfig } from "./ActionSplitConfig"; interface DataSaveSettingsProps { settings: DataSaveSettingsType; onSettingsChange: (settings: DataSaveSettingsType) => void; availableTables: TableInfo[]; fromTableColumns: ColumnInfo[]; toTableColumns: ColumnInfo[]; fromTableName?: string; toTableName?: string; tableColumnsCache: { [tableName: string]: ColumnInfo[] }; } export const DataSaveSettings: React.FC = ({ settings, onSettingsChange, availableTables, fromTableColumns, toTableColumns, fromTableName, toTableName, tableColumnsCache, }) => { const addAction = () => { const newAction = { id: `action_${settings.actions.length + 1}`, name: `액션 ${settings.actions.length + 1}`, actionType: "insert" as const, // 첫 번째 액션이 아니면 기본적으로 AND 연산자 추가 ...(settings.actions.length > 0 && { logicalOperator: "AND" as const }), fieldMappings: [], conditions: [], splitConfig: { sourceField: "", delimiter: "", targetField: "", }, }; onSettingsChange({ ...settings, actions: [...settings.actions, newAction], }); }; const updateAction = (actionIndex: number, field: string, value: any) => { const newActions = [...settings.actions]; (newActions[actionIndex] as any)[field] = value; onSettingsChange({ ...settings, actions: newActions }); }; const removeAction = (actionIndex: number) => { const newActions = settings.actions.filter((_, i) => i !== actionIndex); // 첫 번째 액션을 삭제했다면, 새로운 첫 번째 액션의 logicalOperator 제거 if (actionIndex === 0 && newActions.length > 0) { delete newActions[0].logicalOperator; } onSettingsChange({ ...settings, actions: newActions }); }; return (
데이터 저장 설정
{/* 액션 목록 */}
{settings.actions.length === 0 ? (
저장 액션을 추가하여 데이터를 어떻게 저장할지 설정하세요.
) : (
{settings.actions.map((action, actionIndex) => (
{/* 첫 번째 액션이 아닌 경우 논리 연산자 표시 */} {actionIndex > 0 && (
이전 액션과의 관계:
)}
updateAction(actionIndex, "name", e.target.value)} className="h-7 flex-1 text-xs font-medium" placeholder="액션 이름" />
{/* 액션 타입 */}
{/* 액션별 개별 실행 조건 */} {/* 데이터 분할 설정 - DELETE 액션은 제외 */} {action.actionType !== "delete" && ( )} {/* 필드 매핑 - DELETE 액션은 제외 */} {action.actionType !== "delete" && ( )} {/* DELETE 액션일 때 다중 커넥션 지원 */} {action.actionType === "delete" && ( )}
))}
)}
); };