import {
  Component,
  OnInit,
  Input,
  ViewEncapsulation,
  Output,
  EventEmitter
} from '@angular/core';
import { CardModel, CardValues } from '../../models/card-model';
import { CallbackModel } from '../../models/callback-model';
import { GenericHelper } from '../../helpers/generic-helper';

@Component({
  selector: 'sts-checkout-item',
  templateUrl: './checkout-item.component.html',
  styleUrls: ['./checkout-item.component.scss']
})
export class CheckoutItemComponent implements OnInit {
// @Input() wishListModel: WishListModel;
@Input() cardValues: CardValues;
@Output() methodToExecute: EventEmitter<CallbackModel> = new EventEmitter<
  CallbackModel
>();

constructor() {}
CallReturnMethod(returnVal: CallbackModel) {
  // check method with params
  GenericHelper.CallReturnMethod<CheckoutItemComponent>(returnVal, this);
}

RemoveBrowsed(obj: CallbackModel) {
  this.methodToExecute.emit(obj);
}
AddToWishList(obj: CallbackModel) {
  this.cardValues.cardOptions.addWishExpanded = false;
  this.methodToExecute.emit(obj);
}

RemoveFromWishlist(obj: CallbackModel) {
  this.methodToExecute.emit(obj);
}

SendEmail(obj: CallbackModel) {
  const email = obj.returnValue;
  console.log('Email sent to : ' + email);
}

ActionMethod(obj: CallbackModel) {
  this.methodToExecute.emit(obj);
}


toggleExpansion() {
  this.cardValues.cardOptions.addWishExpanded = !this.cardValues.cardOptions.addWishExpanded;
}

ngOnInit() {}
}
