2019-10-21 21:03:57 +02:00
|
|
|
import { ACTION_TYPES } from '../constants';
|
2017-10-10 16:30:06 +02:00
|
|
|
|
2019-11-03 14:18:16 +01:00
|
|
|
/**
|
2019-11-03 18:45:16 +01:00
|
|
|
* @typedef {import('redux').Action} Action
|
2019-11-03 14:18:16 +01:00
|
|
|
* @typedef {import('../../../types/index').Choices.Item} Item
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Item} item
|
2019-11-03 18:45:16 +01:00
|
|
|
* @returns {Action & Item}
|
2019-11-03 14:18:16 +01:00
|
|
|
*/
|
2018-05-29 20:55:33 +02:00
|
|
|
export const addItem = ({
|
2017-10-10 16:26:38 +02:00
|
|
|
value,
|
|
|
|
label,
|
|
|
|
id,
|
|
|
|
choiceId,
|
|
|
|
groupId,
|
|
|
|
customProperties,
|
|
|
|
placeholder,
|
|
|
|
keyCode,
|
2018-05-29 20:55:33 +02:00
|
|
|
}) => ({
|
2017-10-10 16:30:06 +02:00
|
|
|
type: ACTION_TYPES.ADD_ITEM,
|
2017-10-10 16:26:38 +02:00
|
|
|
value,
|
|
|
|
label,
|
|
|
|
id,
|
|
|
|
choiceId,
|
|
|
|
groupId,
|
|
|
|
customProperties,
|
|
|
|
placeholder,
|
|
|
|
keyCode,
|
|
|
|
});
|
|
|
|
|
2019-11-03 14:18:16 +01:00
|
|
|
/**
|
2019-11-24 18:32:02 +01:00
|
|
|
* @param {number} id
|
|
|
|
* @param {number} choiceId
|
|
|
|
* @returns {Action & { id: number, choiceId: number }}
|
2019-11-03 14:18:16 +01:00
|
|
|
*/
|
2017-10-10 16:26:38 +02:00
|
|
|
export const removeItem = (id, choiceId) => ({
|
2017-10-10 16:30:06 +02:00
|
|
|
type: ACTION_TYPES.REMOVE_ITEM,
|
2017-10-10 16:26:38 +02:00
|
|
|
id,
|
|
|
|
choiceId,
|
|
|
|
});
|
|
|
|
|
2019-11-03 14:18:16 +01:00
|
|
|
/**
|
2019-11-24 18:32:02 +01:00
|
|
|
* @param {number} id
|
2019-11-03 14:18:16 +01:00
|
|
|
* @param {boolean} highlighted
|
2019-11-24 18:32:02 +01:00
|
|
|
* @returns {Action & { id: number, highlighted: boolean }}
|
2019-11-03 14:18:16 +01:00
|
|
|
*/
|
2017-10-10 16:26:38 +02:00
|
|
|
export const highlightItem = (id, highlighted) => ({
|
2017-10-10 16:30:06 +02:00
|
|
|
type: ACTION_TYPES.HIGHLIGHT_ITEM,
|
2017-10-10 16:26:38 +02:00
|
|
|
id,
|
|
|
|
highlighted,
|
|
|
|
});
|