use-config.ts 739 B

123456789101112131415161718192021222324252627
  1. import useVarList from '../_base/hooks/use-var-list'
  2. import type { EndNodeType } from './types'
  3. import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
  4. import {
  5. useNodesReadOnly,
  6. } from '@/app/components/workflow/hooks'
  7. const useConfig = (id: string, payload: EndNodeType) => {
  8. const { nodesReadOnly: readOnly } = useNodesReadOnly()
  9. const { inputs, setInputs } = useNodeCrud<EndNodeType>(id, payload)
  10. const { handleVarListChange, handleAddVariable } = useVarList<EndNodeType>({
  11. inputs,
  12. setInputs: (newInputs) => {
  13. setInputs(newInputs)
  14. },
  15. varKey: 'outputs',
  16. })
  17. return {
  18. readOnly,
  19. inputs,
  20. handleVarListChange,
  21. handleAddVariable,
  22. }
  23. }
  24. export default useConfig