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) {
|
async deleteData(id, path = this.defaultPath) {
|
||||||
|
this.connectToDb();
|
||||||
await timeOutConnect(this.firebaseService.delete(id, path));
|
await timeOutConnect(this.firebaseService.delete(id, path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,9 +30,7 @@ class FirebaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete(id, path) {
|
delete(id, path) {
|
||||||
const dbRef = ref(this.db, `${path}${id}/`);
|
return remove(ref(this.db, path + id));
|
||||||
|
|
||||||
return remove(dbRef);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -311,11 +311,20 @@ export default class HomeView extends CommonView {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (idEl.value) {
|
if (idEl.value) {
|
||||||
|
try {
|
||||||
this.transactionDialog.close();
|
this.transactionDialog.close();
|
||||||
this.toggleLoaderSpinner();
|
this.toggleLoaderSpinner();
|
||||||
|
|
||||||
await this.deleteTransaction(idEl.value);
|
await this.deleteTransaction(idEl.value);
|
||||||
this.toggleLoaderSpinner();
|
|
||||||
this.showSuccessToast('Delete success!', MESSAGE.DEFAULT_MESSAGE);
|
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);
|
this.clearInputTransactionForm(this.transactionForm);
|
||||||
|
|
||||||
// Reload data
|
// Reload data
|
||||||
this.loadData();
|
await this.loadData();
|
||||||
|
this.addEventTransactionItem();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.showErrorToast(error);
|
this.showErrorToast(error);
|
||||||
}
|
}
|
||||||
@@ -503,7 +513,8 @@ export default class HomeView extends CommonView {
|
|||||||
|
|
||||||
await this.updateAmountWallet(+amount, this.saveWallet); // Update wallet
|
await this.updateAmountWallet(+amount, this.saveWallet); // Update wallet
|
||||||
|
|
||||||
this.loadData();
|
await this.loadData();
|
||||||
|
this.addEventTransactionItem();
|
||||||
|
|
||||||
// Hide loader spinner
|
// Hide loader spinner
|
||||||
this.toggleLoaderSpinner();
|
this.toggleLoaderSpinner();
|
||||||
@@ -571,8 +582,7 @@ export default class HomeView extends CommonView {
|
|||||||
MESSAGE.DEFAULT_MESSAGE,
|
MESSAGE.DEFAULT_MESSAGE,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.loadEvent(); // Load event page
|
await this.loadData(); // Load data from database into page
|
||||||
this.loadData(); // Load data from database into page
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Show toast error
|
// Show toast error
|
||||||
this.showErrorToast(error);
|
this.showErrorToast(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user