updated type type context, need to change place where call api
This commit is contained in:
parent
9e76c50f09
commit
a8f2d69f9a
2 changed files with 10 additions and 1 deletions
|
|
@ -12,6 +12,8 @@ const initialValue:typesContextType = {
|
||||||
setTypes: () => {},
|
setTypes: () => {},
|
||||||
templates: {},
|
templates: {},
|
||||||
setTemplates: () => {},
|
setTemplates: () => {},
|
||||||
|
data:{},
|
||||||
|
setData:()=>{}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const typesContext = createContext<typesContextType>(initialValue);
|
export const typesContext = createContext<typesContextType>(initialValue);
|
||||||
|
|
@ -20,6 +22,7 @@ export function TypesProvider({ children }:{children:ReactNode}) {
|
||||||
const [types, setTypes] = useState({});
|
const [types, setTypes] = useState({});
|
||||||
const [reactFlowInstance, setReactFlowInstance] = useState(null);
|
const [reactFlowInstance, setReactFlowInstance] = useState(null);
|
||||||
const [templates, setTemplates] = useState({});
|
const [templates, setTemplates] = useState({});
|
||||||
|
const [data, setData] = useState({});
|
||||||
function deleteNode(idx:string) {
|
function deleteNode(idx:string) {
|
||||||
reactFlowInstance.setNodes(
|
reactFlowInstance.setNodes(
|
||||||
reactFlowInstance.getNodes().filter((n:Node) => n.id !== idx)
|
reactFlowInstance.getNodes().filter((n:Node) => n.id !== idx)
|
||||||
|
|
@ -35,7 +38,9 @@ export function TypesProvider({ children }:{children:ReactNode}) {
|
||||||
setReactFlowInstance,
|
setReactFlowInstance,
|
||||||
deleteNode,
|
deleteNode,
|
||||||
setTemplates,
|
setTemplates,
|
||||||
templates
|
templates,
|
||||||
|
data,
|
||||||
|
setData
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ import { ReactFlowInstance } from "reactflow";
|
||||||
|
|
||||||
const types:{[char: string]: string}={};
|
const types:{[char: string]: string}={};
|
||||||
const template:{[char: string]: string}={}
|
const template:{[char: string]: string}={}
|
||||||
|
const data:{[char: string]: string}={}
|
||||||
|
|
||||||
|
|
||||||
export type typesContextType = {
|
export type typesContextType = {
|
||||||
reactFlowInstance: ReactFlowInstance|null;
|
reactFlowInstance: ReactFlowInstance|null;
|
||||||
|
|
@ -11,4 +13,6 @@ export type typesContextType = {
|
||||||
setTypes: (newState: {}) => void;
|
setTypes: (newState: {}) => void;
|
||||||
templates: typeof template;
|
templates: typeof template;
|
||||||
setTemplates: (newState: {}) => void;
|
setTemplates: (newState: {}) => void;
|
||||||
|
data: typeof data;
|
||||||
|
setData: (newState: {}) => void;
|
||||||
};
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue