diff --git a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Client.tsx b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Client.tsx index f0cc9b2ef..3e08de171 100644 --- a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Client.tsx +++ b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Client.tsx @@ -7,9 +7,8 @@ import { trpc } from "@/lib/trpc/client" import LoadingSpinner from "@/components/LoadingSpinner" -import DesktopTable from "./Desktop" -import MobileTable from "./Mobile" import Pagination from "./Pagination" +import Table from "./Table" import { Transactions } from "@/types/components/myPages/myPage/earnAndBurn" @@ -40,8 +39,7 @@ export default function TransactionTable({ ) : ( <> - - + {data && data.meta.totalPages > 1 ? ( 0) { - variant = "addition" - } else if (awardPoints < 0) { - variant = "negation" - awardPoints = Math.abs(awardPoints) - } - - const classNames = awardPointsVariants({ - variant, - }) - - // sv hardcoded to force space on thousands - const formatter = new Intl.NumberFormat(Lang.sv) - return -} diff --git a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Desktop/Row/index.tsx b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Desktop/Row/index.tsx deleted file mode 100644 index 297aa39cf..000000000 --- a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Desktop/Row/index.tsx +++ /dev/null @@ -1,35 +0,0 @@ -"use client" - -import { useIntl } from "react-intl" - -import { dt } from "@/lib/dt" - -import useLang from "@/hooks/useLang" - -import AwardPoints from "./AwardPoints" - -import styles from "./row.module.css" - -import type { RowProps } from "@/types/components/myPages/myPage/earnAndBurn" - -export default function Row({ transaction }: RowProps) { - const intl = useIntl() - const lang = useLang() - const description = - transaction.hotelName && transaction.city - ? `${transaction.hotelName}, ${transaction.city} ${transaction.nights} ${intl.formatMessage({ id: "nights" })}` - : `${transaction.nights} ${intl.formatMessage({ id: "nights" })}` - const arrival = dt(transaction.checkinDate).locale(lang).format("DD MMM YYYY") - const departure = dt(transaction.checkoutDate) - .locale(lang) - .format("DD MMM YYYY") - return ( - - - - - - - - ) -} diff --git a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Mobile/index.tsx b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Mobile/index.tsx deleted file mode 100644 index d4de69ac4..000000000 --- a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Mobile/index.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import { useIntl } from "react-intl" - -import { dt } from "@/lib/dt" - -import AwardPoints from "@/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Desktop/Row/AwardPoints" -import Body from "@/components/TempDesignSystem/Text/Body" -import useLang from "@/hooks/useLang" - -import styles from "./mobile.module.css" - -import type { TableProps } from "@/types/components/myPages/myPage/earnAndBurn" - -export default function MobileTable({ transactions }: TableProps) { - const intl = useIntl() - const lang = useLang() - return ( -
-
{formatter.format(awardPoints)} pts
{arrival}{description}{transaction.confirmationNumber}{departure}
- - - - - - - - - - - - {transactions.length ? ( - transactions.map((transaction, idx) => ( - - - - - )) - ) : ( - - - - )} - -
- {intl.formatMessage({ id: "Transactions" })} - - {intl.formatMessage({ id: "Points" })} -
- - {dt(transaction.checkinDate) - .locale(lang) - .format("DD MMM YYYY")} - - {transaction.hotelName && transaction.city ? ( - {`${transaction.hotelName}, ${transaction.city}`} - ) : null} - - {`${transaction.nights} ${intl.formatMessage({ id: transaction.nights === 1 ? "night" : "nights" })}`} - -
- {intl.formatMessage({ - id: "There are no transactions to display", - })} -
- - ) -} diff --git a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Mobile/mobile.module.css b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Mobile/mobile.module.css deleted file mode 100644 index ac7e30bda..000000000 --- a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Mobile/mobile.module.css +++ /dev/null @@ -1,52 +0,0 @@ -.table { - border-collapse: collapse; - border-spacing: 0; - width: 100%; -} - -.thead { - background-color: var(--Main-Grey-10); -} - -.th { - padding: var(--Spacing-x2); -} - -.tr { - border-top: 1px solid var(--Main-Grey-10); -} - -.td { - padding: var(--Spacing-x2); -} - -.transactionDetails { - display: grid; - font-size: var(--typography-Footnote-Regular-fontSize); -} - -.transactionDate { - font-weight: 700; -} - -.placeholder { - text-align: center; - padding: var(--Spacing-x4); - border: 1px solid var(--Main-Grey-10); -} -.loadMoreButton { - background-color: var(--Main-Grey-10); - border: none; - display: flex; - align-items: center; - justify-content: center; - gap: var(--Spacing-x-half); - padding: var(--Spacing-x2); - width: 100%; -} - -@media screen and (min-width: 768px) { - .container { - display: none; - } -} diff --git a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/Row/AwardPoints.tsx b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/Row/AwardPoints.tsx new file mode 100644 index 000000000..a2d281dca --- /dev/null +++ b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/Row/AwardPoints.tsx @@ -0,0 +1,40 @@ +import { useIntl } from "react-intl" + +import { Lang } from "@/constants/languages" + +import { awardPointsVariants } from "./awardPointsVariants" + +import type { AwardPointsVariantProps } from "@/types/components/myPages/myPage/earnAndBurn" + +export default function AwardPoints({ + awardPoints, + isCalculated, +}: { + awardPoints: number + isCalculated: boolean +}) { + let variant: AwardPointsVariantProps["variant"] = undefined + const intl = useIntl() + + if (isCalculated) { + if (awardPoints > 0) { + variant = "addition" + } else if (awardPoints < 0) { + variant = "negation" + awardPoints = Math.abs(awardPoints) + } + } + const classNames = awardPointsVariants({ + variant, + }) + + // sv hardcoded to force space on thousands + const formatter = new Intl.NumberFormat(Lang.sv) + return ( + + {isCalculated + ? formatter.format(awardPoints) + : intl.formatMessage({ id: "Points being calculated" })} + + ) +} diff --git a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Desktop/Row/awardPointsVariants.ts b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/Row/awardPointsVariants.ts similarity index 100% rename from components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Desktop/Row/awardPointsVariants.ts rename to components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/Row/awardPointsVariants.ts diff --git a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/Row/index.tsx b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/Row/index.tsx new file mode 100644 index 000000000..c3fd5b5a5 --- /dev/null +++ b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/Row/index.tsx @@ -0,0 +1,82 @@ +"use client" + +import { useIntl } from "react-intl" + +import { dt } from "@/lib/dt" + +import Link from "@/components/TempDesignSystem/Link" +import useLang from "@/hooks/useLang" + +import AwardPoints from "./AwardPoints" + +import styles from "./row.module.css" + +import type { RowProps } from "@/types/components/myPages/myPage/earnAndBurn" +import { RewardTransactionTypes } from "@/types/components/myPages/myPage/enums" + +export default function Row({ transaction }: RowProps) { + const intl = useIntl() + const lang = useLang() + + const nightString = `${transaction.nights} ${transaction.nights === 1 ? intl.formatMessage({ id: "night" }) : intl.formatMessage({ id: "nights" })}` + + let description = + transaction.hotelName && transaction.city + ? `${transaction.hotelName}, ${transaction.city} ${nightString}` + : `${nightString}` + + switch (transaction.type) { + case RewardTransactionTypes.stay: + if (transaction.hotelId === "ORS") + description = intl.formatMessage({ id: "Former Scandic Hotel" }) + break + case RewardTransactionTypes.ancillary: + description = intl.formatMessage({ id: "Extras to your booking" }) + break + case RewardTransactionTypes.enrollment: + description = intl.formatMessage({ id: "Sign up bonus" }) + break + case RewardTransactionTypes.mastercard_points: + description = intl.formatMessage({ id: "Scandic Friends Mastercard" }) + 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") + + return ( + + + {description} + + {transaction.type === RewardTransactionTypes.stay && + transaction.bookingUrl ? ( + + {transaction.confirmationNumber} + + ) : ( + transaction.confirmationNumber + )} + + + {transaction.checkinDate ? arrival : transactionDate} + + + ) +} diff --git a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Desktop/Row/row.module.css b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/Row/row.module.css similarity index 50% rename from components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Desktop/Row/row.module.css rename to components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/Row/row.module.css index 1a75072da..eb59b55ea 100644 --- a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Desktop/Row/row.module.css +++ b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/Row/row.module.css @@ -1,13 +1,21 @@ .tr { - border: 1px solid #e6e9ec; + border-bottom: 1px solid var(--Scandic-Brand-Pale-Peach); + &:last-child { + border-bottom: none; + } } .td { background-color: #fff; color: var(--UI-Text-High-contrast); - padding: var(--Spacing-x2) var(--Spacing-x4); + padding: var(--Spacing-x2); position: relative; text-align: left; + text-wrap: nowrap; +} + +.description { + font-weight: var(--typography-Body-Bold-fontWeight); } .addition { @@ -17,8 +25,7 @@ .addition::before { color: var(--Secondary-Light-On-Surface-Accent); content: "+"; - left: var(--Spacing-x2); - position: absolute; + margin-right: var(--Spacing-x-half); } .negation { @@ -28,6 +35,11 @@ .negation::before { color: var(--Base-Text-Accent); content: "-"; - left: var(--Spacing-x2); - position: absolute; + margin-right: var(--Spacing-x-half); +} + +@media screen and (min-width: 768px) { + .td { + padding: var(--Spacing-x3); + } } diff --git a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Desktop/index.tsx b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/index.tsx similarity index 54% rename from components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Desktop/index.tsx rename to components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/index.tsx index 3d50eb609..c49695e88 100644 --- a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Desktop/index.tsx +++ b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/index.tsx @@ -1,50 +1,48 @@ +"use client" + import { useIntl } from "react-intl" import Body from "@/components/TempDesignSystem/Text/Body" import Row from "./Row" -import styles from "./desktop.module.css" +import styles from "./table.module.css" import type { TableProps } from "@/types/components/myPages/myPage/earnAndBurn" const tableHeadings = [ - "Arrival date", + "Points", "Description", "Booking number", - "Transaction date", - "Points", + "Arrival date", ] -export default function DesktopTable({ transactions }: TableProps) { +export default function Table({ transactions }: TableProps) { const intl = useIntl() - return (
{transactions.length ? ( -
- - - - {tableHeadings.map((heading) => ( - - ))} - - - - {transactions.map((transaction, idx) => ( - +
- - {intl.formatMessage({ id: heading })} - -
+ + + {tableHeadings.map((heading) => ( + ))} - -
+ + {intl.formatMessage({ id: heading })} + +
-
+ + + + {transactions.map((transaction, index) => ( + + ))} + + ) : ( diff --git a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Desktop/desktop.module.css b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/table.module.css similarity index 79% rename from components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Desktop/desktop.module.css rename to components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/table.module.css index 113c23aba..8c319b619 100644 --- a/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Desktop/desktop.module.css +++ b/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/table.module.css @@ -1,5 +1,8 @@ .container { - display: none; + display: flex; + flex-direction: column; + overflow-x: auto; + border-radius: var(--Corner-radius-Small); } .table { @@ -17,7 +20,8 @@ .th { text-align: left; - padding: 20px 32px; + text-wrap: nowrap; + padding: var(--Spacing-x2); } .placeholder { @@ -49,9 +53,10 @@ } @media screen and (min-width: 768px) { .container { - display: flex; - flex-direction: column; - gap: 16px; - overflow-x: auto; + border-radius: var(--Corner-radius-Large); + } + + .th { + padding: var(--Spacing-x2) var(--Spacing-x3); } } diff --git a/i18n/dictionaries/da.json b/i18n/dictionaries/da.json index dc4301e19..31af5e52f 100644 --- a/i18n/dictionaries/da.json +++ b/i18n/dictionaries/da.json @@ -42,10 +42,12 @@ "Edit": "Redigere", "Edit profile": "Rediger profil", "Email": "E-mail", + "Extras to your booking": "Ekstra 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", "Find booking": "Find booking", "Flexibility": "Fleksibilitet", + "Former Scandic Hotel": "Tidligere Scandic Hotel", "From": "Fra", "Get inspired": "Bliv inspireret", "Go back to overview": "Gå tilbage til oversigten", @@ -95,7 +97,9 @@ "Phone is required": "Telefonnummer er påkrævet", "Phone number": "Telefonnummer", "Please enter a valid phone number": "Indtast venligst et gyldigt telefonnummer", - "Points": "Point", + "Points": "Points", + "Points being calculated": "Point udregnes", + "Points earned prior to May 1, 2021": "Point optjent før 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", @@ -107,6 +111,8 @@ "Retype new password": "Gentag den nye adgangskode", "Rooms": "Værelser", "Save": "Gemme", + "Scandic Friends Mastercard": "Scandic Friends Mastercard", + "Scandic Friends Point Shop": "Scandic Friends Point Shop", "Select a country": "Vælg et land", "Select country of residence": "Vælg bopælsland", "Select date of birth": "Vælg fødselsdato", @@ -115,6 +121,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", "Something went wrong!": "Noget gik galt!", "Street": "Gade", "special character": "speciel karakter", @@ -124,6 +131,7 @@ "Transactions": "Transaktioner", "Tripadvisor reviews": "{rating} ({count} anmeldelser på Tripadvisor)", "to": "til", + "TUI Points": "TUI-point", "User information": "Brugeroplysninger", "uppercase letter": "stort bogstav", "Visiting address": "Besøgsadresse", diff --git a/i18n/dictionaries/de.json b/i18n/dictionaries/de.json index 421308f13..7f0a26f2c 100644 --- a/i18n/dictionaries/de.json +++ b/i18n/dictionaries/de.json @@ -41,10 +41,12 @@ "Edit": "Bearbeiten", "Edit profile": "Profil bearbeiten", "Email": "Email", + "Extras to your booking": "Extras zu Ihrer Buchung", "There are no transactions to display": "Es sind keine Transaktionen zum Anzeigen vorhanden", "Explore all levels and benefits": "Entdecken Sie alle Levels und Vorteile", "Find booking": "Buchung finden", "Flexibility": "Flexibilität", + "Former Scandic Hotel": "Ehemaliges Scandic Hotel", "From": "Fromm", "Get inspired": "Lassen Sie sich inspieren", "Go back to overview": "Zurück zur Übersicht", @@ -93,6 +95,8 @@ "Phone number": "Telefonnummer", "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 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", @@ -102,6 +106,8 @@ "Read more about the hotel": "Lesen Sie mehr über das Hotel", "Retype new password": "Neues Passwort erneut eingeben", "Save": "Speichern", + "Scandic Friends Mastercard": "Scandic Friends Mastercard", + "Scandic Friends Point Shop": "Scandic Friends Point Shop", "Select a country": "Wähle ein Land", "Select country of residence": "Wählen Sie das Land Ihres Wohnsitzes aus", "Select date of birth": "Geburtsdatum auswählen", @@ -110,6 +116,7 @@ "Show more": "Mehr anzeigen", "Show all amenities": "Alle Annehmlichkeiten anzeigen", "Skip to main content": "Direkt zum Inhalt", + "Sign up bonus": "Anmeldebonus", "Something went wrong!": "Etwas ist schief gelaufen!", "Street": "Straße", "special character": "sonderzeichen", @@ -119,6 +126,7 @@ "Transactions": "Transaktionen", "Tripadvisor reviews": "{rating} ({count} Bewertungen auf Tripadvisor)", "to": "zu", + "TUI Points": "TUI Punkte", "User information": "Nutzerinformation", "uppercase letter": "großbuchstabe", "Visiting address": "Besuchsadresse", diff --git a/i18n/dictionaries/en.json b/i18n/dictionaries/en.json index 32a55c8dd..62790f4fc 100644 --- a/i18n/dictionaries/en.json +++ b/i18n/dictionaries/en.json @@ -45,8 +45,10 @@ "Email": "Email", "There are no transactions to display": "There are no transactions to display", "Explore all levels and benefits": "Explore all levels and benefits", + "Extras to your booking": "Extras to your booking", "FAQ": "FAQ", "Find booking": "Find booking", + "Former Scandic Hotel": "Former Scandic Hotel", "Flexibility": "Flexibility", "From": "From", "Get inspired": "Get inspired", @@ -101,6 +103,8 @@ "Phone number": "Phone number", "Please enter a valid phone number": "Please enter a valid phone number", "Points": "Points", + "Points being calculated": "Points being calculated", + "Points earned prior to May 1, 2021": "Points earned prior to May 1, 2021", "Points may take up to 10 days to be displayed.": "Points may take up to 10 days to be displayed.", "Points needed to level up": "Points needed to level up", "Points needed to stay on level": "Points needed to stay on level", @@ -113,6 +117,8 @@ "Rooms": "Rooms", "Save": "Save", "See room details": "See room details", + "Scandic Friends Mastercard": "Scandic Friends Mastercard", + "Scandic Friends Point Shop": "Scandic Friends Point Shop", "Select a country": "Select a country", "Select country of residence": "Select country of residence", "Select date of birth": "Select date of birth", @@ -121,6 +127,7 @@ "Show more": "Show more", "Show all amenities": "Show all amenities", "Skip to main content": "Skip to main content", + "Sign up bonus": "Sign up bonus", "Something went wrong!": "Something went wrong!", "Street": "Street", "special character": "special character", @@ -130,6 +137,7 @@ "Transactions": "Transactions", "Tripadvisor reviews": "{rating} ({count} reviews on Tripadvisor)", "to": "to", + "TUI Points": "TUI Points", "User information": "User information", "uppercase letter": "uppercase letter", "Welcome": "Welcome", diff --git a/i18n/dictionaries/fi.json b/i18n/dictionaries/fi.json index 9f5903970..a244f16d3 100644 --- a/i18n/dictionaries/fi.json +++ b/i18n/dictionaries/fi.json @@ -42,10 +42,12 @@ "Edit": "Muokata", "Edit profile": "Muokkaa profiilia", "Email": "Sähköposti", + "Extras to your booking": "Lisävarusteet varaukseesi", "There are no transactions to display": "Näytettäviä tapahtumia ei ole", "Explore all levels and benefits": "Tutustu kaikkiin tasoihin ja etuihin", "Find booking": "Etsi varaus", "Flexibility": "Joustavuus", + "Former Scandic Hotel": "Entinen Scandic Hotel", "From": "From", "Get inspired": "Inspiroidu", "Go back to overview": "Palaa yleiskatsaukseen", @@ -96,6 +98,8 @@ "Phone number": "Puhelinnumero", "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 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", @@ -107,6 +111,8 @@ "Retype new password": "Kirjoita uusi salasana uudelleen", "Rooms": "Huoneet", "Save": "Tallentaa", + "Scandic Friends Mastercard": "Scandic Friends Mastercard", + "Scandic Friends Point Shop": "Scandic Friends Point Shop", "Select a country": "Valitse maa", "Select country of residence": "Valitse asuinmaa", "Select date of birth": "Valitse syntymäaika", @@ -115,6 +121,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", "Something went wrong!": "Jotain meni pieleen!", "Street": "Katu", "special character": "erikoishahmo", @@ -124,6 +131,7 @@ "Transactions": "Tapahtumat", "Tripadvisor reviews": "{rating} ({count} arvostelua TripAdvisorissa)", "to": "to", + "TUI Points": "TUI-pisteet", "User information": "Käyttäjän tiedot", "uppercase letter": "iso kirjain", "Visiting address": "Käyntiosoite", diff --git a/i18n/dictionaries/no.json b/i18n/dictionaries/no.json index 8a7b15e6c..cc79768ee 100644 --- a/i18n/dictionaries/no.json +++ b/i18n/dictionaries/no.json @@ -42,10 +42,12 @@ "Edit": "Redigere", "Edit profile": "Rediger profil", "Email": "E-post", + "Extras to your booking": "Ekstra til din bestilling", "There are no transactions to display": "Det er ingen transaksjoner å vise", "Explore all levels and benefits": "Utforsk alle nivåer og fordeler", "Find booking": "Finn booking", "Flexibility": "Fleksibilitet", + "Former Scandic Hotel": "Tidligere Scandic Hotel", "From": "Fra", "Get inspired": "Bli inspirert", "Go back to overview": "Gå tilbake til oversikten", @@ -96,6 +98,8 @@ "Phone number": "Telefonnummer", "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 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å", @@ -107,6 +111,8 @@ "Retype new password": "Skriv inn nytt passord på nytt", "Rooms": "Rom", "Save": "Lagre", + "Scandic Friends Mastercard": "Scandic Friends Mastercard", + "Scandic Friends Point Shop": "Scandic Friends Point Shop", "Select a country": "Velg et land", "Select country of residence": "Velg bostedsland", "Select date of birth": "Velg fødselsdato", @@ -115,6 +121,7 @@ "Show more": "Vis mer", "Show all amenities": "Vis alle fasiliteter", "Skip to main content": "Gå videre til hovedsiden", + "Sign up bonus": "Registreringsbonus", "Something went wrong!": "Noe gikk galt!", "Street": "Gate", "special character": "spesiell karakter", @@ -124,6 +131,7 @@ "Transactions": "Transaksjoner", "Tripadvisor reviews": "{rating} ({count} anmeldelser på Tripadvisor)", "to": "til", + "TUI Points": "TUI-poeng", "User information": "Brukerinformasjon", "uppercase letter": "stor bokstav", "Visiting address": "Besøksadresse", diff --git a/i18n/dictionaries/sv.json b/i18n/dictionaries/sv.json index e96fa533c..0e8f4695f 100644 --- a/i18n/dictionaries/sv.json +++ b/i18n/dictionaries/sv.json @@ -42,10 +42,12 @@ "Edit": "Redigera", "Edit profile": "Redigera profil", "Email": "E-post", + "Extras to your booking": "Extra 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", "Find booking": "Hitta bokning", "Flexibility": "Flexibilitet", + "Former Scandic Hotel": "Tidigare Scandic Hotel", "From": "Från", "Get inspired": "Bli inspirerad", "Go back to overview": "Gå tillbaka till översikten", @@ -99,6 +101,8 @@ "Phone number": "Telefonnummer", "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 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å", @@ -110,6 +114,8 @@ "Retype new password": "Upprepa nytt lösenord", "Rooms": "Rum", "Save": "Spara", + "Scandic Friends Mastercard": "Scandic Friends Mastercard", + "Scandic Friends Point Shop": "Scandic Friends Point Shop", "Select a country": "Välj ett land", "Select country of residence": "Välj bosättningsland", "Select date of birth": "Välj födelsedatum", @@ -118,6 +124,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", "Something went wrong!": "Något gick fel!", "Street": "Gata", "special character": "speciell karaktär", @@ -127,6 +134,7 @@ "Transactions": "Transaktioner", "Tripadvisor reviews": "{rating} ({count} recensioner på Tripadvisor)", "to": "till", + "TUI Points": "TUI-poäng", "User information": "Användar information", "uppercase letter": "stor bokstav", "Visiting address": "Besöksadress", diff --git a/server/routers/user/output.ts b/server/routers/user/output.ts index 77f8e992a..d079b8323 100644 --- a/server/routers/user/output.ts +++ b/server/routers/user/output.ts @@ -115,6 +115,8 @@ export const getFriendTransactionsSchema = z.object({ hotelOperaId: z.string().default(""), nights: z.number().default(1), pointsCalculated: z.boolean().default(true), + transactionDate: z.string().default(""), + bookingUrl: z.string().default(""), hotelInformation: z .object({ city: z.string().default(""), @@ -170,6 +172,10 @@ export const getFriendTransactionsSchema = z.object({ .nullable(), }) +type GetFriendTransactionsData = z.infer + +export type FriendTransaction = GetFriendTransactionsData["data"][number] + export const getCreditCardsSchema = z.object({ data: z.array( z.object({ diff --git a/server/routers/user/query.ts b/server/routers/user/query.ts index d39c0f929..47247658e 100644 --- a/server/routers/user/query.ts +++ b/server/routers/user/query.ts @@ -26,6 +26,7 @@ import { staysInput, } from "./input" import { + FriendTransaction, getCreditCardsSchema, getFriendTransactionsSchema, getMembershipCardsSchema, @@ -38,6 +39,7 @@ import { benefits, extendedUser, nextLevelPerks } from "./temp" import type { Session } from "next-auth" +import { RewardTransactionTypes } from "@/types/components/myPages/myPage/enums" import type { LoginType, TrackingSDKUserData, @@ -91,11 +93,23 @@ function fakingRequest(payload: T): Promise { }) } -const updateStaysBookingUrl = async ( +async function updateStaysBookingUrl( data: Stay[], token: string, lang: Lang -) => { +): Promise + +async function updateStaysBookingUrl( + data: FriendTransaction[], + token: string, + lang: Lang +): Promise + +async function updateStaysBookingUrl( + data: Stay[] | FriendTransaction[], + token: string, + lang: Lang +) { // Tenporary API call needed till we have user name in ctx session data const apiResponse = await api.get(api.endpoints.v1.profile, { cache: "no-store", @@ -135,9 +149,9 @@ const updateStaysBookingUrl = async ( if (apiResponse.ok) { const apiJson = await apiResponse.json() if (apiJson.data?.attributes) { - return data.map((stay: Stay) => { + return data.map((d) => { const originalString = - stay.attributes.confirmationNumber.toString() + + d.attributes.confirmationNumber.toString() + "," + apiJson.data.attributes.lastName const encryptedBookingValue = encryptValue(originalString) @@ -147,11 +161,11 @@ const updateStaysBookingUrl = async ( "?lastName=" + apiJson.data.attributes.lastName + "&bookingId=" + - stay.attributes.confirmationNumber + d.attributes.confirmationNumber return { - ...stay, + ...d, attributes: { - ...stay.attributes, + ...d.attributes, bookingUrl: bookingUrl, }, } @@ -492,15 +506,29 @@ export const userQueryRouter = router({ return null } - const pageData = verifiedData.data.data.slice( - limit * (page - 1), - limit * page + const updatedData = await updateStaysBookingUrl( + verifiedData.data.data, + ctx.session.token.access_token, + ctx.lang ) + const pageData = updatedData + .filter((t) => t.type !== RewardTransactionTypes.expired) + .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 + }) + .slice(limit * (page - 1), limit * page) + return { data: { - transactions: pageData.map(({ attributes }) => { + transactions: pageData.map(({ type, attributes }) => { return { + type, awardPoints: attributes.awardPoints, checkinDate: attributes.checkinDate, checkoutDate: attributes.checkoutDate, @@ -508,6 +536,10 @@ export const userQueryRouter = router({ confirmationNumber: attributes.confirmationNumber, hotelName: attributes.hotelInformation?.name, nights: attributes.nights, + pointsCalculated: attributes.pointsCalculated, + hotelId: attributes.hotelOperaId, + transactionDate: attributes.transactionDate, + bookingUrl: attributes.bookingUrl, } }), }, diff --git a/types/components/myPages/myPage/earnAndBurn.ts b/types/components/myPages/myPage/earnAndBurn.ts index ebe3060ff..9bc0c69aa 100644 --- a/types/components/myPages/myPage/earnAndBurn.ts +++ b/types/components/myPages/myPage/earnAndBurn.ts @@ -1,4 +1,4 @@ -import { awardPointsVariants } from "@/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Desktop/Row/awardPointsVariants" +import { awardPointsVariants } from "@/components/MyPages/Blocks/Points/EarnAndBurn/JourneyTable/Table/Row/awardPointsVariants" import type { VariantProps } from "class-variance-authority" diff --git a/types/components/myPages/myPage/enums.ts b/types/components/myPages/myPage/enums.ts index 294944620..67ee8e12a 100644 --- a/types/components/myPages/myPage/enums.ts +++ b/types/components/myPages/myPage/enums.ts @@ -16,3 +16,17 @@ export enum ContentEntries { AccountPageContentShortcuts = "AccountPageContentShortcuts", AccountPageContentTextContent = "AccountPageContentTextContent", } + +export enum RewardTransactionTypes { + stay = "stay", + rewardNight = "rewardnight", + enrollment = "enrollment", + expired = "expired", + redgift = "redgift", + ancillary = "ancillary", + pointShop = "pointshop", + tui_points = "tui_points", + mastercard_points = "mastercard_points", + stayAdj = "stay/adj", + othersAdj = "others/adj", +}