import { Component, HostListener } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { FooterComponent } from './footer/footer.component';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { Router } from '@angular/router';
import { AuthService } from './auth.service';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [RouterOutlet, FooterComponent, HttpClientModule],
  templateUrl: './app.component.html',
  styleUrl: './app.component.css'
})
export class AppComponent {
  title = 'code';
  message= 'Right-click is disabled on this page.';

  // constructor(private http: HttpClient, private router: Router) {}
  constructor(private authService: AuthService, private router: Router,
    private http: HttpClient) {}


  ngOnInit(): void {
  // this.checkSessionStatus();
  this.authService.initializeAuthState();
 
}

// checkSessionStatus(): void {
//   this.http.get<any>('https://infoways.in/funtelapi/get_user.php', {
//     withCredentials: true
//   }).subscribe({
//     next: (res) => {
//       if (res.status !== 'success') {
       
//         this.handleAutoLogout();
//       }
//     },
//     error: () => {
    
//       this.handleAutoLogout();
//     }
//   });
// }

handleAutoLogout(): void {
  sessionStorage.clear();
  localStorage.clear();
  // this.router.navigateByUrl('/login');
}
  // @HostListener('contextmenu', ['$event'])
  // onRightClick(event: MouseEvent) {
  //   event.preventDefault();
    
  // }
  
}
