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:
Tobias Johansson
2024-08-22 14:34:55 +00:00
parent 0815075ba2
commit 159114a082
7 changed files with 80 additions and 50 deletions

View File

@@ -27,8 +27,15 @@ export default function Row({ transaction }: RowProps) {
switch (transaction.type) {
case RewardTransactionTypes.stay:
if (transaction.hotelId === "ORS")
case RewardTransactionTypes.stayAdj:
if (transaction.hotelId === "ORS") {
description = intl.formatMessage({ id: "Former Scandic Hotel" })
}
if (transaction.confirmationNumber === "BALFWD") {
description = intl.formatMessage({
id: "Points earned prior to May 1, 2021",
})
}
break
case RewardTransactionTypes.ancillary:
description = intl.formatMessage({ id: "Extras to your booking" })
@@ -41,21 +48,31 @@ export default function Row({ transaction }: RowProps) {
break
case RewardTransactionTypes.tui_points:
description = intl.formatMessage({ id: "TUI Points" })
case RewardTransactionTypes.stayAdj:
if (transaction.confirmationNumber === "BALFWD")
description = intl.formatMessage({
id: "Points earned prior to May 1, 2021",
})
break
case RewardTransactionTypes.pointShop:
description = intl.formatMessage({ id: "Scandic Friends Point Shop" })
break
}
const arrival = dt(transaction.checkinDate).locale(lang).format("DD MMM YYYY")
const transactionDate = dt(transaction.transactionDate)
.locale(lang)
.format("DD MMM YYYY")
function renderConfirmationNumber() {
if (transaction.confirmationNumber === "BALFWD") return null
if (
transaction.bookingUrl &&
(transaction.type === RewardTransactionTypes.stay ||
transaction.type === RewardTransactionTypes.rewardNight)
) {
return (
<Link variant="underscored" href={transaction.bookingUrl}>
{transaction.confirmationNumber}
</Link>
)
}
return transaction.confirmationNumber
}
return (
<tr className={styles.tr}>
@@ -64,18 +81,11 @@ export default function Row({ transaction }: RowProps) {
isCalculated={transaction.pointsCalculated}
/>
<td className={`${styles.td} ${styles.description}`}>{description}</td>
<td className={styles.td}>{renderConfirmationNumber()}</td>
<td className={styles.td}>
{transaction.type === RewardTransactionTypes.stay &&
transaction.bookingUrl ? (
<Link variant="underscored" href={transaction.bookingUrl}>
{transaction.confirmationNumber}
</Link>
) : (
transaction.confirmationNumber
)}
</td>
<td className={styles.td}>
{transaction.checkinDate ? arrival : transactionDate}
{transaction.checkinDate && transaction.confirmationNumber !== "BALFWD"
? arrival
: null}
</td>
</tr>
)

View File

@@ -45,7 +45,7 @@
"Edit": "Redigere",
"Edit profile": "Rediger profil",
"Email": "E-mail",
"Extras to your booking": "Ekstra til din booking",
"Extras to your booking": "Tillæg til din booking",
"There are no transactions to display": "Der er ingen transaktioner at vise",
"Explore all levels and benefits": "Udforsk alle niveauer og fordele",
"Failed to delete credit card, please try again later.": "Kunne ikke slette kreditkort. Prøv venligst igen senere.",
@@ -105,7 +105,7 @@
"Please enter a valid phone number": "Indtast venligst et gyldigt telefonnummer",
"Points": "Points",
"Points being calculated": "Point udregnes",
"Points earned prior to May 1, 2021": "Point optjent før 1. maj 2021",
"Points earned prior to May 1, 2021": "Point optjent inden 1. maj 2021",
"Points may take up to 10 days to be displayed.": "Det kan tage op til 10 dage at få vist point.",
"Points needed to level up": "Point nødvendige for at komme i niveau",
"Points needed to stay on level": "Point nødvendige for at holde sig på niveau",
@@ -128,7 +128,7 @@
"Show more": "Vis mere",
"Show all amenities": "Vis alle faciliteter",
"Skip to main content": "Spring over og gå til hovedindhold",
"Sign up bonus": "Tilmeldingsbonus",
"Sign up bonus": "Velkomstbonus",
"Something went wrong!": "Noget gik galt!",
"Something went wrong and we couldn't add your card. Please try again later.": "Noget gik galt, og vi kunne ikke tilføje dit kort. Prøv venligst igen senere.",
"Something went wrong and we couldn't remove your card. Please try again later.": "Noget gik galt, og vi kunne ikke fjerne dit kort. Prøv venligst igen senere.",
@@ -140,7 +140,7 @@
"Transactions": "Transaktioner",
"Tripadvisor reviews": "{rating} ({count} anmeldelser på Tripadvisor)",
"to": "til",
"TUI Points": "TUI-point",
"TUI Points": "TUI Points",
"User information": "Brugeroplysninger",
"uppercase letter": "stort bogstav",
"Visiting address": "Besøgsadresse",

View File

@@ -102,7 +102,7 @@
"Please enter a valid phone number": "Bitte geben Sie eine gültige Telefonnummer ein",
"Points": "Punkte",
"Points being calculated": "Punkte werden berechnet",
"Points earned prior to May 1, 2021": "Vor dem 1. Mai 2021 gesammelte Punkte",
"Points earned prior to May 1, 2021": "Zusammengeführte Punkte vor dem 1. Mai 2021",
"Points may take up to 10 days to be displayed.": "Es kann bis zu 10 Tage dauern, bis Punkte angezeigt werden.",
"Points needed to level up": "Punkte, die zum Levelaufstieg benötigt werden",
"Points needed to stay on level": "Erforderliche Punkte, um auf diesem Level zu bleiben",
@@ -123,7 +123,7 @@
"Show more": "Mehr anzeigen",
"Show all amenities": "Alle Annehmlichkeiten anzeigen",
"Skip to main content": "Direkt zum Inhalt",
"Sign up bonus": "Anmeldebonus",
"Sign up bonus": "Anmelde-Bonus",
"Something went wrong!": "Etwas ist schief gelaufen!",
"Something went wrong and we couldn't add your card. Please try again later.": "Ein Fehler ist aufgetreten und wir konnten Ihre Karte nicht hinzufügen. Bitte versuchen Sie es später erneut.",
"Something went wrong and we couldn't remove your card. Please try again later.": "Ein Fehler ist aufgetreten und wir konnten Ihre Karte nicht entfernen. Bitte versuchen Sie es später noch einmal.",
@@ -135,7 +135,7 @@
"Transactions": "Transaktionen",
"Tripadvisor reviews": "{rating} ({count} Bewertungen auf Tripadvisor)",
"to": "zu",
"TUI Points": "TUI Punkte",
"TUI Points": "TUI Points",
"User information": "Nutzerinformation",
"uppercase letter": "großbuchstabe",
"Visiting address": "Besuchsadresse",

View File

@@ -45,13 +45,13 @@
"Edit": "Muokata",
"Edit profile": "Muokkaa profiilia",
"Email": "Sähköposti",
"Extras to your booking": "Lisävarusteet varaukseesi",
"Extras to your booking": "Varauksessa lisäpalveluita",
"There are no transactions to display": "Näytettäviä tapahtumia ei ole",
"Explore all levels and benefits": "Tutustu kaikkiin tasoihin ja etuihin",
"Failed to delete credit card, please try again later.": "Luottokortin poistaminen epäonnistui, yritä myöhemmin uudelleen.",
"Find booking": "Etsi varaus",
"Flexibility": "Joustavuus",
"Former Scandic Hotel": "Entinen Scandic Hotel",
"Former Scandic Hotel": "Entinen Scandic-hotelli",
"From": "From",
"from your member profile?": "jäsenprofiilistasi?",
"Get inspired": "Inspiroidu",
@@ -105,7 +105,7 @@
"Please enter a valid phone number": "Ole hyvä ja näppäile voimassaoleva puhelinnumero",
"Points": "Pistettä",
"Points being calculated": "Pisteitä lasketaan",
"Points earned prior to May 1, 2021": "Ennen 1. toukokuuta 2021 ansaitut pisteet",
"Points earned prior to May 1, 2021": "Pisteet, jotka ansaittu ennen 1.5.2021",
"Points may take up to 10 days to be displayed.": "Pisteiden näyttäminen voi kestää jopa 10 päivää.",
"Points needed to level up": "Pisteitä tarvitaan tasolle pääsemiseksi",
"Points needed to stay on level": "Tällä tasolla pysymiseen tarvittavat pisteet",
@@ -128,7 +128,7 @@
"Show more": "Näytä lisää",
"Show all amenities": "Näytä kaikki mukavuudet",
"Skip to main content": "Siirry pääsisältöön",
"Sign up bonus": "Rekisteröidy bonus",
"Sign up bonus": "Liittymisbonus",
"Something went wrong!": "Jotain meni pieleen!",
"Something went wrong and we couldn't add your card. Please try again later.": "Jotain meni pieleen, emmekä voineet lisätä korttiasi. Yritä myöhemmin uudelleen.",
"Something went wrong and we couldn't remove your card. Please try again later.": "Jotain meni pieleen, emmekä voineet poistaa korttiasi. Yritä myöhemmin uudelleen.",
@@ -140,7 +140,7 @@
"Transactions": "Tapahtumat",
"Tripadvisor reviews": "{rating} ({count} arvostelua TripAdvisorissa)",
"to": "to",
"TUI Points": "TUI-pisteet",
"TUI Points": "TUI Points",
"User information": "Käyttäjän tiedot",
"uppercase letter": "iso kirjain",
"Visiting address": "Käyntiosoite",

View File

@@ -45,13 +45,13 @@
"Edit": "Redigere",
"Edit profile": "Rediger profil",
"Email": "E-post",
"Extras to your booking": "Ekstra til din bestilling",
"Extras to your booking": "Tilvalg til bestillingen din",
"There are no transactions to display": "Det er ingen transaksjoner å vise",
"Explore all levels and benefits": "Utforsk alle nivåer og fordeler",
"Failed to delete credit card, please try again later.": "Kunne ikke slette kredittkortet, prøv igjen senere.",
"Find booking": "Finn booking",
"Flexibility": "Fleksibilitet",
"Former Scandic Hotel": "Tidligere Scandic Hotel",
"Former Scandic Hotel": "Tidligere Scandic-hotell",
"From": "Fra",
"from your member profile?": "fra medlemsprofilen din?",
"Get inspired": "Bli inspirert",
@@ -105,7 +105,7 @@
"Please enter a valid phone number": "Vennligst oppgi et gyldig telefonnummer",
"Points": "Poeng",
"Points being calculated": "Poeng beregnes",
"Points earned prior to May 1, 2021": "Poeng opptjent før 1. mai 2021",
"Points earned prior to May 1, 2021": "Opptjente poeng før 1. mai 2021",
"Points may take up to 10 days to be displayed.": "Det kan ta opptil 10 dager før poeng vises.",
"Points needed to level up": "Poeng som trengs for å komme opp i nivå",
"Points needed to stay on level": "Poeng som trengs for å holde seg på nivå",
@@ -128,7 +128,7 @@
"Show more": "Vis mer",
"Show all amenities": "Vis alle fasiliteter",
"Skip to main content": "Gå videre til hovedsiden",
"Sign up bonus": "Registreringsbonus",
"Sign up bonus": "Velkomstbonus",
"Something went wrong!": "Noe gikk galt!",
"Something went wrong and we couldn't add your card. Please try again later.": "Noe gikk galt, og vi kunne ikke legge til kortet ditt. Prøv igjen senere.",
"Something went wrong and we couldn't remove your card. Please try again later.": "Noe gikk galt, og vi kunne ikke fjerne kortet ditt. Vennligst prøv igjen senere.",
@@ -140,7 +140,7 @@
"Transactions": "Transaksjoner",
"Tripadvisor reviews": "{rating} ({count} anmeldelser på Tripadvisor)",
"to": "til",
"TUI Points": "TUI-poeng",
"TUI Points": "TUI Points",
"User information": "Brukerinformasjon",
"uppercase letter": "stor bokstav",
"Visiting address": "Besøksadresse",

View File

@@ -45,13 +45,13 @@
"Edit": "Redigera",
"Edit profile": "Redigera profil",
"Email": "E-post",
"Extras to your booking": "Extra till din bokning",
"Extras to your booking": "Extra tillval till din bokning",
"There are no transactions to display": "Det finns inga transaktioner att visa",
"Explore all levels and benefits": "Utforska alla nivåer och fördelar",
"Failed to delete credit card, please try again later.": "Det gick inte att ta bort kreditkortet, försök igen senare.",
"Find booking": "Hitta bokning",
"Flexibility": "Flexibilitet",
"Former Scandic Hotel": "Tidigare Scandic Hotel",
"Former Scandic Hotel": "Tidigare Scandichotell",
"From": "Från",
"from your member profile?": "från din medlemsprofil?",
"Get inspired": "Bli inspirerad",
@@ -108,7 +108,7 @@
"Please enter a valid phone number": "Var vänlig och ange ett giltigt telefonnummer",
"Points": "Poäng",
"Points being calculated": "Poäng beräknas",
"Points earned prior to May 1, 2021": "Poäng intjänade före 1 maj 2021",
"Points earned prior to May 1, 2021": "Intjänade poäng före den 1 maj 2021",
"Points may take up to 10 days to be displayed.": "Det kan ta upp till 10 dagar innan poäng visas.",
"Points needed to level up": "Poäng som behövs för att gå upp i nivå",
"Points needed to stay on level": "Poäng som behövs för att hålla sig på nivå",
@@ -131,7 +131,7 @@
"Show more": "Visa mer",
"Show all amenities": "Visa alla bekvämligheter",
"Skip to main content": "Fortsätt till huvudinnehåll",
"Sign up bonus": "Registreringsbonus",
"Sign up bonus": "Välkomstbonus",
"Something went wrong!": "Något gick fel!",
"Something went wrong and we couldn't add your card. Please try again later.": "Något gick fel och vi kunde inte lägga till ditt kort. Försök igen senare.",
"Something went wrong and we couldn't remove your card. Please try again later.": "Något gick fel och vi kunde inte ta bort ditt kort. Försök igen senare.",
@@ -143,7 +143,7 @@
"Transactions": "Transaktioner",
"Tripadvisor reviews": "{rating} ({count} recensioner på Tripadvisor)",
"to": "till",
"TUI Points": "TUI-poäng",
"TUI Points": "TUI Points",
"User information": "Användar information",
"uppercase letter": "stor bokstav",
"Visiting address": "Besöksadress",

View File

@@ -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),
},
}
}),