@empathyco/x-components
Version:
Empathy X Components
41 lines (38 loc) • 1.26 kB
JavaScript
import '@vue/devtools-api';
import '../../../../plugins/devtools/timeline.devtools.js';
import '@empathyco/x-utils';
import 'rxjs/operators';
import 'rxjs';
import '../../../../plugins/devtools/colors.utils.js';
import '../../../../plugins/x-bus.js';
import { XPlugin } from '../../../../plugins/x-plugin.js';
/**
* Default implementation for the `AiActions.fetchAndSaveAiSuggestionsSearch`.
*
* @param _ - The {@link https://vuex.vuejs.org/guide/actions.html | context} of the commits and
* getters provided by Vuex.
* @returns The AI search response.
* @public
*/
const fetchAndSaveAiSuggestionsSearch = async ({ commit, getters }) => {
const request = getters.suggestionsSearchRequest;
if (!request) {
return;
}
commit('setSuggestionsSearchLoading', true);
return XPlugin.adapter
.aiSuggestionsSearch(request)
.then(response => {
if (response) {
commit('setSuggestionsSearch', response.suggestions);
}
})
.catch(error => {
console.error(error);
})
.finally(() => {
commit('setSuggestionsSearchLoading', false);
});
};
export { fetchAndSaveAiSuggestionsSearch };
//# sourceMappingURL=fetch-and-save-ai-suggestions-search.action.js.map