From 79874a0413e845d7652bfce304c2d384718c9d3e Mon Sep 17 00:00:00 2001 From: 1ilit Date: Tue, 19 Sep 2023 15:47:30 +0300 Subject: [PATCH] fix add field --- src/components/rect.jsx | 38 ++++++++++--------------------------- src/components/sql_types.js | 27 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 src/components/sql_types.js diff --git a/src/components/rect.jsx b/src/components/rect.jsx index 849a564..164f041 100644 --- a/src/components/rect.jsx +++ b/src/components/rect.jsx @@ -1,5 +1,6 @@ import { React, useState } from "react"; import Node from "./node"; +import sqlDataTypes from "./sql_types"; import { IconEdit, IconDelete, @@ -49,37 +50,19 @@ const Rect = (props) => { }; const handleOk = () => { - console.log(field); setFields((prev) => [...prev, field]); + setField({ + name: "", + type: "", + default: "", + primary: false, + unique: false, + notNull: false, + increment: false, + }); setVisible(false); }; - const sqlDataTypes = [ - "INT", - "SMALLINT", - "BIGINT", - "DECIMAL", - "NUMERIC", - "FLOAT", - "REAL", - "DOUBLE PRECISION", - "CHAR", - "VARCHAR", - "TEXT", - "DATE", - "TIME", - "TIMESTAMP", - "INTERVAL", - "BOOLEAN", - "BINARY", - "VARBINARY", - "BLOB", - "CLOB", - "UUID", - "XML", - "JSON", - ]; - const height = fields.length * 36 + 40 + 4; return ( @@ -303,7 +286,6 @@ const Rect = (props) => { title="Add new field" visible={visible} onOk={handleOk} - afterClose={() => {}} onCancel={handleOk} centered closeOnEsc={true} diff --git a/src/components/sql_types.js b/src/components/sql_types.js new file mode 100644 index 0000000..aebd37c --- /dev/null +++ b/src/components/sql_types.js @@ -0,0 +1,27 @@ +const sqlDataTypes = [ + "INT", + "SMALLINT", + "BIGINT", + "DECIMAL", + "NUMERIC", + "FLOAT", + "REAL", + "DOUBLE PRECISION", + "CHAR", + "VARCHAR", + "TEXT", + "DATE", + "TIME", + "TIMESTAMP", + "INTERVAL", + "BOOLEAN", + "BINARY", + "VARBINARY", + "BLOB", + "CLOB", + "UUID", + "XML", + "JSON", +]; + +export default sqlDataTypes;