mirror of
https://github.com/Nezumi-2711/javascript-training.git
synced 2026-09-22 20:01:31 +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() {
|
||||
if (this.registerView.checkRegisterFormElExist()) {
|
||||
if (this.registerView.isRegisterPage()) {
|
||||
this.registerView.addHandlerForm(
|
||||
this.hanlderCheckUserExist.bind(this),
|
||||
this.handlerSaveUser.bind(this),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,38 +7,43 @@
|
||||
<title>Login - Money Lover</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- <div class="loader"></div> -->
|
||||
<div class="background">
|
||||
<div class="wrapper">
|
||||
<img class="logo-web" src="../assets/images/logo.svg" alt="Logo web" />
|
||||
<!-- Log in form -->
|
||||
<form action="#" class="form" method="post">
|
||||
<div class="form__container">
|
||||
<h1 class="form__title">Log In</h1>
|
||||
<p class="form__description">Using Money Lover account</p>
|
||||
<input
|
||||
type="email"
|
||||
class="form__input"
|
||||
placeholder="Email"
|
||||
name="email"
|
||||
required
|
||||
/>
|
||||
<input
|
||||
type="password"
|
||||
name="password"
|
||||
class="form__input"
|
||||
placeholder="Password"
|
||||
required
|
||||
/>
|
||||
<button type="submit" class="form__submit-btn">Login</button>
|
||||
<p class="form__redirect-signup-text">
|
||||
Don't have an account?
|
||||
<a href="/register" class="form__link">Register</a>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
<!-- End form -->
|
||||
<main id="loginPage">
|
||||
<div class="background">
|
||||
<div class="wrapper">
|
||||
<img
|
||||
class="logo-web"
|
||||
src="../assets/images/logo.svg"
|
||||
alt="Logo web"
|
||||
/>
|
||||
<!-- Log in form -->
|
||||
<form action="#" class="form" method="post">
|
||||
<div class="form__container">
|
||||
<h1 class="form__title">Log In</h1>
|
||||
<p class="form__description">Using Money Lover account</p>
|
||||
<input
|
||||
type="email"
|
||||
class="form__input"
|
||||
placeholder="Email"
|
||||
name="email"
|
||||
required
|
||||
/>
|
||||
<input
|
||||
type="password"
|
||||
name="password"
|
||||
class="form__input"
|
||||
placeholder="Password"
|
||||
required
|
||||
/>
|
||||
<button type="submit" class="form__submit-btn">Login</button>
|
||||
<p class="form__redirect-signup-text">
|
||||
Don't have an account?
|
||||
<a href="/register" class="form__link">Register</a>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
<!-- End form -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -7,54 +7,51 @@
|
||||
<title>Register - Money Lover</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- <div class="loader hidden"></div> -->
|
||||
<!-- <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="wrapper">
|
||||
<img class="logo-web" src="../assets/images/logo.svg" alt="Logo web" />
|
||||
<!-- Register form -->
|
||||
<form action="#" class="form" method="post" id="registerForm">
|
||||
<div class="form__container">
|
||||
<h1 class="form__title">Register</h1>
|
||||
<p class="form__description">Using Money Lover account</p>
|
||||
<input
|
||||
type="email"
|
||||
class="form__input"
|
||||
placeholder="Email"
|
||||
name="email"
|
||||
required
|
||||
/>
|
||||
<input
|
||||
type="password"
|
||||
name="password"
|
||||
class="form__input"
|
||||
placeholder="Password"
|
||||
required
|
||||
/>
|
||||
<input
|
||||
type="password"
|
||||
name="password_confirm"
|
||||
class="form__input"
|
||||
placeholder="Confirm Password"
|
||||
required
|
||||
/>
|
||||
<button type="submit" class="form__submit-btn">Register</button>
|
||||
<p class="form__redirect-signup-text">
|
||||
Have you an account?
|
||||
<a href="/login" class="form__link">Sign in</a>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
<!-- End form -->
|
||||
<main id="registerPage">
|
||||
<div class="background">
|
||||
<div class="wrapper">
|
||||
<img
|
||||
class="logo-web"
|
||||
src="../assets/images/logo.svg"
|
||||
alt="Logo web"
|
||||
/>
|
||||
<!-- Register form -->
|
||||
<form action="#" class="form" method="post" id="registerForm">
|
||||
<div class="form__container">
|
||||
<h1 class="form__title">Register</h1>
|
||||
<p class="form__description">Using Money Lover account</p>
|
||||
<input
|
||||
type="email"
|
||||
class="form__input"
|
||||
placeholder="Email"
|
||||
name="email"
|
||||
required
|
||||
/>
|
||||
<input
|
||||
type="password"
|
||||
name="password"
|
||||
class="form__input"
|
||||
placeholder="Password"
|
||||
required
|
||||
/>
|
||||
<input
|
||||
type="password"
|
||||
name="password_confirm"
|
||||
class="form__input"
|
||||
placeholder="Confirm Password"
|
||||
required
|
||||
/>
|
||||
<button type="submit" class="form__submit-btn">Register</button>
|
||||
<p class="form__redirect-signup-text">
|
||||
Have you an account?
|
||||
<a href="/login" class="form__link">Sign in</a>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
<!-- End form -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<script type="module" src="../js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user