Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Manos Chorianopoulos
2024-10-16 11:51:20 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
245e7719cfbe79e7d0c4f5f2427e7b39fa1db2e0
245e7719
1 parent
d907d80d
add createUnifiedCoupon functionality at UnifiedCouponsViewController
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
3 deletions
SwiftWarplyFramework/SwiftWarplyFramework/UnifiedCouponsViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/UnifiedCouponsViewController.swift
View file @
245e771
...
...
@@ -37,7 +37,9 @@ import SwiftEventBus
DispatchQueue
.
main
.
async
{
self
.
unifiedCoupons
=
swiftApi
()
.
getUnifiedCouponList
()
self
.
tableView
.
reloadData
()
// self.tableView.reloadData()
// Reload the Unified Coupons section only
self
.
tableView
.
reloadSections
(
IndexSet
(
integer
:
0
),
with
:
.
automatic
)
if
(
self
.
unifiedCoupons
.
count
==
0
&&
self
.
smCoupons
.
count
==
0
)
{
self
.
emptyView
.
isHidden
=
false
...
...
@@ -53,7 +55,9 @@ import SwiftEventBus
DispatchQueue
.
main
.
async
{
self
.
smCoupons
=
swiftApi
()
.
getSMCouponList
()
self
.
tableView
.
reloadData
()
// self.tableView.reloadData()
// Reload the SM Coupons section only
self
.
tableView
.
reloadSections
(
IndexSet
(
integer
:
1
),
with
:
.
automatic
)
if
(
self
.
unifiedCoupons
.
count
==
0
&&
self
.
smCoupons
.
count
==
0
)
{
self
.
emptyView
.
isHidden
=
false
...
...
@@ -183,12 +187,70 @@ import SwiftEventBus
}
}
func
showSuccessDialog
()
->
Void
{
let
alert
=
UIAlertController
(
title
:
"Δημιουργία Κουπονιού"
,
message
:
"Το ενιαίο κουπόνι σου δημιουργήθηκε επιτυχώς."
,
preferredStyle
:
.
alert
)
alert
.
addAction
(
UIAlertAction
(
title
:
"OK"
,
style
:
.
default
,
handler
:
{
action
in
switch
action
.
style
{
case
.
default
:
print
(
"default"
)
// self.navigationController?.popViewController(animated: true)
// self.dismiss(animated: true, completion: {})
case
.
cancel
:
print
(
"cancel"
)
case
.
destructive
:
print
(
"destructive"
)
}
}))
self
.
present
(
alert
,
animated
:
true
,
completion
:
nil
)
}
func
showFailureDialog
()
->
Void
{
let
alert
=
UIAlertController
(
title
:
"Αποτυχία Δημιουργίας Κουπονιού"
,
message
:
"Το ενιαίο κουπόνι σου δεν δημιουργήθηκε. Προσπάθησε ξανά."
,
preferredStyle
:
.
alert
)
alert
.
addAction
(
UIAlertAction
(
title
:
"OK"
,
style
:
.
default
,
handler
:
{
action
in
switch
action
.
style
{
case
.
default
:
print
(
"default"
)
case
.
cancel
:
print
(
"cancel"
)
case
.
destructive
:
print
(
"destructive"
)
}
}))
self
.
present
(
alert
,
animated
:
true
,
completion
:
nil
)
}
// MARK: - Actions
@IBAction
func
submitButtonAction
(
_
sender
:
Any
)
{
// let smCouponsString = self.smCouponsSelected.map { $0.coupon ?? "" }.joined(separator: ",")
// swiftApi().logTrackersEvent("click", ("UnifySMCoupons:" + (smCouponsString)))
// TODO: Add action
let
smCouponCodes
=
self
.
smCouponsSelected
.
map
{
$0
.
coupon
??
""
}
swiftApi
()
.
createUnifiedCouponAsync
(
couponCodes
:
smCouponCodes
)
{
responseData
in
if
(
responseData
!=
nil
)
{
DispatchQueue
.
main
.
async
{
if
(
responseData
?
.
getStatus
==
1
)
{
self
.
smCouponsSelected
=
[]
self
.
circleImageView
.
image
=
UIImage
(
named
:
"circle_unchecked"
,
in
:
MyEmptyClass
.
resourceBundle
(),
compatibleWith
:
nil
)
// Unselected image
self
.
handleSubmitButtonUI
()
// Reload the SM Coupons section only
self
.
tableView
.
reloadSections
(
IndexSet
(
integer
:
1
),
with
:
.
automatic
)
self
.
showSuccessDialog
()
}
}
}
}
failureCallback
:
{
errorCode
in
self
.
showFailureDialog
()
}
}
}
...
...
Please
register
or
login
to post a comment