fixed header to new logic

This commit is contained in:
Lucas Oliveira 2023-06-12 19:23:34 -03:00
commit b45966051a
3 changed files with 13 additions and 13 deletions

View file

@ -135,7 +135,7 @@ export default function App() {
> >
{flows.length !== 0 && ( {flows.length !== 0 && (
<> <>
{/* <Header /> */} <Header />
<Router /> <Router />
</> </>
)} )}

View file

@ -15,8 +15,8 @@ export default function Header(){
flows, flows,
addFlow, addFlow,
removeFlow, removeFlow,
tabIndex, tabId,
setTabIndex, setTabId,
uploadFlow, uploadFlow,
downloadFlow, downloadFlow,
} = useContext(TabsContext); } = useContext(TabsContext);
@ -41,7 +41,7 @@ export default function Header(){
setRename={setRename} setRename={setRename}
rename={rename} rename={rename}
flows={flows} flows={flows}
tabIndex={tabIndex} tabId={tabId}
/> />
<div className="flex"> <div className="flex">
<Button>Explore</Button> <Button>Explore</Button>

View file

@ -20,8 +20,8 @@ import ApiModal from "../../../../modals/ApiModal";
import { alertContext } from "../../../../contexts/alertContext"; import { alertContext } from "../../../../contexts/alertContext";
import { updateFlowInDatabase } from "../../../../controllers/API"; import { updateFlowInDatabase } from "../../../../controllers/API";
export const MenuBar = ({ activeTab, setRename, rename, flows, tabIndex }) => { export const MenuBar = ({ activeTab, setRename, rename, flows, tabId }) => {
const { updateFlow, setTabIndex, addFlow } = useContext(TabsContext); const { updateFlow, setTabId, addFlow } = useContext(TabsContext);
const { setErrorData } = useContext(alertContext); const { setErrorData } = useContext(alertContext);
const { openPopUp } = useContext(PopUpContext); const { openPopUp } = useContext(PopUpContext);
@ -42,7 +42,7 @@ export const MenuBar = ({ activeTab, setRename, rename, flows, tabIndex }) => {
setErrorData(err); setErrorData(err);
} }
} }
let current_flow = flows[tabIndex]; let current_flow = flows.find((flow) => flow.id === tabId);
// robot emoji // robot emoji
let emoji = current_flow.style?.emoji || "🤖"; let emoji = current_flow.style?.emoji || "🤖";
@ -63,10 +63,10 @@ export const MenuBar = ({ activeTab, setRename, rename, flows, tabIndex }) => {
{emoji} {emoji}
</span> </span>
<RenameLabel <RenameLabel
value={flows[tabIndex].name} value={current_flow.name}
setValue={(value) => { setValue={(value) => {
if (value !== "") { if (value !== "") {
let newFlow = _.cloneDeep(flows[tabIndex]); let newFlow = _.cloneDeep(current_flow);
newFlow.name = value; newFlow.name = value;
updateFlow(newFlow); updateFlow(newFlow);
} }
@ -97,7 +97,7 @@ export const MenuBar = ({ activeTab, setRename, rename, flows, tabIndex }) => {
</MenubarItem> </MenubarItem>
<MenubarItem <MenubarItem
onClick={() => { onClick={() => {
openPopUp(<ApiModal flow={flows[tabIndex]} />); openPopUp(<ApiModal flow={current_flow} />);
}} }}
> >
<Code className="w-4 h-4 mr-2" /> <Code className="w-4 h-4 mr-2" />
@ -110,7 +110,7 @@ export const MenuBar = ({ activeTab, setRename, rename, flows, tabIndex }) => {
<MenubarContent> <MenubarContent>
<MenubarItem <MenubarItem
onClick={() => { onClick={() => {
handleSaveFlow(flows[tabIndex]); handleSaveFlow(current_flow);
}} }}
> >
<Save className="w-4 h-4 mr-2" /> <Save className="w-4 h-4 mr-2" />
@ -130,9 +130,9 @@ export const MenuBar = ({ activeTab, setRename, rename, flows, tabIndex }) => {
<MenubarTrigger>Flows</MenubarTrigger> <MenubarTrigger>Flows</MenubarTrigger>
<MenubarContent> <MenubarContent>
<MenubarRadioGroup <MenubarRadioGroup
value={tabIndex.toString()} value={tabId}
onValueChange={(value) => { onValueChange={(value) => {
setTabIndex(parseInt(value)); setTabId(value);
}} }}
> >
{flows.map((flow, idx) => { {flows.map((flow, idx) => {