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