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.

46 lines (37 loc) 1.21 kB
import constants from '../constants'; import { unauthorized } from './generic'; import { getLastTools } from '../data/tools'; import entityFake from '../../iso/entity/fake'; const requestGenericLastTools = (timeStamp) => ({ type: constants.tool.REQUEST_GENERIC_LAST_TOOLS, data: { timeStamp, }, }); const receiveGenericLastTools = (tools, page, fake, timeStamp) => { const pageNumber = page || 0; return { type: constants.tool.RECEIVE_GENERIC_LAST_TOOLS, data: { tools, isFake: fake, pageNumber: (pageNumber + 1), timeStamp, }, }; }; const invalidGenericLastTools = () => ({ type: constants.tool.INVALID_GENERIC_LAST_TOOLS, }); export function fetchGenericLastTools(timeStamp) { return (dispatch, getState) => { dispatch(requestGenericLastTools(timeStamp)); const pageNumber = getState().tool.pageNumber; getLastTools(pageNumber).then((resp) => { if (!resp || resp.length === 0) { dispatch(receiveGenericLastTools(entityFake.tool || [], pageNumber, true, timeStamp)); } dispatch(receiveGenericLastTools(resp, pageNumber, false, timeStamp)); }).catch(unauthorized(dispatch, invalidGenericLastTools)); }; }