Showing
1 changed file
with
25 additions
and
1 deletions
| ... | @@ -175,10 +175,34 @@ import UIKit | ... | @@ -175,10 +175,34 @@ import UIKit |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | let alert = UIAlertController(title: "Επιτυχία", message: message, preferredStyle: .alert) | 177 | let alert = UIAlertController(title: "Επιτυχία", message: message, preferredStyle: .alert) |
| 178 | - alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) | 178 | + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { [weak self] _ in |
| 179 | + self?.navigateToCouponViewController(couponCode: couponCode, expiration: expiration) | ||
| 180 | + })) | ||
| 179 | present(alert, animated: true, completion: nil) | 181 | present(alert, animated: true, completion: nil) |
| 180 | } | 182 | } |
| 181 | 183 | ||
| 184 | + private func navigateToCouponViewController(couponCode: String, expiration: String) { | ||
| 185 | + // Build a CouponItemModel from the retrieve response + current couponset | ||
| 186 | + let couponDict: [String: Any] = [ | ||
| 187 | + "coupon": couponCode, | ||
| 188 | + "expiration": expiration, | ||
| 189 | + "status": 1, | ||
| 190 | + "couponset_uuid": couponset?._uuid ?? "" | ||
| 191 | + ] | ||
| 192 | + | ||
| 193 | + let couponItem = CouponItemModel(dictionary: couponDict) | ||
| 194 | + | ||
| 195 | + // Attach the couponset data so CouponViewController can display name, image, description, terms, etc. | ||
| 196 | + if let couponsetData = couponset { | ||
| 197 | + couponItem.setCouponSetData(couponsetData) | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + // Navigate to CouponViewController | ||
| 201 | + let couponVC = CouponViewController() | ||
| 202 | + couponVC.coupon = couponItem | ||
| 203 | + self.navigationController?.pushViewController(couponVC, animated: true) | ||
| 204 | + } | ||
| 205 | + | ||
| 182 | private func showErrorAlert(message: String) { | 206 | private func showErrorAlert(message: String) { |
| 183 | let alert = UIAlertController(title: "Σφάλμα", message: message, preferredStyle: .alert) | 207 | let alert = UIAlertController(title: "Σφάλμα", message: message, preferredStyle: .alert) |
| 184 | alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) | 208 | alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) | ... | ... |
-
Please register or login to post a comment