Manos Chorianopoulos

refactor setCouponList

......@@ -2343,14 +2343,17 @@ public class swiftApi {
public func setCouponList(_ coupons: Array<CouponItemModel>) {
let filteredCoupons = coupons.filter { CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: $0.discount ?? "")) }
GlobalVariables.couponList = filteredCoupons
let activeCoupons = filteredCoupons.filter({ return $0.status == 1 })
let oldCoupons = filteredCoupons.filter({ return $0.status == 0 })
GlobalVariables.couponList = activeCoupons
let loyaltyBadge = LoyaltyBadgeModel()
let totalCouponDiscount = filteredCoupons.reduce(0) { $0 + (Float($1.discount ?? "") ?? 0) }
let totalCouponDiscount = oldCoupons.reduce(0) { $0 + (Float($1.discount ?? "") ?? 0) }
loyaltyBadge._value = totalCouponDiscount
loyaltyBadge._couponCount = filteredCoupons.count
loyaltyBadge._couponCount = oldCoupons.count
GlobalVariables.loyaltyBadge = loyaltyBadge
}
......