Fix delete function work not correctly

This commit is contained in:
2023-09-15 20:38:49 +07:00
parent 22534090bc
commit 98103a3da2
3 changed files with 20 additions and 11 deletions
@@ -104,6 +104,7 @@ export default class CommonService {
}
async deleteData(id, path = this.defaultPath) {
this.connectToDb();
await timeOutConnect(this.firebaseService.delete(id, path));
}
}
@@ -30,9 +30,7 @@ class FirebaseService {
}
delete(id, path) {
const dbRef = ref(this.db, `${path}${id}/`);
return remove(dbRef);
return remove(ref(this.db, path + id));
}
/**
+15 -5
View File
@@ -311,11 +311,20 @@ export default class HomeView extends CommonView {
);
if (idEl.value) {
try {
this.transactionDialog.close();
this.toggleLoaderSpinner();
await this.deleteTransaction(idEl.value);
this.toggleLoaderSpinner();
this.showSuccessToast('Delete success!', MESSAGE.DEFAULT_MESSAGE);
await this.loadData();
this.addEventTransactionItem();
} catch (error) {
this.showErrorToast(error);
}
this.toggleLoaderSpinner();
}
});
}
@@ -389,7 +398,8 @@ export default class HomeView extends CommonView {
this.clearInputTransactionForm(this.transactionForm);
// Reload data
this.loadData();
await this.loadData();
this.addEventTransactionItem();
} catch (error) {
this.showErrorToast(error);
}
@@ -503,7 +513,8 @@ export default class HomeView extends CommonView {
await this.updateAmountWallet(+amount, this.saveWallet); // Update wallet
this.loadData();
await this.loadData();
this.addEventTransactionItem();
// Hide loader spinner
this.toggleLoaderSpinner();
@@ -571,8 +582,7 @@ export default class HomeView extends CommonView {
MESSAGE.DEFAULT_MESSAGE,
);
this.loadEvent(); // Load event page
this.loadData(); // Load data from database into page
await this.loadData(); // Load data from database into page
} catch (error) {
// Show toast error
this.showErrorToast(error);