Manos Chorianopoulos

fix campaign url constructions at GFYVC

......@@ -86,7 +86,26 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
let url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
var url = ""
let hasLoyaltyCampaignId = campaigns[indexPath.row].loyaltyCampaignId != ""
if (hasLoyaltyCampaignId) {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].loyaltyCampaignId }
if (loyaltyCampaignIdExists == true) {
var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel()
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaigns[indexPath.row].loyaltyCampaignId) {
ccmsCampaignFound = item
}
}
url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound)
}
} else {
url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
}
vc.campaignUrl = url
self.navigationController?.pushViewController(vc, animated: true)
}
......