21.02 Write Data - When Task Added

This commit is contained in:
Fredrick W. Warren 2021-02-15 07:52:27 -08:00
parent 8a28fd068a
commit d09fc4e6ba

View File

@ -54,13 +54,13 @@ const actions = {
deleteTask ({ commit }, id) {
commit('deleteTask', id)
},
addTask ({ commit }, task) {
addTask ({ dispatch }, task) {
const taskId = uid()
const payload = {
id: taskId,
task: task
}
commit('addTask', payload)
dispatch('fbAddTask', payload)
},
setSearch ({ commit }, value) {
commit('setSearch', value)
@ -97,6 +97,11 @@ const actions = {
const taskId = snapshot.key
commit('deleteTask', taskId)
})
},
fbAddTask ({ commit }, payload) {
const userId = firebaseAuth.currentUser.uid
const taskRef = firebaseDb.ref('tasks/' + userId + '/' + payload.id)
taskRef.set(payload.task)
}
}