diff --git a/javascript-practice/src/js/controllers/registerController.js b/javascript-practice/src/js/controllers/registerController.js index fcde6da..0ecfc65 100644 --- a/javascript-practice/src/js/controllers/registerController.js +++ b/javascript-practice/src/js/controllers/registerController.js @@ -13,7 +13,7 @@ export default class RegisterController { } init() { - if (this.registerView.checkRegisterFormElExist()) { + if (this.registerView.isRegisterPage()) { this.registerView.addHandlerForm( this.hanlderCheckUserExist.bind(this), this.handlerSaveUser.bind(this), diff --git a/javascript-practice/src/js/services/commonService.js b/javascript-practice/src/js/services/commonService.js index 08f0c76..569a6d3 100644 --- a/javascript-practice/src/js/services/commonService.js +++ b/javascript-practice/src/js/services/commonService.js @@ -12,6 +12,7 @@ export default class CommonService { } async findKeyByProperty(property, value, path = this.defaultPath) { + this.connectToDb(); const existUser = this.firebaseService.findKeyByPropery( path, property, @@ -28,6 +29,7 @@ export default class CommonService { } async getDataFromId(id, path = this.path) { + this.connectToDb(); const data = await this.firebaseService.getDataFromId(id, path); if (data) return data; return null; diff --git a/javascript-practice/src/js/views/commonLoginRegisterView.js b/javascript-practice/src/js/views/commonLoginRegisterView.js index 70d22eb..1e5dcf3 100644 --- a/javascript-practice/src/js/views/commonLoginRegisterView.js +++ b/javascript-practice/src/js/views/commonLoginRegisterView.js @@ -25,11 +25,9 @@ export default class CommonLoginRegisterView extends CommonView { return true; } this.showError(CONSTANT.MESSAGE.PASSWORD_NOT_STRONG); - this.toogleErrorStyleInputPass(); return false; } this.showError(CONSTANT.MESSAGE.PASSWORD_NOT_MATCH); - this.toogleErrorStyleInputPass(); return false; } @@ -48,9 +46,10 @@ export default class CommonLoginRegisterView extends CommonView { // Reassign again to check error message element haved on page or not this.errorMessageEl = document.querySelector('.form__error-message'); - // If have error message on page, remove it + // If have error message on page, remove it with style error input password if (this.errorMessageEl) { this.errorMessageEl.remove(); + this.toogleErrorStyleInputPass(); } } diff --git a/javascript-practice/src/js/views/registerView.js b/javascript-practice/src/js/views/registerView.js index 0b3460f..3a26d6b 100644 --- a/javascript-practice/src/js/views/registerView.js +++ b/javascript-practice/src/js/views/registerView.js @@ -6,7 +6,7 @@ export default class RegisterView extends CommonLoginRegisterView { constructor() { super(); - this.registerForm = document.getElementById('registerForm'); + this.registerPage = document.getElementById('registerPage'); } /** @@ -100,7 +100,7 @@ export default class RegisterView extends CommonLoginRegisterView { this.toogleLoaderSpinner(); } - checkRegisterFormElExist() { - return this.registerForm !== null; + isRegisterPage() { + return this.registerPage !== null; } } diff --git a/javascript-practice/src/pages/login.html b/javascript-practice/src/pages/login.html index 06bcb74..4c19064 100644 --- a/javascript-practice/src/pages/login.html +++ b/javascript-practice/src/pages/login.html @@ -7,38 +7,43 @@