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

import UIKit

class CartListCell: UITableViewCell {

    @IBOutlet weak var productImage: UIImageView!
    @IBOutlet weak var productTitle: LocalisedElementsLabel!
    @IBOutlet weak var productStatus: LocalisedElementsLabel!
    @IBOutlet weak var productPrice: LocalisedElementsLabel!
    @IBOutlet weak var productQty: LocalisedElementsLabel!
    
    typealias btnTappedBlock = () -> Void  // 0 - plus 1 - minus
    var btnTapped : btnTappedBlock!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.backgroundColor = .clear
        // Initialization code
    }

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

        // Configure the view for the selected state
    }
    
    func setData(data : CartListingDM.ResultData){
        self.productTitle.text = data.productName ?? "NA"
        self.productStatus.text = "Product_Status: " + (data.stockStatus ?? "NA")
        self.productPrice.text = data.productPrice ?? "Rs. 0"
        self.productQty.text =  "Quantity: " + (data.productQuantity?.toString() ?? "1") 
        
        if let imageURL = data.shopImage?.first{
            self.productImage.imageURL(imageURL, color: UIColor.appColor(.TextDarkBlue)!)
        }
    }
    
    @IBAction func deleteBtnTapped(_ sender: UIButton) {
        if btnTapped != nil {
            btnTapped()
        }
    }
}
