From 96821c7a6f2584583f3e6b2cfe4a9251295522b5 Mon Sep 17 00:00:00 2001 From: Linus Flood Date: Fri, 16 May 2025 09:30:04 +0000 Subject: [PATCH] Merged in feat/my-stay-masking (pull request #2116) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mask values on my-stay and receipt pages SW-2788 * Mask values on my-stay and receipt pages Approved-by: Joakim Jäderberg --- .../hotelreservation/my-stay/page.tsx | 33 ++++++++++++++--- .../webview/hotelreservation/my-stay/page.tsx | 33 ++++++++++++++--- .../HotelReservation/MyStay/Receipt/index.tsx | 36 ++++++++++++++----- 3 files changed, 85 insertions(+), 17 deletions(-) diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/my-stay/page.tsx b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/my-stay/page.tsx index cc92c33b2..bd2dee513 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/my-stay/page.tsx +++ b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/my-stay/page.tsx @@ -34,6 +34,7 @@ import Image from "@/components/Image" import { getIntl } from "@/i18n" import { setLang } from "@/i18n/serverContext" import MyStayProvider from "@/providers/MyStay" +import * as maskValue from "@/utils/maskValue" import { parseRefId } from "@/utils/refId" import { isValidSession } from "@/utils/session" import { getCurrentWebUrl } from "@/utils/url" @@ -42,6 +43,8 @@ import styles from "./page.module.css" import { BreakfastPackageEnum } from "@/types/enums/breakfast" import type { LangParams, PageArgs } from "@/types/params" +import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" +import type { SafeUser } from "@/types/user" export default async function MyStay({ params, @@ -174,9 +177,31 @@ export default async function MyStay({ promoUrl.searchParams.set("hotel", hotel.operaId) + const maskedBookingConfirmation = { + ...bookingConfirmation, + booking: { + ...bookingConfirmation.booking, + guest: { + ...bookingConfirmation.booking.guest, + email: maskValue.email(bookingConfirmation.booking.guest.email), + phoneNumber: maskValue.phone( + bookingConfirmation.booking.guest.phoneNumber ?? "" + ), + }, + }, + } satisfies BookingConfirmation + + const maskedUser = user + ? ({ + ...user, + email: maskValue.email(user.email), + phoneNumber: maskValue.phone(user.phoneNumber ?? ""), + } satisfies SafeUser) + : null + return ( )} - - + + )} - - + + p.currency !== CurrencyEnum.POINTS) ?.currency) + const maskedBookingConfirmation = { + ...bookingConfirmation, + booking: { + ...bookingConfirmation.booking, + guest: { + ...bookingConfirmation.booking.guest, + email: maskValue.email(bookingConfirmation.booking.guest.email), + phoneNumber: maskValue.phone( + bookingConfirmation.booking.guest.phoneNumber ?? "" + ), + }, + }, + } satisfies BookingConfirmation + + const { booking: maskedBooking } = maskedBookingConfirmation + return (
@@ -127,39 +145,39 @@ export async function Receipt({ refId }: { refId: string }) {
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */} -
{`${booking.guest.firstName} ${booking.guest.lastName}`}
+
{`${maskedBooking.guest.firstName} ${maskedBooking.guest.lastName}`}
- {booking.guest.membershipNumber && ( + {maskedBooking.guest.membershipNumber && ( {/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
{`${intl.formatMessage({ defaultMessage: "Member", - })} ${booking.guest.membershipNumber}`}
+ })} ${maskedBooking.guest.membershipNumber}`}
)}
- {booking.guest.email} + {maskedBooking.guest.email}
- {booking.guest.phoneNumber} + {maskedBooking.guest.phoneNumber}
- +
-
) }