//
//  CallbackLinkCell.swift
//  kt
//
//  Created by Assylkhan Rakhatov on 02.06.16.
//  Copyright © 2016 Alexandr Zalutskiy. All rights reserved.
//

import Foundation
import UIKit

class CallbackLinkCell : UITableViewCell {
  @IBOutlet weak var agreementLabel: UILabel!
  @IBOutlet weak var linkButton: UIButton!
  @IBOutlet weak var checkButton: NextButton!
  var vc: ServiceCallbackController!
  var pay_touchUpInside: (() -> Void)?
  
  override func awakeFromNib() {
    super.awakeFromNib()
    checkButton.backgroundColor = Color.DashboardBlueColor
    localizeSubviews()
  }
  
  func fillCell(vc: ServiceCallbackController) {
    self.vc = vc
  }
  
  private func localizeSubviews() {
    checkButton.setTitle(LS("offer_callback.button.send"), forState: .Normal)
  }
  
  @IBAction func checkButton_touchUpInside(sender: NextButton) {
//    self.vc!.fillVarsFromTextViews()
//    let request = ServiceCallbackRequest(cityId: self.vc.region?.id, serviceId: self.vc.serviceItem.id!, fullName: self.vc.fullName, phone: self.vc.phoneNumber, email: self.vc.email, type: self.vc.type)
//    guard request.validateFields() else {
//      AlertViewUtil.showAlert(request.validationMessage);
//      return }
//    Facade.sharedInstance().callbackSend(request.params, onSuccess: { (msg) in
//      AlertViewUtil.showAlert(msg)
//      }, onError: { (error) in
//        AlertViewUtil.showErrorAlert(message: error)
//    }) {
//    }
    //    Facade.sharedInstance().sendCallbackRequest(self.vc.region!.id, serviceId: self.vc.serviceItem.id!, fio: self.vc.fullName!, phoneNumber: self.vc.phoneNumber!, email: self.vc.email!, onSuccess: {
    //        AlertViewUtil.showIncorrectAlert(LS("callback_success", description: "Запрос отправлен. Ожидайте звонка"))
    //      }, onError: { (error) in
    //        AlertViewUtil.showErrorAlert(message: error)
    //      }) {
    //    }
  }
  
  @IBAction func linkButton_touchUpInside(sender: UIButton) {
    //    vc!.performSegueWithIdentifier("callback", sender: nil)
  }
  
}

extension CallbackLinkCell: LocalizedParent {
  var localizedId: String {
    return "service_callback"
  }
}
