import { memo } from "react"; import { Handle, Position, type NodeProps } from "@xyflow/react"; import type { ErdColumn } from "@/types"; import { KeyRound, Link } from "lucide-react"; export interface ErdTableNodeData { label: string; schema: string; columns: ErdColumn[]; fkColumnNames: string[]; [key: string]: unknown; } function ErdTableNodeComponent({ data }: NodeProps) { const { label, columns, fkColumnNames } = data as unknown as ErdTableNodeData; return (
{label}
{(columns as ErdColumn[]).map((col, i) => (
{col.is_primary_key ? ( ) : (fkColumnNames as string[]).includes(col.name) ? ( ) : ( )} {col.name} {col.data_type} {col.is_nullable && ( ? )}
))}
); } export const ErdTableNode = memo(ErdTableNodeComponent);