Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

728 B
Raw Blame
import { JSONSchema } from '@/components/jsonjoy-builder';
import { useSetModalState } from '@/hooks/common-hooks';
import { useCallback } from 'react';
import { UseFormReturn } from 'react-hook-form';

export function useShowSchemaDialog(form: UseFormReturn<any>) {
  const {
    visible: schemaDialogVisible,
    showModal: showSchemaDialog,
    hideModal: hideSchemaDialog,
  } = useSetModalState();

  const handleSchemaDialogOk = useCallback(
    (values: JSONSchema) => {
      // Sync data to canvas
      form.setValue('schema', values);
      hideSchemaDialog();
    },
    [form, hideSchemaDialog],
  );

  return {
    schemaDialogVisible,
    showSchemaDialog,
    hideSchemaDialog,
    handleSchemaDialogOk,
  };
}