-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathCreateWorkflowItemButton.jsx
More file actions
29 lines (27 loc) · 1.03 KB
/
CreateWorkflowItemButton.jsx
File metadata and controls
29 lines (27 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { useSelector, useDispatch } from "react-redux";
import { WriteNewConfigToLocalStorage } from "../../services/utils";
import Button from "./shared/WorkflowFooterButtons";
import cloneDeep from "lodash/cloneDeep";
import { setCurrentWorkflows } from "../settings/settingsSlice";
import { WorkflowItemTypes } from "../../constants/enums";
import PrideText from "../../themes/PrideText";
export default function CreateWorkflowItemButton(props) {
const config = useSelector((state) => state.settings.config);
const dispatch = useDispatch();
const onClick = () => {
const newConfig = cloneDeep(config);
const workflow = newConfig.workflows.items.find((r) => r.id === props.id);
const nextId = workflow.payload.length + 1;
workflow.payload.push({
type: WorkflowItemTypes.HEAT_OFF,
id: nextId,
});
WriteNewConfigToLocalStorage(newConfig);
dispatch(setCurrentWorkflows(newConfig.workflows.items));
};
return (
<Button onClick={onClick}>
<PrideText text="Add Action" />
</Button>
);
}