Manos Chorianopoulos

fix unified coupon MapVC

......@@ -27,9 +27,11 @@ import MapKit
// public
public var couponSet: swiftApi.CouponSetItemModel?
public var isMarket: Bool? = false
var merchantsArray:Array<swiftApi.MerchantModel> = []
var selectedMerchant: swiftApi.MerchantModel?
var annotationGroup = [MKPointAnnotation]()
var parentMerchant: swiftApi.MerchantModel?
//
var loading: Bool = false
......@@ -126,7 +128,14 @@ import MapKit
}
} else {
let appUuid = swiftApi().getAppUuid()
let categoryUuids = appUuid == "0086a2088301440792091b9f814c2267" ? [""] : ["adcace6cab6049c7b7271bc85bc2b26d"]
// 2a6adade35f1484994a3d4c8f006b909 category is for SM only
var categoryUuids = [""]
if (self.isMarket == true) {
categoryUuids = appUuid == "0086a2088301440792091b9f814c2267" ? ["2a6adade35f1484994a3d4c8f006b909"] : ["adcace6cab6049c7b7271bc85bc2b26d"]
} else {
categoryUuids = appUuid == "0086a2088301440792091b9f814c2267" ? [""] : ["adcace6cab6049c7b7271bc85bc2b26d"]
}
swiftApi().getMultilingualMerchantsAsync(categoryUuids, false, 0.0, [], "", 0, [], getMerchantsCallback)
showContent()
......@@ -138,10 +147,22 @@ import MapKit
if (merchantsData != nil) {
DispatchQueue.main.async {
self.merchantsArray = merchantsData ?? []
let filteredMerchants = (merchantsData ?? []).filter({ return (($0._latitude != 0.0) && ($0._longitude != 0.0)) })
if (self.isMarket == true) {
self.merchantsArray = filteredMerchants
if let parent = (merchantsData ?? []).first(where: {(($0._latitude == 0.0) && ($0._longitude == 0.0))}) {
self.parentMerchant = parent
}
} else {
self.merchantsArray = merchantsData ?? []
}
self.loadMapPins()
let filteredMerchants = self.merchantsArray.filter({ return (($0._latitude != 0.0) && ($0._longitude != 0.0)) })
// let filteredMerchants = self.merchantsArray.filter({ return (($0._latitude != 0.0) && ($0._longitude != 0.0)) })
if (filteredMerchants.count == 0) {
self.showDialog("Καταστήματα συνεργάτη", "Ο συνεργάτης διαθέτει μόνο ηλεκτρονικό κατάστημα για ηλεκτρονικές παραγγελίες.")
}
......@@ -298,7 +319,13 @@ import MapKit
self.selectedMerchant = annotation.model
self.titleView.text = self.selectedMerchant?._admin_name
self.nameImageView.load(link: self.selectedMerchant?._img_preview ?? "", placeholder: UIImage(), cache: URLCache())
if (self.isMarket == true) {
self.nameImageView.load(link: self.parentMerchant?._img_preview ?? "", placeholder: UIImage(), cache: URLCache())
} else {
self.nameImageView.load(link: self.selectedMerchant?._img_preview ?? "", placeholder: UIImage(), cache: URLCache())
}
self.nameView.text = self.selectedMerchant?._name
// TODO: Make dynamic
self.hoursView.text = ""
......
......@@ -82,6 +82,7 @@ import AVFoundation
//
let vc = SwiftWarplyFramework.MapsViewController(nibName: "MapsViewController", bundle: Bundle(for: MyEmptyClass.self))
// vc.couponSet = coupon?.couponset_data
vc.isMarket = true
self.navigationController?.pushViewController(vc, animated: true)
// if (mapBtnVisible == true) {
......