Manos Chorianopoulos

fix unified coupon expiration date

...@@ -176,8 +176,9 @@ import AVFoundation ...@@ -176,8 +176,9 @@ import AVFoundation
176 showBarcodeButtonTopSpace.constant = 0 176 showBarcodeButtonTopSpace.constant = 0
177 // === 177 // ===
178 178
179 - if let earliestExpiration = coupon?._coupons.min(by: { ($0.expiration ?? "") < ($1.expiration ?? "") }) { 179 +// if let earliestExpiration = coupon?._coupons.min(by: { ($0.expiration ?? "") < ($1.expiration ?? "") }) {
180 - expirationLabel.text = "Το κουπόνι ισχύει έως " + (earliestExpiration.expiration ?? "") 180 + if let latestExpiration = coupon?._coupons.max(by: { ($0.expiration ?? "") < ($1.expiration ?? "") }) {
181 + expirationLabel.text = "Το κουπόνι ισχύει έως " + (latestExpiration.expiration ?? "")
181 } else { 182 } else {
182 expirationLabel.text = "" 183 expirationLabel.text = ""
183 } 184 }
......
...@@ -65,8 +65,9 @@ import UIKit ...@@ -65,8 +65,9 @@ import UIKit
65 activeCouponsCount == 1 ? "έχεις " + String(activeCouponsCount) + " ενεργό κουπόνι" 65 activeCouponsCount == 1 ? "έχεις " + String(activeCouponsCount) + " ενεργό κουπόνι"
66 : "έχεις " + String(activeCouponsCount) + " ενεργά κουπόνια" 66 : "έχεις " + String(activeCouponsCount) + " ενεργά κουπόνια"
67 67
68 - if let earliestExpiration = activeCoupons.min(by: { ($0.expiration ?? "") < ($1.expiration ?? "") }) { 68 +// if let earliestExpiration = activeCoupons.min(by: { ($0.expiration ?? "") < ($1.expiration ?? "") }) {
69 - expirationLabel.text = "Ισχύει έως " + (earliestExpiration.expiration ?? "") 69 + if let latestExpiration = activeCoupons.max(by: { ($0.expiration ?? "") < ($1.expiration ?? "") }) {
70 + expirationLabel.text = "Ισχύει έως " + (latestExpiration.expiration ?? "")
70 } else { 71 } else {
71 expirationLabel.text = "" 72 expirationLabel.text = ""
72 } 73 }
......