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.
118 lines (98 loc) • 2.59 kB
JavaScript
import constants from '../constants';
import { unauthorized } from './generic';
import { followEntity, unFollowEntity } from '../data/follow';
import { getAll } from '../data/insight';
var dispatchFollow = __cluedIn.dispatchFollow;
var dispatchUnFollow = __cluedIn.dispatchUnFollow;
var invalidFollow = ( id ) => {
return {
type: constants.follow.INVALID_FOLLOW,
data: {
id: id
}
}
};
var receive_follow = ( entity ) => {
return {
type: constants.follow.RECEIVE_FOLLOW,
data: {
entity: entity
}
};
};
var requestFollow = ( id ) => {
return {
type: constants.follow.REQUEST_FOLLOW,
data: {
id: id
}
};
};
var requestUnFollow = ( id ) => {
return {
type: constants.follow.REQUEST_UNFOLLOW,
data: {
id: id
}
};
};
var invalidUnFollow = ( id ) => {
return {
type: constants.follow.REQUEST_UNFOLLOW,
data: {
id: id
}
};
};
var receive_UnFollow = ( entity ) => {
return {
type: constants.follow.RECEIVE_UNFOLLOW,
data: {
entity: entity
}
};
};
export function unFollow( entity ) {
return function( dispatch ) {
dispatch( requestUnFollow( entity.id ) );
return unFollowEntity( entity.id ).then( function() {
dispatchUnFollow( entity );
dispatch( receive_UnFollow( entity ) );
} ).catch( unauthorized( dispatch, invalidUnFollow ) )
}
}
export function follow( entity ) {
return function( dispatch ) {
dispatch( requestFollow( entity.id ) );
return followEntity( entity.id ).then( function() {
dispatchFollow( entity );
dispatch( receive_follow( entity ) );
} ).catch( unauthorized( dispatch, invalidFollow ) );
};
}
var requestAllFollow = () => {
return {
type: constants.follow.REQUEST_ALL_FOLLOW
}
};
var receiveAllFollow = ( followers ) => {
return {
type: constants.follow.RECEIVE_ALL_FOLLOW,
data: {
followers: followers
}
}
};
var invalidAllFollow = () => {
return {
type: constants / follow.INVALID_ALL_FOLLOW
};
};
export function fetchAllFollow() {
return function( dispatch ) {
dispatch( requestAllFollow() );
return getAll().then( function( allFollowers ) {
dispatch( receiveAllFollow( allFollowers ) );
} ).catch( unauthorized( dispatch, invalidAllFollow ) );
};
}