Manos Chorianopoulos

openArticle with matched couponset

......@@ -553,10 +553,21 @@ import UIKit
return
}
// TODO: Implement article navigation
// This could navigate to a web view with article content,
// or a dedicated article detail screen
print("TODO: Navigate to article: \(article._name) - \(article._id)")
// 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) {
......