Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

743 B
Raw Blame
import { useCallback, useState } from 'react'
import { useSubmitHumanInputForm } from '@/service/use-share'

export const useFormSubmit = (token: string) => {
  const [success, setSuccess] = useState(false)
  const { mutate: submitForm, isPending: isSubmitting } = useSubmitHumanInputForm()

  const submit = useCallback(
    (inputs: Record<string, unknown> | undefined, actionID: string) => {
      submitForm(
        {
          token,
          data: {
            inputs: inputs || {},
            action: actionID,
          },
        },
        {
          onSuccess: () => {
            setSuccess(true)
          },
        },
      )
    },
    [submitForm, token],
  )

  return {
    isSubmitting,
    submit,
    success,
  }
}