import { AfterViewInit, Component, OnInit } from '@angular/core';
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
import { ModalController } from '@ionic/angular';
import { OfferDiscountService } from 'src/app/offersdiscount/services/service';
import { ItemForSaleService } from '../services/service.service';
@Component({
  selector: 'app-filter',
  templateUrl: './filter.component.html',
  styleUrls: ['./filter.component.scss'],
})
export class FilterComponent implements AfterViewInit {

  segment: any = '1';
  categoriesObj: any;
  categories: any = [];
  offersData: any = [];
  activeClass: any;
  tempSearch: any = [];
  searchText: String;
  public activeKey = {}
  direction: any;

  constructor(public ts: TranslatorService, public modalController: ModalController, public cs: CommonService, public offersService: OfferDiscountService) { }

  ngAfterViewInit(): void {
    this.direction = TranslatorService.getCurrentDirection();
    this.categories = this.cs.sharedService.getSharedData(OfferDiscountService.categories, false);


    // this.getOfferDiscount();
  }


  openDetails(offer) {
    // this.cs.sharedService.setSharedData(offer, OfferDiscountService.selected_offers);

    // var related = this.offersData.filter((res) => res.rowID != offer.rowID);
    // this.cs.sharedService.setSharedData(related, OfferDiscountService.related_offers);

    // this.cs.navigateForward('/offersdiscount/offer-details');
  }


  filterOffers(key) {
    this.activeKey = key
    this.activeClass = key.title;

  }


  applyFilters() {
    this.cs.sharedService.setSharedData(this.activeKey, ItemForSaleService.selected_filters);
    this.cs.back();
  }
}
