import { Router } from '@angular/router';
import { Component, inject, OnInit } from '@angular/core';

import { BreadcrumbService } from '../breadcrumb.service';
import { environment } from '../../environments/environment';
import { AuthenticationService } from '../../providers/user/authentication.service';


@Component({
  standalone: true,
  selector: 'app-home',
  templateUrl: './home.component.html'
})
export class HomeComponent implements OnInit
{
  public imgSrc: string = ''

  constructor()
  {
    const router = inject(Router);
    const authService = inject(AuthenticationService);

    if (!authService.currentUserValue)
    {
      router.navigate(['/login']);
      return;
    }

    const bcSvc = inject(BreadcrumbService);
    bcSvc.setItems([{ label: 'Home', routerLink: ['/home'] }]);
  }

  ngOnInit()
  {
    if (environment.production)
    {
      this.imgSrc = '../../OnlineSalesAutoCrop/assets/layout/images/bg-home.jpg'
    }
    else
    {
      this.imgSrc = '../../assets/layout/images/bg-home.jpg';
    }
  }
}
