2025-09-26 01:28:51 +09:00
|
|
|
"use client";
|
|
|
|
|
|
2025-10-01 16:15:53 +09:00
|
|
|
import React, { useState } from "react";
|
|
|
|
|
import { Database, ArrowRight, CheckCircle } from "lucide-react";
|
|
|
|
|
import { Connection } from "../types/redesigned";
|
2025-09-26 01:28:51 +09:00
|
|
|
|
|
|
|
|
interface ConnectionStepProps {
|
|
|
|
|
fromConnection?: Connection;
|
|
|
|
|
toConnection?: Connection;
|
2025-10-01 16:15:53 +09:00
|
|
|
onFromConnectionChange: (connection: Connection) => void;
|
|
|
|
|
onToConnectionChange: (connection: Connection) => void;
|
2025-09-26 01:28:51 +09:00
|
|
|
onNext: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-01 16:15:53 +09:00
|
|
|
// 임시 연결 데이터 (실제로는 API에서 가져올 것)
|
|
|
|
|
const mockConnections: Connection[] = [
|
|
|
|
|
{
|
|
|
|
|
id: "conn1",
|
|
|
|
|
name: "메인 데이터베이스",
|
|
|
|
|
type: "PostgreSQL",
|
|
|
|
|
host: "localhost",
|
|
|
|
|
port: 5432,
|
|
|
|
|
database: "main_db",
|
|
|
|
|
username: "admin",
|
2026-03-10 18:30:18 +09:00
|
|
|
tables: [],
|
2025-10-01 16:15:53 +09:00
|
|
|
},
|
|
|
|
|
{
|
2026-03-10 18:30:18 +09:00
|
|
|
id: "conn2",
|
2025-10-01 16:15:53 +09:00
|
|
|
name: "외부 API",
|
|
|
|
|
type: "REST API",
|
|
|
|
|
host: "api.example.com",
|
|
|
|
|
port: 443,
|
|
|
|
|
database: "external",
|
|
|
|
|
username: "api_user",
|
2026-03-10 18:30:18 +09:00
|
|
|
tables: [],
|
2025-10-01 16:15:53 +09:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "conn3",
|
|
|
|
|
name: "백업 데이터베이스",
|
|
|
|
|
type: "MySQL",
|
|
|
|
|
host: "backup.local",
|
|
|
|
|
port: 3306,
|
|
|
|
|
database: "backup_db",
|
|
|
|
|
username: "backup_user",
|
2026-03-10 18:30:18 +09:00
|
|
|
tables: [],
|
|
|
|
|
},
|
2025-10-01 16:15:53 +09:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export const ConnectionStep: React.FC<ConnectionStepProps> = ({
|
|
|
|
|
fromConnection,
|
|
|
|
|
toConnection,
|
|
|
|
|
onFromConnectionChange,
|
|
|
|
|
onToConnectionChange,
|
|
|
|
|
onNext,
|
|
|
|
|
}) => {
|
|
|
|
|
const [selectedFrom, setSelectedFrom] = useState<string>(fromConnection?.id || "");
|
|
|
|
|
const [selectedTo, setSelectedTo] = useState<string>(toConnection?.id || "");
|
|
|
|
|
|
|
|
|
|
const handleFromSelect = (connectionId: string) => {
|
2026-03-10 18:30:18 +09:00
|
|
|
const connection = mockConnections.find((c) => c.id === connectionId);
|
2025-10-01 16:15:53 +09:00
|
|
|
if (connection) {
|
|
|
|
|
setSelectedFrom(connectionId);
|
|
|
|
|
onFromConnectionChange(connection);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleToSelect = (connectionId: string) => {
|
2026-03-10 18:30:18 +09:00
|
|
|
const connection = mockConnections.find((c) => c.id === connectionId);
|
2025-10-01 16:15:53 +09:00
|
|
|
if (connection) {
|
|
|
|
|
setSelectedTo(connectionId);
|
|
|
|
|
onToConnectionChange(connection);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const canProceed = selectedFrom && selectedTo && selectedFrom !== selectedTo;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<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>
|
|
|
|
|
|
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 13:52:32 +09:00
|
|
|
</div>
|
2025-10-01 16:15:53 +09:00
|
|
|
<h3 className="text-lg font-semibold text-gray-900">FROM 연결</h3>
|
|
|
|
|
<span className="text-sm text-gray-500">(데이터 소스)</span>
|
2025-09-26 13:52:32 +09:00
|
|
|
</div>
|
2026-03-10 18:30:18 +09:00
|
|
|
|
2025-10-01 16:15:53 +09:00
|
|
|
<div className="space-y-2">
|
|
|
|
|
{mockConnections.map((connection) => (
|
|
|
|
|
<div
|
|
|
|
|
key={connection.id}
|
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
|
|
|
selectedFrom === connection.id
|
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={() => handleFromSelect(connection.id)}
|
|
|
|
|
>
|
|
|
|
|
<div className="flex items-center gap-3">
|
2026-03-10 18:30:18 +09:00
|
|
|
<Database 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">{connection.name}</h4>
|
2026-03-10 18:30:18 +09:00
|
|
|
<p className="text-muted-foreground text-sm">{connection.type}</p>
|
|
|
|
|
<p className="text-xs text-gray-500">
|
|
|
|
|
{connection.host}:{connection.port}
|
|
|
|
|
</p>
|
2025-09-26 01:28:51 +09:00
|
|
|
</div>
|
2026-03-10 18:30:18 +09:00
|
|
|
{selectedFrom === connection.id && <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
|
|
|
{/* 화살표 */}
|
2026-03-10 18:30:18 +09:00
|
|
|
<div className="hidden items-center justify-center lg:flex">
|
|
|
|
|
<div className="flex h-12 w-12 items-center justify-center rounded-full bg-orange-100">
|
|
|
|
|
<ArrowRight className="h-6 w-6 text-orange-600" />
|
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">TO 연결</h3>
|
|
|
|
|
<span className="text-sm text-gray-500">(데이터 대상)</span>
|
|
|
|
|
</div>
|
2026-03-10 18:30:18 +09:00
|
|
|
|
2025-10-01 16:15:53 +09:00
|
|
|
<div className="space-y-2">
|
|
|
|
|
{mockConnections.map((connection) => (
|
|
|
|
|
<div
|
|
|
|
|
key={connection.id}
|
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
|
|
|
selectedTo === connection.id
|
|
|
|
|
? "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={() => handleToSelect(connection.id)}
|
|
|
|
|
>
|
|
|
|
|
<div className="flex items-center gap-3">
|
2026-03-10 18:30:18 +09:00
|
|
|
<Database 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">{connection.name}</h4>
|
2026-03-10 18:30:18 +09:00
|
|
|
<p className="text-muted-foreground text-sm">{connection.type}</p>
|
|
|
|
|
<p className="text-xs text-gray-500">
|
|
|
|
|
{connection.host}:{connection.port}
|
|
|
|
|
</p>
|
2025-09-26 01:28:51 +09:00
|
|
|
</div>
|
2026-03-10 18:30:18 +09:00
|
|
|
{selectedTo === connection.id && <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
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* 다음 버튼 */}
|
|
|
|
|
<div className="flex justify-end">
|
|
|
|
|
<button
|
|
|
|
|
onClick={onNext}
|
|
|
|
|
disabled={!canProceed}
|
2026-03-10 18:30:18 +09:00
|
|
|
className={`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
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
다음 단계: 테이블 선택
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2026-03-10 18:30:18 +09:00
|
|
|
};
|