ERP-node/frontend/components/dataflow/DataFlowSidebar.tsx

109 lines
3.9 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client";
import React from "react";
import { TableSelector } from "./TableSelector";
import { TableDefinition } from "@/lib/api/dataflow";
import { ExtendedJsonRelationship } from "@/types/dataflowTypes";
interface DataFlowSidebarProps {
companyCode: string;
nodes: Array<{ id: string; data: { table: { tableName: string } } }>;
edges: Array<{ id: string }>;
tempRelationships: ExtendedJsonRelationship[];
hasUnsavedChanges: boolean;
currentDiagramId: number | null;
currentDiagramCategory: string;
onTableAdd: (table: TableDefinition) => void;
onRemoveOrphanedNodes: () => void;
onClearAll: () => void;
onOpenSaveModal: () => void;
getSelectedTableNames: () => string[];
}
export const DataFlowSidebar: React.FC<DataFlowSidebarProps> = ({
companyCode,
nodes,
edges,
tempRelationships,
hasUnsavedChanges,
currentDiagramId,
currentDiagramCategory,
onTableAdd,
onRemoveOrphanedNodes,
onClearAll,
onOpenSaveModal,
getSelectedTableNames,
}) => {
return (
<div className="w-80 border-r border-gray-200 bg-white shadow-lg">
<div className="p-6">
<h2 className="mb-6 text-xl font-bold text-gray-800"> </h2>
{/* 테이블 선택기 */}
<TableSelector companyCode={companyCode} onTableAdd={onTableAdd} selectedTables={getSelectedTableNames()} />
{/* 컨트롤 버튼들 */}
<div className="space-y-3">
<button
onClick={onRemoveOrphanedNodes}
className="w-full rounded-lg bg-orange-500 p-3 font-medium text-white transition-colors hover:bg-orange-600"
disabled={nodes.length === 0}
>
🧹
</button>
<button
onClick={onClearAll}
className="w-full rounded-lg bg-destructive/100 p-3 font-medium text-white transition-colors hover:bg-red-600"
>
🗑
</button>
<button
onClick={onOpenSaveModal}
className={`w-full rounded-lg bg-green-500 p-3 font-medium text-white transition-colors hover:bg-green-600 ${
hasUnsavedChanges ? "animate-pulse" : ""
}`}
>
💾 {tempRelationships.length > 0 && `(${tempRelationships.length})`}
</button>
</div>
{/* 통계 정보 */}
<div className="mt-6 rounded-lg bg-gray-50 p-4">
<div className="mb-2 text-sm font-semibold text-gray-700"></div>
<div className="space-y-1 text-sm text-muted-foreground">
<div className="flex justify-between">
<span> :</span>
<span className="font-medium">{nodes.length}</span>
</div>
<div className="flex justify-between">
<span>:</span>
<span className="font-medium">{edges.length}</span>
</div>
<div className="flex justify-between">
<span> :</span>
<span className="font-medium text-orange-600">{tempRelationships.length}</span>
</div>
<div className="flex justify-between">
<span> ID:</span>
<span className="font-medium">{currentDiagramId || "미설정"}</span>
</div>
<div className="flex justify-between">
<span> :</span>
<span className="font-medium">
{currentDiagramCategory === "simple-key" && "단순 키값"}
{currentDiagramCategory === "data-save" && "데이터 저장"}
{currentDiagramCategory === "external-call" && "외부 호출"}
</span>
</div>
{hasUnsavedChanges && (
<div className="mt-2 text-xs font-medium text-orange-600"> </div>
)}
</div>
</div>
</div>
</div>
);
};