Files
MaxWaterSystem-Electron/app/src/reducers/reducer_events.js
2018-04-12 18:33:35 -05:00

28 lines
657 B
JavaScript

import _ from "lodash";
import { IPC_TAGUPDATE } from "../actions/actions_tags";
import {event_tags as eventTags} from "../../../tagList.json";
export default function(state = [], action){
switch (action.type) {
case IPC_TAGUPDATE:
const { name, value } = action.payload;
const eventTagList = _.map(eventTags, (ftag) => {
return ftag.tag;
});
if (eventTagList.includes(name)){
if(value){
const thisEvent = _.find(eventTags, (tag) => {
return tag.tag === name;
});
const newHistory = _.concat([{...thisEvent, timestamp: new Date()}], state);
return newHistory;
}
}
return state;
default:
return state;
}
}