|
|
@@ -1,6 +1,8 @@ |
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
import { ConfirmPasswordValidator } from 'src/app/_helper/matchpassword.validators'; |
|
|
|
import { AuthService } from 'src/app/_services'; |
|
|
|
@Component({ |
|
|
|
selector: 'app-sign-up', |
|
|
|
templateUrl: './sign-up.component.html', |
|
|
@@ -9,14 +11,13 @@ import { ConfirmPasswordValidator } from 'src/app/_helper/matchpassword.validato |
|
|
|
export class SignUpComponent implements OnInit { |
|
|
|
public signupForm!: FormGroup; |
|
|
|
public submitted: boolean = false; |
|
|
|
constructor(private formBuilder: FormBuilder) {} |
|
|
|
constructor(private formBuilder: FormBuilder, private router: Router, private auth: AuthService) {} |
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
this.signupForm = this.formBuilder.group( |
|
|
|
{ |
|
|
|
fullname: ['', Validators.required], |
|
|
|
imei: ['', Validators.required], |
|
|
|
email: ['', [Validators.required, Validators.email]], |
|
|
|
password: [ |
|
|
|
'', |
|
|
|
[ |
|
|
@@ -42,5 +43,19 @@ export class SignUpComponent implements OnInit { |
|
|
|
this.submitted = true; |
|
|
|
return; |
|
|
|
} |
|
|
|
const reqObj = { |
|
|
|
fullName: this.signupForm.value.fullname, |
|
|
|
imei: this.signupForm.value.imei, |
|
|
|
password: this.signupForm.value.password, |
|
|
|
confirmPassword : this.signupForm.value.confirmPassword, |
|
|
|
}; |
|
|
|
this.auth.login(reqObj).subscribe( |
|
|
|
(data: any) => { |
|
|
|
this.router.navigateByUrl('/login'); |
|
|
|
}, |
|
|
|
(error) => { |
|
|
|
localStorage.clear(); |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
} |