2025-09-26 01:28:51 +09:00
|
|
|
"use client";
|
|
|
|
|
|
2025-10-01 16:15:53 +09:00
|
|
|
import React, { useState } from "react";
|
|
|
|
|
import { Table, ArrowLeft, ArrowRight, CheckCircle, Database } from "lucide-react";
|
|
|
|
|
import { Connection, TableInfo } from "../types/redesigned";
|
2025-09-26 01:28:51 +09:00
|
|
|
|
|
|
|
|
interface TableStepProps {
|
|
|
|
|
fromConnection?: Connection;
|
|
|
|
|
toConnection?: Connection;
|
|
|
|
|
fromTable?: TableInfo;
|
|
|
|
|
toTable?: TableInfo;
|
2025-10-01 16:15:53 +09:00
|
|
|
onFromTableChange: (table: TableInfo) => void;
|
|
|
|
|
onToTableChange: (table: TableInfo) => void;
|
2025-09-26 01:28:51 +09:00
|
|
|
onNext: () => void;
|
|
|
|
|
onBack: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-01 16:15:53 +09:00
|
|
|
// 임시 테이블 데이터
|
|
|
|
|
const mockTables: TableInfo[] = [
|
|
|
|
|
{
|
|
|
|
|
name: "users",
|
|
|
|
|
schema: "public",
|
|
|
|
|
columns: [
|
|
|
|
|
{ name: "id", type: "integer", nullable: false, primaryKey: true },
|
|
|
|
|
{ name: "name", type: "varchar", nullable: false, primaryKey: false },
|
|
|
|
|
{ name: "email", type: "varchar", nullable: true, primaryKey: false },
|
2026-03-10 18:30:18 +09:00
|
|
|
{ name: "created_at", type: "timestamp", nullable: false, primaryKey: false },
|
2025-10-01 16:15:53 +09:00
|
|
|
],
|
2026-03-10 18:30:18 +09:00
|
|
|
rowCount: 1250,
|
2025-10-01 16:15:53 +09:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "orders",
|
2026-03-10 18:30:18 +09:00
|
|
|
schema: "public",
|
2025-10-01 16:15:53 +09:00
|
|
|
columns: [
|
|
|
|
|
{ name: "id", type: "integer", nullable: false, primaryKey: true },
|
|
|
|
|
{ name: "user_id", type: "integer", nullable: false, primaryKey: false, foreignKey: true },
|
|
|
|
|
{ name: "product_name", type: "varchar", nullable: false, primaryKey: false },
|
|
|
|
|
{ name: "amount", type: "decimal", nullable: false, primaryKey: false },
|
2026-03-10 18:30:18 +09:00
|
|
|
{ name: "order_date", type: "timestamp", nullable: false, primaryKey: false },
|
2025-10-01 16:15:53 +09:00
|
|
|
],
|
2026-03-10 18:30:18 +09:00
|
|
|
rowCount: 3420,
|
2025-10-01 16:15:53 +09:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "products",
|
|
|
|
|
schema: "public",
|
|
|
|
|
columns: [
|
|
|
|
|
{ name: "id", type: "integer", nullable: false, primaryKey: true },
|
|
|
|
|
{ name: "name", type: "varchar", nullable: false, primaryKey: false },
|
|
|
|
|
{ name: "price", type: "decimal", nullable: false, primaryKey: false },
|
2026-03-10 18:30:18 +09:00
|
|
|
{ name: "category", type: "varchar", nullable: true, primaryKey: false },
|
2025-10-01 16:15:53 +09:00
|
|
|
],
|
2026-03-10 18:30:18 +09:00
|
|
|
rowCount: 156,
|
|
|
|
|
},
|
2025-10-01 16:15:53 +09:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export const TableStep: React.FC<TableStepProps> = ({
|
2025-09-26 01:28:51 +09:00
|
|
|
fromConnection,
|
|
|
|
|
toConnection,
|
|
|
|
|
fromTable,
|
|
|
|
|
toTable,
|
2025-10-01 16:15:53 +09:00
|
|
|
onFromTableChange,
|
|
|
|
|
onToTableChange,
|
2025-09-26 01:28:51 +09:00
|
|
|
onNext,
|
|
|
|
|
onBack,
|
|
|
|
|
}) => {
|
2025-10-01 16:15:53 +09:00
|
|
|
const [selectedFromTable, setSelectedFromTable] = useState<string>(fromTable?.name || "");
|
|
|
|
|
const [selectedToTable, setSelectedToTable] = useState<string>(toTable?.name || "");
|
2025-09-26 01:28:51 +09:00
|
|
|
|
2025-10-01 16:15:53 +09:00
|
|
|
const handleFromTableSelect = (tableName: string) => {
|
2026-03-10 18:30:18 +09:00
|
|
|
const table = mockTables.find((t) => t.name === tableName);
|
2025-10-01 16:15:53 +09:00
|
|
|
if (table) {
|
|
|
|
|
setSelectedFromTable(tableName);
|
|
|
|
|
onFromTableChange(table);
|
2025-09-26 01:28:51 +09:00
|
|
|
}
|
2025-10-01 16:15:53 +09:00
|
|
|
};
|
2025-09-26 01:28:51 +09:00
|
|
|
|
2025-10-01 16:15:53 +09:00
|
|
|
const handleToTableSelect = (tableName: string) => {
|
2026-03-10 18:30:18 +09:00
|
|
|
const table = mockTables.find((t) => t.name === tableName);
|
2025-09-26 01:28:51 +09:00
|
|
|
if (table) {
|
2025-10-01 16:15:53 +09:00
|
|
|
setSelectedToTable(tableName);
|
|
|
|
|
onToTableChange(table);
|
2025-09-26 01:28:51 +09:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-01 16:15:53 +09:00
|
|
|
const canProceed = selectedFromTable && selectedToTable;
|
2025-09-26 01:28:51 +09:00
|
|
|
|
|
|
|
|
return (
|
2025-10-01 16:15:53 +09:00
|
|
|
<div className="space-y-8">
|
|
|
|
|
<div className="text-center">
|
2026-03-10 18:30:18 +09:00
|
|
|
<h2 className="mb-2 text-2xl font-bold text-gray-900">테이블 선택</h2>
|
|
|
|
|
<p className="text-muted-foreground">소스 테이블과 대상 테이블을 선택하세요</p>
|
2025-10-01 16:15:53 +09:00
|
|
|
</div>
|
2025-09-26 01:28:51 +09:00
|
|
|
|
2025-10-01 16:15:53 +09:00
|
|
|
{/* 연결 정보 표시 */}
|
2026-03-10 18:30:18 +09:00
|
|
|
<div className="rounded-lg bg-gray-50 p-4">
|
2025-10-01 16:15:53 +09:00
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<div className="flex items-center gap-3">
|
2026-03-10 18:30:18 +09:00
|
|
|
<Database className="text-primary h-5 w-5" />
|
2025-10-01 16:15:53 +09:00
|
|
|
<span className="font-medium text-gray-900">{fromConnection?.name}</span>
|
|
|
|
|
<span className="text-sm text-gray-500">→</span>
|
2026-03-10 18:30:18 +09:00
|
|
|
<Database className="h-5 w-5 text-green-600" />
|
2025-10-01 16:15:53 +09:00
|
|
|
<span className="font-medium text-gray-900">{toConnection?.name}</span>
|
2025-09-26 01:28:51 +09:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-10-01 16:15:53 +09:00
|
|
|
</div>
|
2025-09-26 01:28:51 +09:00
|
|
|
|
2026-03-10 18:30:18 +09:00
|
|
|
<div className="grid grid-cols-1 gap-8 lg:grid-cols-2">
|
2025-10-01 16:15:53 +09:00
|
|
|
{/* FROM 테이블 */}
|
|
|
|
|
<div className="space-y-4">
|
|
|
|
|
<div className="flex items-center gap-2">
|
2026-03-10 18:30:18 +09:00
|
|
|
<div className="bg-primary/20 flex h-8 w-8 items-center justify-center rounded-full">
|
2025-10-02 14:34:15 +09:00
|
|
|
<span className="text-primary font-bold">1</span>
|
2025-09-26 01:28:51 +09:00
|
|
|
</div>
|
2025-10-01 16:15:53 +09:00
|
|
|
<h3 className="text-lg font-semibold text-gray-900">소스 테이블</h3>
|
|
|
|
|
<span className="text-sm text-gray-500">(FROM)</span>
|
|
|
|
|
</div>
|
2026-03-10 18:30:18 +09:00
|
|
|
|
2025-10-01 16:15:53 +09:00
|
|
|
<div className="space-y-2">
|
|
|
|
|
{mockTables.map((table) => (
|
|
|
|
|
<div
|
|
|
|
|
key={table.name}
|
2026-03-10 18:30:18 +09:00
|
|
|
className={`cursor-pointer rounded-lg border-2 p-4 transition-all duration-200 ${
|
2025-10-01 16:15:53 +09:00
|
|
|
selectedFromTable === table.name
|
2025-10-02 14:34:15 +09:00
|
|
|
? "border-primary bg-accent shadow-md"
|
2026-03-10 18:30:18 +09:00
|
|
|
: "hover:bg-blue-25 border-gray-200 bg-white hover:border-blue-300"
|
2025-10-01 16:15:53 +09:00
|
|
|
}`}
|
|
|
|
|
onClick={() => handleFromTableSelect(table.name)}
|
|
|
|
|
>
|
|
|
|
|
<div className="flex items-center gap-3">
|
2026-03-10 18:30:18 +09:00
|
|
|
<Table className="text-primary h-6 w-6" />
|
2025-10-01 16:15:53 +09:00
|
|
|
<div className="flex-1">
|
|
|
|
|
<h4 className="font-medium text-gray-900">{table.name}</h4>
|
2026-03-10 18:30:18 +09:00
|
|
|
<p className="text-muted-foreground text-sm">{table.columns.length}개 컬럼</p>
|
2025-10-01 16:15:53 +09:00
|
|
|
<p className="text-xs text-gray-500">{table.rowCount?.toLocaleString()}개 행</p>
|
|
|
|
|
</div>
|
2026-03-10 18:30:18 +09:00
|
|
|
{selectedFromTable === table.name && <CheckCircle className="text-primary h-5 w-5" />}
|
2025-09-26 01:28:51 +09:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-10-01 16:15:53 +09:00
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-09-26 01:28:51 +09:00
|
|
|
|
2025-10-01 16:15:53 +09:00
|
|
|
{/* TO 테이블 */}
|
|
|
|
|
<div className="space-y-4">
|
|
|
|
|
<div className="flex items-center gap-2">
|
2026-03-10 18:30:18 +09:00
|
|
|
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-green-100">
|
|
|
|
|
<span className="font-bold text-green-600">2</span>
|
2025-10-01 16:15:53 +09:00
|
|
|
</div>
|
|
|
|
|
<h3 className="text-lg font-semibold text-gray-900">대상 테이블</h3>
|
|
|
|
|
<span className="text-sm text-gray-500">(TO)</span>
|
|
|
|
|
</div>
|
2026-03-10 18:30:18 +09:00
|
|
|
|
2025-10-01 16:15:53 +09:00
|
|
|
<div className="space-y-2">
|
|
|
|
|
{mockTables.map((table) => (
|
|
|
|
|
<div
|
|
|
|
|
key={table.name}
|
2026-03-10 18:30:18 +09:00
|
|
|
className={`cursor-pointer rounded-lg border-2 p-4 transition-all duration-200 ${
|
2025-10-01 16:15:53 +09:00
|
|
|
selectedToTable === table.name
|
|
|
|
|
? "border-green-500 bg-green-50 shadow-md"
|
2026-03-10 18:30:18 +09:00
|
|
|
: "hover:bg-green-25 border-gray-200 bg-white hover:border-green-300"
|
2025-10-01 16:15:53 +09:00
|
|
|
}`}
|
|
|
|
|
onClick={() => handleToTableSelect(table.name)}
|
|
|
|
|
>
|
|
|
|
|
<div className="flex items-center gap-3">
|
2026-03-10 18:30:18 +09:00
|
|
|
<Table className="h-6 w-6 text-green-600" />
|
2025-10-01 16:15:53 +09:00
|
|
|
<div className="flex-1">
|
|
|
|
|
<h4 className="font-medium text-gray-900">{table.name}</h4>
|
2026-03-10 18:30:18 +09:00
|
|
|
<p className="text-muted-foreground text-sm">{table.columns.length}개 컬럼</p>
|
2025-10-01 16:15:53 +09:00
|
|
|
<p className="text-xs text-gray-500">{table.rowCount?.toLocaleString()}개 행</p>
|
|
|
|
|
</div>
|
2026-03-10 18:30:18 +09:00
|
|
|
{selectedToTable === table.name && <CheckCircle className="h-5 w-5 text-green-600" />}
|
2025-09-26 01:28:51 +09:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-10-01 16:15:53 +09:00
|
|
|
))}
|
2025-09-26 01:28:51 +09:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-10-01 16:15:53 +09:00
|
|
|
</div>
|
2025-09-26 01:28:51 +09:00
|
|
|
|
2025-10-01 16:15:53 +09:00
|
|
|
{/* 버튼들 */}
|
|
|
|
|
<div className="flex justify-between">
|
|
|
|
|
<button
|
|
|
|
|
onClick={onBack}
|
2026-03-10 18:30:18 +09:00
|
|
|
className="text-muted-foreground flex items-center gap-2 rounded-lg bg-gray-100 px-6 py-3 font-medium transition-all duration-200 hover:bg-gray-200"
|
2025-10-01 16:15:53 +09:00
|
|
|
>
|
2026-03-10 18:30:18 +09:00
|
|
|
<ArrowLeft className="h-4 w-4" />
|
2025-10-01 16:15:53 +09:00
|
|
|
이전 단계
|
|
|
|
|
</button>
|
2026-03-10 18:30:18 +09:00
|
|
|
|
2025-10-01 16:15:53 +09:00
|
|
|
<button
|
|
|
|
|
onClick={onNext}
|
|
|
|
|
disabled={!canProceed}
|
2026-03-10 18:30:18 +09:00
|
|
|
className={`flex items-center gap-2 rounded-lg px-6 py-3 font-medium transition-all duration-200 ${
|
2025-10-01 16:15:53 +09:00
|
|
|
canProceed
|
2026-03-10 18:30:18 +09:00
|
|
|
? "bg-orange-500 text-white shadow-md hover:bg-orange-600 hover:shadow-lg"
|
|
|
|
|
: "cursor-not-allowed bg-gray-300 text-gray-500"
|
2025-10-01 16:15:53 +09:00
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
다음 단계: 필드 매핑
|
2026-03-10 18:30:18 +09:00
|
|
|
<ArrowRight className="h-4 w-4" />
|
2025-10-01 16:15:53 +09:00
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2026-03-10 18:30:18 +09:00
|
|
|
};
|