Format code

This commit is contained in:
2023-09-05 09:30:46 +07:00
parent ff394c13b4
commit ab6e14b3fa
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,19 +19,23 @@ export default class CommonService {
value,
);
const result = await timeOutConnect(existUser);
return result;
}
async save(data, path = this.path) {
this.connectToDb();
const saveUser = this.firebaseService.save(data, path);
await timeOutConnect(saveUser);
}
async getDataFromId(id, path = this.path) {
this.connectToDb();
const data = await this.firebaseService.getDataFromId(id, path);
if (data) return data;
return null;
}
}
@@ -14,6 +14,7 @@ export default class UserService extends CommonService {
*/
saveUser(user) {
const pathData = this.defaultPath + User.createIdUser();
this.save(user, pathData);
}
@@ -33,9 +34,11 @@ export default class UserService extends CommonService {
*/
async checkUserExist(email) {
const userExist = await this.getUserIdByEmail(email);
if (userExist) {
return true;
}
return false;
}
@@ -46,10 +49,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;
}