Merged in fix/LOY-391-fix-for-transaction-details-not-available (pull request #3513)
fix(LOY-391): uses transaction date if checkinDate does not exist * fix(LOY-391): uses transaction date if checkinDate does not exist * fix(LOY-391): changed date to datejs and fixed description for reward night and reward gift * fix(LOY-391):use year transaction date * fix(LOY-391): fixed date timezone and dt() instead of datejs() * fix(LOY-391): small improv with year * fix(LOY-391): utc fix * fix(LOY-391): changed sorting order on transaction date * fix(LOY-391): filter out transactions with 0 award points Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -26,14 +26,14 @@ export function PointTransactionRow({
|
||||
focusRef: React.Ref<HTMLAnchorElement>
|
||||
}) {
|
||||
const intl = useIntl()
|
||||
|
||||
const { confirmationNumber, bookingUrl, checkinDate, awardPoints } =
|
||||
const { confirmationNumber, bookingUrl, transactionDate, awardPoints } =
|
||||
transaction.attributes
|
||||
const balfwd = confirmationNumber === BALFWD
|
||||
const nonTransactional = confirmationNumber === NON_TRANSACTIONAL
|
||||
|
||||
const day = checkinDate.split("-")[2].replace(/^0/, "")
|
||||
const month = dt(checkinDate.split("-")[1]).locale(lang).format("MMM")
|
||||
const date = dt.utc(transactionDate).locale(lang)
|
||||
const day = date.format("D")
|
||||
const month = date.format("MMM")
|
||||
|
||||
const formattedPoints = intl.formatNumber(Math.abs(awardPoints))
|
||||
const calculatedPoints =
|
||||
@@ -93,41 +93,52 @@ export function PointTransactionRow({
|
||||
|
||||
function getDescription(transaction: Transaction, intl: IntlShape) {
|
||||
const hotelInformation = transaction.attributes.hotelInformation
|
||||
const balfwd = transaction.attributes.confirmationNumber === BALFWD
|
||||
const nonTransactional =
|
||||
const isBalfwd = transaction.attributes.confirmationNumber === BALFWD
|
||||
const isNonTransactional =
|
||||
transaction.attributes.confirmationNumber === NON_TRANSACTIONAL
|
||||
|
||||
if (isNonTransactional && transaction.attributes.nights === 0) {
|
||||
return intl.formatMessage({
|
||||
id: "myPoints.pointTransactions.pointsActivity",
|
||||
defaultMessage: "Point activity",
|
||||
})
|
||||
}
|
||||
switch (transaction.type) {
|
||||
case Transactions.rewardType.stay:
|
||||
return nonTransactional && transaction.attributes.nights === 0
|
||||
? intl.formatMessage({
|
||||
id: "myPoints.pointTransactions.pointsActivity",
|
||||
defaultMessage: "Point activity",
|
||||
})
|
||||
: hotelInformation?.name
|
||||
? intl.formatMessage(
|
||||
{
|
||||
id: "myPoints.pointTransactions.stayAt",
|
||||
defaultMessage: "Stay at {hotelName}",
|
||||
},
|
||||
{ hotelName: hotelInformation?.name }
|
||||
)
|
||||
: ""
|
||||
|
||||
if (hotelInformation?.name) {
|
||||
return intl.formatMessage(
|
||||
{
|
||||
id: "myPoints.pointTransactions.stayAt",
|
||||
defaultMessage: "Stay at {hotelName}",
|
||||
},
|
||||
{ hotelName: hotelInformation.name }
|
||||
)
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
case Transactions.rewardType.stayAdj:
|
||||
if (transaction.attributes.hotelOperaId === "ORS") {
|
||||
return intl.formatMessage({
|
||||
id: "earnAndBurn.journeyTable.formerScandicHotel",
|
||||
id: "myPoints.pointTransactions.formerScandicHotel",
|
||||
defaultMessage: "Former Scandic Hotel",
|
||||
})
|
||||
}
|
||||
if (balfwd) {
|
||||
if (isBalfwd) {
|
||||
return intl.formatMessage({
|
||||
id: "myPoints.pointTransactions.pointsEarnedPriorMay2021",
|
||||
defaultMessage: "Points earned prior to May 1, 2021",
|
||||
})
|
||||
}
|
||||
break
|
||||
|
||||
case Transactions.rewardType.redgift:
|
||||
return intl.formatMessage({
|
||||
id: "myPoints.pointTransactions.redGift",
|
||||
defaultMessage: "Reward Gift",
|
||||
})
|
||||
case Transactions.rewardType.rewardNight:
|
||||
return intl.formatMessage({
|
||||
id: "myPoints.pointTransactions.rewardNight",
|
||||
defaultMessage: "Reward Night",
|
||||
})
|
||||
case Transactions.rewardType.ancillary:
|
||||
return intl.formatMessage({
|
||||
id: "myPoints.pointTransactions.extrasToBooking",
|
||||
@@ -157,5 +168,7 @@ function getDescription(transaction: Transaction, intl: IntlShape) {
|
||||
id: "myPoints.pointTransactions.pointShop",
|
||||
defaultMessage: "Scandic Friends Point Shop",
|
||||
})
|
||||
default:
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { Fragment, useCallback, useRef } from "react"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { dt } from "@scandic-hotels/common/dt"
|
||||
import useStickyPosition from "@scandic-hotels/common/hooks/useStickyPosition"
|
||||
import { StickyElementNameEnum } from "@scandic-hotels/common/stores/sticky-position"
|
||||
import { Divider } from "@scandic-hotels/design-system/Divider"
|
||||
@@ -40,9 +41,9 @@ export function PointTransactionList() {
|
||||
.flatMap((page) => page.data)
|
||||
|
||||
const groupedTransactions =
|
||||
transactions?.reduce<Record<number, typeof transactions>>(
|
||||
transactions?.reduce<Record<string, typeof transactions>>(
|
||||
(acc, transaction) => {
|
||||
const year = new Date(transaction.attributes.checkinDate).getFullYear()
|
||||
const year = dt.utc(transaction.attributes.transactionDate).year()
|
||||
if (!acc[year]) acc[year] = []
|
||||
acc[year].push(transaction)
|
||||
return acc
|
||||
|
||||
Reference in New Issue
Block a user