Refactor: Remove isBuilt from zustand store

This commit is contained in:
igorrCarvalho 2024-01-23 18:45:01 -03:00
commit e90fdd00e7
3 changed files with 2 additions and 14 deletions

View file

@ -37,7 +37,6 @@ export default function ExtraSidebar(): JSX.Element {
const hasApiKey = useStoreStore((state) => state.hasApiKey); const hasApiKey = useStoreStore((state) => state.hasApiKey);
const validApiKey = useStoreStore((state) => state.validApiKey); const validApiKey = useStoreStore((state) => state.validApiKey);
const isBuilt = useFlowStore((state) => state.isBuilt);
const setErrorData = useAlertStore((state) => state.setErrorData); const setErrorData = useAlertStore((state) => state.setErrorData);
const [dataFilter, setFilterData] = useState(data); const [dataFilter, setFilterData] = useState(data);
const [search, setSearch] = useState(""); const [search, setSearch] = useState("");
@ -281,14 +280,13 @@ export default function ExtraSidebar(): JSX.Element {
{currentFlow && currentFlow.data && ( {currentFlow && currentFlow.data && (
<ApiModal flow={currentFlow}> <ApiModal flow={currentFlow}>
<button <button
className={"w-full " + (!isBuilt ? "button-disable" : "")} className={"w-full "}
> >
<div className={classNames("extra-side-bar-buttons")}> <div className={classNames("extra-side-bar-buttons")}>
<IconComponent <IconComponent
name="Code2" name="Code2"
className={ className={
"side-bar-button-size" + "side-bar-button-size"
(isBuilt ? " " : " extra-side-bar-save-disable")
} }
/> />
</div> </div>

View file

@ -36,7 +36,6 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
edges: [], edges: [],
isBuilding: false, isBuilding: false,
isPending: false, isPending: false,
isBuilt: false,
reactFlowInstance: null, reactFlowInstance: null,
lastCopiedSelection: null, lastCopiedSelection: null,
flowPool: {}, flowPool: {},
@ -66,16 +65,12 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
nodes, nodes,
edges, edges,
flowState: undefined, flowState: undefined,
isBuilt: false,
}); });
get().reactFlowInstance!.setViewport(viewport); get().reactFlowInstance!.setViewport(viewport);
}, },
setIsBuilding: (isBuilding) => { setIsBuilding: (isBuilding) => {
set({ isBuilding }); set({ isBuilding });
}, },
setIsBuilt: (isBuilt) => {
set({ isBuilt });
},
setFlowState: (flowState) => { setFlowState: (flowState) => {
const newFlowState = const newFlowState =
typeof flowState === "function" ? flowState(get().flowState) : flowState; typeof flowState === "function" ? flowState(get().flowState) : flowState;
@ -107,7 +102,6 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
edges: newEdges, edges: newEdges,
nodes: newChange, nodes: newChange,
flowState: undefined, flowState: undefined,
isBuilt: false,
}); });
const flowsManager = useFlowsManagerStore.getState(); const flowsManager = useFlowsManagerStore.getState();
@ -124,7 +118,6 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
set({ set({
edges: newChange, edges: newChange,
flowState: undefined, flowState: undefined,
isBuilt: false,
}); });
const flowsManager = useFlowsManagerStore.getState(); const flowsManager = useFlowsManagerStore.getState();
@ -286,7 +279,6 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
nodes: [], nodes: [],
edges: [], edges: [],
flowState: undefined, flowState: undefined,
isBuilt: false,
getFilterEdge: [], getFilterEdge: [],
}); });
}, },

View file

@ -78,8 +78,6 @@ export type FlowStoreType = {
setLastCopiedSelection: ( setLastCopiedSelection: (
newSelection: { nodes: any; edges: any } | null newSelection: { nodes: any; edges: any } | null
) => void; ) => void;
isBuilt: boolean;
setIsBuilt: (isBuilt: boolean) => void;
cleanFlow: () => void; cleanFlow: () => void;
setFilterEdge: (newState) => void; setFilterEdge: (newState) => void;
getFilterEdge: any[]; getFilterEdge: any[];