@lookiero/checkout 9.14.0 → 10.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fake-dependencies/@lookiero/payments-front/index.d.ts +8 -6
- package/dist/fake-dependencies/@lookiero/payments-front/index.js +7 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -2
- package/dist/pact.config.d.ts +21 -0
- package/dist/pact.config.js +16 -0
- package/dist/public/public/assets/adaptive-icon.png +0 -0
- package/dist/public/public/assets/favicon.png +0 -0
- package/dist/public/public/assets/icon.png +0 -0
- package/dist/public/public/assets/splash.png +0 -0
- package/dist/public/public/images/not-found.png +0 -0
- package/dist/src/Expo.js +0 -2
- package/dist/src/ExpoRoot.js +19 -15
- package/dist/src/infrastructure/domain/checkoutBooking/react/useBlockCheckoutBooking.d.ts +1 -1
- package/dist/src/infrastructure/domain/checkoutBooking/react/useBlockCheckoutBooking.js +2 -0
- package/dist/src/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.pact.js +55 -0
- package/dist/src/infrastructure/projection/checkout/httpCheckoutByIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkout/httpCheckoutByIdView.pact.js +116 -0
- package/dist/src/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.pact.js +56 -0
- package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.js +51 -0
- package/dist/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.js +51 -0
- package/dist/src/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.pact.js +51 -0
- package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.d.ts +13 -0
- package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.js +19 -0
- package/dist/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.js +56 -0
- package/dist/src/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.pact.js +57 -0
- package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.pact.js +55 -0
- package/dist/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.js +120 -0
- package/dist/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.pact.js +55 -0
- package/dist/src/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.d.ts +1 -1
- package/dist/src/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.js +2 -1
- package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.pact.js +55 -0
- package/dist/src/infrastructure/tracking/tracking.d.ts +2 -2
- package/dist/src/infrastructure/tracking/useTrackCheckout.d.ts +10 -17
- package/dist/src/infrastructure/tracking/useTrackCheckout.js +27 -12
- package/dist/src/infrastructure/ui/Root.d.ts +6 -6
- package/dist/src/infrastructure/ui/Root.js +2 -3
- package/dist/src/infrastructure/ui/components/atoms/fiveItemsDiscountBanner/FiveItemsDiscountBanner.js +1 -2
- package/dist/src/infrastructure/ui/components/atoms/fiveItemsDiscountBanner/FiveItemsDiscountBanner.style.js +2 -3
- package/dist/src/infrastructure/ui/components/atoms/price/Price.js +0 -3
- package/dist/src/infrastructure/ui/components/layouts/layout/Layout.d.ts +22 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/Layout.js +1 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.d.ts +7 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.js +5 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.d.ts +7 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.js +6 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.d.ts +4 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.js +20 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.d.ts +4 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.js +43 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.d.ts +12 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.js +14 -0
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.js +3 -7
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.style.d.ts +2 -18
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.style.js +2 -14
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.js +1 -2
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.js +1 -2
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.js +3 -4
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.style.d.ts +1 -0
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.style.js +1 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +3 -3
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.js +2 -3
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.js +4 -4
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.js +2 -3
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.js +2 -3
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.js +1 -2
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.js +4 -5
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.js +6 -6
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +3 -4
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.style.d.ts +1 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.style.js +1 -0
- package/dist/src/infrastructure/ui/components/templates/footer/Footer.d.ts +3 -0
- package/dist/src/infrastructure/ui/components/templates/footer/Footer.js +13 -0
- package/dist/src/infrastructure/ui/components/templates/header/checkoutHeader/CheckoutHeader.js +2 -2
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.d.ts +7 -0
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.js +21 -0
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.d.ts +8 -0
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.js +12 -0
- package/dist/src/infrastructure/ui/components/templates/header/itemDetailHeader/ItemDetailHeader.js +2 -2
- package/dist/src/infrastructure/ui/components/templates/header/itemHeader/ItemHeader.js +4 -4
- package/dist/src/infrastructure/ui/hooks/useCheckoutFlow.d.ts +26 -0
- package/dist/src/infrastructure/ui/hooks/useCheckoutFlow.js +135 -0
- package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.d.ts +12 -0
- package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.js +64 -0
- package/dist/src/infrastructure/ui/hooks/usePaymentInstrumentEvents.d.ts +3 -2
- package/dist/src/infrastructure/ui/hooks/usePaymentInstrumentEvents.js +17 -26
- package/dist/src/infrastructure/ui/hooks/useStaticInfo.d.ts +2 -0
- package/dist/src/infrastructure/ui/hooks/useStaticInfo.js +2 -2
- package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.d.ts +1 -1
- package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.js +22 -55
- package/dist/src/infrastructure/ui/i18n/fetchTranslations.d.ts +10 -0
- package/dist/src/infrastructure/ui/i18n/fetchTranslations.js +17 -0
- package/dist/src/infrastructure/ui/i18n/i18n.d.ts +2 -2
- package/dist/src/infrastructure/ui/i18n/i18n.js +2 -2
- package/dist/src/infrastructure/ui/i18n/translationEndpoint.d.ts +20 -0
- package/dist/src/infrastructure/ui/i18n/translationEndpoint.js +27 -0
- package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.d.ts +10 -0
- package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +27 -0
- package/dist/src/infrastructure/ui/routing/CheckoutMiddleware.js +3 -14
- package/dist/src/infrastructure/ui/routing/Routing.d.ts +5 -5
- package/dist/src/infrastructure/ui/routing/Routing.js +8 -18
- package/dist/src/infrastructure/ui/routing/routes.d.ts +0 -1
- package/dist/src/infrastructure/ui/routing/routes.js +0 -1
- package/dist/src/infrastructure/ui/test/render.js +3 -7
- package/dist/src/infrastructure/ui/views/App.js +5 -7
- package/dist/src/infrastructure/ui/views/App.style.d.ts +6 -0
- package/dist/src/infrastructure/ui/views/App.style.js +8 -0
- package/dist/src/infrastructure/ui/views/checkout/Checkout.d.ts +7 -2
- package/dist/src/infrastructure/ui/views/checkout/Checkout.js +24 -15
- package/dist/src/infrastructure/ui/views/checkout/Checkout.style.d.ts +3 -0
- package/dist/src/infrastructure/ui/views/checkout/Checkout.style.js +3 -0
- package/dist/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +16 -16
- package/dist/src/infrastructure/ui/views/checkout/components/deliveryBanner/DeliveryBanner.js +2 -2
- package/dist/src/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.js +7 -7
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.js +2 -2
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.d.ts +7 -0
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.js +11 -0
- package/dist/src/infrastructure/ui/views/item/Item.js +1 -3
- package/dist/src/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.js +3 -3
- package/dist/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.js +5 -11
- package/dist/src/infrastructure/ui/views/item/components/itemActions/ItemActions.js +4 -4
- package/dist/src/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.js +3 -3
- package/dist/src/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.style.d.ts +0 -1
- package/dist/src/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.style.js +1 -2
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.js +2 -2
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +12 -0
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +64 -0
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +12 -0
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.js +16 -0
- package/dist/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/SizeWithoutStockModal.js +4 -4
- package/dist/src/infrastructure/ui/views/return/Return.style.d.ts +40 -0
- package/dist/src/infrastructure/ui/views/return/Return.style.js +44 -0
- package/dist/src/infrastructure/ui/views/return/components/price/Price.js +0 -3
- package/dist/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.js +3 -3
- package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.js +6 -6
- package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +0 -1
- package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.style.js +1 -2
- package/dist/src/infrastructure/ui/views/shared/components/productVariant/ProductVariant.js +4 -4
- package/dist/src/infrastructure/ui/views/summary/Summary.js +5 -6
- package/dist/src/infrastructure/ui/views/summary/components/collapsiblePricing/CollapsiblePricing.js +2 -3
- package/dist/src/infrastructure/ui/views/summary/components/pricing/Pricing.js +6 -8
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.d.ts +14 -0
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.js +28 -0
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.d.ts +7 -0
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.js +11 -0
- package/dist/src/infrastructure/ui/views/summaryTabs/SummaryTabs.js +1 -3
- package/dist/src/infrastructure/ui/views/summaryTabs/components/checkoutItemsTabs/CheckoutItemsTabs.js +5 -5
- package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.d.ts +26 -0
- package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.js +21 -0
- package/dist/src/projection/customer/customer.d.ts +2 -0
- package/dist/src/projection/order/order.d.ts +1 -1
- package/dist/src/projection/shared/country.d.ts +14 -0
- package/dist/src/projection/shared/country.js +15 -0
- package/dist/src/projection/shared/customer.d.ts +9 -0
- package/dist/src/projection/shared/customer.js +1 -0
- package/dist/src/projection/shared/locale.d.ts +12 -0
- package/dist/src/projection/shared/locale.js +13 -0
- package/dist/src/projection/shared/order.d.ts +6 -0
- package/dist/src/projection/shared/order.js +1 -0
- package/dist/src/projection/shared/price.d.ts +11 -0
- package/dist/src/projection/shared/price.js +1 -0
- package/dist/src/projection/shared/size.d.ts +21 -0
- package/dist/src/projection/shared/size.js +4 -0
- package/dist/src/projection/shared/subscription.d.ts +2 -0
- package/dist/src/projection/shared/subscription.js +1 -0
- package/dist/src/projection/subscription/subscription.d.ts +1 -1
- package/dist/src/shared/ui/components/atoms/aspectRatioView/AspectRatioView.d.ts +15 -0
- package/dist/src/shared/ui/components/atoms/aspectRatioView/AspectRatioView.js +16 -0
- package/dist/src/shared/ui/components/atoms/error/Error.d.ts +11 -0
- package/dist/src/shared/ui/components/atoms/error/Error.js +6 -0
- package/dist/src/shared/ui/components/atoms/field/Field.d.ts +14 -0
- package/dist/src/shared/ui/components/atoms/field/Field.js +29 -0
- package/dist/src/shared/ui/components/atoms/field/Field.style.d.ts +16 -0
- package/dist/src/shared/ui/components/atoms/field/Field.style.js +19 -0
- package/dist/src/shared/ui/components/molecules/inputField/InputField.d.ts +24 -0
- package/dist/src/shared/ui/components/molecules/inputField/InputField.js +28 -0
- package/dist/src/shared/ui/components/molecules/inputField/InputField.style.d.ts +29 -0
- package/dist/src/shared/ui/components/molecules/inputField/InputField.style.js +37 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/fake-dependencies/@lookiero/payments-front/index.tsx +32 -9
- package/index.ts +11 -5
- package/jest.config.js +2 -2
- package/package.json +9 -9
- package/src/Expo.tsx +0 -3
- package/src/ExpoRoot.tsx +44 -38
- package/src/infrastructure/domain/checkoutBooking/react/useBlockCheckoutBooking.ts +4 -1
- package/src/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.ts +3 -2
- package/src/infrastructure/tracking/tracking.ts +2 -2
- package/src/infrastructure/tracking/useTrackCheckout.ts +66 -56
- package/src/infrastructure/ui/Root.tsx +9 -9
- package/src/infrastructure/ui/components/atoms/fiveItemsDiscountBanner/FiveItemsDiscountBanner.style.ts +2 -3
- package/src/infrastructure/ui/components/atoms/fiveItemsDiscountBanner/FiveItemsDiscountBanner.tsx +2 -3
- package/src/infrastructure/ui/components/atoms/fiveItemsDiscountBanner/__snapshots__/FiveItemsDiscountBanner.test.tsx.snap +1 -1
- package/src/infrastructure/ui/components/atoms/price/Price.tsx +0 -3
- package/src/infrastructure/ui/components/atoms/price/__snapshots__/Price.test.tsx.snap +3 -3
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.style.ts +4 -25
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.tsx +7 -13
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.tsx +1 -2
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.tsx +1 -2
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.style.ts +1 -0
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.tsx +2 -4
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.tsx +3 -3
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.tsx +2 -3
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.tsx +5 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.tsx +2 -3
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.tsx +2 -3
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.tsx +1 -2
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.tsx +5 -6
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.tsx +7 -7
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.style.ts +1 -0
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.tsx +2 -4
- package/src/infrastructure/ui/components/templates/footer/Footer.test.tsx +15 -0
- package/src/infrastructure/ui/components/templates/footer/Footer.tsx +19 -0
- package/src/infrastructure/ui/components/templates/footer/__snapshots__/Footer.test.tsx.snap +1127 -0
- package/src/infrastructure/ui/components/templates/header/checkoutHeader/CheckoutHeader.tsx +2 -2
- package/src/infrastructure/ui/components/templates/header/checkoutHeader/__snapshots__/CheckoutHeader.test.tsx.snap +1 -1
- package/src/infrastructure/ui/components/templates/header/itemDetailHeader/ItemDetailHeader.tsx +2 -2
- package/src/infrastructure/ui/components/templates/header/itemDetailHeader/__snapshots__/ItemDetailHeader.test.tsx.snap +1 -1
- package/src/infrastructure/ui/components/templates/header/itemHeader/ItemHeader.tsx +5 -4
- package/src/infrastructure/ui/components/templates/header/itemHeader/__snapshots__/ItemHeader.test.tsx.snap +1 -1
- package/src/infrastructure/ui/hooks/{useSubmitCheckout.test.ts → useCheckoutFlow.test.ts} +1 -1
- package/src/infrastructure/ui/hooks/useCheckoutFlow.tsx +212 -0
- package/src/infrastructure/ui/hooks/usePaymentInstrumentEvents.ts +18 -60
- package/src/infrastructure/ui/hooks/useStaticInfo.tsx +4 -2
- package/src/infrastructure/ui/i18n/i18n.ts +2 -3
- package/src/infrastructure/ui/routing/CheckoutMiddleware.test.tsx +3 -3
- package/src/infrastructure/ui/routing/CheckoutMiddleware.tsx +3 -17
- package/src/infrastructure/ui/routing/Routing.tsx +25 -39
- package/src/infrastructure/ui/routing/routes.ts +0 -1
- package/src/infrastructure/ui/test/render.tsx +4 -10
- package/src/infrastructure/ui/views/App.tsx +5 -14
- package/src/infrastructure/ui/views/checkout/Checkout.style.ts +3 -0
- package/src/infrastructure/ui/views/checkout/Checkout.tsx +55 -18
- package/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.test.tsx +116 -121
- package/src/infrastructure/ui/views/checkout/components/deliveryBanner/DeliveryBanner.tsx +2 -2
- package/src/infrastructure/ui/views/checkout/components/deliveryBanner/__snapshots__/DeliveryBanner.test.tsx.snap +1 -1
- package/src/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.tsx +8 -8
- package/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.tsx +2 -2
- package/src/infrastructure/ui/views/item/Item.tsx +1 -2
- package/src/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.tsx +3 -3
- package/src/infrastructure/ui/views/item/components/banner/__snapshots__/CustomerDecissionBanner.test.tsx.snap +3 -3
- package/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.tsx +5 -11
- package/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/__snapshots__/GetOutOfCheckoutModal.test.tsx.snap +88 -160
- package/src/infrastructure/ui/views/item/components/itemActions/ItemActions.tsx +4 -4
- package/src/infrastructure/ui/views/item/components/itemActions/__snapshots__/ItemActions.test.tsx.snap +128 -244
- package/src/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.style.ts +1 -2
- package/src/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.tsx +3 -3
- package/src/infrastructure/ui/views/item/components/productVariantDescription/__snapshots__/ProductVariantDescription.test.tsx.snap +8 -10
- package/src/infrastructure/ui/views/item/components/productVariantSlider/__snapshots__/ProductVariantSlider.test.tsx.snap +30 -30
- package/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.tsx +2 -2
- package/src/infrastructure/ui/views/item/components/selectModal/__snapshots__/SelecModal.test.tsx.snap +1 -1
- package/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/SizeWithoutStockModal.tsx +4 -4
- package/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/__snapshots__/SizeWithoutStockModal.test.tsx.snap +41 -75
- package/src/infrastructure/ui/views/item/views/productVariant/__snapshots__/ProductVariant.test.tsx.snap +102 -105
- package/src/infrastructure/ui/views/return/components/price/Price.tsx +0 -3
- package/src/infrastructure/ui/views/return/components/price/__snapshots__/Price.test.tsx.snap +3 -3
- package/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.tsx +3 -3
- package/src/infrastructure/ui/views/return/components/productVariantPreview/__snapshots__/ProductVariantPreview.test.tsx.snap +1 -1
- package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.style.ts +1 -2
- package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +6 -6
- package/src/infrastructure/ui/views/shared/components/productVariant/ProductVariant.tsx +4 -4
- package/src/infrastructure/ui/views/shared/components/productVariant/__snapshots__/ProductVariant.test.tsx.snap +30 -30
- package/src/infrastructure/ui/views/summary/Summary.tsx +5 -6
- package/src/infrastructure/ui/views/summary/components/collapsiblePricing/CollapsiblePricing.tsx +2 -3
- package/src/infrastructure/ui/views/summary/components/collapsiblePricing/__snapshots__/CollapsiblePricing.test.tsx.snap +82 -154
- package/src/infrastructure/ui/views/summary/components/pricing/Pricing.tsx +6 -8
- package/src/infrastructure/ui/views/summaryTabs/SummaryTabs.tsx +1 -2
- package/src/infrastructure/ui/views/summaryTabs/components/checkoutItemsTabs/CheckoutItemsTabs.tsx +5 -5
- package/src/infrastructure/ui/views/summaryTabs/components/checkoutItemsTabs/__snapshots__/CheckoutItemsTabs.test.tsx.snap +62 -62
- package/src/projection/customer/customer.ts +2 -0
- package/src/projection/order/order.ts +1 -1
- package/src/projection/subscription/subscription.ts +1 -1
- package/src/infrastructure/ui/hooks/useSubmitCheckout.ts +0 -169
- package/src/infrastructure/ui/routing/useBasePath.test.tsx +0 -19
- package/src/infrastructure/ui/routing/useBasePath.tsx +0 -24
- package/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.tsx +0 -125
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC } from "react";
|
|
2
2
|
import { ButtonIcon, Text } from "@lookiero/aurora";
|
|
3
3
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
4
|
-
import {
|
|
4
|
+
import { I18nMessages } from "../../../../i18n/i18n";
|
|
5
5
|
import { Header } from "../Header";
|
|
6
6
|
import { ButtonIconPlaceholder } from "../buttonIconPlaceholder/ButtonIconPlaceholder";
|
|
7
7
|
import { style } from "./CheckoutHeader.style";
|
|
@@ -11,7 +11,7 @@ interface CheckoutHeaderProps {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const CheckoutHeader: FC<CheckoutHeaderProps> = ({ onBack }) => {
|
|
14
|
-
const title = useI18nMessage({
|
|
14
|
+
const title = useI18nMessage({ id: I18nMessages.HEADER_COMPLETE_CHECKOUT_TITLE });
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
17
|
<Header testID="checkout-header">
|
package/src/infrastructure/ui/components/templates/header/itemDetailHeader/ItemDetailHeader.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC } from "react";
|
|
2
2
|
import { ButtonIcon, Text } from "@lookiero/aurora";
|
|
3
3
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
4
|
-
import {
|
|
4
|
+
import { I18nMessages } from "../../../../i18n/i18n";
|
|
5
5
|
import { Header } from "../Header";
|
|
6
6
|
import { ButtonIconPlaceholder } from "../buttonIconPlaceholder/ButtonIconPlaceholder";
|
|
7
7
|
import { style } from "./ItemDetailHeader.style";
|
|
@@ -10,7 +10,7 @@ interface ItemDetailHeaderProps {
|
|
|
10
10
|
readonly onBack: () => void;
|
|
11
11
|
}
|
|
12
12
|
const ItemDetailHeader: FC<ItemDetailHeaderProps> = ({ onBack }) => {
|
|
13
|
-
const title = useI18nMessage({
|
|
13
|
+
const title = useI18nMessage({ id: I18nMessages.HEADER_CHECKOUT_TITLE });
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
16
|
<Header testID="item-detail-header">
|
|
@@ -4,9 +4,9 @@ import { generatePath, useNavigate } from "react-router-native";
|
|
|
4
4
|
import { ButtonIcon, Text } from "@lookiero/aurora";
|
|
5
5
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
6
6
|
import { CheckoutItemProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
|
|
7
|
-
import {
|
|
7
|
+
import { useStaticInfo } from "../../../../hooks/useStaticInfo";
|
|
8
|
+
import { I18nMessages } from "../../../../i18n/i18n";
|
|
8
9
|
import { Routes } from "../../../../routing/routes";
|
|
9
|
-
import { useBasePath } from "../../../../routing/useBasePath";
|
|
10
10
|
import { Header } from "../Header";
|
|
11
11
|
import { ButtonIconPlaceholder } from "../buttonIconPlaceholder/ButtonIconPlaceholder";
|
|
12
12
|
import style from "./ItemHeader.style";
|
|
@@ -33,12 +33,13 @@ interface ItemHeaderProps {
|
|
|
33
33
|
readonly onNext?: OnNextItemFunction;
|
|
34
34
|
readonly onPrevious?: OnPreviousItemFunction;
|
|
35
35
|
}
|
|
36
|
+
|
|
36
37
|
const ItemHeader: FC<ItemHeaderProps> = ({ items, item, onNext, onPrevious }) => {
|
|
37
|
-
const title = useI18nMessage({
|
|
38
|
+
const title = useI18nMessage({ id: I18nMessages.HEADER_CHECKOUT_TITLE });
|
|
38
39
|
const itemIndex = items.indexOf(item);
|
|
39
40
|
const isFirstItem = itemIndex === 0;
|
|
40
41
|
const isLastItem = itemIndex === items.length - 1;
|
|
41
|
-
const basePath =
|
|
42
|
+
const { basePath } = useStaticInfo();
|
|
42
43
|
const navigate = useNavigate();
|
|
43
44
|
|
|
44
45
|
const navigateToPreviousItem = useCallback(() => {
|
|
@@ -11,7 +11,7 @@ import { useSubmitCheckout } from "../../domain/checkout/react/useSubmitCheckout
|
|
|
11
11
|
import { useBlockCheckoutBooking } from "../../domain/checkoutBooking/react/useBlockCheckoutBooking";
|
|
12
12
|
import { paymentFlowPayload as mockPaymentFlowPayload } from "../../projection/payment/paymentFlowPayload.mock";
|
|
13
13
|
import { useQueryBus } from "./useQueryBus";
|
|
14
|
-
import { useSubmitCheckout as sut } from "./
|
|
14
|
+
import { useSubmitCheckout as sut } from "./useCheckoutFlow";
|
|
15
15
|
|
|
16
16
|
const checkoutId = "9c450400-0cd7-44a4-b0e3-e0002a9bf8df";
|
|
17
17
|
const checkoutBookingId = "07c996bb-a0b4-45f9-ae21-6bb9c784d12b";
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import React, { ReactNode, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { CommandStatus } from "@lookiero/messaging-react";
|
|
3
|
+
import { PaymentFlow, PaymentFlowRef, PaymentPayload, Section } from "@lookiero/payments-front";
|
|
4
|
+
import { LegacyBoxCheckoutStrategyPayload } from "@lookiero/payments-front/build/components/PaymentFlow/internals/strategies/LegacyBoxCheckoutStrategy";
|
|
5
|
+
import { useLogger } from "@lookiero/sty-psp-logging";
|
|
6
|
+
import { NotificationLevel, useCreateToastNotification } from "@lookiero/sty-psp-notifications";
|
|
7
|
+
import { CheckoutProjection } from "../../../projection/checkout/checkout";
|
|
8
|
+
import {
|
|
9
|
+
ViewCheckoutBookingById,
|
|
10
|
+
viewCheckoutBookingById,
|
|
11
|
+
ViewCheckoutBookingByIdResult,
|
|
12
|
+
} from "../../../projection/checkoutBooking/viewCheckoutBookingById";
|
|
13
|
+
import { OrderProjection } from "../../../projection/order/order";
|
|
14
|
+
import { SubscriptionProjection } from "../../../projection/subscription/subscription";
|
|
15
|
+
import { MESSAGING_CONTEXT_ID } from "../../delivery/baseBootstrap";
|
|
16
|
+
import { useSubmitCheckout as useSubmitCheckoutCommand } from "../../domain/checkout/react/useSubmitCheckout";
|
|
17
|
+
import { useBlockCheckoutBooking } from "../../domain/checkoutBooking/react/useBlockCheckoutBooking";
|
|
18
|
+
import { useViewIsSizeChangeEnabledByCheckoutId } from "../../projection/checkout/react/useViewIsSizeChangeEnabledByCheckoutId";
|
|
19
|
+
import { useViewPaymentFlowPayloadByCheckoutId } from "../../projection/payment/react/useViewPaymentFlowPayloadByCheckoutId";
|
|
20
|
+
import { useViewPricingByCheckoutId } from "../../projection/pricing/react/useViewPricingByCheckoutId";
|
|
21
|
+
import { useTrackCheckout } from "../../tracking/useTrackCheckout";
|
|
22
|
+
import { I18nMessages } from "../i18n/i18n";
|
|
23
|
+
import { Routes } from "../routing/routes";
|
|
24
|
+
import { usePaymentInstrumentEvents } from "./usePaymentInstrumentEvents";
|
|
25
|
+
import { useQueryBus } from "./useQueryBus";
|
|
26
|
+
import { useStaticInfo } from "./useStaticInfo";
|
|
27
|
+
|
|
28
|
+
type CheckoutFlowStatus = "idle" | "loading" | "success" | "error";
|
|
29
|
+
|
|
30
|
+
interface CheckoutFlowFunction {
|
|
31
|
+
(): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type CheckoutFlowReturn = [
|
|
35
|
+
checkoutFlow: CheckoutFlowFunction,
|
|
36
|
+
checkoutFlowStatus: CheckoutFlowStatus,
|
|
37
|
+
paymentFlow: ReactNode,
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
interface UseCheckoutFlowArgs {
|
|
41
|
+
readonly checkout: CheckoutProjection | undefined;
|
|
42
|
+
readonly order: OrderProjection;
|
|
43
|
+
readonly subscription: SubscriptionProjection;
|
|
44
|
+
readonly getAuthToken: () => Promise<string>;
|
|
45
|
+
readonly onSuccess: () => void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface UseCheckoutFlowFunction {
|
|
49
|
+
(args: UseCheckoutFlowArgs): CheckoutFlowReturn;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const useCheckoutFlow: UseCheckoutFlowFunction = ({
|
|
53
|
+
checkout: checkoutProjection,
|
|
54
|
+
order: orderProjection,
|
|
55
|
+
subscription: subscriptionProjection,
|
|
56
|
+
getAuthToken,
|
|
57
|
+
onSuccess,
|
|
58
|
+
}) => {
|
|
59
|
+
const logger = useLogger();
|
|
60
|
+
const queryBus = useQueryBus();
|
|
61
|
+
const {
|
|
62
|
+
customer: { customerId, country, segment, name, email },
|
|
63
|
+
basePath,
|
|
64
|
+
} = useStaticInfo();
|
|
65
|
+
const paymentFlowRef = useRef<PaymentFlowRef>(null);
|
|
66
|
+
const [paymentFlowPayload] = useViewPaymentFlowPayloadByCheckoutId({
|
|
67
|
+
checkoutId: checkoutProjection?.id as string,
|
|
68
|
+
});
|
|
69
|
+
const [sizeChangeEnabled] = useViewIsSizeChangeEnabledByCheckoutId({ checkoutId: checkoutProjection?.id as string });
|
|
70
|
+
const [pricing] = useViewPricingByCheckoutId({
|
|
71
|
+
checkoutId: checkoutProjection?.id,
|
|
72
|
+
queryOptions: { refetchOnMount: true },
|
|
73
|
+
});
|
|
74
|
+
const [submitCheckoutCommand, submitCheckoutCommandStatus] = useSubmitCheckoutCommand({
|
|
75
|
+
checkoutId: checkoutProjection?.id,
|
|
76
|
+
logger,
|
|
77
|
+
});
|
|
78
|
+
const [blockCheckoutBooking, blockCheckoutBookingStatus] = useBlockCheckoutBooking({
|
|
79
|
+
checkoutBookingId: checkoutProjection?.checkoutBookingId,
|
|
80
|
+
logger,
|
|
81
|
+
});
|
|
82
|
+
const [createNotification] = useCreateToastNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
|
|
83
|
+
const [checkoutBookingExpired, setCheckoutBookingExpired] = useState(false);
|
|
84
|
+
const [startLegacyBoxCheckoutStatus, setStartLegacyBoxCheckoutStatus] = useState<CheckoutFlowStatus>("idle");
|
|
85
|
+
const [authToken, setAuthToken] = useState<string>();
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
const loadAuthToken = async () => setAuthToken(await getAuthToken());
|
|
88
|
+
loadAuthToken();
|
|
89
|
+
}, [getAuthToken]);
|
|
90
|
+
const trackCheckout = useTrackCheckout({
|
|
91
|
+
checkout: checkoutProjection,
|
|
92
|
+
order: orderProjection,
|
|
93
|
+
pricing,
|
|
94
|
+
subscription: subscriptionProjection,
|
|
95
|
+
userId: customerId,
|
|
96
|
+
country,
|
|
97
|
+
segment,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const checkoutFlow: CheckoutFlowFunction = useCallback(async () => {
|
|
101
|
+
try {
|
|
102
|
+
sizeChangeEnabled && (await blockCheckoutBooking());
|
|
103
|
+
} catch (error) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (checkoutProjection?.checkoutBookingId) {
|
|
108
|
+
const checkoutBooking = await queryBus<ViewCheckoutBookingById, ViewCheckoutBookingByIdResult>(
|
|
109
|
+
viewCheckoutBookingById({ checkoutBookingId: checkoutProjection?.checkoutBookingId }),
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
if (checkoutBooking?.isExpired) {
|
|
113
|
+
setCheckoutBookingExpired(true);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
setStartLegacyBoxCheckoutStatus("loading");
|
|
119
|
+
|
|
120
|
+
paymentFlowRef.current?.startLegacyBoxCheckout({
|
|
121
|
+
...paymentFlowPayload,
|
|
122
|
+
userInformation: { email, name },
|
|
123
|
+
returnUrl: `${basePath}/${Routes.CHECKOUT}`,
|
|
124
|
+
} as unknown as LegacyBoxCheckoutStrategyPayload);
|
|
125
|
+
}, [
|
|
126
|
+
checkoutProjection?.checkoutBookingId,
|
|
127
|
+
paymentFlowPayload,
|
|
128
|
+
email,
|
|
129
|
+
name,
|
|
130
|
+
basePath,
|
|
131
|
+
sizeChangeEnabled,
|
|
132
|
+
blockCheckoutBooking,
|
|
133
|
+
queryBus,
|
|
134
|
+
]);
|
|
135
|
+
const handleOnCheckoutFlowSuccess = useCallback(() => {
|
|
136
|
+
trackCheckout();
|
|
137
|
+
onSuccess();
|
|
138
|
+
}, [onSuccess, trackCheckout]);
|
|
139
|
+
|
|
140
|
+
const onPaymentSuccess = useCallback(async () => {
|
|
141
|
+
setStartLegacyBoxCheckoutStatus("success");
|
|
142
|
+
|
|
143
|
+
await submitCheckoutCommand();
|
|
144
|
+
|
|
145
|
+
createNotification({
|
|
146
|
+
bodyI18nKey: I18nMessages.CHECKOUT_TOAST_PAYMENT_SUCCESS,
|
|
147
|
+
level: NotificationLevel.SUCCESS,
|
|
148
|
+
});
|
|
149
|
+
}, [createNotification, submitCheckoutCommand]);
|
|
150
|
+
const onPaymentError = useCallback(
|
|
151
|
+
(payload: PaymentPayload) => {
|
|
152
|
+
setStartLegacyBoxCheckoutStatus("error");
|
|
153
|
+
|
|
154
|
+
createNotification({
|
|
155
|
+
bodyI18nKey: payload.metadata?.toaster?.id || I18nMessages.CHECKOUT_TOAST_PAYMENT_ERROR,
|
|
156
|
+
level: NotificationLevel.ERROR,
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
[createNotification],
|
|
160
|
+
);
|
|
161
|
+
usePaymentInstrumentEvents({ onSuccess: onPaymentSuccess, onError: onPaymentError });
|
|
162
|
+
|
|
163
|
+
const checkoutFlowStatus: CheckoutFlowStatus = useMemo(() => {
|
|
164
|
+
if (
|
|
165
|
+
blockCheckoutBookingStatus === CommandStatus.LOADING ||
|
|
166
|
+
startLegacyBoxCheckoutStatus === "loading" ||
|
|
167
|
+
submitCheckoutCommandStatus === CommandStatus.LOADING
|
|
168
|
+
) {
|
|
169
|
+
return "loading";
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (
|
|
173
|
+
blockCheckoutBookingStatus === CommandStatus.SUCCESS &&
|
|
174
|
+
startLegacyBoxCheckoutStatus === "success" &&
|
|
175
|
+
submitCheckoutCommandStatus === CommandStatus.SUCCESS
|
|
176
|
+
) {
|
|
177
|
+
return "success";
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (
|
|
181
|
+
blockCheckoutBookingStatus === CommandStatus.ERROR ||
|
|
182
|
+
startLegacyBoxCheckoutStatus === "error" ||
|
|
183
|
+
submitCheckoutCommandStatus === CommandStatus.ERROR ||
|
|
184
|
+
checkoutBookingExpired
|
|
185
|
+
) {
|
|
186
|
+
return "error";
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return "idle";
|
|
190
|
+
}, [blockCheckoutBookingStatus, startLegacyBoxCheckoutStatus, submitCheckoutCommandStatus, checkoutBookingExpired]);
|
|
191
|
+
|
|
192
|
+
useEffect(() => {
|
|
193
|
+
if (checkoutFlowStatus !== "success") {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
handleOnCheckoutFlowSuccess();
|
|
198
|
+
}, [handleOnCheckoutFlowSuccess, checkoutFlowStatus]);
|
|
199
|
+
|
|
200
|
+
const paymentFlow = useMemo(
|
|
201
|
+
() => (authToken ? <PaymentFlow ref={paymentFlowRef} section={Section.BOX_CHECKOUT} token={authToken} /> : null),
|
|
202
|
+
[authToken],
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
return useMemo(
|
|
206
|
+
() => [checkoutFlow, checkoutFlowStatus, paymentFlow],
|
|
207
|
+
[checkoutFlow, paymentFlow, checkoutFlowStatus],
|
|
208
|
+
);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export type { CheckoutFlowStatus };
|
|
212
|
+
export { useCheckoutFlow };
|
|
@@ -1,75 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Logger } from "@lookiero/sty-psp-logging";
|
|
4
|
-
import { NotificationLevel, useCreateToastNotification } from "@lookiero/sty-psp-notifications";
|
|
5
|
-
import { MESSAGING_CONTEXT_ID } from "../../delivery/baseBootstrap";
|
|
6
|
-
import { I18nMessages } from "../i18n/i18n";
|
|
7
|
-
|
|
8
|
-
const PAYMENT_ERROR = "ERROR";
|
|
9
|
-
const PAYMENT_SUCCESS = "PAYMENT_INSTRUMENT_UPDATED";
|
|
10
|
-
|
|
11
|
-
interface Message {
|
|
12
|
-
readonly id: string;
|
|
13
|
-
}
|
|
14
|
-
interface OnSuccessFunctionArgs {
|
|
15
|
-
readonly message: Message;
|
|
16
|
-
}
|
|
17
|
-
interface OnSuccessFunction {
|
|
18
|
-
(args: OnSuccessFunctionArgs): void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface Toaster {
|
|
22
|
-
readonly id: string;
|
|
23
|
-
}
|
|
24
|
-
interface Error {
|
|
25
|
-
readonly toaster?: Toaster;
|
|
26
|
-
}
|
|
27
|
-
interface OnErrorFunctionArgs {
|
|
28
|
-
readonly error: Error;
|
|
29
|
-
}
|
|
30
|
-
interface OnErrorFunction {
|
|
31
|
-
(args: OnErrorFunctionArgs): void;
|
|
32
|
-
}
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { PaymentPayload, Section, usePaymentStatusManager } from "@lookiero/payments-front";
|
|
33
3
|
|
|
34
4
|
interface UsePaymentInstrumentEventsFunctionArgs {
|
|
35
|
-
readonly
|
|
5
|
+
readonly onSuccess: (payload: PaymentPayload) => void;
|
|
6
|
+
readonly onError: (payload: PaymentPayload) => void;
|
|
36
7
|
}
|
|
37
8
|
|
|
38
9
|
interface UsePaymentInstrumentEventsFunction {
|
|
39
10
|
(args: UsePaymentInstrumentEventsFunctionArgs): void;
|
|
40
11
|
}
|
|
41
12
|
|
|
42
|
-
const usePaymentInstrumentEvents: UsePaymentInstrumentEventsFunction = ({
|
|
43
|
-
const
|
|
13
|
+
const usePaymentInstrumentEvents: UsePaymentInstrumentEventsFunction = ({ onSuccess, onError }) => {
|
|
14
|
+
const refreshStatus = usePaymentStatusManager(Section.BOX_CHECKOUT);
|
|
44
15
|
|
|
45
|
-
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const { isLoading, consumePayload } = refreshStatus;
|
|
46
18
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
);
|
|
19
|
+
if (isLoading) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
51
22
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
level: NotificationLevel.ERROR,
|
|
58
|
-
});
|
|
23
|
+
consumePayload((payload) => {
|
|
24
|
+
if (payload.success) {
|
|
25
|
+
onSuccess(payload);
|
|
26
|
+
} else {
|
|
27
|
+
onError(payload);
|
|
59
28
|
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
subscribe({ event: PAYMENT_ERROR }, onError);
|
|
66
|
-
subscribe({ event: PAYMENT_SUCCESS }, onSuccess);
|
|
67
|
-
|
|
68
|
-
return () => {
|
|
69
|
-
unsubscribe({ event: PAYMENT_ERROR }, onError);
|
|
70
|
-
unsubscribe({ event: PAYMENT_SUCCESS }, onSuccess);
|
|
71
|
-
};
|
|
72
|
-
}, [subscribe, unsubscribe, createNotification, onError, onSuccess]);
|
|
29
|
+
});
|
|
30
|
+
}, [onError, onSuccess, refreshStatus]);
|
|
73
31
|
};
|
|
74
32
|
|
|
75
33
|
export { usePaymentInstrumentEvents };
|
|
@@ -6,6 +6,7 @@ import { KameleoonEnvironment } from "../../ab-testing/kameleoonEnvironment";
|
|
|
6
6
|
interface StaticInfo {
|
|
7
7
|
readonly kameleoon: KameleoonEnvironment;
|
|
8
8
|
readonly customer: Customer;
|
|
9
|
+
readonly basePath: string;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
const StaticInfoContext = createContext<StaticInfo>(null as unknown as StaticInfo);
|
|
@@ -14,10 +15,11 @@ interface StaticInfoProviderProps {
|
|
|
14
15
|
readonly children: ReactNode;
|
|
15
16
|
readonly kameleoon: KameleoonEnvironment;
|
|
16
17
|
readonly customer: Customer;
|
|
18
|
+
readonly basePath: string;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
const StaticInfoProvider: FC<StaticInfoProviderProps> = ({ children, kameleoon, customer }) => {
|
|
20
|
-
const value = useMemo(() => ({ kameleoon, customer }), [customer, kameleoon]);
|
|
21
|
+
const StaticInfoProvider: FC<StaticInfoProviderProps> = ({ children, kameleoon, customer, basePath }) => {
|
|
22
|
+
const value = useMemo(() => ({ kameleoon, customer, basePath }), [customer, kameleoon, basePath]);
|
|
21
23
|
|
|
22
24
|
return <StaticInfoContext.Provider value={value}>{children}</StaticInfoContext.Provider>;
|
|
23
25
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const DOMAIN = "CheckoutI18n";
|
|
2
|
-
|
|
3
1
|
// TODO: deprecated?
|
|
4
2
|
const COLOR_I18N_PREFIX = "catalog.color.";
|
|
5
3
|
|
|
@@ -50,6 +48,7 @@ enum I18nMessages {
|
|
|
50
48
|
CHECKOUT_TITLE = "checkout.title",
|
|
51
49
|
CHECKOUT_PAY_BUTTON = "checkout.pay_button",
|
|
52
50
|
CHECKOUT_TOAST_PAYMENT_ERROR = "checkout.toast_payment_error",
|
|
51
|
+
CHECKOUT_TOAST_PAYMENT_SUCCESS = "checkout.toast_payment_success",
|
|
53
52
|
CHECKOUT_SUCCESS_MODAL_TITLE = "checkout.success_modal_title",
|
|
54
53
|
CHECKOUT_SUCCESS_MODAL_DESCRIPTION = "checkout.success_modal_description",
|
|
55
54
|
CHECKOUT_SUCCESS_MODAL_BUTTON = "checkout.success_modal_button",
|
|
@@ -60,4 +59,4 @@ enum I18nMessages {
|
|
|
60
59
|
CHECKOUT_TOAST_BOOKING_EXPIRED = "checkout.toast_booking_expired",
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
export {
|
|
62
|
+
export { I18nMessages, COLOR_I18N_PREFIX };
|
|
@@ -12,9 +12,9 @@ import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutI
|
|
|
12
12
|
import { useStartCheckout } from "../../domain/checkout/react/useStartCheckout";
|
|
13
13
|
import { checkout } from "../../projection/checkout/checkout.mock";
|
|
14
14
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
15
|
+
import { StaticInfoProvider } from "../hooks/useStaticInfo";
|
|
15
16
|
import { CheckoutMiddleware } from "./CheckoutMiddleware";
|
|
16
17
|
import { Routes } from "./routes";
|
|
17
|
-
import { BasePathProvider } from "./useBasePath";
|
|
18
18
|
|
|
19
19
|
jest.mock("../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId", () => ({
|
|
20
20
|
useViewFirstAvailableCheckoutByCustomerId: jest.fn(),
|
|
@@ -91,7 +91,7 @@ const renderCheckoutMiddleware = ({
|
|
|
91
91
|
{
|
|
92
92
|
path: "/*",
|
|
93
93
|
element: (
|
|
94
|
-
<
|
|
94
|
+
<StaticInfoProvider basePath="" customer={} kameleoon={}>
|
|
95
95
|
<CheckoutMiddleware
|
|
96
96
|
customerId={customerId}
|
|
97
97
|
loader={<Text>{loaderText}</Text>}
|
|
@@ -99,7 +99,7 @@ const renderCheckoutMiddleware = ({
|
|
|
99
99
|
>
|
|
100
100
|
<Text>{checkoutChildrenText}</Text>
|
|
101
101
|
</CheckoutMiddleware>
|
|
102
|
-
</
|
|
102
|
+
</StaticInfoProvider>
|
|
103
103
|
),
|
|
104
104
|
},
|
|
105
105
|
],
|
|
@@ -8,8 +8,8 @@ import { CheckoutItemProjection } from "../../../projection/checkoutItem/checkou
|
|
|
8
8
|
import { useStartCheckout } from "../../domain/checkout/react/useStartCheckout";
|
|
9
9
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
10
10
|
import { useViewIsSizeChangeEnabledByCheckoutId } from "../../projection/checkout/react/useViewIsSizeChangeEnabledByCheckoutId";
|
|
11
|
+
import { useStaticInfo } from "../hooks/useStaticInfo";
|
|
11
12
|
import { Routes } from "./routes";
|
|
12
|
-
import { useBasePath } from "./useBasePath";
|
|
13
13
|
|
|
14
14
|
interface CheckoutMiddlewareProps {
|
|
15
15
|
readonly customerId: string;
|
|
@@ -25,7 +25,7 @@ const CheckoutMiddleware: FC<CheckoutMiddlewareProps> = ({
|
|
|
25
25
|
children,
|
|
26
26
|
}) => {
|
|
27
27
|
const logger = useLogger();
|
|
28
|
-
const basePath =
|
|
28
|
+
const { basePath } = useStaticInfo();
|
|
29
29
|
const navigate = useNavigate();
|
|
30
30
|
const navigateRef = useRef(navigate);
|
|
31
31
|
navigateRef.current = navigate;
|
|
@@ -48,12 +48,6 @@ const CheckoutMiddleware: FC<CheckoutMiddlewareProps> = ({
|
|
|
48
48
|
const feedbackRouteMatch = useMatch(`${basePath}/${Routes.FEEDBACK}`);
|
|
49
49
|
const feedbackRouteMatchRef = useRef(feedbackRouteMatch);
|
|
50
50
|
feedbackRouteMatchRef.current = feedbackRouteMatch;
|
|
51
|
-
const checkoutPaymentRouteMatch = useMatch(`${basePath}/${Routes.CHECKOUT}/${Routes.CHECKOUT_PAYMENT}`);
|
|
52
|
-
const checkoutPaymentRouteMatchRef = useRef(checkoutPaymentRouteMatch);
|
|
53
|
-
checkoutPaymentRouteMatchRef.current = checkoutPaymentRouteMatch;
|
|
54
|
-
|
|
55
|
-
const checkoutShown = useRef(false);
|
|
56
|
-
checkoutShown.current = checkoutShown.current || (Boolean(checkoutRouteMatch) && !Boolean(checkoutPaymentRouteMatch));
|
|
57
51
|
|
|
58
52
|
const [checkout] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
59
53
|
const checkoutItemsRef = useRef<CheckoutItemProjection[]>();
|
|
@@ -99,8 +93,7 @@ const CheckoutMiddleware: FC<CheckoutMiddlewareProps> = ({
|
|
|
99
93
|
summaryRouteMatchRef.current ||
|
|
100
94
|
summaryTabsRouteMatchRef.current ||
|
|
101
95
|
itemDetailRouteMatchRef.current ||
|
|
102
|
-
checkoutRouteMatchRef.current
|
|
103
|
-
checkoutPaymentRouteMatchRef.current
|
|
96
|
+
checkoutRouteMatchRef.current
|
|
104
97
|
)
|
|
105
98
|
) {
|
|
106
99
|
navigateRef.current(`${basePath}/${Routes.SUMMARY}`, { replace: true });
|
|
@@ -127,13 +120,6 @@ const CheckoutMiddleware: FC<CheckoutMiddlewareProps> = ({
|
|
|
127
120
|
return null;
|
|
128
121
|
}
|
|
129
122
|
|
|
130
|
-
/* Prevent direct payment access */
|
|
131
|
-
if (checkoutPaymentRouteMatch && !checkoutShown.current) {
|
|
132
|
-
onNotAccessible();
|
|
133
|
-
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
123
|
return children;
|
|
138
124
|
};
|
|
139
125
|
|
|
@@ -6,13 +6,12 @@ import { Kameleoon } from "@lookiero/sty-psp-ab-testing";
|
|
|
6
6
|
import { Locale } from "@lookiero/sty-psp-locale";
|
|
7
7
|
import { Layout } from "@lookiero/sty-psp-ui";
|
|
8
8
|
import { Customer } from "../../../projection/customer/customer";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { OrderProjection } from "../../../projection/order/order";
|
|
10
|
+
import { SubscriptionProjection } from "../../../projection/subscription/subscription";
|
|
11
11
|
import { KameleoonEnvironment } from "../../ab-testing/kameleoonEnvironment";
|
|
12
12
|
import { StaticInfoProvider } from "../hooks/useStaticInfo";
|
|
13
13
|
import { App } from "../views/App";
|
|
14
14
|
import { Checkout } from "../views/checkout/Checkout";
|
|
15
|
-
import { CheckoutPaymentModal } from "../views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal";
|
|
16
15
|
import { Feedback } from "../views/feedback/Feedback";
|
|
17
16
|
import { Item } from "../views/item/Item";
|
|
18
17
|
import { Return } from "../views/return/Return";
|
|
@@ -20,20 +19,19 @@ import { Summary } from "../views/summary/Summary";
|
|
|
20
19
|
import { SummaryTabs } from "../views/summaryTabs/SummaryTabs";
|
|
21
20
|
import { CheckoutMiddleware } from "./CheckoutMiddleware";
|
|
22
21
|
import { Routes } from "./routes";
|
|
23
|
-
import { BasePathProvider } from "./useBasePath";
|
|
24
22
|
|
|
25
23
|
interface RoutingProps {
|
|
26
24
|
readonly basePath?: string;
|
|
27
25
|
readonly customer: Customer;
|
|
28
|
-
readonly order:
|
|
29
|
-
readonly subscription:
|
|
26
|
+
readonly order: OrderProjection;
|
|
27
|
+
readonly subscription: SubscriptionProjection;
|
|
30
28
|
readonly locale: Locale;
|
|
31
29
|
readonly I18n: I18n;
|
|
32
30
|
readonly kameleoon: KameleoonEnvironment;
|
|
33
31
|
readonly layout: Layout;
|
|
34
32
|
readonly getAuthToken: () => Promise<string>;
|
|
35
33
|
readonly onNotAccessible: () => void;
|
|
36
|
-
readonly
|
|
34
|
+
readonly onCheckoutFlowSuccess: () => void;
|
|
37
35
|
readonly onI18nError?: (err: Error) => void;
|
|
38
36
|
readonly useRedirect: () => Record<string, string>;
|
|
39
37
|
readonly useRoutes: typeof reactRouterUseRoutes;
|
|
@@ -51,7 +49,7 @@ const Routing: FC<RoutingProps> = ({
|
|
|
51
49
|
getAuthToken,
|
|
52
50
|
onI18nError,
|
|
53
51
|
onNotAccessible,
|
|
54
|
-
|
|
52
|
+
onCheckoutFlowSuccess,
|
|
55
53
|
useRedirect,
|
|
56
54
|
useRoutes = reactRouterUseRoutes,
|
|
57
55
|
}) => {
|
|
@@ -59,19 +57,17 @@ const Routing: FC<RoutingProps> = ({
|
|
|
59
57
|
{
|
|
60
58
|
path: "",
|
|
61
59
|
element: (
|
|
62
|
-
<
|
|
63
|
-
<
|
|
64
|
-
<
|
|
65
|
-
<
|
|
66
|
-
<
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
</StaticInfoProvider>
|
|
74
|
-
</BasePathProvider>
|
|
60
|
+
<StaticInfoProvider basePath={basePath} customer={customer} kameleoon={kameleoon}>
|
|
61
|
+
<I18n loader={<Spinner />} locale={locale} onError={onI18nError}>
|
|
62
|
+
<Kameleoon loader={<Spinner />} siteCode={kameleoon.siteCode}>
|
|
63
|
+
<CheckoutMiddleware customerId={customer?.customerId as string} onNotAccessible={onNotAccessible}>
|
|
64
|
+
<App>
|
|
65
|
+
<Outlet />
|
|
66
|
+
</App>
|
|
67
|
+
</CheckoutMiddleware>
|
|
68
|
+
</Kameleoon>
|
|
69
|
+
</I18n>
|
|
70
|
+
</StaticInfoProvider>
|
|
75
71
|
),
|
|
76
72
|
children: [
|
|
77
73
|
{
|
|
@@ -114,26 +110,16 @@ const Routing: FC<RoutingProps> = ({
|
|
|
114
110
|
path: Routes.CHECKOUT,
|
|
115
111
|
element: (
|
|
116
112
|
<Suspense fallback={<Spinner />}>
|
|
117
|
-
<Checkout
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
<Checkout
|
|
114
|
+
getAuthToken={getAuthToken}
|
|
115
|
+
layout={layout}
|
|
116
|
+
order={order}
|
|
117
|
+
subscription={subscription}
|
|
118
|
+
useRedirect={useRedirect}
|
|
119
|
+
onCheckoutFlowSuccess={onCheckoutFlowSuccess}
|
|
120
|
+
/>
|
|
120
121
|
</Suspense>
|
|
121
122
|
),
|
|
122
|
-
children: [
|
|
123
|
-
{
|
|
124
|
-
path: Routes.CHECKOUT_PAYMENT,
|
|
125
|
-
element: (
|
|
126
|
-
<CheckoutPaymentModal
|
|
127
|
-
coupon={order?.coupon || null}
|
|
128
|
-
getAuthToken={getAuthToken}
|
|
129
|
-
isFirstOrder={order?.isFirstOrder as boolean}
|
|
130
|
-
orderNumber={order?.orderNumber as number}
|
|
131
|
-
subscription={subscription as Subscription}
|
|
132
|
-
onCheckoutSubmitted={onCheckoutSubmitted}
|
|
133
|
-
/>
|
|
134
|
-
),
|
|
135
|
-
},
|
|
136
|
-
],
|
|
137
123
|
},
|
|
138
124
|
{
|
|
139
125
|
path: Routes.FEEDBACK,
|