fix add field

This commit is contained in:
1ilit 2023-09-19 15:47:30 +03:00
parent 11d2d2810d
commit 79874a0413
2 changed files with 37 additions and 28 deletions

View File

@ -1,5 +1,6 @@
import { React, useState } from "react"; import { React, useState } from "react";
import Node from "./node"; import Node from "./node";
import sqlDataTypes from "./sql_types";
import { import {
IconEdit, IconEdit,
IconDelete, IconDelete,
@ -49,37 +50,19 @@ const Rect = (props) => {
}; };
const handleOk = () => { const handleOk = () => {
console.log(field);
setFields((prev) => [...prev, field]); setFields((prev) => [...prev, field]);
setField({
name: "",
type: "",
default: "",
primary: false,
unique: false,
notNull: false,
increment: false,
});
setVisible(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; const height = fields.length * 36 + 40 + 4;
return ( return (
@ -303,7 +286,6 @@ const Rect = (props) => {
title="Add new field" title="Add new field"
visible={visible} visible={visible}
onOk={handleOk} onOk={handleOk}
afterClose={() => {}}
onCancel={handleOk} onCancel={handleOk}
centered centered
closeOnEsc={true} closeOnEsc={true}

View File

@ -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;