2023-09-19 20:48:13 +08:00
|
|
|
import React, { useState, useEffect } from "react";
|
2023-09-19 20:46:48 +08:00
|
|
|
import Header from "../components/header";
|
|
|
|
import Sidebar from "../components/sidebar";
|
|
|
|
import ControlPanel from "../components/control_panel";
|
2023-09-19 20:47:01 +08:00
|
|
|
import { DndProvider } from "react-dnd";
|
2023-09-19 20:46:54 +08:00
|
|
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
2023-09-19 20:47:43 +08:00
|
|
|
import Canvas from "../components/canvas";
|
2023-09-19 20:47:01 +08:00
|
|
|
import EditorPanel from "../components/editor_panel";
|
2023-09-19 20:46:54 +08:00
|
|
|
|
2023-09-19 20:46:46 +08:00
|
|
|
export default function Editor(props) {
|
2023-09-19 20:46:56 +08:00
|
|
|
const [code, setCode] = useState("");
|
2023-09-19 20:47:41 +08:00
|
|
|
const [tables, setTables] = useState([]);
|
2023-09-19 20:47:59 +08:00
|
|
|
const [relationships, setRelationships] = useState([]);
|
2023-09-19 20:48:04 +08:00
|
|
|
const [areas, setAreas] = useState([]);
|
2023-09-19 20:46:56 +08:00
|
|
|
|
2023-09-19 20:48:13 +08:00
|
|
|
useEffect(() => {
|
|
|
|
console.log("changed: ", tables);
|
|
|
|
}, [tables]);
|
2023-09-19 20:48:11 +08:00
|
|
|
|
2023-09-19 20:48:13 +08:00
|
|
|
// const handleDelete = useCallback((id)=>{
|
|
|
|
// setTables(prev=>prev.filter(e=>e.id!==id).map((e, i)=>({...e, id: i})))
|
|
|
|
// }, [])
|
2023-09-19 20:48:11 +08:00
|
|
|
|
2023-09-19 20:46:46 +08:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Header name={props.name} />
|
2023-09-19 20:46:50 +08:00
|
|
|
<ControlPanel />
|
2023-09-19 20:46:48 +08:00
|
|
|
<div className="flex h-full">
|
2023-09-19 20:46:58 +08:00
|
|
|
<DndProvider backend={HTML5Backend}>
|
2023-09-19 20:47:06 +08:00
|
|
|
<EditorPanel
|
2023-09-19 20:47:41 +08:00
|
|
|
tables={tables}
|
|
|
|
setTables={setTables}
|
2023-09-19 20:47:06 +08:00
|
|
|
code={code}
|
|
|
|
setCode={setCode}
|
2023-09-19 20:47:59 +08:00
|
|
|
relationships={relationships}
|
|
|
|
setRelationships={setRelationships}
|
2023-09-19 20:48:04 +08:00
|
|
|
areas={areas}
|
|
|
|
setAreas={setAreas}
|
2023-09-19 20:48:13 +08:00
|
|
|
// handleDelete={handleDelete}
|
2023-09-19 20:47:06 +08:00
|
|
|
/>
|
|
|
|
<Canvas
|
2023-09-19 20:47:41 +08:00
|
|
|
tables={tables}
|
|
|
|
setTables={setTables}
|
2023-09-19 20:47:06 +08:00
|
|
|
code={code}
|
|
|
|
setCode={setCode}
|
2023-09-19 20:47:59 +08:00
|
|
|
relationships={relationships}
|
|
|
|
setRelationships={setRelationships}
|
2023-09-19 20:48:04 +08:00
|
|
|
areas={areas}
|
|
|
|
setAreas={setAreas}
|
2023-09-19 20:47:06 +08:00
|
|
|
/>
|
2023-09-19 20:46:58 +08:00
|
|
|
</DndProvider>
|
2023-09-19 20:46:50 +08:00
|
|
|
<Sidebar />
|
2023-09-19 20:46:46 +08:00
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|