Commit a36a2a10 authored by Joel's avatar Joel

feat: handleupdate logic

parent 474c7865
import { useWorkflow } from '@/app/components/workflow/hooks'
import type { CommonNodeType } from '@/app/components/workflow/types'
const useNodeCrud = <T>(id: string, data: CommonNodeType<T>) => {
const { handleNodeDataUpdate } = useWorkflow()
const setInputs = (newInputs: CommonNodeType<T>) => {
handleNodeDataUpdate({
id,
data: newInputs,
})
}
return {
inputs: data,
setInputs,
}
}
export default useNodeCrud
...@@ -3,17 +3,10 @@ import produce from 'immer' ...@@ -3,17 +3,10 @@ import produce from 'immer'
import { useBoolean } from 'ahooks' import { useBoolean } from 'ahooks'
import type { StartNodeType } from './types' import type { StartNodeType } from './types'
import type { InputVar } from '@/app/components/workflow/types' import type { InputVar } from '@/app/components/workflow/types'
import { useWorkflow } from '@/app/components/workflow/hooks' import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
const useConfig = (id: string, payload: StartNodeType) => { const useConfig = (id: string, payload: StartNodeType) => {
const { handleNodeDataUpdate } = useWorkflow() const { inputs, setInputs } = useNodeCrud<StartNodeType>(id, payload)
// const [inputs, setInputs] = useState<StartNodeType>(initInputs)
const inputs = payload
const setInputs = (newInputs: StartNodeType) => {
handleNodeDataUpdate({
id,
data: newInputs,
})
}
const [isShowAddVarModal, { const [isShowAddVarModal, {
setTrue: showAddVarModal, setTrue: showAddVarModal,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment