57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
import { ActionTree, Module } from 'vuex';
|
|
import AuthRepository from '@/api/AuthRepository';
|
|
import { RepositoryFactory } from '@/api/RepositoryFactory';
|
|
import AreaRepository from '@/api/AreaRepository';
|
|
import { Area } from '@/models/Area';
|
|
import StatusRepository from '@/api/StatusRepository';
|
|
import { Status } from '@/models/Status';
|
|
|
|
const statusRepository: StatusRepository = RepositoryFactory.get('status');
|
|
|
|
const store = {
|
|
status: undefined,
|
|
icons: undefined
|
|
};
|
|
|
|
const actions: ActionTree<any, any> = {
|
|
findAll: async ({ commit }): Promise<Status[]> => {
|
|
const response = await statusRepository.findAll();
|
|
const status: Status[] = response.map((statusData: any) =>
|
|
new Status(statusData));
|
|
|
|
commit('saveStatus', status);
|
|
return status;
|
|
},
|
|
getIcons: async ({ commit }, lastUpdate?: Date):
|
|
Promise<any> => {
|
|
const response = await statusRepository.getIcons(lastUpdate);
|
|
|
|
commit('saveIcons', response);
|
|
|
|
return response;
|
|
},
|
|
};
|
|
|
|
const mutations = {
|
|
saveStatus: (state: any, status: any) => {
|
|
state.status = status;
|
|
},
|
|
saveIcons: (state: any, iconData: any) => {
|
|
state.icons = iconData;
|
|
}
|
|
};
|
|
|
|
const getters = {
|
|
status: (state: any) => state.status,
|
|
icons: (state: any) => state.icons,
|
|
};
|
|
|
|
const statusStore: Module<any, any> = {
|
|
state: store,
|
|
actions,
|
|
mutations,
|
|
getters
|
|
};
|
|
|
|
export default statusStore;
|