Manos Chorianopoulos

added getMerchants requests at MyRewardsVC

......@@ -43,6 +43,9 @@ import UIKit
// Coupon sets data
var couponSets: [CouponSetItemModel] = []
// Merchants data
var merchants: [MerchantModel] = []
// Profile data
var profileModel: ProfileModel?
var profileSection: SectionModel?
......@@ -151,6 +154,40 @@ import UIKit
self.couponSets = couponSets
// Load merchants after getting coupon sets
self.loadMerchants()
} failureCallback: { [weak self] errorCode in
print("Failed to load coupon sets: \(errorCode)")
// No sections added on failure - table will be empty
}
}
// MARK: - Merchants Loading
private func loadMerchants() {
// Load merchants from WarplySDK (using enhanced getMerchants method)
WarplySDK.shared.getMerchants { [weak self] merchants in
guard let self = self, let merchants = merchants else {
// If merchants fail to load, still create coupon sets section without filtering
self?.createCouponSetsSection()
return
}
self.merchants = merchants
print("✅ [MyRewardsViewController] Loaded \(merchants.count) merchants")
// For now, create the coupon sets section without filtering
// Later this will be enhanced to filter by merchant categories
self.createCouponSetsSection()
} failureCallback: { [weak self] errorCode in
print("Failed to load merchants: \(errorCode)")
// If merchants fail, still show coupon sets without filtering
self?.createCouponSetsSection()
}
}
private func createCouponSetsSection() {
// Create coupon sets section with real data
if !self.couponSets.isEmpty {
let couponSetsSection = SectionModel(
......@@ -166,10 +203,6 @@ import UIKit
DispatchQueue.main.async {
self.tableView.reloadData()
}
} failureCallback: { [weak self] errorCode in
print("Failed to load coupon sets: \(errorCode)")
// No sections added on failure - table will be empty
}
}
// MARK: - Profile Loading
......