From 2f73fce6f29e8ae1fa9104803cf6f2313edebbd2 Mon Sep 17 00:00:00 2001 From: Emma Zettervall Date: Fri, 30 Jan 2026 14:59:14 +0000 Subject: [PATCH] Merged in fix/LOY-391-fix-for-transaction-details-not-available (pull request #3513) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../PointTransactionRow/index.tsx | 63 +++++++++++-------- .../PointTransactionList/index.tsx | 5 +- packages/trpc/lib/routers/user/query/index.ts | 18 +++--- 3 files changed, 48 insertions(+), 38 deletions(-) diff --git a/apps/scandic-web/components/Blocks/DynamicContent/Points/PointTransactions/PointTransactionList/PointTransactionRow/index.tsx b/apps/scandic-web/components/Blocks/DynamicContent/Points/PointTransactions/PointTransactionList/PointTransactionRow/index.tsx index 466c1d56f..30ecc509b 100644 --- a/apps/scandic-web/components/Blocks/DynamicContent/Points/PointTransactions/PointTransactionList/PointTransactionRow/index.tsx +++ b/apps/scandic-web/components/Blocks/DynamicContent/Points/PointTransactions/PointTransactionList/PointTransactionRow/index.tsx @@ -26,14 +26,14 @@ export function PointTransactionRow({ focusRef: React.Ref }) { 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 } } diff --git a/apps/scandic-web/components/Blocks/DynamicContent/Points/PointTransactions/PointTransactionList/index.tsx b/apps/scandic-web/components/Blocks/DynamicContent/Points/PointTransactions/PointTransactionList/index.tsx index 7d5191e76..92db5fcd6 100644 --- a/apps/scandic-web/components/Blocks/DynamicContent/Points/PointTransactions/PointTransactionList/index.tsx +++ b/apps/scandic-web/components/Blocks/DynamicContent/Points/PointTransactions/PointTransactionList/index.tsx @@ -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>( + transactions?.reduce>( (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 diff --git a/packages/trpc/lib/routers/user/query/index.ts b/packages/trpc/lib/routers/user/query/index.ts index 065d7f357..cb5591ecf 100644 --- a/packages/trpc/lib/routers/user/query/index.ts +++ b/packages/trpc/lib/routers/user/query/index.ts @@ -279,21 +279,17 @@ export const userQueryRouter = router({ language ) const allTransactions = updatedData - .filter((t) => t.type !== Transactions.rewardType.expired) + .filter( + (t) => + t.type !== Transactions.rewardType.expired && + t.attributes.awardPoints !== 0 + ) .sort((a, b) => { 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 - ) + const dateA = new Date(a.attributes.transactionDate) + const dateB = new Date(b.attributes.transactionDate) return dateA > dateB ? -1 : 1 })