import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { AuthService } from 'feature-auth';

/**
 * Admin landing page. v1 renders a self-test panel for the
 * admin-portal auth chain: status from `AuthService` (signed-in
 * payload + roles, or anonymous), a "Sign in" button when no admin
 * session is present, and the next-up roadmap from ADR-0020 §"v1
 * scope".
 *
 * Functional modules (CMS, menu management, user list, audit log
 * viewer) replace this page progressively. The audit-log viewer is
 * next per the chantier sequence.
 */
@Component({
  selector: 'app-home',
  templateUrl: './home.html',
  styleUrl: './home.scss',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class Home {
  private readonly auth = inject(AuthService);

  protected readonly state = this.auth.state;
  protected readonly currentUser = this.auth.currentUser;
  protected readonly isLoading = this.auth.isLoading;

  protected signIn(): void {
    this.auth.login();
  }
}
