chore: Properly type alerts

This commit is contained in:
Matthias 2021-12-20 20:15:39 +01:00
parent 7350b5109a
commit e0a47f49f1
3 changed files with 10 additions and 3 deletions

View File

@ -19,12 +19,13 @@ import { Component, Vue } from 'vue-property-decorator';
import { namespace } from 'vuex-class';
import { AlertActions } from '@/store/modules/alerts';
import StoreModules from '@/store/storeSubModules';
import { AlertType } from '@/types/alertTypes';
const alerts = namespace(StoreModules.alerts);
@Component({})
export default class BotAlerts extends Vue {
@alerts.State activeMessages;
@alerts.State activeMessages!: AlertType[];
@alerts.Action [AlertActions.removeAlert];

View File

@ -1,3 +1,5 @@
import { AlertType } from '@/types/alertTypes';
export enum AlertActions {
addAlert = 'addAlert',
removeAlert = 'removeAlert',
@ -14,7 +16,7 @@ export default {
activeMessages: [],
},
mutations: {
[AlertMutations.addAlert](state, message) {
[AlertMutations.addAlert](state, message: AlertType) {
console.log(`adding message '${message.message}' to message queue`);
state.activeMessages.push(message);
},
@ -23,7 +25,7 @@ export default {
},
},
actions: {
[AlertActions.addAlert]({ commit }, message) {
[AlertActions.addAlert]({ commit }, message: AlertType) {
commit(AlertMutations.addAlert, message);
},
[AlertActions.removeAlert]({ commit }) {

4
src/types/alertTypes.ts Normal file
View File

@ -0,0 +1,4 @@
export interface AlertType {
message: string;
severity: string;
}