12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import { Component, OnInit } from '@angular/core';
- import { BaseForm } from '../../../core/base/base-form';
- import { ComponentBase } from '@core/base/common-base';
- import {
- FormGroup,
- UntypedFormControl,
- UntypedFormGroup,
- Validators,
- } from '@angular/forms';
- import { AuthService } from '@core/services/authentication/auth.service';
- import { takeUntil } from 'rxjs';
- import { Router } from '@angular/router';
- import { ToastrService } from 'ngx-toastr';
- @Component({
- selector: 'app-sign-in',
- templateUrl: './sign-in.component.html',
- styleUrls: ['./sign-in.component.scss'],
- })
- export class SignInComponent extends ComponentBase implements BaseForm, OnInit {
- hide: boolean = true;
- form!: FormGroup;
- constructor(
- private readonly authService: AuthService,
- private readonly router: Router,
- private readonly toastr: ToastrService
- ) {
- super();
- }
- ngOnInit(): void {
- this.initForm();
- }
- initForm(): void {
- this.form = new UntypedFormGroup({
- email: new UntypedFormControl(null, [
- Validators.email,
- Validators.required,
- ]),
- password: new UntypedFormControl(null, [Validators.required]),
- });
- }
- onSubmit(): void {
- if (super.submitValidity(this.form)) {
- this.authService
- .Login(this.form.value)
- .pipe(takeUntil(this.destroy$))
- .subscribe((response) => {
- console.log(response);
- this.router.navigate(['/modules']);
- });
- }
- }
- }
|