diff --git a/typescript-practice/src/ts/models/user.ts b/typescript-practice/src/ts/models/user.ts index bd30afd..66b92bb 100644 --- a/typescript-practice/src/ts/models/user.ts +++ b/typescript-practice/src/ts/models/user.ts @@ -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; + } } diff --git a/typescript-practice/src/ts/views/commonView.ts b/typescript-practice/src/ts/views/commonView.ts index 4791241..f8ea0eb 100644 --- a/typescript-practice/src/ts/views/commonView.ts +++ b/typescript-practice/src/ts/views/commonView.ts @@ -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; } diff --git a/typescript-practice/src/ts/views/home/homeView.ts b/typescript-practice/src/ts/views/home/homeView.ts index e5c9a99..7687b59 100644 --- a/typescript-practice/src/ts/views/home/homeView.ts +++ b/typescript-practice/src/ts/views/home/homeView.ts @@ -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 ? '+' : '-'; diff --git a/typescript-practice/src/ts/views/home/walletView.ts b/typescript-practice/src/ts/views/home/walletView.ts index 9c79496..6abd27e 100644 --- a/typescript-practice/src/ts/views/home/walletView.ts +++ b/typescript-practice/src/ts/views/home/walletView.ts @@ -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!(); } diff --git a/typescript-practice/src/ts/views/registerView.ts b/typescript-practice/src/ts/views/registerView.ts index f60d587..98c141f 100644 --- a/typescript-practice/src/ts/views/registerView.ts +++ b/typescript-practice/src/ts/views/registerView.ts @@ -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();