mirror of
https://github.com/Nezumi-2711/javascript-training.git
synced 2026-09-22 13:38:43 +00:00
Fix delete function work not correctly
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user