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 = (
value,
label,
@ -9,7 +11,7 @@ export const addChoice = (
placeholder,
keyCode,
) => ({
type: 'ADD_CHOICE',
type: ACTION_TYPES.ADD_CHOICE,
value,
label,
id,
@ -22,15 +24,15 @@ export const addChoice = (
});
export const filterChoices = results => ({
type: 'FILTER_CHOICES',
type: ACTION_TYPES.FILTER_CHOICES,
results,
});
export const activateChoices = (active = true) => ({
type: 'ACTIVATE_CHOICES',
type: ACTION_TYPES.ACTIVATE_CHOICES,
active,
});
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 */
export const addGroup = (value, id, active, disabled) => ({
type: 'ADD_GROUP',
type: ACTION_TYPES.ADD_GROUP,
value,
id,
active,

View file

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

View file

@ -79,3 +79,15 @@ export const EVENTS = {
removeItem: 'removeItem',
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',
};