summaryrefslogtreecommitdiff
path: root/buildscripts/libdeps/graph_visualizer_web_stack/src/redux/linksTrans.js
blob: f0cff77a89262ae32429c7d6433d4403905688df (plain)
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
30
31
32
import { initialState } from "./store";

export const linksTrans = (state = initialState, action) => {
  switch (action.type) {
    case "addLinkTrans":
      var arr = Object.assign(state);
      return [...arr, action.payload];
    case "setLinksTrans":
      return action.payload;
    case "updateSelectedLinksTrans":
      var newState = Object.assign(state);
      newState[action.payload.index].selected = action.payload.value;
      return newState;
    default:
      return state;
  }
};

export const addLinkTrans = (link) => ({
  type: "addLinkTrans",
  payload: link,
});

export const setLinksTrans = (links) => ({
  type: "setLinksTrans",
  payload: links,
});

export const updateSelectedLinksTrans = (newValue) => ({
  type: "updateSelectedLinksTrans",
  payload: newValue,
});