1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-26 06:11:33 +03:00
guide/front/client/store/modules/categoryItem.ts
2018-09-21 18:09:32 +05:00

35 lines
940 B
TypeScript

import { ActionTree, GetterTree, MutationTree, ActionContext, Module } from 'vuex'
import { ICategoryItem, CategoryItemService } from 'client/service/CategoryItem'
interface CategoryItemState {
categoryItemList: ICategoryItem[]
}
const state: CategoryItemState = {
categoryItemList: []
}
const getters: GetterTree<CategoryItemState, any> = {}
const actions: ActionTree<CategoryItemState, any> = {
async loadCategoryItem({ commit }: ActionContext<CategoryItemState, any>): Promise<any> {
const data: ICategoryItem[] = await CategoryItemService.getCategoryItem()
commit('setCategoryItem', data)
}
}
const mutations: MutationTree<CategoryItemState> = {
setCategoryItem: (state: CategoryItemState, payload: ICategoryItem[]) => {
state.categoryItemList = payload
}
}
const categoryItem: Module<CategoryItemState, any> = {
namespaced: true,
state,
getters,
actions,
mutations
}
export default categoryItem