2017-08-26 01:37:28 +02:00
|
|
|
import { UNION, SUBTRACT, EXCLUSIVE, NONE } from '../actions/selection';
|
2017-08-25 15:43:54 +02:00
|
|
|
|
|
|
|
export default function selection(state = [], action) {
|
|
|
|
const { id } = action;
|
|
|
|
switch (action.type) {
|
|
|
|
case UNION:
|
|
|
|
return [id, ...state.filter(t => t !== id)];
|
|
|
|
case SUBTRACT:
|
|
|
|
return state.filter(t => t !== id);
|
|
|
|
case EXCLUSIVE:
|
|
|
|
return [id];
|
2017-08-26 01:37:28 +02:00
|
|
|
case NONE:
|
|
|
|
return [];
|
2017-08-25 15:43:54 +02:00
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|