summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/header_search/store/mutations.js
blob: 26b4a8854fe8bc713a75d102e6414b0d916f7729 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import * as types from './mutation_types';

export default {
  [types.REQUEST_AUTOCOMPLETE](state) {
    state.loading = true;
    state.autocompleteOptions = [];
  },
  [types.RECEIVE_AUTOCOMPLETE_SUCCESS](state, data) {
    state.loading = false;
    state.autocompleteOptions = data.map((d, i) => {
      return { html_id: `autocomplete-${d.category}-${i}`, ...d };
    });
  },
  [types.RECEIVE_AUTOCOMPLETE_ERROR](state) {
    state.loading = false;
    state.autocompleteOptions = [];
  },
  [types.CLEAR_AUTOCOMPLETE](state) {
    state.autocompleteOptions = [];
  },
  [types.SET_SEARCH](state, value) {
    state.search = value;
  },
};