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
2022-09-13 17:09:22 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
547ce2e1b1860720a366355a4d31e5b58a830bed
547ce2e1
1 parent
48324c1f
add active coupons sortin by expiration date
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
3 deletions
SwiftWarplyFramework/SwiftWarplyFramework/WalletViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/WalletViewController.swift
View file @
547ce2e
...
...
@@ -206,7 +206,8 @@ import SwiftEventBus
if
(
dfyCoupons
.
count
>
0
)
{
if
(
dfyCoupons
.
count
==
1
)
{
let
dateFormatter
=
DateFormatter
()
dateFormatter
.
dateFormat
=
"yyyy-MM-dd hh:mm:ss"
// dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss"
dateFormatter
.
dateFormat
=
"yyyy-MM-dd HH:mm"
// sort dfyCoupons by date
dfyCoupons
.
sort
(
by
:
{
...
...
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
547ce2e
...
...
@@ -644,7 +644,22 @@ public class swiftApi {
// SwiftEventBus.post("coupons_fetched")
let
activeCoupons
=
tempCoupons
.
filter
({
return
$0
.
status
==
1
})
var
activeCoupons
=
tempCoupons
.
filter
({
return
$0
.
status
==
1
})
// sort activeCoupons by expiration date
let
dateFormatter
=
DateFormatter
()
dateFormatter
.
dateFormat
=
"dd/MM/yyyy"
activeCoupons
.
sort
(
by
:
{
let
date1
=
dateFormatter
.
date
(
from
:
$0
.
expiration
??
""
)
let
date2
=
dateFormatter
.
date
(
from
:
$1
.
expiration
??
""
)
if
((
date1
!=
nil
)
&&
(
date2
!=
nil
))
{
return
date1
!.
compare
(
date2
!
)
==
.
orderedAscending
}
else
{
return
false
}
})
getCouponsCallback
(
activeCoupons
)
}
...
...
@@ -3781,9 +3796,25 @@ public class swiftApi {
public
func
setCouponList
(
_
coupons
:
Array
<
CouponItemModel
>
)
{
// let filteredCoupons = coupons.filter { CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: $0.discount ?? "")) }
let
activeCoupons
=
coupons
.
filter
({
return
$0
.
status
==
1
})
var
activeCoupons
=
coupons
.
filter
({
return
$0
.
status
==
1
})
let
oldCoupons
=
coupons
.
filter
({
return
$0
.
status
==
0
})
// sort activeCoupons by expiration date
let
dateFormatter
=
DateFormatter
()
dateFormatter
.
dateFormat
=
"dd/MM/yyyy"
activeCoupons
.
sort
(
by
:
{
let
date1
=
dateFormatter
.
date
(
from
:
$0
.
expiration
??
""
)
let
date2
=
dateFormatter
.
date
(
from
:
$1
.
expiration
??
""
)
if
((
date1
!=
nil
)
&&
(
date2
!=
nil
))
{
return
date1
!.
compare
(
date2
!
)
==
.
orderedAscending
}
else
{
return
false
}
})
GlobalVariables
.
couponList
=
activeCoupons
let
loyaltyBadge
=
LoyaltyBadgeModel
()
...
...
Please
register
or
login
to post a comment