From 6fa301f8e790a3c94a485307981acf4c9ec4811f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20J=C3=A4derberg?= Date: Thu, 4 Sep 2025 13:01:36 +0000 Subject: [PATCH] Merged in SW-3396-move-my-saved-cards-to-design-system (pull request #2762) SW-3396 move my saved cards to design system * Move PaymentOption, PaymentOptionsGroup, PaymentIcons and MySavedCards (renamed SelectPaymentMethod) to design-system * Remove unused svg payment icons * cleanu * cleanup * trackUpdatePaymentMethod: remove hotelId argument that was never passed Approved-by: Anton Gunnarsson --- .../EnterDetails/Confirm/Guarantee/index.tsx | 18 ++- .../EnterDetails/Payment/PaymentClient.tsx | 15 +- .../HotelReservation/MySavedCards/index.tsx | 45 ------ .../Steps/ConfirmationStep/index.tsx | 18 ++- .../GuaranteeLateArrival/Form/index.tsx | 21 ++- .../HotelReservation/PaymentOption/index.tsx | 55 ------- .../PaymentOption/paymentOption.ts | 5 - apps/scandic-web/constants/booking.ts | 52 ------- .../icons/payment/american-express.svg | 17 --- .../_static/icons/payment/apple-pay.svg | 21 --- .../_static/icons/payment/card-generic.svg | 21 --- .../public/_static/icons/payment/dankort.svg | 16 --- .../_static/icons/payment/diners-club.svg | 16 --- .../public/_static/icons/payment/discover.svg | 28 ---- .../_static/icons/payment/google-pay.svg | 18 --- .../public/_static/icons/payment/jcb.svg | 48 ------- .../public/_static/icons/payment/klarna.svg | 11 -- .../public/_static/icons/payment/maestro.svg | 15 -- .../_static/icons/payment/mastercard.svg | 15 -- .../_static/icons/payment/mobilepay.svg | 51 ------- .../public/_static/icons/payment/paypal.svg | 17 --- .../public/_static/icons/payment/swish.svg | 38 ----- .../public/_static/icons/payment/unionpay.svg | 24 ---- .../public/_static/icons/payment/vipps.svg | 16 --- .../public/_static/icons/payment/visa.svg | 16 --- apps/scandic-web/utils/tracking/payment.ts | 4 +- packages/common/constants/paymentMethod.ts | 25 ++++ .../.storybook/decorators/FormDecorator.tsx | 10 ++ .../Form/Checkbox/Checkbox.stories.tsx | 18 +++ .../Form/PaymentOption/PaymentOption.tsx | 53 +++++++ .../PaymentOptionsGroup.stories.tsx | 46 ++++++ .../PaymentOption/PaymentOptionsGroup.tsx | 23 ++- .../PaymentOption/paymentOption.module.css | 0 .../SelectPaymentMethod.stories.tsx | 45 ++++++ .../Form/SelectPaymentMethod/index.tsx | 62 ++++++++ .../selectPaymentMethod.module.css | 0 .../Payment/Icons/AmericanExpressIcon.tsx | 48 +++++++ .../components/Payment/Icons/ApplePayIcon.tsx | 67 +++++++++ .../Payment/Icons/ChinaUnionPayIcon.tsx | 103 +++++++++++++ .../components/Payment/Icons/DanKortIcon.tsx | 45 ++++++ .../Payment/Icons/DinersClubIcon.tsx | 47 ++++++ .../components/Payment/Icons/DiscoverIcon.tsx | 102 +++++++++++++ .../Payment/Icons/GenericCardIcon.tsx | 76 ++++++++++ .../Payment/Icons/GooglePayIcon.tsx | 58 ++++++++ .../lib/components/Payment/Icons/IconProps.ts | 5 + .../lib/components/Payment/Icons/JcbIcon.tsx | 115 +++++++++++++++ .../components/Payment/Icons/KlarnaIcon.tsx | 30 ++++ .../components/Payment/Icons/MaestroIcon.tsx | 49 +++++++ .../Payment/Icons/MasterCardIcon.tsx | 49 +++++++ .../Payment/Icons/MobilePayIcon.tsx | 135 ++++++++++++++++++ .../components/Payment/Icons/PayPalIcon.tsx | 61 ++++++++ .../components/Payment/Icons/SwishIcon.tsx | 112 +++++++++++++++ .../components/Payment/Icons/VippsIcon.tsx | 54 +++++++ .../lib/components/Payment/Icons/VisaIcon.tsx | 55 +++++++ .../Payment/PaymentMethodIcon.stories.tsx | 81 +++++++++++ .../components/Payment/PaymentMethodIcon.tsx | 61 ++++++++ packages/design-system/package.json | 14 +- 57 files changed, 1687 insertions(+), 583 deletions(-) delete mode 100644 apps/scandic-web/components/HotelReservation/MySavedCards/index.tsx delete mode 100644 apps/scandic-web/components/HotelReservation/PaymentOption/index.tsx delete mode 100644 apps/scandic-web/components/HotelReservation/PaymentOption/paymentOption.ts delete mode 100644 apps/scandic-web/public/_static/icons/payment/american-express.svg delete mode 100644 apps/scandic-web/public/_static/icons/payment/apple-pay.svg delete mode 100644 apps/scandic-web/public/_static/icons/payment/card-generic.svg delete mode 100644 apps/scandic-web/public/_static/icons/payment/dankort.svg delete mode 100644 apps/scandic-web/public/_static/icons/payment/diners-club.svg delete mode 100644 apps/scandic-web/public/_static/icons/payment/discover.svg delete mode 100644 apps/scandic-web/public/_static/icons/payment/google-pay.svg delete mode 100644 apps/scandic-web/public/_static/icons/payment/jcb.svg delete mode 100644 apps/scandic-web/public/_static/icons/payment/klarna.svg delete mode 100644 apps/scandic-web/public/_static/icons/payment/maestro.svg delete mode 100644 apps/scandic-web/public/_static/icons/payment/mastercard.svg delete mode 100644 apps/scandic-web/public/_static/icons/payment/mobilepay.svg delete mode 100644 apps/scandic-web/public/_static/icons/payment/paypal.svg delete mode 100644 apps/scandic-web/public/_static/icons/payment/swish.svg delete mode 100644 apps/scandic-web/public/_static/icons/payment/unionpay.svg delete mode 100644 apps/scandic-web/public/_static/icons/payment/vipps.svg delete mode 100644 apps/scandic-web/public/_static/icons/payment/visa.svg create mode 100644 packages/design-system/.storybook/decorators/FormDecorator.tsx create mode 100644 packages/design-system/lib/components/Form/Checkbox/Checkbox.stories.tsx create mode 100644 packages/design-system/lib/components/Form/PaymentOption/PaymentOption.tsx create mode 100644 packages/design-system/lib/components/Form/PaymentOption/PaymentOptionsGroup.stories.tsx rename apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentOptionsGroup/index.tsx => packages/design-system/lib/components/Form/PaymentOption/PaymentOptionsGroup.tsx (57%) rename {apps/scandic-web/components/HotelReservation => packages/design-system/lib/components/Form}/PaymentOption/paymentOption.module.css (100%) create mode 100644 packages/design-system/lib/components/Form/SelectPaymentMethod/SelectPaymentMethod.stories.tsx create mode 100644 packages/design-system/lib/components/Form/SelectPaymentMethod/index.tsx rename apps/scandic-web/components/HotelReservation/MySavedCards/mySavedCards.module.css => packages/design-system/lib/components/Form/SelectPaymentMethod/selectPaymentMethod.module.css (100%) create mode 100644 packages/design-system/lib/components/Payment/Icons/AmericanExpressIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/Icons/ApplePayIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/Icons/ChinaUnionPayIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/Icons/DanKortIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/Icons/DinersClubIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/Icons/DiscoverIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/Icons/GenericCardIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/Icons/GooglePayIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/Icons/IconProps.ts create mode 100644 packages/design-system/lib/components/Payment/Icons/JcbIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/Icons/KlarnaIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/Icons/MaestroIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/Icons/MasterCardIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/Icons/MobilePayIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/Icons/PayPalIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/Icons/SwishIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/Icons/VippsIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/Icons/VisaIcon.tsx create mode 100644 packages/design-system/lib/components/Payment/PaymentMethodIcon.stories.tsx create mode 100644 packages/design-system/lib/components/Payment/PaymentMethodIcon.tsx diff --git a/apps/scandic-web/components/HotelReservation/EnterDetails/Confirm/Guarantee/index.tsx b/apps/scandic-web/components/HotelReservation/EnterDetails/Confirm/Guarantee/index.tsx index 2e06a60b2..41eeca363 100644 --- a/apps/scandic-web/components/HotelReservation/EnterDetails/Confirm/Guarantee/index.tsx +++ b/apps/scandic-web/components/HotelReservation/EnterDetails/Confirm/Guarantee/index.tsx @@ -13,13 +13,13 @@ import { PaymentMethodEnum } from "@scandic-hotels/common/constants/paymentMetho import useSetOverflowVisibleOnRA from "@scandic-hotels/common/hooks/useSetOverflowVisibleOnRA" import { Button } from "@scandic-hotels/design-system/Button" import Checkbox from "@scandic-hotels/design-system/Form/Checkbox" +import { PaymentOption } from "@scandic-hotels/design-system/Form/PaymentOption" +import { PaymentOptionsGroup } from "@scandic-hotels/design-system/Form/PaymentOptionsGroup" +import { SelectPaymentMethod } from "@scandic-hotels/design-system/Form/SelectPaymentMethod" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" -import MySavedCards from "@/components/HotelReservation/MySavedCards" -import PaymentOption from "@/components/HotelReservation/PaymentOption" - -import PaymentOptionsGroup from "../../Payment/PaymentOptionsGroup" +import { trackUpdatePaymentMethod } from "@/utils/tracking" import styles from "./guarantee.module.css" @@ -105,11 +105,19 @@ export default function Guarantee({ savedCreditCards }: GuaranteeProps) { {savedCreditCards?.length && guarantee ? ( - + trackUpdatePaymentMethod({ method })} + paymentMethods={savedCreditCards.map((x) => ({ + ...x, + cardType: x.cardType as PaymentMethodEnum, + }))} + /> ) : null} {guarantee ? ( trackUpdatePaymentMethod({ method })} label={ savedCreditCards?.length ? intl.formatMessage({ diff --git a/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx b/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx index 182ddfb82..7eefda5e4 100644 --- a/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx +++ b/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx @@ -8,7 +8,10 @@ import { Label } from "react-aria-components" import { FormProvider, useForm } from "react-hook-form" import { useIntl } from "react-intl" -import { PaymentMethodEnum } from "@scandic-hotels/common/constants/paymentMethod" +import { + PAYMENT_METHOD_TITLES, + PaymentMethodEnum, +} from "@scandic-hotels/common/constants/paymentMethod" import { bookingConfirmation, selectRate, @@ -20,6 +23,8 @@ import { formatPhoneNumber } from "@scandic-hotels/common/utils/phone" import Body from "@scandic-hotels/design-system/Body" import { Button } from "@scandic-hotels/design-system/Button" import Checkbox from "@scandic-hotels/design-system/Form/Checkbox" +import { PaymentOption } from "@scandic-hotels/design-system/Form/PaymentOption" +import { PaymentOptionsGroup } from "@scandic-hotels/design-system/Form/PaymentOptionsGroup" import { Typography } from "@scandic-hotels/design-system/Typography" import { trpc } from "@scandic-hotels/trpc/client" import { bedTypeMap } from "@scandic-hotels/trpc/constants/bedTypeMap" @@ -27,15 +32,13 @@ import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking" import { BookingStatusEnum } from "@scandic-hotels/trpc/enums/bookingStatus" import { RoomPackageCodeEnum } from "@scandic-hotels/trpc/enums/roomFilter" -import { PAYMENT_METHOD_TITLES } from "@/constants/booking" import { env } from "@/env/client" import { useEnterDetailsStore } from "@/stores/enter-details" -import PaymentOption from "@/components/HotelReservation/PaymentOption" import { useAvailablePaymentOptions } from "@/hooks/booking/useAvailablePaymentOptions" import { useHandleBookingStatus } from "@/hooks/booking/useHandleBookingStatus" import useLang from "@/hooks/useLang" -import { trackPaymentEvent } from "@/utils/tracking" +import { trackPaymentEvent, trackUpdatePaymentMethod } from "@/utils/tracking" import { trackGlaSaveCardAttempt } from "@/utils/tracking/myStay" import ConfirmBooking, { ConfirmBookingRedemption } from "../Confirm" @@ -50,7 +53,6 @@ import { writePaymentInfoToSessionStorage, } from "./helpers" import MixedRatePaymentBreakdown from "./MixedRatePaymentBreakdown" -import PaymentOptionsGroup from "./PaymentOptionsGroup" import { type PaymentFormData, paymentSchema } from "./schema" import TermsAndConditions from "./TermsAndConditions" @@ -551,6 +553,7 @@ export default function PaymentClient({ trackUpdatePaymentMethod({ method })} >