import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { AuthService } from 'src/app/core/service/auth.service'; type LockedForm = { password: FormControl; }; @Component({ selector: 'app-locked', templateUrl: './locked.component.html', styleUrls: ['./locked.component.scss'], }) export class LockedComponent implements OnInit { authForm!: FormGroup; submitted = false; userImg!: string; userFullName!: string; hide = true; constructor( private formBuilder: FormBuilder, private router: Router, private authService: AuthService ) { } ngOnInit() { this.authForm = this.formBuilder.group({ password: ['', Validators.required], }); this.userImg = this.authService.currentUserValue.img || 'assets/images/user/admin.jpg'; this.userFullName = this.authService.currentUserValue.firstName + ' ' + this.authService.currentUserValue.lastName; } get f() { return this.authForm.controls; } onSubmit() { this.submitted = true; // stop here if form is invalid if (this.authForm.invalid) { return; } else { this.router.navigate(['/dashboard/rests']); } } }