mirror of
https://github.com/Nezumi-2711/javascript-training.git
synced 2026-09-23 04:09:58 +00:00
Add main element in html file and fix bug
- Fix checkExistUser call once time
This commit is contained in:
@@ -13,7 +13,7 @@ export default class RegisterController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
if (this.registerView.checkRegisterFormElExist()) {
|
if (this.registerView.isRegisterPage()) {
|
||||||
this.registerView.addHandlerForm(
|
this.registerView.addHandlerForm(
|
||||||
this.hanlderCheckUserExist.bind(this),
|
this.hanlderCheckUserExist.bind(this),
|
||||||
this.handlerSaveUser.bind(this),
|
this.handlerSaveUser.bind(this),
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export default class CommonService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async findKeyByProperty(property, value, path = this.defaultPath) {
|
async findKeyByProperty(property, value, path = this.defaultPath) {
|
||||||
|
this.connectToDb();
|
||||||
const existUser = this.firebaseService.findKeyByPropery(
|
const existUser = this.firebaseService.findKeyByPropery(
|
||||||
path,
|
path,
|
||||||
property,
|
property,
|
||||||
@@ -28,6 +29,7 @@ export default class CommonService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getDataFromId(id, path = this.path) {
|
async getDataFromId(id, path = this.path) {
|
||||||
|
this.connectToDb();
|
||||||
const data = await this.firebaseService.getDataFromId(id, path);
|
const data = await this.firebaseService.getDataFromId(id, path);
|
||||||
if (data) return data;
|
if (data) return data;
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -25,11 +25,9 @@ export default class CommonLoginRegisterView extends CommonView {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
this.showError(CONSTANT.MESSAGE.PASSWORD_NOT_STRONG);
|
this.showError(CONSTANT.MESSAGE.PASSWORD_NOT_STRONG);
|
||||||
this.toogleErrorStyleInputPass();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.showError(CONSTANT.MESSAGE.PASSWORD_NOT_MATCH);
|
this.showError(CONSTANT.MESSAGE.PASSWORD_NOT_MATCH);
|
||||||
this.toogleErrorStyleInputPass();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,9 +46,10 @@ export default class CommonLoginRegisterView extends CommonView {
|
|||||||
// Reassign again to check error message element haved on page or not
|
// Reassign again to check error message element haved on page or not
|
||||||
this.errorMessageEl = document.querySelector('.form__error-message');
|
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) {
|
if (this.errorMessageEl) {
|
||||||
this.errorMessageEl.remove();
|
this.errorMessageEl.remove();
|
||||||
|
this.toogleErrorStyleInputPass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export default class RegisterView extends CommonLoginRegisterView {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.registerForm = document.getElementById('registerForm');
|
this.registerPage = document.getElementById('registerPage');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,7 +100,7 @@ export default class RegisterView extends CommonLoginRegisterView {
|
|||||||
this.toogleLoaderSpinner();
|
this.toogleLoaderSpinner();
|
||||||
}
|
}
|
||||||
|
|
||||||
checkRegisterFormElExist() {
|
isRegisterPage() {
|
||||||
return this.registerForm !== null;
|
return this.registerPage !== null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,14 @@
|
|||||||
<title>Login - Money Lover</title>
|
<title>Login - Money Lover</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- <div class="loader"></div> -->
|
<main id="loginPage">
|
||||||
<div class="background">
|
<div class="background">
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<img class="logo-web" src="../assets/images/logo.svg" alt="Logo web" />
|
<img
|
||||||
|
class="logo-web"
|
||||||
|
src="../assets/images/logo.svg"
|
||||||
|
alt="Logo web"
|
||||||
|
/>
|
||||||
<!-- Log in form -->
|
<!-- Log in form -->
|
||||||
<form action="#" class="form" method="post">
|
<form action="#" class="form" method="post">
|
||||||
<div class="form__container">
|
<div class="form__container">
|
||||||
@@ -40,5 +44,6 @@
|
|||||||
<!-- End form -->
|
<!-- End form -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -7,18 +7,14 @@
|
|||||||
<title>Register - Money Lover</title>
|
<title>Register - Money Lover</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- <div class="loader hidden"></div> -->
|
<main id="registerPage">
|
||||||
<!-- <div class="overlay"></div>
|
|
||||||
<div class="modal-box success-form">
|
|
||||||
<div class="mark check"></div>
|
|
||||||
<h2 class="modal-box__title">Register success!</h2>
|
|
||||||
<p class="modal-box__message">Please login to continue.</p>
|
|
||||||
|
|
||||||
<button class="modal-box__redirect-btn">OK!</button>
|
|
||||||
</div> -->
|
|
||||||
<div class="background">
|
<div class="background">
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<img class="logo-web" src="../assets/images/logo.svg" alt="Logo web" />
|
<img
|
||||||
|
class="logo-web"
|
||||||
|
src="../assets/images/logo.svg"
|
||||||
|
alt="Logo web"
|
||||||
|
/>
|
||||||
<!-- Register form -->
|
<!-- Register form -->
|
||||||
<form action="#" class="form" method="post" id="registerForm">
|
<form action="#" class="form" method="post" id="registerForm">
|
||||||
<div class="form__container">
|
<div class="form__container">
|
||||||
@@ -55,6 +51,7 @@
|
|||||||
<!-- End form -->
|
<!-- End form -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</main>
|
||||||
<script type="module" src="../js/main.js"></script>
|
<script type="module" src="../js/main.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user