import { useFetchFlow } from '@/hooks/flow-hooks'; import get from 'lodash/get'; import React, { MouseEventHandler, useCallback, useMemo } from 'react'; import JsonView from 'react18-json-view'; import 'react18-json-view/src/style.css'; import { useGetComponentLabelByValue, useReplaceIdWithText } from '../../hooks'; import { Popover, PopoverContent, PopoverTrigger, } from '@/components/ui/popover'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table'; import { useTranslate } from '@/hooks/common-hooks'; interface IProps extends React.PropsWithChildren { nodeId: string; name?: string; } export function NextNodePopover({ children, nodeId, name }: IProps) { const { t } = useTranslate('flow'); const { data } = useFetchFlow(); const component = useMemo(() => { return get(data, ['dsl', 'components', nodeId], {}); }, [nodeId, data]); const inputs: Array<{ component_id: string; content: string }> = get( component, ['obj', 'inputs'], [], ); const output = get(component, ['obj', 'output'], {}); const { replacedOutput } = useReplaceIdWithText(output); const stopPropagation: MouseEventHandler = useCallback((e) => { e.stopPropagation(); }, []); const getLabel = useGetComponentLabelByValue(nodeId); return ( {children}
{name} {t('operationResults')}
{t('input')}
{t('componentId')} {t('content')} {inputs.map((x, idx) => ( {getLabel(x.component_id)} {x.content} ))}
{t('output')}
); }