Fixed flow id after uploading to DB

This commit is contained in:
Lucas Oliveira 2023-06-13 11:00:09 -03:00
commit 1af07ec453
2 changed files with 9 additions and 3 deletions

View file

@ -423,8 +423,8 @@ export function TabsProvider({ children }: { children: ReactNode }) {
saveFlowToDatabase(newFlow) saveFlowToDatabase(newFlow)
.then((id) => { .then((id) => {
// Increment the ID counter. // Change the id to the new id.
setId(id); newFlow.id = id.id;
}) })
.then(() => { .then(() => {
// Add the new flow to the list of flows. // Add the new flow to the list of flows.

View file

@ -8,7 +8,7 @@ import ExtraSidebar from "../../components/ExtraSidebarComponent";
import { ReactFlowProvider } from "reactflow"; import { ReactFlowProvider } from "reactflow";
import FlowPage from "../FlowPage"; import FlowPage from "../FlowPage";
import { useContext, useEffect, useState } from "react"; 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 { TabsContext } from "../../contexts/tabsContext";
import AlertDropdown from "../../alerts/alertDropDown"; import AlertDropdown from "../../alerts/alertDropDown";
import { alertContext } from "../../contexts/alertContext"; import { alertContext } from "../../contexts/alertContext";
@ -29,6 +29,7 @@ export default function HomePage() {
setTabId, setTabId,
downloadFlows, downloadFlows,
uploadFlows, uploadFlows,
addFlow,
} = useContext(TabsContext); } = useContext(TabsContext);
useEffect(() => { useEffect(() => {
setTabId(""); setTabId("");
@ -52,11 +53,16 @@ export default function HomePage() {
<Upload className="w-4 mr-2" /> <Upload className="w-4 mr-2" />
Upload Database Upload Database
</Button> </Button>
<Button variant="outline" onClick={() => {addFlow();}}>
<Plus className="w-4 mr-2" />
Add Flow
</Button>
</div> </div>
</div> </div>
<div className="w-full p-4 grid gap-4 md:grid-cols-2 lg:grid-cols-4"> <div className="w-full p-4 grid gap-4 md:grid-cols-2 lg:grid-cols-4">
{flows.map((flow, idx) => ( {flows.map((flow, idx) => (
<CardComponent <CardComponent
key={idx}
flow={flow} flow={flow}
id={flow.id} id={flow.id}
/> />