feat(frontend): add snackbar and updateTasks

This commit is contained in:
DCsunset 2020-07-14 01:50:16 -07:00
parent c82b1ef0ac
commit 0b2efb515b

View file

@ -3,7 +3,12 @@ import { Task } from 'taskwarrior-lib';
import { getAccessorType } from 'typed-vuex';
export const state = () => ({
tasks: [] as Task[]
tasks: [] as Task[],
snackbar: false,
notification: {
color: '',
text: ''
}
});
export type RootState = ReturnType<typeof state>;
@ -18,6 +23,16 @@ export const getters: GetterTree<RootState, RootState> = {
export const mutations: MutationTree<RootState> = {
setTasks(state, tasks: Task[]) {
state.tasks = tasks;
},
setNotification(state, notification) {
state.notification = notification;
// Show notification
state.snackbar = true;
},
setSnackbar(state, value) {
state.snackbar = value;
}
};
@ -33,6 +48,12 @@ export const actions: ActionTree<RootState, RootState> = {
});
// Refresh
await context.dispatch('fetchTasks');
},
async updateTasks(context, tasks: Task[]) {
await this.$axios.$put('/api/tasks', { tasks });
// Refresh
await context.dispatch('fetchTasks');
}
};