MyRewardsViewController.swift
27.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
//
// MyRewardsViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 22/5/25.
//
import UIKit
@objc public class MyRewardsViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
// MARK: - Initializers
public convenience init() {
self.init(nibName: "MyRewardsViewController", bundle: Bundle.frameworkBundle)
}
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
// match - survey - tesla - energy saver
// COMMENTED OUT: Static contest URLs no longer used
// let contestUrls: [String] = [
// "https://warply.s3.amazonaws.com/dei/campaigns/match_dev/index.html",
// "https://warply.s3.amazonaws.com/dei/campaigns/questionnaire_dev/index.html",
// "https://warply.s3.amazonaws.com/dei/campaigns/tesla_dev/index.html",
// "https://warply.s3.amazonaws.com/dei/campaigns/EnergySaverContest_dev/index.html"
// ]
// Dynamic sections array - populated by API calls
var sections: [SectionModel] = []
// Campaign data for banners
var bannerCampaigns: [CampaignItemModel] = []
// Articles data for banners
var articles: [ArticleModel] = []
// Coupon sets data
var couponSets: [CouponSetItemModel] = []
// Merchants data
var merchants: [MerchantModel] = []
// Merchant categories data
var merchantCategories: [MerchantCategoryModel] = []
// Profile data
var profileModel: ProfileModel?
var profileSection: SectionModel?
public override func viewDidLoad() {
super.viewDidLoad()
// Hide the navigation bar
// self.navigationController?.setNavigationBarHidden(true, animated: false)
// UPDATED: Safe XIB registration with error handling
registerTableViewCells()
// Set up table view
tableView.delegate = self
tableView.dataSource = self
tableView.separatorStyle = .none
tableView.estimatedRowHeight = 200
tableView.rowHeight = UITableView.automaticDimension
// Add bottom padding
tableView.contentInset.bottom = 60.0
// Always create profile section first (with default state)
createDefaultProfileSection()
// Load data
loadProfile() // Load Profile
loadCampaigns() // Load campaigns
loadCouponSets() // Load couponsets
}
// NEW: Safe XIB registration method
private func registerTableViewCells() {
let cellConfigs = [
("MyRewardsProfileInfoTableViewCell", "MyRewardsProfileInfoTableViewCell"),
("MyRewardsBannerOffersScrollTableViewCell", "MyRewardsBannerOffersScrollTableViewCell"),
("MyRewardsOffersScrollTableViewCell", "MyRewardsOffersScrollTableViewCell")
]
for (nibName, identifier) in cellConfigs {
XIBLoader.registerTableViewCell(
tableView,
cellClass: UITableViewCell.self,
nibName: nibName,
identifier: identifier
)
}
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Hide navigation bar when this view appears
self.navigationController?.setNavigationBarHidden(true, animated: animated)
}
public override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Show navigation bar when leaving this view (for other screens)
self.navigationController?.setNavigationBarHidden(false, animated: animated)
}
// MARK: - Campaign Loading
private func loadCampaigns() {
// Load campaigns from WarplySDK
WarplySDK.shared.getCampaigns { [weak self] campaigns in
guard let self = self, let campaigns = campaigns else {
// Even if campaigns fail, try to load articles
self?.loadArticles()
return
}
// Filter campaigns for banner display (contest campaigns) if needed
self.bannerCampaigns = campaigns
.filter { campaign in
// Filter by category "contest" or campaign_type "contest"
return campaign._category == "contest" || campaign._campaign_type == "contest"
}
print("=== getCampaigns ✅ [MyRewardsViewController] Loaded \(bannerCampaigns.count) campaigns")
// Load articles after campaigns are loaded
self.loadArticles()
} failureCallback: { [weak self] errorCode in
print("=== getCampaigns Failed to load campaigns: \(errorCode)")
// Even if campaigns fail, try to load articles
self?.loadArticles()
}
}
// MARK: - Articles Loading
private func loadArticles() {
// Load articles from WarplySDK with "Carousel" category filter
WarplySDK.shared.getArticles(categories: ["Carousel"]) { [weak self] articles in
guard let self = self, let articles = articles else {
// Create banner section with only campaigns if articles fail
self?.createBannerSection()
return
}
self.articles = articles
print("=== getArticles ✅ [MyRewardsViewController] Loaded \(articles.count) carousel articles")
// Create banner section with both campaigns and articles
self.createBannerSection()
// TODO: Add Couponsets here
} failureCallback: { [weak self] errorCode in
print("=== getArticles Failed to load carousel articles: \(errorCode)")
// Create banner section with only campaigns if articles fail
self?.createBannerSection()
}
}
// MARK: - Banner Section Creation
private func createBannerSection() {
// Combine campaigns and articles for banner section
var bannerItems: [Any] = []
// Add campaigns first
bannerItems.append(contentsOf: self.bannerCampaigns)
// Add articles after campaigns
bannerItems.append(contentsOf: self.articles)
// Create banner section if we have any items
if !bannerItems.isEmpty {
let bannerSection = SectionModel(
sectionType: .myRewardsBannerOffers,
title: "Διαγωνισμός",
items: bannerItems,
itemType: .mixed
)
self.sections.append(bannerSection)
print("✅ [MyRewardsViewController] Created banner section with \(self.bannerCampaigns.count) campaigns and \(self.articles.count) articles")
}
// Reload table view with new sections
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
// MARK: - Coupon Sets Loading
private func loadCouponSets() {
// Load coupon sets from WarplySDK
WarplySDK.shared.getCouponSets { [weak self] couponSets in
guard let self = self, let couponSets = couponSets else { return }
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")
// Load merchant categories after merchants success
self.loadMerchantCategories()
} failureCallback: { [weak self] errorCode in
print("Failed to load merchants: \(errorCode)")
// If merchants fail, still show coupon sets without filtering
self?.createCouponSetsSection()
}
}
// MARK: - Merchant Categories Loading
private func loadMerchantCategories() {
// Load merchant categories from WarplySDK
WarplySDK.shared.getMerchantCategories { [weak self] categories in
guard let self = self, let categories = categories else {
// If categories fail to load, still create coupon sets section without filtering
self?.createCouponSetsSection()
return
}
self.merchantCategories = categories
print("✅ [MyRewardsViewController] Loaded \(categories.count) merchant categories")
// Create coupon sets sections with category-based filtering
self.createCouponSetsSection()
} failureCallback: { [weak self] errorCode in
print("Failed to load merchant categories: \(errorCode)")
// If categories fail, still show coupon sets without filtering
self?.createCouponSetsSection()
}
}
private func createCouponSetsSection() {
print("🔍 [MyRewardsViewController] Starting coupon filtering:")
print(" - Coupon Sets: \(couponSets.count)")
print(" - Merchants: \(merchants.count)")
print(" - Categories: \(merchantCategories.count)")
// Check if we have all required data for filtering
guard !couponSets.isEmpty, !merchants.isEmpty, !merchantCategories.isEmpty else {
print("⚠️ [MyRewardsViewController] Missing data for filtering - using fallback single section")
print(" - Coupon Sets Empty: \(couponSets.isEmpty)")
print(" - Merchants Empty: \(merchants.isEmpty)")
print(" - Categories Empty: \(merchantCategories.isEmpty)")
// Fallback: Create single section with all coupon sets
createSingleCouponSetsSection()
return
}
// Group coupon sets by merchant category
var categorySections: [SectionModel] = []
var processedCouponSets: Set<String> = [] // Track processed coupon sets to avoid duplicates
// Extract promoted couponsets for "Top offers" section
let promotedCouponSets = couponSets.filter { $0._promoted }
print("🌟 [MyRewardsViewController] Found \(promotedCouponSets.count) promoted couponsets")
// Create "Top offers" section if we have promoted couponsets
if !promotedCouponSets.isEmpty {
// Bind merchant data to promoted couponsets
for couponSet in promotedCouponSets {
if let merchant = merchants.first(where: { $0._uuid == couponSet._merchant_uuid }) {
couponSet._merchant = merchant
print(" 🔗 Bound merchant '\(merchant._name)' to promoted coupon set '\(couponSet._name)'")
}
}
let topOffersSection = SectionModel(
sectionType: .myRewardsHorizontalCouponsets,
title: "Top offers",
items: promotedCouponSets,
itemType: .couponSets
)
categorySections.append(topOffersSection)
print(" ✅ Created 'Top offers' section with \(promotedCouponSets.count) items")
}
print("🔄 [MyRewardsViewController] Processing categories for filtering...")
for category in merchantCategories {
// Find merchants in this category
let categoryMerchants = merchants.filter { merchant in
merchant._category_uuid == category._uuid
}
print(" - Category '\(category.displayName)' has \(categoryMerchants.count) merchants")
// Find coupon sets from merchants in this category
let categoryCouponSets = couponSets.filter { couponSet in
// Skip if already processed (avoid duplicates)
guard !processedCouponSets.contains(couponSet._uuid) else { return false }
// Check if this coupon set belongs to any merchant in this category
let belongsToCategory = categoryMerchants.contains { merchant in
merchant._uuid == couponSet._merchant_uuid
}
if belongsToCategory {
processedCouponSets.insert(couponSet._uuid)
// BIND MERCHANT DATA: Find and bind the merchant to this coupon set
if let merchant = categoryMerchants.first(where: { $0._uuid == couponSet._merchant_uuid }) {
couponSet._merchant = merchant
print(" 🔗 Bound merchant '\(merchant._name)' to coupon set '\(couponSet._name)'")
}
}
return belongsToCategory
}
print(" - Category '\(category.displayName)' has \(categoryCouponSets.count) coupon sets")
// Create section if we have coupon sets for this category
if !categoryCouponSets.isEmpty {
let section = SectionModel(
sectionType: .myRewardsHorizontalCouponsets,
title: category.displayName,
items: categoryCouponSets,
itemType: .couponSets
)
categorySections.append(section)
print(" ✅ Created section for '\(category.displayName)' with \(categoryCouponSets.count) items")
}
}
// COMMENTED OUT: Don't show unmatched couponsets - only show categorized ones
/*
// Handle any remaining unmatched coupon sets
let unmatchedCouponSets = couponSets.filter { couponSet in
!processedCouponSets.contains(couponSet._uuid)
}
if !unmatchedCouponSets.isEmpty {
print(" ⚠️ Found \(unmatchedCouponSets.count) unmatched coupon sets - adding to 'Άλλες Προσφορές' section")
// BIND MERCHANT DATA for unmatched coupon sets too
for couponSet in unmatchedCouponSets {
if let merchant = merchants.first(where: { $0._uuid == couponSet._merchant_uuid }) {
couponSet._merchant = merchant
print(" 🔗 Bound merchant '\(merchant._name)' to unmatched coupon set '\(couponSet._name)'")
}
}
let unmatchedSection = SectionModel(
sectionType: .myRewardsHorizontalCouponsets,
title: "Άλλες Προσφορές", // "Other Offers"
items: unmatchedCouponSets,
itemType: .couponSets
)
categorySections.append(unmatchedSection)
}
*/
// Sort sections by title for consistent ordering, but keep "Top offers" at the top
categorySections.sort { section1, section2 in
let title1 = section1.title ?? ""
let title2 = section2.title ?? ""
// Put "Top offers" at the beginning
if title1 == "Top offers" { return true }
if title2 == "Top offers" { return false }
// All other sections sorted alphabetically
return title1.localizedCaseInsensitiveCompare(title2) == .orderedAscending
}
print("✅ [MyRewardsViewController] Created \(categorySections.count) category sections:")
for section in categorySections {
print(" - '\(section.title ?? "Unknown")': \(section.itemCount) coupon sets")
}
// Add category sections to main sections array
self.sections.append(contentsOf: categorySections)
// Reload table view with new sections
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
private func createSingleCouponSetsSection() {
print("📦 [MyRewardsViewController] Creating single fallback coupon sets section")
// Fallback: Single section with all coupon sets
if !self.couponSets.isEmpty {
let couponSetsSection = SectionModel(
sectionType: .myRewardsHorizontalCouponsets,
title: "Προσφορές", // "Offers"
items: self.couponSets,
itemType: .couponSets
)
self.sections.append(couponSetsSection)
print("✅ [MyRewardsViewController] Created fallback section with \(self.couponSets.count) coupon sets")
} else {
print("⚠️ [MyRewardsViewController] No coupon sets available - no section created")
}
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
// MARK: - Profile Loading
public func loadProfile() {
// Always attempt to load profile, regardless of authentication status
// If not authenticated, the API call will fail gracefully and we keep the default state
WarplySDK.shared.getProfile { [weak self] profile in
guard let self = self else { return }
if let profile = profile {
// Success: Update with real profile data
self.profileModel = profile
self.updateProfileSectionWithData(profile)
print("✅ [MyRewardsViewController] Profile loaded successfully")
} else {
// No profile data: Keep default state
print("ℹ️ [MyRewardsViewController] No profile data received - keeping default state")
}
} failureCallback: { [weak self] errorCode in
print("⚠️ [MyRewardsViewController] Profile loading failed with error: \(errorCode) - keeping default state")
// Don't remove section - just keep the default state
// The profile section remains visible with default profile pic
}
}
private func createDefaultProfileSection() {
// Create profile section with default/empty state
let defaultProfileSection = SectionModel(
sectionType: .myRewardsProfileInfo,
title: nil,
count: 1,
metadata: ["profile": nil] // nil profile = default state
)
// Always insert at index 0 (top of the list)
sections.insert(defaultProfileSection, at: 0)
profileSection = defaultProfileSection
}
private func updateProfileSectionWithData(_ profile: ProfileModel) {
// Create updated profile section with real data
let updatedProfileSection = SectionModel(
sectionType: .myRewardsProfileInfo,
title: nil,
count: 1,
metadata: ["profile": profile]
)
// Find and update the profile section
if let profileIndex = sections.firstIndex(where: { $0.sectionType == .myRewardsProfileInfo }) {
sections[profileIndex] = updatedProfileSection
profileSection = updatedProfileSection
// Reload only the profile section
DispatchQueue.main.async {
self.tableView.reloadSections(IndexSet(integer: profileIndex), with: .none)
}
}
}
private func openCampaignViewController(with index: Int) {
// Get the combined banner items (campaigns + articles)
var bannerItems: [Any] = []
bannerItems.append(contentsOf: self.bannerCampaigns)
bannerItems.append(contentsOf: self.articles)
// Validate index bounds for combined items
guard index < bannerItems.count else {
print("Invalid banner item index: \(index)")
return
}
let item = bannerItems[index]
// Handle only campaigns - articles will be handled by didSelectBannerArticle
guard let campaign = item as? CampaignItemModel else {
print("Item at index \(index) is not a campaign")
return
}
let campaignUrl = campaign._campaign_url ?? campaign.index_url
// Check if URL is not empty before proceeding
guard let url = campaignUrl, !url.isEmpty else {
print("Campaign URL is empty, cannot open CampaignViewController for campaign: \(campaign._title ?? "Unknown")")
return
}
// Proceed with navigation only if we have a valid URL
let vc = SwiftWarplyFramework.CampaignViewController(nibName: "CampaignViewController", bundle: Bundle.frameworkBundle)
vc.campaignUrl = url
vc.showHeader = false
self.navigationController?.pushViewController(vc, animated: true)
}
private func openArticleViewController(with index: Int) {
// Get the combined banner items (campaigns + articles)
var bannerItems: [Any] = []
bannerItems.append(contentsOf: self.bannerCampaigns)
bannerItems.append(contentsOf: self.articles)
// Validate index bounds for combined items
guard index < bannerItems.count else {
print("Invalid banner item index: \(index)")
return
}
let item = bannerItems[index]
// Handle only articles
guard let article = item as? ArticleModel else {
print("Item at index \(index) is not an article")
return
}
// Try to match article's url_link with a couponset uuid
let urlLink = article._url_link
if !urlLink.isEmpty,
let matchedCouponSet = self.couponSets.first(where: { $0._uuid == urlLink }) {
// Bind merchant data if available
if matchedCouponSet._merchant == nil,
let merchant = self.merchants.first(where: { $0._uuid == matchedCouponSet._merchant_uuid }) {
matchedCouponSet._merchant = merchant
}
openCouponsetViewController(with: matchedCouponSet)
return
}
// No matching couponset found
print("No matching couponset found for article: \(article._name) with url_link: \(article._url_link)")
}
private func openCouponViewController(with offer: OfferModel) {
// let vc = SwiftWarplyFramework.CouponViewController(nibName: "CouponViewController", bundle: Bundle.frameworkBundle)
// vc.coupon = offer
// self.navigationController?.pushViewController(vc, animated: true)
print("CouponViewController navigation commented out - will handle later")
}
private func openCouponsetViewController(with couponSet: CouponSetItemModel) {
let vc = SwiftWarplyFramework.CouponsetViewController(nibName: "CouponsetViewController", bundle: Bundle.frameworkBundle)
vc.couponset = couponSet
self.navigationController?.pushViewController(vc, animated: true)
}
private func openProfileViewController() {
let vc = SwiftWarplyFramework.ProfileViewController(nibName: "ProfileViewController", bundle: Bundle.frameworkBundle)
self.navigationController?.pushViewController(vc, animated: true)
}
}
// MARK: - TableView
extension MyRewardsViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
return sections.count
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return nil
}
public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 0.0
}
public func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.0
}
public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return nil
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard indexPath.section < sections.count else {
return UITableViewCell() // Return empty cell if section doesn't exist
}
let sectionModel = sections[indexPath.section]
switch sectionModel.sectionType {
case .myRewardsProfileInfo:
let cell = tableView.dequeueReusableCell(withIdentifier: "MyRewardsProfileInfoTableViewCell", for: indexPath) as! MyRewardsProfileInfoTableViewCell
cell.delegate = self
cell.configureCell(data: sectionModel)
return cell
case .myRewardsBannerOffers:
let cell = tableView.dequeueReusableCell(withIdentifier: "MyRewardsBannerOffersScrollTableViewCell", for: indexPath) as! MyRewardsBannerOffersScrollTableViewCell
cell.delegate = self
cell.configureCell(data: sectionModel)
return cell
case .myRewardsHorizontalCouponsets:
let cell = tableView.dequeueReusableCell(withIdentifier: "MyRewardsOffersScrollTableViewCell", for: indexPath) as! MyRewardsOffersScrollTableViewCell
cell.delegate = self
cell.configureCell(data: sectionModel)
return cell
case .profileHeader, .profileQuestionnaire, .profileCouponFilters, .profileCoupon, .staticContent:
// These sections don't belong in MyRewardsViewController - return empty cell
// This should not happen in normal operation since MyRewardsViewController
// should only contain MyRewards-specific sections
let cell = UITableViewCell()
cell.isHidden = true
return cell
}
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// Handle selection if needed - currently no action required
tableView.deselectRow(at: indexPath, animated: true)
}
}
// Add delegate conformance
extension MyRewardsViewController: MyRewardsProfileInfoTableViewCellDelegate {
func didTapProfileButton() {
// Navigate to ProfileViewController
openProfileViewController()
}
}
// Add delegate conformance
extension MyRewardsViewController: MyRewardsBannerOffersScrollTableViewCellDelegate {
func didSelectBannerOffer(_ index: Int) {
// Navigate to CampaignViewController
openCampaignViewController(with: index)
}
func didSelectBannerArticle(_ index: Int) {
// Navigate to Article detail (TODO implementation)
openArticleViewController(with: index)
}
// func didTapProfileButton() {
// // Navigate to ProfileViewController
// openProfileViewController()
// }
}
// Add delegate conformance
extension MyRewardsViewController: MyRewardsOffersScrollTableViewCellDelegate {
func didSelectOffer(_ offer: OfferModel) {
// Navigate to CouponViewController
openCouponViewController(with: offer)
}
func didSelectCouponSet(_ couponSet: CouponSetItemModel) {
openCouponsetViewController(with: couponSet)
}
}