diff --git a/packages/client/src/components/Navbar/Variables/VariableList.tsx b/packages/client/src/components/Navbar/Variables/VariableList.tsx index f265551..1bed1ff 100644 --- a/packages/client/src/components/Navbar/Variables/VariableList.tsx +++ b/packages/client/src/components/Navbar/Variables/VariableList.tsx @@ -31,11 +31,13 @@ function VariableList() { }; const onDeleteVariable = (variable: Variable) => { - dispatch( - deleteVariableThunk({ - id: variable.id, - }) - ); + if (window.confirm("Are you sure you want to delete this variable?")) { + dispatch( + deleteVariableThunk({ + id: variable.id, + }) + ); + } }; return ( diff --git a/packages/client/src/components/commons/UI/Input.tsx b/packages/client/src/components/commons/UI/Input.tsx index 16c61cb..b0dfa58 100644 --- a/packages/client/src/components/commons/UI/Input.tsx +++ b/packages/client/src/components/commons/UI/Input.tsx @@ -1,18 +1,18 @@ -import React, { InputHTMLAttributes } from "react"; -import { alpha, styled } from "@mui/material/styles"; -import { InputBase } from "@mui/material"; - -export const Input = styled(InputBase)(({ theme }) => ({ - "label + &": { - marginTop: theme.spacing(3), - }, - "& .MuiInputBase-input": { - fontSize: "0.5rem", - border: `1px solid ${alpha(theme.palette.secondary.main, 0.5)}`, - padding: "0.2rem", - borderRadius: "0.2rem", - "&:focus": { - borderColor: theme.palette.primary.main, - }, - }, -})); +import React, { InputHTMLAttributes } from "react"; +import { alpha, styled } from "@mui/material/styles"; +import { InputBase } from "@mui/material"; + +export const Input = styled(InputBase)(({ theme }) => ({ + "label + &": { + marginTop: theme.spacing(3), + }, + "& .MuiInputBase-input": { + fontSize: "0.5rem", + border: `1px solid ${alpha(theme.palette.secondary.main, 0.5)}`, + padding: "0.2rem", + borderRadius: "0.2rem", + "&:focus": { + borderColor: theme.palette.primary.main, + }, + }, +})); diff --git a/packages/client/src/predefined_components/Number/addNumber.ts b/packages/client/src/predefined_components/Number/addNumber.ts index 6d4cc20..3fdab67 100644 --- a/packages/client/src/predefined_components/Number/addNumber.ts +++ b/packages/client/src/predefined_components/Number/addNumber.ts @@ -8,26 +8,33 @@ import { import { defaultComment, main } from "../../utils/default"; import { DefaultComponent, functionCreator } from "../default"; -export const number_AddNumbers = () => - DefaultComponent( +export const number_AddNumbers = () => { + const inputCount = Number(prompt("How many inputs should be there?")); + if (inputCount < 2) { + alert("Input number should be at least 2"); + throw new Error("Input number should be at least 2"); + } + + const inputs = []; + for (let i = 0; i < inputCount; i++) { + inputs.push({ + id: `${Parameters.number}__input__${nanoid()}`, + type: Parameters.number, + value: "", + name: `Input${i + 1}`, + }); + } + + const functionBody = inputs + .map((input, index) => `input['Input${index + 1}']`) + .join(" + "); + + return DefaultComponent( "Add Numbers", functionCreator(` - call('Event', {out: input['A'] + input['B']}) + call('Event', {out: ${functionBody}}) `), - [ - { - id: `${Parameters.number}__input__${nanoid()}`, - type: Parameters.number, - value: "", - name: `A`, - }, - { - id: `${Parameters.number}__input__${nanoid()}`, - type: Parameters.number, - value: "", - name: `B`, - }, - ], + inputs, [ { type: Parameters.number, @@ -39,6 +46,7 @@ export const number_AddNumbers = () => [], null ); +}; // const temp = { // type: "input",