Skip to content

Commit

Permalink
Multi add number+1 (#37)
Browse files Browse the repository at this point in the history
* Added Subtract no. Node

* Added Multi -Add number && Show warning while deleting variables
  • Loading branch information
Anupam0-0 authored Dec 1, 2024
1 parent 9dcc96a commit 87573d9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 40 deletions.
12 changes: 7 additions & 5 deletions packages/client/src/components/Navbar/Variables/VariableList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
36 changes: 18 additions & 18 deletions packages/client/src/components/commons/UI/Input.tsx
Original file line number Diff line number Diff line change
@@ -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,
},
},
}));
42 changes: 25 additions & 17 deletions packages/client/src/predefined_components/Number/addNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -39,6 +46,7 @@ export const number_AddNumbers = () =>
[],
null
);
};

// const temp = {
// type: "input",
Expand Down

0 comments on commit 87573d9

Please sign in to comment.