import { IBeginNode } from '@/interfaces/database/flow'; import { cn } from '@/lib/utils'; import { NodeProps, Position } from '@xyflow/react'; import get from 'lodash/get'; import { memo } from 'react'; import { useTranslation } from 'react-i18next'; import { BeginQueryType, BeginQueryTypeIconMap, NodeHandleId, Operator, } from '../../constant'; import { BeginQuery } from '../../interface'; import OperatorIcon from '../../operator-icon'; import { LabelCard } from './card'; import { CommonHandle } from './handle'; import { RightHandleStyle } from './handle-icon'; import styles from './index.less'; import { NodeWrapper } from './node-wrapper'; // TODO: do not allow other nodes to connect to this node function InnerBeginNode({ data, id, selected }: NodeProps) { const { t } = useTranslation(); const inputs: Record = get(data, 'form.inputs', {}); return (
{t(`flow.begin`)}
{Object.entries(inputs).map(([key, val], idx) => { const Icon = BeginQueryTypeIconMap[val.type as BeginQueryType]; return ( {val.name} {val.optional ? 'Yes' : 'No'} ); })}
); } export const BeginNode = memo(InnerBeginNode);