UNPKG

cluedin-widget

Version:

This project contains all the pages needed for browsing entities and searching them. The aim is to replace the CluedIn.Webapp project with this one when all the pages ( including the Admin page ) will be ported to REACT.

92 lines (85 loc) 3.07 kB
import constants from '../constants'; const initialState = { allFollowers: [], isFetchingAllFollowers: true, isDoingFollowingRequest: false, shouldAddFollowerEntityId: void 0, shouldRemoveFollowerEntityId: void 0, showNotification: false, }; export default function update(state = initialState, action = {}) { switch (action.type) { case constants.follow.RESET_NOTIFICATION_FOR_FOLLOW: return Object.assign({}, { allFollowers: state.allFollowers, isDoingFollowingRequest: state.isDoingFollowingRequest, shouldAddFollowerEntityId: state.shouldAddFollowerEntityId, shouldRemoveFollowerEntityId: state.shouldRemoveFollowerEntityId, showNotification: false, }); case constants.follow.REQUEST_ALL_FOLLOW: return Object.assign({}, { allFollowers: state.allFollowers, isDoingFollowingRequest: true, shouldAddFollowerEntityId: void 0, shouldRemoveFollowerEntityId: void 0, showNotification: state.showNotification, }); case constants.follow.RECEIVE_ALL_FOLLOW: return Object.assign({}, { allFollowers: action.data.followers, isDoingFollowingRequest: false, shouldAddFollowerEntityId: void 0, shouldRemoveFollowerEntityId: void 0, showNotification: state.showNotification, }); case constants.follow.REQUEST_FOLLOW: return Object.assign({}, { allFollowers: state.allFollowers, isDoingFollowingRequest: true, shouldAddFollowerEntityId: void 0, shouldRemoveFollowerEntityId: void 0, showNotification: state.showNotification, }); case constants.follow.REQUEST_UNFOLLOW: return Object.assign({}, { allFollowers: state.allFollowers, isDoingFollowingRequest: true, shouldAddFollowerEntityId: void 0, shouldRemoveFollowerEntityId: void 0, showNotification: state.showNotification, }); case constants.follow.RECEIVE_UNFOLLOW: state.allFollowers = state.allFollowers.filter((f) => { return f.Entity.EntityId !== action.data.entity.id; }); return Object.assign({}, { allFollowers: state.allFollowers.slice(), isDoingFollowingRequest: false, shouldAddFollowerEntityId: void 0, shouldRemoveFollowerEntityId: action.data.entity.id, showNotification: state.showNotification, }); case constants.follow.RECEIVE_FOLLOW: state.allFollowers.unshift({ Count: 0, Entities: [], Entity: { Count: 0, EntityId: action.data.entity.id, EntityName: action.data.entity.name, EntityType: action.data.entity.data.entityType, }, }); return Object.assign({}, { allFollowers: state.allFollowers.slice(), isDoingFollowingRequest: false, shouldAddFollowerEntityId: action.data.entity.id, shouldRemoveFollowerEntityId: void 0, showNotification: true, }); default : return state; } } ;