From 1af07ec45315f6708e8029002f746b275b6cbed3 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Tue, 13 Jun 2023 11:00:09 -0300 Subject: [PATCH] Fixed flow id after uploading to DB --- src/frontend/src/contexts/tabsContext.tsx | 4 ++-- src/frontend/src/pages/MainPage/index.tsx | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/contexts/tabsContext.tsx b/src/frontend/src/contexts/tabsContext.tsx index 749ca348c..fc04b98fa 100644 --- a/src/frontend/src/contexts/tabsContext.tsx +++ b/src/frontend/src/contexts/tabsContext.tsx @@ -423,8 +423,8 @@ export function TabsProvider({ children }: { children: ReactNode }) { saveFlowToDatabase(newFlow) .then((id) => { - // Increment the ID counter. - setId(id); + // Change the id to the new id. + newFlow.id = id.id; }) .then(() => { // Add the new flow to the list of flows. diff --git a/src/frontend/src/pages/MainPage/index.tsx b/src/frontend/src/pages/MainPage/index.tsx index d6c10e291..4abafdfbd 100644 --- a/src/frontend/src/pages/MainPage/index.tsx +++ b/src/frontend/src/pages/MainPage/index.tsx @@ -8,7 +8,7 @@ import ExtraSidebar from "../../components/ExtraSidebarComponent"; import { ReactFlowProvider } from "reactflow"; import FlowPage from "../FlowPage"; import { useContext, useEffect, useState } from "react"; -import { SunIcon, MoonIcon, BellIcon, GithubIcon, Download, Upload } from "lucide-react"; +import { SunIcon, MoonIcon, BellIcon, GithubIcon, Download, Upload, Plus } from "lucide-react"; import { TabsContext } from "../../contexts/tabsContext"; import AlertDropdown from "../../alerts/alertDropDown"; import { alertContext } from "../../contexts/alertContext"; @@ -29,6 +29,7 @@ export default function HomePage() { setTabId, downloadFlows, uploadFlows, + addFlow, } = useContext(TabsContext); useEffect(() => { setTabId(""); @@ -52,11 +53,16 @@ export default function HomePage() { Upload Database +
{flows.map((flow, idx) => (