use-node-crud.ts 492 B

12345678910111213141516171819
  1. import { useNodeDataUpdate } from '@/app/components/workflow/hooks'
  2. import type { CommonNodeType } from '@/app/components/workflow/types'
  3. const useNodeCrud = <T>(id: string, data: CommonNodeType<T>) => {
  4. const { handleNodeDataUpdateWithSyncDraft } = useNodeDataUpdate()
  5. const setInputs = (newInputs: CommonNodeType<T>) => {
  6. handleNodeDataUpdateWithSyncDraft({
  7. id,
  8. data: newInputs,
  9. })
  10. }
  11. return {
  12. inputs: data,
  13. setInputs,
  14. }
  15. }
  16. export default useNodeCrud