From bfc8ad8e307183d913e9624edc0ddc70e9937d59 Mon Sep 17 00:00:00 2001 From: igorrCarvalho Date: Wed, 30 Aug 2023 14:20:10 -0300 Subject: [PATCH] feat: Add uploadFlow function to import from JSON button --- .../DropdownButtonComponent/index.tsx | 26 +++++++++++++------ src/frontend/src/pages/MainPage/index.tsx | 7 ++--- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/frontend/src/components/DropdownButtonComponent/index.tsx b/src/frontend/src/components/DropdownButtonComponent/index.tsx index 71e02c43b..b9fffbb00 100644 --- a/src/frontend/src/components/DropdownButtonComponent/index.tsx +++ b/src/frontend/src/components/DropdownButtonComponent/index.tsx @@ -1,14 +1,15 @@ -import { useState } from "react"; +import { Fragment, useState } from "react"; import IconComponent from "../genericIconComponent"; import { Button } from "../ui/button"; import { dropdownButtonPropsType } from "../../types/components"; +import { Transition } from "@headlessui/react"; export default function DropdownButton({ firstButtonName, onFirstBtnClick, options, }: dropdownButtonPropsType): JSX.Element { - const [showOptions, setShowOptions] = useState(false); + const [showOptions, setShowOptions] = useState(false); return (
@@ -36,20 +37,29 @@ export default function DropdownButton({ )}
- {showOptions && ( -
- {options.map(({ name, onBtnClick }) => ( + +
+ {options.map(({ name, onBtnClick }, index) => ( ))}
- )} +
); } diff --git a/src/frontend/src/pages/MainPage/index.tsx b/src/frontend/src/pages/MainPage/index.tsx index bdcf76c19..f3fe68a6c 100644 --- a/src/frontend/src/pages/MainPage/index.tsx +++ b/src/frontend/src/pages/MainPage/index.tsx @@ -8,8 +8,9 @@ import { USER_PROJECTS_HEADER } from "../../constants/constants"; import { TabsContext } from "../../contexts/tabsContext"; import DropdownButton from "../../components/DropdownButtonComponent"; export default function HomePage(): JSX.Element { - const { flows, setTabId, downloadFlows, uploadFlows, addFlow, removeFlow } = + const { flows, setTabId, downloadFlows, uploadFlows, addFlow, removeFlow, uploadFlow } = useContext(TabsContext); + const dropdownOptions = [{name: "Import from JSON", onBtnClick: () => uploadFlow(true)}] // Set a null id useEffect(() => { @@ -53,12 +54,12 @@ export default function HomePage(): JSX.Element { navigate("/flow/" + id); }); }} - options={[{name: "Import from JSON", onBtnClick: () => console.log('imported')}]} + options={dropdownOptions} /> - Manage your personal projects. Download or upload your collection. + Manage your personal projects. Download or upload your collection.
{flows.map((flow, idx) => (