1 | function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2 |
|
3 | import updateVariables from '../rule-engine/apply-instructions';
|
4 |
|
5 | const variables = config => (_state, action) => {
|
6 | const state = _state.variables ? _state : _extends(_extends({}, _state), {}, {
|
7 | variables: {}
|
8 | });
|
9 |
|
10 | switch (action.type) {
|
11 | case 'answer':
|
12 | case 'move':
|
13 | {
|
14 | const {
|
15 | instructions
|
16 | } = action.payload;
|
17 | if (!instructions) return state;
|
18 | return updateVariables(instructions)(state);
|
19 | }
|
20 |
|
21 | default:
|
22 | {
|
23 | return state;
|
24 | }
|
25 | }
|
26 | };
|
27 |
|
28 | export default variables;
|
29 |
|
\ | No newline at end of file |