Skip to content

Open source personal finance application

CategoryModal use action deleteTrnsByIds

Ilya Komichev471c7c63b916
diff --git a/src/components/categories/modal/CategoryModal.vue b/src/components/categories/modal/CategoryModal.vue
index 99659745..a290a31d 100644
--- a/src/components/categories/modal/CategoryModal.vue
+++ b/src/components/categories/modal/CategoryModal.vue
@@ -98,23 +98,11 @@ export default {
this.$store.commit('setCategoryModalId', null)
setTimeout(async () => {
- await this.deleteAllTrns(trnsIds)
+ await this.$store.dispatch('deleteTrnsByIds', trnsIds)
db.ref(`users/${uid}/categories/${id}`)
.remove()
- .then(() => { console.log('removed category') })
+ .then(() => { console.log('category deleted') })
}, 200)
- },
-
- async deleteAllTrns (trnsIds) {
- const uid = this.$store.state.user.user.uid
- const removeTrnsIds = {}
- for (const trnId of trnsIds) {
- removeTrnsIds[trnId] = null
- }
-
- await db.ref(`users/${uid}/trns`)
- .update(removeTrnsIds)
- .then(() => console.log('removed all'))
}
}
}