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,27 +154,57 @@ import UIKit ...@@ -151,27 +154,57 @@ import UIKit
151 154
152 self.couponSets = couponSets 155 self.couponSets = couponSets
153 156
154 - // Create coupon sets section with real data 157 + // Load merchants after getting coupon sets
155 - if !self.couponSets.isEmpty { 158 + self.loadMerchants()
156 - let couponSetsSection = SectionModel(
157 - sectionType: .myRewardsHorizontalCouponsets,
158 - title: "Προσφορές",
159 - items: self.couponSets,
160 - itemType: .couponSets
161 - )
162 - self.sections.append(couponSetsSection)
163 - }
164 159
165 - // Reload table view with new sections
166 - DispatchQueue.main.async {
167 - self.tableView.reloadData()
168 - }
169 } failureCallback: { [weak self] errorCode in 160 } failureCallback: { [weak self] errorCode in
170 print("Failed to load coupon sets: \(errorCode)") 161 print("Failed to load coupon sets: \(errorCode)")
171 // No sections added on failure - table will be empty 162 // No sections added on failure - table will be empty
172 } 163 }
173 } 164 }
174 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() {
191 + // Create coupon sets section with real data
192 + if !self.couponSets.isEmpty {
193 + let couponSetsSection = SectionModel(
194 + sectionType: .myRewardsHorizontalCouponsets,
195 + title: "Προσφορές",
196 + items: self.couponSets,
197 + itemType: .couponSets
198 + )
199 + self.sections.append(couponSetsSection)
200 + }
201 +
202 + // Reload table view with new sections
203 + DispatchQueue.main.async {
204 + self.tableView.reloadData()
205 + }
206 + }
207 +
175 // MARK: - Profile Loading 208 // MARK: - Profile Loading
176 public func loadProfile() { 209 public func loadProfile() {
177 // Always attempt to load profile, regardless of authentication status 210 // Always attempt to load profile, regardless of authentication status
......