Merge code from feat/javascript-practice branch

This commit is contained in:
2023-09-05 09:45:15 +07:00
4 changed files with 13 additions and 0 deletions
+1
View File
@@ -3,5 +3,6 @@ import App from './app';
// Sure that scripts called after DOM loaded
document.addEventListener('DOMContentLoaded', () => {
const myApp = new App();
myApp.start();
});
@@ -19,12 +19,14 @@ export default class CommonService {
value,
);
const result = await timeOutConnect(existUser);
return result;
}
async save(data, path = this.defaultPath) {
this.connectToDb();
const saveUser = this.firebaseService.save(data, path);
await timeOutConnect(saveUser);
}
@@ -32,7 +34,9 @@ export default class CommonService {
this.connectToDb();
const result = await this.firebaseService.getDataFromId(id, path);
const data = await timeOutConnect(result);
if (data) return data;
return null;
}
}
@@ -15,6 +15,7 @@ export default class UserService extends CommonService {
*/
saveUser(user) {
const pathData = this.defaultPath + User.createIdUser();
this.save(user, pathData);
}
@@ -34,9 +35,11 @@ export default class UserService extends CommonService {
*/
async checkUserExist(email) {
const userExist = await this.getUserIdByEmail(email);
if (userExist) {
return true;
}
return false;
}
@@ -47,10 +50,13 @@ export default class UserService extends CommonService {
*/
async getUserByEmail(email) {
const id = await this.getUserIdByEmail(email);
if (id) {
const user = await this.getDataFromId(id);
return new User(user);
}
return null;
}
@@ -24,8 +24,10 @@ export default class RegisterView extends CommonLoginRegisterView {
if (this.validateForm(account)) {
const user = new User(account);
return user;
}
return null;
}