### What problem does this PR solve? Feat: Initialize the data pipeline canvas. #9869 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
20 lines
448 B
TypeScript
20 lines
448 B
TypeScript
import { RAGFlowNodeType } from '@/interfaces/database/flow';
|
|
import { isEmpty } from 'lodash';
|
|
import { useMemo } from 'react';
|
|
|
|
export function useFormValues(
|
|
defaultValues: Record<string, any>,
|
|
node?: RAGFlowNodeType,
|
|
) {
|
|
const values = useMemo(() => {
|
|
const formData = node?.data?.form;
|
|
|
|
if (isEmpty(formData)) {
|
|
return defaultValues;
|
|
}
|
|
|
|
return formData;
|
|
}, [defaultValues, node?.data?.form]);
|
|
|
|
return values;
|
|
}
|