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>
|
focusRef: React.Ref<HTMLAnchorElement>
|
||||||
}) {
|
}) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
|
const { confirmationNumber, bookingUrl, transactionDate, awardPoints } =
|
||||||
const { confirmationNumber, bookingUrl, checkinDate, awardPoints } =
|
|
||||||
transaction.attributes
|
transaction.attributes
|
||||||
const balfwd = confirmationNumber === BALFWD
|
const balfwd = confirmationNumber === BALFWD
|
||||||
const nonTransactional = confirmationNumber === NON_TRANSACTIONAL
|
const nonTransactional = confirmationNumber === NON_TRANSACTIONAL
|
||||||
|
|
||||||
const day = checkinDate.split("-")[2].replace(/^0/, "")
|
const date = dt.utc(transactionDate).locale(lang)
|
||||||
const month = dt(checkinDate.split("-")[1]).locale(lang).format("MMM")
|
const day = date.format("D")
|
||||||
|
const month = date.format("MMM")
|
||||||
|
|
||||||
const formattedPoints = intl.formatNumber(Math.abs(awardPoints))
|
const formattedPoints = intl.formatNumber(Math.abs(awardPoints))
|
||||||
const calculatedPoints =
|
const calculatedPoints =
|
||||||
@@ -93,41 +93,52 @@ export function PointTransactionRow({
|
|||||||
|
|
||||||
function getDescription(transaction: Transaction, intl: IntlShape) {
|
function getDescription(transaction: Transaction, intl: IntlShape) {
|
||||||
const hotelInformation = transaction.attributes.hotelInformation
|
const hotelInformation = transaction.attributes.hotelInformation
|
||||||
const balfwd = transaction.attributes.confirmationNumber === BALFWD
|
const isBalfwd = transaction.attributes.confirmationNumber === BALFWD
|
||||||
const nonTransactional =
|
const isNonTransactional =
|
||||||
transaction.attributes.confirmationNumber === NON_TRANSACTIONAL
|
transaction.attributes.confirmationNumber === NON_TRANSACTIONAL
|
||||||
|
|
||||||
|
if (isNonTransactional && transaction.attributes.nights === 0) {
|
||||||
|
return intl.formatMessage({
|
||||||
|
id: "myPoints.pointTransactions.pointsActivity",
|
||||||
|
defaultMessage: "Point activity",
|
||||||
|
})
|
||||||
|
}
|
||||||
switch (transaction.type) {
|
switch (transaction.type) {
|
||||||
case Transactions.rewardType.stay:
|
case Transactions.rewardType.stay:
|
||||||
return nonTransactional && transaction.attributes.nights === 0
|
if (hotelInformation?.name) {
|
||||||
? intl.formatMessage({
|
return intl.formatMessage(
|
||||||
id: "myPoints.pointTransactions.pointsActivity",
|
{
|
||||||
defaultMessage: "Point activity",
|
id: "myPoints.pointTransactions.stayAt",
|
||||||
})
|
defaultMessage: "Stay at {hotelName}",
|
||||||
: hotelInformation?.name
|
},
|
||||||
? intl.formatMessage(
|
{ hotelName: hotelInformation.name }
|
||||||
{
|
)
|
||||||
id: "myPoints.pointTransactions.stayAt",
|
} else {
|
||||||
defaultMessage: "Stay at {hotelName}",
|
return ""
|
||||||
},
|
}
|
||||||
{ hotelName: hotelInformation?.name }
|
|
||||||
)
|
|
||||||
: ""
|
|
||||||
|
|
||||||
case Transactions.rewardType.stayAdj:
|
case Transactions.rewardType.stayAdj:
|
||||||
if (transaction.attributes.hotelOperaId === "ORS") {
|
if (transaction.attributes.hotelOperaId === "ORS") {
|
||||||
return intl.formatMessage({
|
return intl.formatMessage({
|
||||||
id: "earnAndBurn.journeyTable.formerScandicHotel",
|
id: "myPoints.pointTransactions.formerScandicHotel",
|
||||||
defaultMessage: "Former Scandic Hotel",
|
defaultMessage: "Former Scandic Hotel",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (balfwd) {
|
if (isBalfwd) {
|
||||||
return intl.formatMessage({
|
return intl.formatMessage({
|
||||||
id: "myPoints.pointTransactions.pointsEarnedPriorMay2021",
|
id: "myPoints.pointTransactions.pointsEarnedPriorMay2021",
|
||||||
defaultMessage: "Points earned prior to May 1, 2021",
|
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:
|
case Transactions.rewardType.ancillary:
|
||||||
return intl.formatMessage({
|
return intl.formatMessage({
|
||||||
id: "myPoints.pointTransactions.extrasToBooking",
|
id: "myPoints.pointTransactions.extrasToBooking",
|
||||||
@@ -157,5 +168,7 @@ function getDescription(transaction: Transaction, intl: IntlShape) {
|
|||||||
id: "myPoints.pointTransactions.pointShop",
|
id: "myPoints.pointTransactions.pointShop",
|
||||||
defaultMessage: "Scandic Friends Point Shop",
|
defaultMessage: "Scandic Friends Point Shop",
|
||||||
})
|
})
|
||||||
|
default:
|
||||||
|
return undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { Fragment, useCallback, useRef } from "react"
|
import { Fragment, useCallback, useRef } from "react"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { dt } from "@scandic-hotels/common/dt"
|
||||||
import useStickyPosition from "@scandic-hotels/common/hooks/useStickyPosition"
|
import useStickyPosition from "@scandic-hotels/common/hooks/useStickyPosition"
|
||||||
import { StickyElementNameEnum } from "@scandic-hotels/common/stores/sticky-position"
|
import { StickyElementNameEnum } from "@scandic-hotels/common/stores/sticky-position"
|
||||||
import { Divider } from "@scandic-hotels/design-system/Divider"
|
import { Divider } from "@scandic-hotels/design-system/Divider"
|
||||||
@@ -40,9 +41,9 @@ export function PointTransactionList() {
|
|||||||
.flatMap((page) => page.data)
|
.flatMap((page) => page.data)
|
||||||
|
|
||||||
const groupedTransactions =
|
const groupedTransactions =
|
||||||
transactions?.reduce<Record<number, typeof transactions>>(
|
transactions?.reduce<Record<string, typeof transactions>>(
|
||||||
(acc, transaction) => {
|
(acc, transaction) => {
|
||||||
const year = new Date(transaction.attributes.checkinDate).getFullYear()
|
const year = dt.utc(transaction.attributes.transactionDate).year()
|
||||||
if (!acc[year]) acc[year] = []
|
if (!acc[year]) acc[year] = []
|
||||||
acc[year].push(transaction)
|
acc[year].push(transaction)
|
||||||
return acc
|
return acc
|
||||||
|
|||||||
@@ -279,21 +279,17 @@ export const userQueryRouter = router({
|
|||||||
language
|
language
|
||||||
)
|
)
|
||||||
const allTransactions = updatedData
|
const allTransactions = updatedData
|
||||||
.filter((t) => t.type !== Transactions.rewardType.expired)
|
.filter(
|
||||||
|
(t) =>
|
||||||
|
t.type !== Transactions.rewardType.expired &&
|
||||||
|
t.attributes.awardPoints !== 0
|
||||||
|
)
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
if (a.attributes.confirmationNumber === BALFWD) return 1
|
if (a.attributes.confirmationNumber === BALFWD) return 1
|
||||||
if (b.attributes.confirmationNumber === BALFWD) return -1
|
if (b.attributes.confirmationNumber === BALFWD) return -1
|
||||||
|
|
||||||
const dateA = new Date(
|
const dateA = new Date(a.attributes.transactionDate)
|
||||||
a.attributes.checkinDate
|
const dateB = new Date(b.attributes.transactionDate)
|
||||||
? a.attributes.checkinDate
|
|
||||||
: a.attributes.transactionDate
|
|
||||||
)
|
|
||||||
const dateB = new Date(
|
|
||||||
b.attributes.checkinDate
|
|
||||||
? b.attributes.checkinDate
|
|
||||||
: b.attributes.transactionDate
|
|
||||||
)
|
|
||||||
|
|
||||||
return dateA > dateB ? -1 : 1
|
return dateA > dateB ? -1 : 1
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user