Manos Chorianopoulos

added getMerchants requests at MyRewardsVC

...@@ -43,6 +43,9 @@ import UIKit ...@@ -43,6 +43,9 @@ import UIKit
43 // Coupon sets data 43 // Coupon sets data
44 var couponSets: [CouponSetItemModel] = [] 44 var couponSets: [CouponSetItemModel] = []
45 45
46 + // Merchants data
47 + var merchants: [MerchantModel] = []
48 +
46 // Profile data 49 // Profile data
47 var profileModel: ProfileModel? 50 var profileModel: ProfileModel?
48 var profileSection: SectionModel? 51 var profileSection: SectionModel?
...@@ -151,6 +154,40 @@ import UIKit ...@@ -151,6 +154,40 @@ import UIKit
151 154
152 self.couponSets = couponSets 155 self.couponSets = couponSets
153 156
157 + // Load merchants after getting coupon sets
158 + self.loadMerchants()
159 +
160 + } failureCallback: { [weak self] errorCode in
161 + print("Failed to load coupon sets: \(errorCode)")
162 + // No sections added on failure - table will be empty
163 + }
164 + }
165 +
166 + // MARK: - Merchants Loading
167 + private func loadMerchants() {
168 + // Load merchants from WarplySDK (using enhanced getMerchants method)
169 + WarplySDK.shared.getMerchants { [weak self] merchants in
170 + guard let self = self, let merchants = merchants else {
171 + // If merchants fail to load, still create coupon sets section without filtering
172 + self?.createCouponSetsSection()
173 + return
174 + }
175 +
176 + self.merchants = merchants
177 + print("✅ [MyRewardsViewController] Loaded \(merchants.count) merchants")
178 +
179 + // For now, create the coupon sets section without filtering
180 + // Later this will be enhanced to filter by merchant categories
181 + self.createCouponSetsSection()
182 +
183 + } failureCallback: { [weak self] errorCode in
184 + print("Failed to load merchants: \(errorCode)")
185 + // If merchants fail, still show coupon sets without filtering
186 + self?.createCouponSetsSection()
187 + }
188 + }
189 +
190 + private func createCouponSetsSection() {
154 // Create coupon sets section with real data 191 // Create coupon sets section with real data
155 if !self.couponSets.isEmpty { 192 if !self.couponSets.isEmpty {
156 let couponSetsSection = SectionModel( 193 let couponSetsSection = SectionModel(
...@@ -166,10 +203,6 @@ import UIKit ...@@ -166,10 +203,6 @@ import UIKit
166 DispatchQueue.main.async { 203 DispatchQueue.main.async {
167 self.tableView.reloadData() 204 self.tableView.reloadData()
168 } 205 }
169 - } failureCallback: { [weak self] errorCode in
170 - print("Failed to load coupon sets: \(errorCode)")
171 - // No sections added on failure - table will be empty
172 - }
173 } 206 }
174 207
175 // MARK: - Profile Loading 208 // MARK: - Profile Loading
......