summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/header_search/store/actions.js
blob: 3a86dcca409fa85adf517f60ecf716fd2b2fe5a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import axios from '~/lib/utils/axios_utils';
import * as types from './mutation_types';

export const fetchAutocompleteOptions = ({ commit, getters }) => {
  commit(types.REQUEST_AUTOCOMPLETE);
  return axios
    .get(getters.autocompleteQuery)
    .then(({ data }) => {
      commit(types.RECEIVE_AUTOCOMPLETE_SUCCESS, data);
    })
    .catch(() => {
      commit(types.RECEIVE_AUTOCOMPLETE_ERROR);
    });
};

export const clearAutocomplete = ({ commit }) => {
  commit(types.CLEAR_AUTOCOMPLETE);
};

export const setSearch = ({ commit }, value) => {
  commit(types.SET_SEARCH, value);
};