Load types for selected db

This commit is contained in:
1ilit
2024-06-06 20:24:05 +03:00
parent 1283f66a86
commit be6ecb066c
15 changed files with 402 additions and 39 deletions

View File

@@ -1,4 +1,4 @@
import { Action, ObjectType, sqlDataTypes } from "../../../data/constants";
import { Action, ObjectType } from "../../../data/constants";
import { Row, Col, Input, Button, Popover, Select } from "@douyinfe/semi-ui";
import { IconMore, IconKeyStroked } from "@douyinfe/semi-icons";
import { getSize, hasCheck, hasPrecision, isSized } from "../../../utils/toSQL";
@@ -6,11 +6,12 @@ import { useTables, useTypes, useUndoRedo } from "../../../hooks";
import { useState } from "react";
import FieldDetails from "./FieldDetails";
import { useTranslation } from "react-i18next";
import { dbToTypes } from "../../../data/datatypes";
export default function TableField({ data, tid, index }) {
const { updateField } = useTables();
const { types } = useTypes();
const { tables } = useTables();
const { tables, database } = useTables();
const { t } = useTranslation();
const { setUndoStack, setRedoStack } = useUndoRedo();
const [editField, setEditField] = useState({});
@@ -50,7 +51,7 @@ export default function TableField({ data, tid, index }) {
<Select
className="w-full"
optionList={[
...sqlDataTypes.map((value) => ({
...dbToTypes[database].map((value) => ({
label: value,
value: value,
})),

View File

@@ -1,5 +1,5 @@
import { useState } from "react";
import { Action, ObjectType, sqlDataTypes } from "../../../data/constants";
import { Action, ObjectType } from "../../../data/constants";
import {
Row,
Col,
@@ -12,11 +12,13 @@ import {
} from "@douyinfe/semi-ui";
import { IconDeleteStroked, IconMore } from "@douyinfe/semi-icons";
import { isSized, hasPrecision, getSize } from "../../../utils/toSQL";
import { useUndoRedo, useTypes } from "../../../hooks";
import { useUndoRedo, useTypes, useTables } from "../../../hooks";
import { useTranslation } from "react-i18next";
import { dbToTypes } from "../../../data/datatypes";
export default function TypeField({ data, tid, fid }) {
const { types, updateType } = useTypes();
const { database } = useTables();
const { setUndoStack, setRedoStack } = useUndoRedo();
const [editField, setEditField] = useState({});
const { t } = useTranslation();
@@ -62,7 +64,7 @@ export default function TypeField({ data, tid, fid }) {
<Select
className="w-full"
optionList={[
...sqlDataTypes.map((value) => ({
...dbToTypes[database].map((value) => ({
label: value,
value: value,
})),