import { useState } from "react"; import { AutoComplete, Collapse, Empty, Row, Col, Select, Button, Popover, Table, } from "@douyinfe/semi-ui"; import { IconDeleteStroked, IconLoopTextStroked, IconMore, IconSearch, } from "@douyinfe/semi-icons"; import { IllustrationNoContent, IllustrationNoContentDark, } from "@douyinfe/semi-illustrations"; import { Cardinality, Constraint, Action, ObjectType } from "../data/data"; import useTables from "../hooks/useTables"; import useUndoRedo from "../hooks/useUndoRedo"; export default function ReferenceOverview() { const columns = [ { title: "Primary", dataIndex: "primary", }, { title: "Foreign", dataIndex: "foreign", }, ]; const { tables, relationships, setRelationships, deleteRelationship } = useTables(); const { setUndoStack, setRedoStack } = useUndoRedo(); const [refActiveIndex, setRefActiveIndex] = useState(""); const [value, setValue] = useState(""); const [filteredResult, setFilteredResult] = useState( relationships.map((t) => { return t.name; }) ); const handleStringSearch = (value) => { setFilteredResult( relationships .map((t) => { return t.name; }) .filter((i) => i.includes(value)) ); }; return ( <> } placeholder="Search..." emptyContent={
No relationships found
} onSearch={(v) => handleStringSearch(v)} onChange={(v) => setValue(v)} onSelect={(v) => { const { id } = relationships.find((t) => t.name === v); setRefActiveIndex(`${id}`); document .getElementById(`scroll_ref_${id}`) .scrollIntoView({ behavior: "smooth" }); }} className="w-full" /> setRefActiveIndex(k)} accordion > {relationships.length <= 0 ? (
} darkModeImage={ } title="No relationships" description="Drag to connect fields and form relationships!" />
) : ( relationships.map((r, i) => (
{r.name}
} itemKey={`${i}`}>
Primary: {tables[r.endTableId].name}
Foreign: {tables[r.startTableId].name}
} trigger="click" position="rightTop" showArrow >
Cardinality
On update:
On delete:
)) )} ); }