mirror of
https://github.com/langgenius/dify.git
synced 2026-02-20 01:44:42 +08:00
fix: initialize requiredInputs state to an empty object and improve requestParamsObj handling in useSingleRunFormParams hook
This commit is contained in:
parent
757b1c7190
commit
307f0d5827
@ -30,7 +30,7 @@ const useSingleRunFormParams = ({
|
||||
const { inputs } = useNodeCrud<HumanInputNodeType>(id, payload)
|
||||
const [showGeneratedForm, setShowGeneratedForm] = useState(false)
|
||||
const [formData, setFormData] = useState<HumanInputFormData | null>(null)
|
||||
const [requiredInputs, setRequiredInputs] = useState<Record<string, any>>()
|
||||
const [requiredInputs, setRequiredInputs] = useState<Record<string, any>>({})
|
||||
const generatedInputs = useMemo(() => {
|
||||
const placeholderInputs = inputs.inputs.reduce((acc, input) => {
|
||||
if (input.placeholder.type === 'variable') {
|
||||
@ -80,16 +80,13 @@ const useSingleRunFormParams = ({
|
||||
const handleFetchFormContent = useCallback(async (inputs: Record<string, any>) => {
|
||||
if (!fetchURL)
|
||||
return null
|
||||
let requestParamsObj
|
||||
let requestParamsObj: Record<string, any> = {}
|
||||
Object.keys(inputs).forEach((key) => {
|
||||
if (inputs[key] === undefined) {
|
||||
delete inputs[key]
|
||||
}
|
||||
})
|
||||
requestParamsObj = { ...inputs }
|
||||
if (Object.keys(requestParamsObj).length === 0) {
|
||||
requestParamsObj = undefined
|
||||
}
|
||||
const data = await fetchHumanInputNodeStepRunForm(fetchURL, { inputs: requestParamsObj! })
|
||||
setFormData(data)
|
||||
setRequiredInputs(requestParamsObj)
|
||||
|
||||
@ -3435,7 +3435,7 @@
|
||||
},
|
||||
"app/components/workflow/nodes/human-input/hooks/use-single-run-form-params.ts": {
|
||||
"ts/no-explicit-any": {
|
||||
"count": 6
|
||||
"count": 7
|
||||
}
|
||||
},
|
||||
"app/components/workflow/nodes/if-else/components/condition-list/condition-input.tsx": {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user