From 1868540a101b87aaaef39aa3d240d7227ffd3fd5 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 14 Sep 2023 20:14:37 -0300 Subject: [PATCH] fix(menuBar): remove unnecessary parameter in addFlow function call to improve code readability fix(tabsContext): change parameter order in addFlow function signature to match the implementation fix(tabsContext): change parameter order in addFlow function call to match the implementation fix(communityPage): change parameter order in addFlow function call to match the implementation fix(mainPage): remove unnecessary parameter in addFlow function call to improve code readability fix(tabs): change parameter order in addFlow function signature to match the implementation --- .../headerComponent/components/menuBar/index.tsx | 2 +- src/frontend/src/contexts/tabsContext.tsx | 8 ++++---- src/frontend/src/pages/CommunityPage/index.tsx | 2 +- src/frontend/src/pages/MainPage/index.tsx | 2 +- src/frontend/src/types/tabs/index.ts | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/frontend/src/components/headerComponent/components/menuBar/index.tsx b/src/frontend/src/components/headerComponent/components/menuBar/index.tsx index 3b3611f16..676dccabe 100644 --- a/src/frontend/src/components/headerComponent/components/menuBar/index.tsx +++ b/src/frontend/src/components/headerComponent/components/menuBar/index.tsx @@ -26,7 +26,7 @@ export const MenuBar = ({ flows, tabId }: menuBarPropsType): JSX.Element => { function handleAddFlow() { try { - addFlow(undefined, true).then((id) => { + addFlow(true).then((id) => { navigate("/flow/" + id); }); // saveFlowStyleInDataBase(); diff --git a/src/frontend/src/contexts/tabsContext.tsx b/src/frontend/src/contexts/tabsContext.tsx index 05d0d0dad..9b824feff 100644 --- a/src/frontend/src/contexts/tabsContext.tsx +++ b/src/frontend/src/contexts/tabsContext.tsx @@ -52,7 +52,7 @@ const TabsContextInitialValue: TabsContextType = { isLoading: true, flows: [], removeFlow: (id: string) => {}, - addFlow: async (flowData?: any) => "", + addFlow: async (newProject:boolean,flowData?: FlowType) => "", updateFlow: (newFlow: FlowType) => {}, incrementNodeId: () => uid(), downloadFlow: (flow: FlowType) => {}, @@ -324,7 +324,7 @@ export function TabsProvider({ children }: { children: ReactNode }) { // parse the text into a JSON object let flow: FlowType = JSON.parse(text); - id = await addFlow(flow, newProject); + id = await addFlow(newProject,flow); } else { // create a file input const input = document.createElement("input"); @@ -339,7 +339,7 @@ export function TabsProvider({ children }: { children: ReactNode }) { const currentfile = (e.target as HTMLInputElement).files![0]; let text = await currentfile.text(); let flow: FlowType = JSON.parse(text); - const flowId = await addFlow(flow, newProject); + const flowId = await addFlow(newProject,flow); resolve(flowId); } }; @@ -485,8 +485,8 @@ export function TabsProvider({ children }: { children: ReactNode }) { } const addFlow = async ( + newProject?: Boolean, flow?: FlowType, - newProject?: Boolean ): Promise => { if (newProject) { let flowData = extractDataFromFlow(flow!); diff --git a/src/frontend/src/pages/CommunityPage/index.tsx b/src/frontend/src/pages/CommunityPage/index.tsx index c96bbdaf4..227bba325 100644 --- a/src/frontend/src/pages/CommunityPage/index.tsx +++ b/src/frontend/src/pages/CommunityPage/index.tsx @@ -86,7 +86,7 @@ export default function CommunityPage(): JSX.Element { size="sm" className="whitespace-nowrap " onClick={() => { - addFlow(flow, true).then((id) => { + addFlow(true,flow).then((id) => { navigate("/flow/" + id); }); }} diff --git a/src/frontend/src/pages/MainPage/index.tsx b/src/frontend/src/pages/MainPage/index.tsx index 92be2525a..9f86d1be3 100644 --- a/src/frontend/src/pages/MainPage/index.tsx +++ b/src/frontend/src/pages/MainPage/index.tsx @@ -71,7 +71,7 @@ export default function HomePage(): JSX.Element { { - addFlow(undefined, true).then((id) => { + addFlow(true).then((id) => { navigate("/flow/" + id); }); }} diff --git a/src/frontend/src/types/tabs/index.ts b/src/frontend/src/types/tabs/index.ts index 4c5b99dd7..3eae14925 100644 --- a/src/frontend/src/types/tabs/index.ts +++ b/src/frontend/src/types/tabs/index.ts @@ -10,8 +10,8 @@ export type TabsContextType = { flows: Array; removeFlow: (id: string) => void; addFlow: ( - flow?: FlowType, - newProject?: Boolean + newProject: boolean, + flow?: FlowType ) => Promise; updateFlow: (newFlow: FlowType) => void; incrementNodeId: () => string;