Merged in feat/SW-165-fixes (pull request #460)
Feat/SW-165 fixes * fix(SW-165): update translations for reward labels * fix(SW-165): Fix sorting and filtering of transactions and hide fields when BALFWD * fix(SW-165): update condition Approved-by: Michael Zetterberg
This commit is contained in:
@@ -510,14 +510,34 @@ export const userQueryRouter = router({
|
||||
)
|
||||
|
||||
const pageData = updatedData
|
||||
.filter((t) => t.type !== RewardTransactionTypes.expired)
|
||||
.filter((t) => {
|
||||
if (
|
||||
t.type === RewardTransactionTypes.rewardNight &&
|
||||
t.attributes.hotelOperaId === "ORS"
|
||||
) {
|
||||
return false
|
||||
}
|
||||
if (t.type === RewardTransactionTypes.expired) return false
|
||||
|
||||
return true
|
||||
})
|
||||
.sort((a, b) => {
|
||||
// 'BALFWD' are transactions from Opera migration that happended in May 2021
|
||||
const isBalfwd =
|
||||
a.type === RewardTransactionTypes.stayAdj &&
|
||||
a.attributes.confirmationNumber === "BALFWD"
|
||||
if (isBalfwd) return 1
|
||||
return a.attributes.checkinDate > b.attributes.checkinDate ? -1 : 1
|
||||
if (a.attributes.confirmationNumber === "BALFWD") return 1
|
||||
if (b.attributes.confirmationNumber === "BALFWD") return -1
|
||||
|
||||
const dateA = new Date(
|
||||
a.attributes.checkinDate
|
||||
? a.attributes.checkinDate
|
||||
: a.attributes.transactionDate
|
||||
)
|
||||
const dateB = new Date(
|
||||
b.attributes.checkinDate
|
||||
? b.attributes.checkinDate
|
||||
: b.attributes.transactionDate
|
||||
)
|
||||
|
||||
return dateA > dateB ? -1 : 1
|
||||
})
|
||||
.slice(limit * (page - 1), limit * page)
|
||||
|
||||
@@ -541,7 +561,7 @@ export const userQueryRouter = router({
|
||||
}),
|
||||
},
|
||||
meta: {
|
||||
totalPages: Math.ceil(verifiedData.data.data.length / limit),
|
||||
totalPages: Math.ceil(pageData.length / limit),
|
||||
},
|
||||
}
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user