//
//  CouponCell.swift
//  WOKA
//
//  Created by MacBook Pro on 23/07/24.
//

import UIKit

class CouponCell: UITableViewCell {

    @IBOutlet weak var couponText: LocalisedElementsLabel!
    @IBOutlet weak var couponStack: UIStackView!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.backgroundColor = .clear
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

    }
    
    func setData(data : CouponListDM.ResultData , isSelected : Bool){
//        let double = data.discountValue?.toDouble()
        if isSelected{
            couponStack.backgroundColor = #colorLiteral(red: 0.7176470588, green: 0.937254902, blue: 0.9960784314, alpha: 1)
        }else{
            couponStack.backgroundColor = .white
        }
        
        if data.discountType == 1{ // Percentage
            self.couponText.text = (data.discountValue ?? "0.0") + "% Off with Coupon Code: " + (data.couponCode ?? "NA")
        }else{ // Amount
            self.couponText.text = K.ConstantString.rupeeSign + " " + (data.discountValue ?? "0.0") + " Off with Coupon Code: " + (data.couponCode ?? "NA")
        }
    }
}
