diff --git a/client/src/components/AddTable/index.jsx b/client/src/components/AddTable/index.jsx new file mode 100644 index 0000000..2808bb1 --- /dev/null +++ b/client/src/components/AddTable/index.jsx @@ -0,0 +1,82 @@ +import React, { useContext, useState, useEffect, useRef } from "react"; +import cx from "classnames"; +import "./style.scss"; +import ColumnElement from "./ColumnElement"; + +export default function AddTable() { + const [tableName, setTableName] = useState(""); + const [columns, setColumns] = useState([]); + const nextId = useRef(1); + + let isNullColumnName = true; + + const removeColumn = remove => { + setColumns(columns.filter(column => column.id !== remove)); + }; + + const handleSubmitColumn = () => { + columns.forEach(column => { + if (column.columnName.length === 0) { + isNullColumnName = true; + return; + } + if (column.columnName.length !== 0) isNullColumnName = false; + }); + if (tableName.length >= 1 && !isNullColumnName) + console.log({ tableName, ...columns }); + }; + + const initialState = { + columnName: "", + dataType: "", + constraint: false, + default: "", + PK: false, + FK: false, + }; + + return ( +
+
+ 테이블 이름: + { + setTableName(e.target.value); + }} + /> + +
+ + + + +
+ ); +} diff --git a/client/src/components/AddTable/style.scss b/client/src/components/AddTable/style.scss new file mode 100644 index 0000000..ae29fa8 --- /dev/null +++ b/client/src/components/AddTable/style.scss @@ -0,0 +1,75 @@ +@import "../../style/color.scss"; +.addContainer { + display: flex; + flex-direction: column; + min-width: 840px; + height: fit-content; + background-color: $white; + box-shadow: $box-shadow; + border-radius: 10px; + margin: 200px auto; + padding: 20px; + font-weight: bold; + .addBox { + display: flex; + flex-direction: row; + background-color: $white; + border: none; + outline: none; + cursor: pointer; + margin: 0 0 0 auto; + padding: 0; + .addCircle { + width: 20px; + height: 20px; + background-color: $adding; + border-radius: 50%; + margin: auto 5px auto 0; + } + .table { + background-color: $create; + } + .addText { + margin: auto 0; + font-weight: bold; + font-size: 17px; + } + } + .table { + margin-top: 15px; + } + .tableInputBox { + display: flex; + flex-direction: row; + .tableLabel { + margin: auto 0; + } + } + .select, + .input { + display: inline; + border: 2px solid $black; + border-radius: 4px; + margin: auto 0; + color: $black; + font-size: 15px; + font-weight: bold; + &:focus { + outline: none; + } + &::placeholder { + color: $black; + font-size: 13px; + } + &::-ms-input-placeholder { + color: $black; + font-size: 13px; + } + } + .input { + max-width: 80px; + } + .tableInput { + margin-left: 11px; + } +}