daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {
  2.   actionCreator,
  3.   asyncActionsCreator,
  4.   asyncDispatcherCreator,
  5.   dispatcherCreator,
  6.   reducerCreator,
  7.   startedActionHandler,
  8.   successActionHandlerFilters,
  9.   failureActionHandler,
  10.   typeActionHandler,
  11.   activeActionHandler
  12. } from 'utils/redux';
  13.  
  14. import { IFiltersState } from 'data/filters/types';
  15. import { filters } from './service';
  16.  
  17. const FiltersInit = asyncActionsCreator('FILTERS_INIT');
  18.  
  19. const FiltersClear = actionCreator('FILTERS_CLEAR');
  20. const FiltersChange = actionCreator('FILTERS_CHANGE');
  21. const FiltersSetActive = actionCreator('FILTERS_SET_ACTIVE');
  22.  
  23. export const create = asyncDispatcherCreator(FiltersInit, filters);
  24. export const clear = dispatcherCreator(FiltersClear);
  25.  
  26.  
  27.  
  28. export const active = (name: string) => {
  29.   return (dispatch: any) => {
  30.     dispatch(FiltersSetActive());
  31.     return name;
  32.   };
  33. };
  34.  
  35. export const change = (filtersType: string) => {
  36.   return (dispatch: any) => {
  37.     dispatch(FiltersChange());
  38.     return filtersType;
  39.   };
  40. };
  41.  
  42. export interface FiltersState extends IReduxAsyncState<IFiltersState> {}
  43.  
  44. const filtersDefaultState: FiltersState = {
  45.   payload: {
  46.     filtersData: '',
  47.     filtersCategories: {
  48.       fundDimensions: [
  49.         { name: 'vintageYear', label: 'Vintage Year' },
  50.         { name: 'sectorGroup', label: 'Sector Focus' },
  51.         { name: 'stageGroup', label: 'Stage Focus' },
  52.         { name: 'teamLocation', label: 'Team Location' },
  53.       ],
  54.       investmentDimensions: [
  55.         { name: 'investmentYear', label: 'Investment Year' },
  56.         { name: 'investmentSectorGroup', label: 'Sector' },
  57.         { name: 'investmentStageGroup', label: 'Stage' },
  58.         { name: 'investmentCountry', label: 'Country' },
  59.       ],
  60.     },
  61.     filtersType: 'fundDimensions',
  62.   },
  63.   working: false,
  64. };
  65.  
  66. const handlers: IReducerHandlers<FiltersState> = {
  67.   [FiltersInit.started.type]: startedActionHandler,
  68.   [FiltersInit.success.type]: successActionHandlerFilters,
  69.   [FiltersInit.failure.type]: failureActionHandler,
  70.   [FiltersChange.type]: typeActionHandler,
  71.   [FiltersSetActive.type]: activeActionHandler,
  72. };
  73.  
  74. export const FiltersReducer = reducerCreator(filtersDefaultState, handlers);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top