From bf678e5f8670fa00f85297628708535c88754a6e Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Mon, 20 Feb 2023 16:48:15 -0300 Subject: [PATCH] tabs context created --- space_flow/src/contexts/tabsContext.tsx | 41 +++++++++++++++++++ .../src/pages/FlowPage/flowManager/index.tsx | 9 ++++ 2 files changed, 50 insertions(+) create mode 100644 space_flow/src/contexts/tabsContext.tsx diff --git a/space_flow/src/contexts/tabsContext.tsx b/space_flow/src/contexts/tabsContext.tsx new file mode 100644 index 000000000..35ab53190 --- /dev/null +++ b/space_flow/src/contexts/tabsContext.tsx @@ -0,0 +1,41 @@ +import { createContext, useState } from "react"; + +type flow={name:string,id:string,flow:any} + +type TabsContextType={ + tabIndex:number; + setTabIndex:(index:number)=>void; + flows:Array + removeFlow:(index:number)=>void; + addFlow:(newFlow:flow)=>void; +} + +const TabsContextInitialValue = { + tabIndex : 0, + setTabIndex:(index:number)=>{}, + flows:[], + removeFlow:(index:number)=>{}, + addFlow:(newFlow:flow)=>{} + +} + +export const TabsContext = createContext(TabsContextInitialValue) + +export function TabsProvider({children}){ + const [tabIndex,setTabIndex] = useState(0) + const [flows,setFlows] = useState>([]) + function removeFlow(index:number){ + let newFlows = flows + newFlows.splice(index) + setFlows(newFlows) + } + function addFlow(newFlow:flow){ + setFlows([...flows,newFlow]) + } + + return( + + {children} + + ) +} \ No newline at end of file diff --git a/space_flow/src/pages/FlowPage/flowManager/index.tsx b/space_flow/src/pages/FlowPage/flowManager/index.tsx index 7d615833a..6979f8963 100644 --- a/space_flow/src/pages/FlowPage/flowManager/index.tsx +++ b/space_flow/src/pages/FlowPage/flowManager/index.tsx @@ -47,3 +47,12 @@ function App() { ); } +/* +tabs initial logic +TO DO +- create a context with the tabs control so tabs can be changed inside the flow +- create a logic to save tabs and flow state for multitabs and each flow inside each tab +- think about the save logic and how to implement it the best way +- define what each tab will need to show and how it will be displayed + +*/