Dimitris Togias

fix sharing model parsing and apply in table cell

......@@ -40,11 +40,21 @@ extension AnalysisItemViewCell {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd-MM-yyyy"
// dateLabel.text = dateFormatter.string(from: item.date)
if let date = item.date {
let dateString = dateFormatter.string(from: date)
dateLabel.text = dateString
} else {
dateLabel.text = ""
}
//itemImage.image =
// titleLabel.text = item.name
// priceLabel.text = String(format: "%.2f€", item.discount)
// subtitleLabel.text = item.subtitle
titleLabel.text = item.name
priceLabel.text = String(format: "%.2f€", item.discount)
if ("sent" == item.sharingType) {
subtitleLabel.text = String(format: "Εκπτωτικό κουπόνι προς @%", "69740000000")
} else if ("received" == item.sharingType) {
subtitleLabel.text = String(format: "Εκπτωτικό κουπόνι από @%", "69740000000")
}
}
}
......
......@@ -34,6 +34,7 @@ class SharingHistoryViewController: AnalysisChildViewController {
}
showLoading()
// TODO: Implement API call
}
......
......@@ -457,18 +457,27 @@ public class swiftApi {
public class SharingCouponModel: Codable {
public let transactionMetadata: String?
public let sharingType: String?
public let discount: String?
public let date: String?
public let discount: Float
public let date: Date?
public let couponsetUuid: String?
public let name: String?
public init(dictionary: [String: Any]) {
self.transactionMetadata = dictionary["transaction_metadata"] as? String? ?? ""
self.sharingType = dictionary["sharing_type"] as? String? ?? ""
self.discount = dictionary["discount"] as? String? ?? ""
self.date = dictionary["date"] as? String? ?? ""
self.discount = dictionary["discount"] as? Float ?? 0.0
self.couponsetUuid = dictionary["couponsetUuid"] as? String? ?? ""
self.name = dictionary["name"] as? String? ?? ""
let dateString = dictionary["date"] as? String? ?? ""
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss"
if let date = dateFormatter.date(from: dateString ?? "") {
self.date = date
} else {
self.date = nil
}
}
}
......