mirror of
https://github.com/langgenius/dify.git
synced 2025-07-15 13:14:44 +00:00
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import React from 'react'
|
|
import { generateZodSchema } from '@/app/components/base/form/form-scenarios/base/utils'
|
|
import { useInputVariables } from './hooks'
|
|
import Form from './form'
|
|
import Actions from './actions'
|
|
import { useConfigurations, useInitialData } from '@/app/components/rag-pipeline/hooks/use-input-fields'
|
|
|
|
type ProcessDocumentsProps = {
|
|
dataSourceNodeId: string
|
|
ref: React.RefObject<any>
|
|
onProcess: () => void
|
|
onPreview: () => void
|
|
onSubmit: (data: Record<string, any>) => void
|
|
onBack: () => void
|
|
}
|
|
|
|
const ProcessDocuments = ({
|
|
dataSourceNodeId,
|
|
onProcess,
|
|
onPreview,
|
|
onSubmit,
|
|
onBack,
|
|
ref,
|
|
}: ProcessDocumentsProps) => {
|
|
const { isFetchingParams, paramsConfig } = useInputVariables(dataSourceNodeId)
|
|
const initialData = useInitialData(paramsConfig?.variables || [])
|
|
const configurations = useConfigurations(paramsConfig?.variables || [])
|
|
const schema = generateZodSchema(configurations)
|
|
|
|
return (
|
|
<div className='flex flex-col gap-y-4 pt-4'>
|
|
<Form
|
|
ref={ref}
|
|
initialData={initialData}
|
|
configurations={configurations}
|
|
schema={schema}
|
|
onSubmit={onSubmit}
|
|
onPreview={onPreview}
|
|
/>
|
|
<Actions runDisabled={isFetchingParams} onBack={onBack} onProcess={onProcess} />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default React.memo(ProcessDocuments)
|