updated type type context, need to change place where call api

This commit is contained in:
anovazzi1 2023-04-24 18:40:24 -03:00
commit a8f2d69f9a
2 changed files with 10 additions and 1 deletions

View file

@ -12,6 +12,8 @@ const initialValue:typesContextType = {
setTypes: () => {},
templates: {},
setTemplates: () => {},
data:{},
setData:()=>{}
};
export const typesContext = createContext<typesContextType>(initialValue);
@ -20,6 +22,7 @@ export function TypesProvider({ children }:{children:ReactNode}) {
const [types, setTypes] = useState({});
const [reactFlowInstance, setReactFlowInstance] = useState(null);
const [templates, setTemplates] = useState({});
const [data, setData] = useState({});
function deleteNode(idx:string) {
reactFlowInstance.setNodes(
reactFlowInstance.getNodes().filter((n:Node) => n.id !== idx)
@ -35,7 +38,9 @@ export function TypesProvider({ children }:{children:ReactNode}) {
setReactFlowInstance,
deleteNode,
setTemplates,
templates
templates,
data,
setData
}}
>
{children}

View file

@ -2,6 +2,8 @@ import { ReactFlowInstance } from "reactflow";
const types:{[char: string]: string}={};
const template:{[char: string]: string}={}
const data:{[char: string]: string}={}
export type typesContextType = {
reactFlowInstance: ReactFlowInstance|null;
@ -11,4 +13,6 @@ export type typesContextType = {
setTypes: (newState: {}) => void;
templates: typeof template;
setTemplates: (newState: {}) => void;
data: typeof data;
setData: (newState: {}) => void;
};