import { Module, ActionTree, MutationTree, GetterTree } from 'vuex'; import { RootState } from '../'; import { NotificationState, NotificationObj } from './types'; import { notify } from './notify'; export const state: NotificationState = { notification: null }; export const actions: ActionTree = { add({ commit, state }, notification: NotificationObj) { notify(commit, state, notification); }, addNotification({ commit, state }, notification: NotificationObj) { notify(commit, state, notification); }, clear({ commit }) { commit('CLEAR'); }, clearNotification({ commit }) { commit('CLEAR'); } }; export const mutations: MutationTree = { ADD(state, notification: NotificationObj) { state.notification = notification; }, CLEAR(state) { state.notification = null; } }; export const getters: GetterTree = {}; export const notification: Module = { namespaced: true, state, actions, mutations, getters };