import { Component, inject } from '@angular/core';
import { ButtonComponent } from '../../../../shared/components/button/button.component';
import { InputComponent } from '../../../../shared/components/input/input.component';
import { PaginatorComponent } from '../../../../shared/components/paginator/paginator.component';
import { ProductCardComponent } from '../../../../shared/components/product-card/product-card.component';
import { StoreSectionComponent } from '../../../../shared/components/store-section/store-section.component';
import { TenantService } from '../../../../core/services/tenant.service';

@Component({
  selector: 'app-reutilizables-test-page',
  imports: [ButtonComponent, InputComponent, PaginatorComponent, ProductCardComponent, StoreSectionComponent],
  templateUrl: './reutilizables-test-page.component.html',
  styleUrl: './reutilizables-test-page.component.scss'
})
export class ReutilizablesTestPageComponent {
  private readonly tenantService = inject(TenantService);
  protected readonly tenant = this.tenantService.tenant;
  protected textValue = 'Auriculares';
  protected numberValue = '24';
  protected email = 'usuario@empresa.com';
  protected user = 'Juan Perez';
  protected password = '12345678';
  protected date = '2026-06-24';
  protected amount = '125000';
  protected percent = '12';
  protected period = '2026-06';
  protected editableValue = 'Solo lectura al cargar';
  protected disabledValue = 'No editable';
  protected invalidEmail = 'correo-invalido';
  protected fileName = '';
  protected clearTrigger = 0;
  protected editableDisabled = true;
  protected currentPage = 1;
  protected readonly paginatorTotalPages = 8;

  protected readonly testProducts = [
    {
      title: 'Pantalón recto de scuba negro',
      originalPrice: 95000,
      discount: 20,
      transferPrice: 74800,
      imageUrl: '/images/pantalon-scuba.png'
    },
    {
      title: 'Zapatillas de running azul',
      originalPrice: 120000,
      discount: 15,
      transferPrice: 98000,
      imageUrl: '/images/zapatillas-running.png'
    },
    {
      title: 'Remera básica blanca (Sin Descuento)',
      originalPrice: 32000,
      discount: null,
      transferPrice: 30000,
      imageUrl: null
    }
  ];

  protected onProductBuy(productTitle: string): void {
    console.log(`Comprando: ${productTitle}`);
    alert(`Comprando: ${productTitle}`);
  }

  protected onFileChange(file: File | null): void {
    this.fileName = file?.name ?? '';
  }

  protected clearFile(): void {
    this.fileName = '';
    this.clearTrigger += 1;
  }
}

