import { Component, Input, OnInit } from '@angular/core';
import { EquipmentDetails } from 'src/app/interfaces/equipment-management.interface';

@Component({
  selector: 'app-equipment-details',
  templateUrl: './equipment-details.component.html',
  styleUrls: ['./equipment-details.component.css']
})
export class EquipmentDetailsComponent implements OnInit {
  @Input() equipment: EquipmentDetails | null;

  images: string[];
  imageIndex: number;

  constructor(){
    this.equipment = null;
    this.images = [];
    this.imageIndex = 0;
  }

  ngOnInit(): void {
    this.images = this.equipment?.GALERIA_IMAGENES as string[];
    
  }

  forward(){
    let index = this.imageIndex + 1;
    if(index > this.images.length - 1){
      this.imageIndex = 0
    }else{
      this.imageIndex = index;
    }
  }

  backward(){
    let index = this.imageIndex - 1;
    if(index < 0){
      this.imageIndex = this.images.length - 1;
    }else{
      this.imageIndex = index;
    }
  }
}
