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

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

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

RemoveBrowsed(dcm: CallbackModel) {
  this.methodToExecute.emit(dcm);
}
AddToWishList(dcm: CallbackModel) {
  this.cardModel.addWishExpanded = false;
  this.methodToExecute.emit(dcm);
}

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

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

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


toggleExpansion() {
  this.cardModel.addWishExpanded = !this.cardModel.addWishExpanded;
}

ngOnInit() {}
}
