@empathyco/x-components
Version:
Empathy X Components
65 lines (62 loc) • 2.03 kB
JavaScript
import { setQuery } from '../../../store/utils/query.utils.js';
import { setStatus } from '../../../store/utils/status-store.utils.js';
import { fetchAndSaveRelatedPrompts, cancelFetchAndSaveRelatedPrompts } from './actions/fetch-and-save-related-prompts.action.js';
import { fetchRelatedPrompts } from './actions/fetch-related-prompts.action.js';
import { setUrlParams } from './actions/set-url-params.action.js';
import { query } from './getters/related-prompts-query.getter.js';
import { request } from './getters/request.getter.js';
/**
* {@link XStoreModule} For the related prompt module.
*
* @internal
*/
const relatedPromptsXStoreModule = {
state: () => ({
query: '',
relatedPrompts: [],
selectedPrompt: -1,
selectedQuery: -1,
status: 'initial',
params: {},
relatedTags: [],
}),
getters: {
request,
query,
},
mutations: {
setStatus,
setQuery,
setParams(state, params) {
state.params = params;
},
setRelatedPromptsProducts(state, products) {
state.relatedPrompts = products;
},
setSelectedPrompt(state, selectedPrompt) {
state.selectedPrompt = state.selectedPrompt === selectedPrompt ? -1 : selectedPrompt;
},
setSelectedQuery(state, selectedQuery) {
state.selectedQuery = selectedQuery;
},
resetRelatedPromptsState(state) {
state.selectedQuery = -1;
state.selectedPrompt = -1;
state.relatedPrompts = [];
},
resetSelectedPrompt(state) {
state.selectedPrompt = -1;
},
setRelatedPromptsRelatedTags(state, relatedTags) {
state.relatedTags = relatedTags;
},
},
actions: {
fetchRelatedPrompts,
fetchAndSaveRelatedPrompts,
cancelFetchAndSaveRelatedPrompts,
setUrlParams,
},
};
export { relatedPromptsXStoreModule };
//# sourceMappingURL=module.js.map