Files
foodify-frontend/src/app/components/auth/send-email/send-email.component.ts
T
Nguyen Ha Khue fe41791608 Deployment 24.4
- Edit Category
- Verify oobCode before reset pass
- Change invoice -> account, delete account in User
2023-04-24 17:01:16 +07:00

96 lines
2.8 KiB
TypeScript

import { Component, OnInit, TemplateRef, ViewChild } from "@angular/core";
import { FormControl, FormGroup, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
import { FirebaseService } from "../../../shared/service/firebase.service";
import { Router } from "@angular/router";
import { Validation } from "src/app/constants/Validation";
import { BsModalRef, BsModalService } from "ngx-bootstrap/modal";
import { AuthService } from "src/app/shared/service/auth.service";
@Component({
selector: "app-send-email",
templateUrl: "./send-email.component.html",
styleUrls: ["./send-email.component.scss"],
})
// @ViewChild('sendMailCompleted') sendMailCompleted: TemplateRef<any>;
export class SendEmailComponent {
public sendEmailForm: FormGroup;
public active = 1;
@ViewChild('sendMailCompleted') sendMailCompleted: TemplateRef<any>
@ViewChild('emailNotExisted') emailNotExisted: TemplateRef<any>
constructor(
private formBuilder: UntypedFormBuilder,
private firebaseService: FirebaseService,
private authService: AuthService,
private modalService: BsModalService,
private router: Router
) {
}
layer1: BsModalRef;
owlcarousel = [
{
title: "Chào mừng đến với Foodify",
desc: "Foodify - Một trong những ứng dụng đặt đồ ăn tốt nhất hiện nay, được phát triển bởi Pyramide team",
},
{
title: "Foodify - xu hướng mới",
desc: "Với mục đích tạo ra những sản phẩm tốt nhất cho người dùng, chúng mình đã quyết định sử dụng các công nghệ mới nhất vào Foodify",
},
{
title: "Về Pyramide Team",
desc: "Pyramide team là một nhóm sinh viên trường Đại học FPT, team nghiên cứu và phát triển sản phẩm theo công nghệ Angular và Spring Boot",
},
];
owlcarouselOptions = {
loop: true,
items: 1,
dots: true,
};
ngOnInit() {
this.sendEmailForm = this.formBuilder.group({
email: new FormControl("", [Validators.required, Validators.email]),
});
}
sendPasswordResetMail() {
if (this.sendEmailForm.invalid) {
this.sendEmailForm.markAllAsTouched();
return;
}
this.authService.checkEmailInDB(this.email.value).subscribe({
next: (response) => {
if (response.isTrue == true) {
this.firebaseService.resetPassword(this.email.value);
this.layer1 = this.modalService.show(this.sendMailCompleted, { class: "modal-sm" });
}
else {
this.layer1 = this.modalService.show(this.emailNotExisted, { class: "modal-sm" })
}
}
})
}
gmail() {
this.layer1.hide();
window.location.assign("https://mail.google.com/");
}
closeLayer1() {
this.layer1.hide();
}
get email() {
return this.sendEmailForm.get("email");
}
}