Manos Chorianopoulos

refactor setCouponList

...@@ -2343,14 +2343,17 @@ public class swiftApi { ...@@ -2343,14 +2343,17 @@ public class swiftApi {
2343 2343
2344 public func setCouponList(_ coupons: Array<CouponItemModel>) { 2344 public func setCouponList(_ coupons: Array<CouponItemModel>) {
2345 let filteredCoupons = coupons.filter { CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: $0.discount ?? "")) } 2345 let filteredCoupons = coupons.filter { CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: $0.discount ?? "")) }
2346 - GlobalVariables.couponList = filteredCoupons 2346 + let activeCoupons = filteredCoupons.filter({ return $0.status == 1 })
2347 + let oldCoupons = filteredCoupons.filter({ return $0.status == 0 })
2348 +
2349 + GlobalVariables.couponList = activeCoupons
2347 2350
2348 let loyaltyBadge = LoyaltyBadgeModel() 2351 let loyaltyBadge = LoyaltyBadgeModel()
2349 2352
2350 - let totalCouponDiscount = filteredCoupons.reduce(0) { $0 + (Float($1.discount ?? "") ?? 0) } 2353 + let totalCouponDiscount = oldCoupons.reduce(0) { $0 + (Float($1.discount ?? "") ?? 0) }
2351 2354
2352 loyaltyBadge._value = totalCouponDiscount 2355 loyaltyBadge._value = totalCouponDiscount
2353 - loyaltyBadge._couponCount = filteredCoupons.count 2356 + loyaltyBadge._couponCount = oldCoupons.count
2354 2357
2355 GlobalVariables.loyaltyBadge = loyaltyBadge 2358 GlobalVariables.loyaltyBadge = loyaltyBadge
2356 } 2359 }
......