//
//  MyOrderCell.swift
//  WOKA
//
//  Created by MacBook Pro on 07/08/24.
//

import UIKit

class MyOrderCell: UITableViewCell {

    @IBOutlet weak var orderNumber: UILabel!
    @IBOutlet weak var placedOn: UILabel!
    @IBOutlet weak var airwayBillNumber: UILabel!
    @IBOutlet weak var courierNumber: UILabel!
    @IBOutlet weak var price: UILabel!
    
    typealias btnTappedBlock = () -> Void
    var btnTapped : btnTappedBlock!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        self.backgroundColor = .clear
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
    }
    
    func setData(data : OrderListingDM.Datum){
        self.orderNumber.text = data.orderID
        self.placedOn.text = data.orderBookedDateTime
        self.airwayBillNumber.text = (data.airwaybilno == "" || data.airwaybilno == nil) ? "NA" : data.airwaybilno
        self.courierNumber.text = (data.courier == "" || data.courier == nil) ? "NA" : data.courier
        self.price.text = data.grandTotal?.toString()
    }
    
    @IBAction func trackBtnTapped(_ sender: UIButton) {
        if btnTapped != nil {
            btnTapped()
        }
    }
}
