import { Component } from '@angular/core';
import { CoreService } from '../../../services/core.service';
import { FormGroup, FormControl, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { Router, RouterModule } from '@angular/router';
import { MaterialModule } from '../../../material.module';
import { BrandingComponent } from '../../../layouts/full/vertical/sidebar/branding.component';
import { OAuthService } from 'angular-oauth2-oidc';

@Component({
  selector: 'app-side-login',
  imports: [RouterModule, MaterialModule, FormsModule, ReactiveFormsModule, BrandingComponent],
  templateUrl: './side-login.component.html'
})
export class AppSideLoginComponent {
  options: any;

  constructor(private settings: CoreService, private router: Router, private readonly as: OAuthService) {
    this.options = this.settings.getOptions();
  }

  form = new FormGroup({
    uname: new FormControl('', [Validators.required, Validators.minLength(6)]),
    password: new FormControl('', [Validators.required]),
  });

  get f() {
    return this.form.controls;
  }

  googleLogin() {
    console.warn('Google login initiated');
    this.as.loadDiscoveryDocumentAndLogin()
      .then(_ =>{}
        // this.as.initLoginFlowInPopup()
      );
  }


  submit() {
    // console.log(this.form.value);
    this.router.navigate(['/dashboards/dashboard1']);
  }
}
