Move action types into constant file

This commit is contained in:
Josh Johnson 2017-10-10 15:30:06 +01:00
parent fb4f80b5f1
commit f98e79e218
4 changed files with 26 additions and 8 deletions

View file

@ -1,3 +1,5 @@
import { ACTION_TYPES } from './../constants';
export const addChoice = ( export const addChoice = (
value, value,
label, label,
@ -9,7 +11,7 @@ export const addChoice = (
placeholder, placeholder,
keyCode, keyCode,
) => ({ ) => ({
type: 'ADD_CHOICE', type: ACTION_TYPES.ADD_CHOICE,
value, value,
label, label,
id, id,
@ -22,15 +24,15 @@ export const addChoice = (
}); });
export const filterChoices = results => ({ export const filterChoices = results => ({
type: 'FILTER_CHOICES', type: ACTION_TYPES.FILTER_CHOICES,
results, results,
}); });
export const activateChoices = (active = true) => ({ export const activateChoices = (active = true) => ({
type: 'ACTIVATE_CHOICES', type: ACTION_TYPES.ACTIVATE_CHOICES,
active, active,
}); });
export const clearChoices = () => ({ export const clearChoices = () => ({
type: 'CLEAR_CHOICES', type: ACTION_TYPES.CLEAR_CHOICES,
}); });

View file

@ -1,6 +1,8 @@
import { ACTION_TYPES } from './../constants';
/* eslint-disable import/prefer-default-export */ /* eslint-disable import/prefer-default-export */
export const addGroup = (value, id, active, disabled) => ({ export const addGroup = (value, id, active, disabled) => ({
type: 'ADD_GROUP', type: ACTION_TYPES.ADD_GROUP,
value, value,
id, id,
active, active,

View file

@ -1,3 +1,5 @@
import { ACTION_TYPES } from './../constants';
export const addItem = ( export const addItem = (
value, value,
label, label,
@ -8,7 +10,7 @@ export const addItem = (
placeholder, placeholder,
keyCode, keyCode,
) => ({ ) => ({
type: 'ADD_ITEM', type: ACTION_TYPES.ADD_ITEM,
value, value,
label, label,
id, id,
@ -20,13 +22,13 @@ export const addItem = (
}); });
export const removeItem = (id, choiceId) => ({ export const removeItem = (id, choiceId) => ({
type: 'REMOVE_ITEM', type: ACTION_TYPES.REMOVE_ITEM,
id, id,
choiceId, choiceId,
}); });
export const highlightItem = (id, highlighted) => ({ export const highlightItem = (id, highlighted) => ({
type: 'HIGHLIGHT_ITEM', type: ACTION_TYPES.HIGHLIGHT_ITEM,
id, id,
highlighted, highlighted,
}); });

View file

@ -79,3 +79,15 @@ export const EVENTS = {
removeItem: 'removeItem', removeItem: 'removeItem',
highlightItem: 'highlightItem', highlightItem: 'highlightItem',
}; };
export const ACTION_TYPES = {
ADD_CHOICE: 'ADD_CHOICE',
FILTER_CHOICES: 'FILTER_CHOICES',
ACTIVATE_CHOICES: 'ACTIVATE_CHOICES',
CLEAR_CHOICES: 'CLEAR_CHOICES',
ADD_GROUP: 'ADD_GROUP',
ADD_ITEM: 'ADD_ITEM',
REMOVE_ITEM: 'REMOVE_ITEM',
HIGHLIGHT_ITEM: 'HIGHLIGHT_ITEM',
CLEAR_ALL: 'CLEAR_ALL',
};