Fix bug wallet dialog show not correctly

This commit is contained in:
2023-10-02 09:22:36 +07:00
parent 60fc544b10
commit d255f961da
5 changed files with 16 additions and 4 deletions
@@ -35,4 +35,13 @@ export default class User {
get id() {
return this._id;
}
get toObject() {
return {
id: this._id,
email: this._email,
password: this._password,
accessToken: this.accessToken,
} as User;
}
}
@@ -14,7 +14,7 @@ export default class CommonView {
public spinner: HTMLBodyElement | null = null;
constructor() {
this.toastDialog = document.querySelector('.dialog');
this.toastDialog = document.querySelector('.dialog .toast');
this.spinner = null;
}
@@ -53,6 +53,10 @@ export default class HomeView extends CommonView {
this._amountInputs = document.querySelectorAll('.form__input-balance');
this._walletView = new WalletView();
this.initToast();
this.initLoader();
this.handleEventToast();
}
initFunction(
@@ -159,7 +163,7 @@ export default class HomeView extends CommonView {
const walletName = document.querySelector('.wallet__name');
const walletPrice = document.querySelector('.wallet__price');
const walletNameValue = wallet!.walletName;
const walletAmountValue = wallet!.amountWallet;
const walletAmountValue = wallet!.inflow + wallet!.outflow;
const sign = walletAmountValue >= 0 ? '+' : '-';
@@ -148,7 +148,6 @@ export default class WalletView {
await this._loadData!();
this._loadEvent!();
this._showSuccessToast!(ADD_WALLET_SUCCESS, DEFAULT_MESSAGE);
await this._loadData!(); // Load data from database into page
this._toggleLoaderSpinner!();
}
@@ -152,7 +152,7 @@ export default class RegisterView extends AuthenticationView {
if (userExist) {
throw Error(USER_EXIST_ERROR);
} else {
await saveUser(user);
await saveUser(user.toObject);
// Show toast success
this.showRegisterSuccessToast();