feat: Digital Twin Editor 테이블 매핑 UI 및 백엔드 API 구현

This commit is contained in:
dohyeons
2025-11-20 10:15:58 +09:00
parent eeed671436
commit 33350a4d46
13 changed files with 3007 additions and 462 deletions

View File

@@ -7,7 +7,7 @@ import { Plus, Check, Trash2 } from "lucide-react";
import YardLayoutCreateModal from "./yard-3d/YardLayoutCreateModal";
import DigitalTwinEditor from "./yard-3d/DigitalTwinEditor";
import DigitalTwinViewer from "./yard-3d/DigitalTwinViewer";
import { yardLayoutApi } from "@/lib/api/yardLayoutApi";
import { getLayouts, createLayout, deleteLayout } from "@/lib/api/digitalTwin";
import type { YardManagementConfig } from "../types";
interface YardLayout {
@@ -40,9 +40,16 @@ export default function YardManagement3DWidget({
const loadLayouts = async () => {
try {
setIsLoading(true);
const response = await yardLayoutApi.getAllLayouts();
if (response.success) {
setLayouts(response.data as YardLayout[]);
const response = await getLayouts();
if (response.success && response.data) {
setLayouts(response.data.map((layout: any) => ({
id: layout.id,
name: layout.layout_name,
description: layout.description || "",
placement_count: layout.object_count || 0,
created_at: layout.created_at,
updated_at: layout.updated_at,
})));
}
} catch (error) {
console.error("야드 레이아웃 목록 조회 실패:", error);
@@ -81,11 +88,21 @@ export default function YardManagement3DWidget({
// 새 레이아웃 생성
const handleCreateLayout = async (name: string) => {
try {
const response = await yardLayoutApi.createLayout({ name });
if (response.success) {
const response = await createLayout({
layoutName: name,
description: "",
});
if (response.success && response.data) {
await loadLayouts();
setIsCreateModalOpen(false);
setEditingLayout(response.data as YardLayout);
setEditingLayout({
id: response.data.id,
name: response.data.layout_name,
description: response.data.description || "",
placement_count: 0,
created_at: response.data.created_at,
updated_at: response.data.updated_at,
});
}
} catch (error) {
console.error("야드 레이아웃 생성 실패:", error);
@@ -110,7 +127,7 @@ export default function YardManagement3DWidget({
if (!deleteLayoutId) return;
try {
const response = await yardLayoutApi.deleteLayout(deleteLayoutId);
const response = await deleteLayout(deleteLayoutId);
if (response.success) {
// 삭제된 레이아웃이 현재 선택된 레이아웃이면 설정 초기화
if (config?.layoutId === deleteLayoutId && onConfigChange) {