From 4a1c9f8daeefb300c070277e4b9bd9853af3808a Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Mon, 5 Feb 2024 18:30:41 -0300 Subject: [PATCH] Add global variable functionality and display on Global Variables page --- .../src/components/inputComponent/index.tsx | 110 +++++++++--------- .../components/addNewVariableButton.tsx | 8 +- .../src/pages/globalVariablesPage/index.tsx | 15 ++- 3 files changed, 71 insertions(+), 62 deletions(-) diff --git a/src/frontend/src/components/inputComponent/index.tsx b/src/frontend/src/components/inputComponent/index.tsx index 720b41eb3..2762c5d21 100644 --- a/src/frontend/src/components/inputComponent/index.tsx +++ b/src/frontend/src/components/inputComponent/index.tsx @@ -7,7 +7,6 @@ import { classNames } from "../../utils/utils"; import IconComponent from "../genericIconComponent"; import { Input } from "../ui/input"; - export default function InputComponent({ autoFocus = false, onBlur, @@ -27,8 +26,13 @@ export default function InputComponent({ const [pwdVisible, setPwdVisible] = useState(false); const refInput = useRef(null); const [showOptions, setShowOptions] = useState(false); - const [filteredOpts, setFilteredValue] = useState(["key", "key2", "key3", "key4", "key5"]); - + const [filteredOpts, setFilteredValue] = useState([ + "key", + "key2", + "key3", + "key4", + "key5", + ]); // Clear component state useEffect(() => { @@ -37,16 +41,15 @@ export default function InputComponent({ } }, [disabled]); - - const filteredOptions = filteredOpts.filter((option) => option.toLowerCase().includes(value.toLowerCase())) - + const filteredOptions = filteredOpts.filter((option) => + option.toLowerCase().includes(value.toLowerCase()) + ); function onInputLostFocus(event): void { if (onBlur) onBlur(event); setShowOptions(false); } - return (
{isForm ? ( @@ -136,59 +139,54 @@ export default function InputComponent({ false ? "mb-2 w-[250px]" : "absolute w-full" )} > - {filteredOptions.map( - (option, id) => ( - - classNames( - active ? " bg-accent" : "", - editNode - ? "dropdown-component-false-option" - : "dropdown-component-true-option", - " hover:bg-accent" - ) - } - value={option} - > - {({ selected, active }) => ( - <> + {filteredOptions.map((option, id) => ( + + classNames( + active ? " bg-accent" : "", + editNode + ? "dropdown-component-false-option" + : "dropdown-component-true-option", + " hover:bg-accent" + ) + } + value={option} + > + {({ selected, active }) => ( + <> + + {option} + + + {selected ? ( - {option} + - - - {selected ? ( - - - ) : null} - - )} - - ) - )} + ) : null} + + )} + + ))}
@@ -199,7 +197,6 @@ export default function InputComponent({ )} - - {password && (