2
0

Add Graph draft

This commit is contained in:
Baptiste Arnaud
2021-12-16 10:43:49 +01:00
parent 0f85d2cd94
commit da9459edf3
35 changed files with 1938 additions and 116 deletions

View File

@ -0,0 +1,39 @@
import { Step, StepType } from 'bot-engine'
import {
createContext,
Dispatch,
ReactNode,
SetStateAction,
useContext,
useState,
} from 'react'
const dndContext = createContext<{
draggedStepType?: StepType
setDraggedStepType: Dispatch<SetStateAction<StepType | undefined>>
draggedStep?: Step
setDraggedStep: Dispatch<SetStateAction<Step | undefined>>
}>({
setDraggedStep: () => console.log("I'm not implemented"),
setDraggedStepType: () => console.log("I'm not implemented"),
})
export const DndContext = ({ children }: { children: ReactNode }) => {
const [draggedStep, setDraggedStep] = useState<Step | undefined>()
const [draggedStepType, setDraggedStepType] = useState<StepType | undefined>()
return (
<dndContext.Provider
value={{
draggedStep,
setDraggedStep,
draggedStepType,
setDraggedStepType,
}}
>
{children}
</dndContext.Provider>
)
}
export const useDnd = () => useContext(dndContext)