@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.
Files changed (288) hide show
  1. package/dist/fake-dependencies/@lookiero/payments-front/index.d.ts +8 -6
  2. package/dist/fake-dependencies/@lookiero/payments-front/index.js +7 -4
  3. package/dist/index.d.ts +3 -3
  4. package/dist/index.js +1 -2
  5. package/dist/pact.config.d.ts +21 -0
  6. package/dist/pact.config.js +16 -0
  7. package/dist/public/public/assets/adaptive-icon.png +0 -0
  8. package/dist/public/public/assets/favicon.png +0 -0
  9. package/dist/public/public/assets/icon.png +0 -0
  10. package/dist/public/public/assets/splash.png +0 -0
  11. package/dist/public/public/images/not-found.png +0 -0
  12. package/dist/src/Expo.js +0 -2
  13. package/dist/src/ExpoRoot.js +19 -15
  14. package/dist/src/infrastructure/domain/checkoutBooking/react/useBlockCheckoutBooking.d.ts +1 -1
  15. package/dist/src/infrastructure/domain/checkoutBooking/react/useBlockCheckoutBooking.js +2 -0
  16. package/dist/src/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.pact.d.ts +1 -0
  17. package/dist/src/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.pact.js +55 -0
  18. package/dist/src/infrastructure/projection/checkout/httpCheckoutByIdView.pact.d.ts +1 -0
  19. package/dist/src/infrastructure/projection/checkout/httpCheckoutByIdView.pact.js +116 -0
  20. package/dist/src/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.pact.d.ts +1 -0
  21. package/dist/src/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.pact.js +56 -0
  22. package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.d.ts +1 -0
  23. package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.js +51 -0
  24. package/dist/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.d.ts +1 -0
  25. package/dist/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.js +51 -0
  26. package/dist/src/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.pact.d.ts +1 -0
  27. package/dist/src/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.pact.js +51 -0
  28. package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.d.ts +13 -0
  29. package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.js +19 -0
  30. package/dist/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.d.ts +1 -0
  31. package/dist/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.js +56 -0
  32. package/dist/src/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.pact.d.ts +1 -0
  33. package/dist/src/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.pact.js +57 -0
  34. package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.pact.d.ts +1 -0
  35. package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.pact.js +55 -0
  36. package/dist/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.d.ts +1 -0
  37. package/dist/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.js +120 -0
  38. package/dist/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.pact.d.ts +1 -0
  39. package/dist/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.pact.js +55 -0
  40. package/dist/src/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.d.ts +1 -1
  41. package/dist/src/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.js +2 -1
  42. package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.pact.d.ts +1 -0
  43. package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.pact.js +55 -0
  44. package/dist/src/infrastructure/tracking/tracking.d.ts +2 -2
  45. package/dist/src/infrastructure/tracking/useTrackCheckout.d.ts +10 -17
  46. package/dist/src/infrastructure/tracking/useTrackCheckout.js +27 -12
  47. package/dist/src/infrastructure/ui/Root.d.ts +6 -6
  48. package/dist/src/infrastructure/ui/Root.js +2 -3
  49. package/dist/src/infrastructure/ui/components/atoms/fiveItemsDiscountBanner/FiveItemsDiscountBanner.js +1 -2
  50. package/dist/src/infrastructure/ui/components/atoms/fiveItemsDiscountBanner/FiveItemsDiscountBanner.style.js +2 -3
  51. package/dist/src/infrastructure/ui/components/atoms/price/Price.js +0 -3
  52. package/dist/src/infrastructure/ui/components/layouts/layout/Layout.d.ts +22 -0
  53. package/dist/src/infrastructure/ui/components/layouts/layout/Layout.js +1 -0
  54. package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.d.ts +7 -0
  55. package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.js +5 -0
  56. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.d.ts +7 -0
  57. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.js +6 -0
  58. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.d.ts +4 -0
  59. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.js +20 -0
  60. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.d.ts +4 -0
  61. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.js +43 -0
  62. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.d.ts +12 -0
  63. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.js +14 -0
  64. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.js +3 -7
  65. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.style.d.ts +2 -18
  66. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.style.js +2 -14
  67. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.js +1 -2
  68. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.js +1 -2
  69. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.js +3 -4
  70. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.style.d.ts +1 -0
  71. package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.style.js +1 -0
  72. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +3 -3
  73. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.js +2 -3
  74. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.js +4 -4
  75. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.js +2 -3
  76. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.js +2 -3
  77. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.js +1 -2
  78. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.js +4 -5
  79. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.js +6 -6
  80. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +3 -4
  81. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.style.d.ts +1 -0
  82. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.style.js +1 -0
  83. package/dist/src/infrastructure/ui/components/templates/footer/Footer.d.ts +3 -0
  84. package/dist/src/infrastructure/ui/components/templates/footer/Footer.js +13 -0
  85. package/dist/src/infrastructure/ui/components/templates/header/checkoutHeader/CheckoutHeader.js +2 -2
  86. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.d.ts +7 -0
  87. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.js +21 -0
  88. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.d.ts +8 -0
  89. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.js +12 -0
  90. package/dist/src/infrastructure/ui/components/templates/header/itemDetailHeader/ItemDetailHeader.js +2 -2
  91. package/dist/src/infrastructure/ui/components/templates/header/itemHeader/ItemHeader.js +4 -4
  92. package/dist/src/infrastructure/ui/hooks/useCheckoutFlow.d.ts +26 -0
  93. package/dist/src/infrastructure/ui/hooks/useCheckoutFlow.js +135 -0
  94. package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.d.ts +12 -0
  95. package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.js +64 -0
  96. package/dist/src/infrastructure/ui/hooks/usePaymentInstrumentEvents.d.ts +3 -2
  97. package/dist/src/infrastructure/ui/hooks/usePaymentInstrumentEvents.js +17 -26
  98. package/dist/src/infrastructure/ui/hooks/useStaticInfo.d.ts +2 -0
  99. package/dist/src/infrastructure/ui/hooks/useStaticInfo.js +2 -2
  100. package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.d.ts +1 -1
  101. package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.js +22 -55
  102. package/dist/src/infrastructure/ui/i18n/fetchTranslations.d.ts +10 -0
  103. package/dist/src/infrastructure/ui/i18n/fetchTranslations.js +17 -0
  104. package/dist/src/infrastructure/ui/i18n/i18n.d.ts +2 -2
  105. package/dist/src/infrastructure/ui/i18n/i18n.js +2 -2
  106. package/dist/src/infrastructure/ui/i18n/translationEndpoint.d.ts +20 -0
  107. package/dist/src/infrastructure/ui/i18n/translationEndpoint.js +27 -0
  108. package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.d.ts +10 -0
  109. package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +27 -0
  110. package/dist/src/infrastructure/ui/routing/CheckoutMiddleware.js +3 -14
  111. package/dist/src/infrastructure/ui/routing/Routing.d.ts +5 -5
  112. package/dist/src/infrastructure/ui/routing/Routing.js +8 -18
  113. package/dist/src/infrastructure/ui/routing/routes.d.ts +0 -1
  114. package/dist/src/infrastructure/ui/routing/routes.js +0 -1
  115. package/dist/src/infrastructure/ui/test/render.js +3 -7
  116. package/dist/src/infrastructure/ui/views/App.js +5 -7
  117. package/dist/src/infrastructure/ui/views/App.style.d.ts +6 -0
  118. package/dist/src/infrastructure/ui/views/App.style.js +8 -0
  119. package/dist/src/infrastructure/ui/views/checkout/Checkout.d.ts +7 -2
  120. package/dist/src/infrastructure/ui/views/checkout/Checkout.js +24 -15
  121. package/dist/src/infrastructure/ui/views/checkout/Checkout.style.d.ts +3 -0
  122. package/dist/src/infrastructure/ui/views/checkout/Checkout.style.js +3 -0
  123. package/dist/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +16 -16
  124. package/dist/src/infrastructure/ui/views/checkout/components/deliveryBanner/DeliveryBanner.js +2 -2
  125. package/dist/src/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.js +7 -7
  126. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.js +2 -2
  127. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.d.ts +7 -0
  128. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.js +11 -0
  129. package/dist/src/infrastructure/ui/views/item/Item.js +1 -3
  130. package/dist/src/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.js +3 -3
  131. package/dist/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.js +5 -11
  132. package/dist/src/infrastructure/ui/views/item/components/itemActions/ItemActions.js +4 -4
  133. package/dist/src/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.js +3 -3
  134. package/dist/src/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.style.d.ts +0 -1
  135. package/dist/src/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.style.js +1 -2
  136. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.js +2 -2
  137. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +12 -0
  138. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +64 -0
  139. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +12 -0
  140. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.js +16 -0
  141. package/dist/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/SizeWithoutStockModal.js +4 -4
  142. package/dist/src/infrastructure/ui/views/return/Return.style.d.ts +40 -0
  143. package/dist/src/infrastructure/ui/views/return/Return.style.js +44 -0
  144. package/dist/src/infrastructure/ui/views/return/components/price/Price.js +0 -3
  145. package/dist/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.js +3 -3
  146. package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.js +6 -6
  147. package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +0 -1
  148. package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.style.js +1 -2
  149. package/dist/src/infrastructure/ui/views/shared/components/productVariant/ProductVariant.js +4 -4
  150. package/dist/src/infrastructure/ui/views/summary/Summary.js +5 -6
  151. package/dist/src/infrastructure/ui/views/summary/components/collapsiblePricing/CollapsiblePricing.js +2 -3
  152. package/dist/src/infrastructure/ui/views/summary/components/pricing/Pricing.js +6 -8
  153. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.d.ts +14 -0
  154. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.js +28 -0
  155. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.d.ts +7 -0
  156. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.js +11 -0
  157. package/dist/src/infrastructure/ui/views/summaryTabs/SummaryTabs.js +1 -3
  158. package/dist/src/infrastructure/ui/views/summaryTabs/components/checkoutItemsTabs/CheckoutItemsTabs.js +5 -5
  159. package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.d.ts +26 -0
  160. package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.js +21 -0
  161. package/dist/src/projection/customer/customer.d.ts +2 -0
  162. package/dist/src/projection/order/order.d.ts +1 -1
  163. package/dist/src/projection/shared/country.d.ts +14 -0
  164. package/dist/src/projection/shared/country.js +15 -0
  165. package/dist/src/projection/shared/customer.d.ts +9 -0
  166. package/dist/src/projection/shared/customer.js +1 -0
  167. package/dist/src/projection/shared/locale.d.ts +12 -0
  168. package/dist/src/projection/shared/locale.js +13 -0
  169. package/dist/src/projection/shared/order.d.ts +6 -0
  170. package/dist/src/projection/shared/order.js +1 -0
  171. package/dist/src/projection/shared/price.d.ts +11 -0
  172. package/dist/src/projection/shared/price.js +1 -0
  173. package/dist/src/projection/shared/size.d.ts +21 -0
  174. package/dist/src/projection/shared/size.js +4 -0
  175. package/dist/src/projection/shared/subscription.d.ts +2 -0
  176. package/dist/src/projection/shared/subscription.js +1 -0
  177. package/dist/src/projection/subscription/subscription.d.ts +1 -1
  178. package/dist/src/shared/ui/components/atoms/aspectRatioView/AspectRatioView.d.ts +15 -0
  179. package/dist/src/shared/ui/components/atoms/aspectRatioView/AspectRatioView.js +16 -0
  180. package/dist/src/shared/ui/components/atoms/error/Error.d.ts +11 -0
  181. package/dist/src/shared/ui/components/atoms/error/Error.js +6 -0
  182. package/dist/src/shared/ui/components/atoms/field/Field.d.ts +14 -0
  183. package/dist/src/shared/ui/components/atoms/field/Field.js +29 -0
  184. package/dist/src/shared/ui/components/atoms/field/Field.style.d.ts +16 -0
  185. package/dist/src/shared/ui/components/atoms/field/Field.style.js +19 -0
  186. package/dist/src/shared/ui/components/molecules/inputField/InputField.d.ts +24 -0
  187. package/dist/src/shared/ui/components/molecules/inputField/InputField.js +28 -0
  188. package/dist/src/shared/ui/components/molecules/inputField/InputField.style.d.ts +29 -0
  189. package/dist/src/shared/ui/components/molecules/inputField/InputField.style.js +37 -0
  190. package/dist/src/version.d.ts +1 -1
  191. package/dist/src/version.js +1 -1
  192. package/fake-dependencies/@lookiero/payments-front/index.tsx +32 -9
  193. package/index.ts +11 -5
  194. package/jest.config.js +2 -2
  195. package/package.json +9 -9
  196. package/src/Expo.tsx +0 -3
  197. package/src/ExpoRoot.tsx +44 -38
  198. package/src/infrastructure/domain/checkoutBooking/react/useBlockCheckoutBooking.ts +4 -1
  199. package/src/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.ts +3 -2
  200. package/src/infrastructure/tracking/tracking.ts +2 -2
  201. package/src/infrastructure/tracking/useTrackCheckout.ts +66 -56
  202. package/src/infrastructure/ui/Root.tsx +9 -9
  203. package/src/infrastructure/ui/components/atoms/fiveItemsDiscountBanner/FiveItemsDiscountBanner.style.ts +2 -3
  204. package/src/infrastructure/ui/components/atoms/fiveItemsDiscountBanner/FiveItemsDiscountBanner.tsx +2 -3
  205. package/src/infrastructure/ui/components/atoms/fiveItemsDiscountBanner/__snapshots__/FiveItemsDiscountBanner.test.tsx.snap +1 -1
  206. package/src/infrastructure/ui/components/atoms/price/Price.tsx +0 -3
  207. package/src/infrastructure/ui/components/atoms/price/__snapshots__/Price.test.tsx.snap +3 -3
  208. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.style.ts +4 -25
  209. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.tsx +7 -13
  210. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostDefaultCheckoutQuestionItem/HostDefaultCheckoutQuestionItem.tsx +1 -2
  211. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/hostSelectCheckoutQuestionItem/HostSelectCheckoutQuestionItem.tsx +1 -2
  212. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.style.ts +1 -0
  213. package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.tsx +2 -4
  214. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.tsx +3 -3
  215. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostRadioGroupReturnQuestionItem/HostRadioGroupReturnQuestionItem.tsx +2 -3
  216. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.tsx +5 -5
  217. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.tsx +2 -3
  218. package/src/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.tsx +2 -3
  219. package/src/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.tsx +1 -2
  220. package/src/infrastructure/ui/components/organisms/returnQuestions/components/radioReturnQuestionItem/RadioReturnQuestionItem.tsx +5 -6
  221. package/src/infrastructure/ui/components/organisms/returnQuestions/components/returnQuestionFeedbackItem/ReturnQuestionFeedbackItem.tsx +7 -7
  222. package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.style.ts +1 -0
  223. package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.tsx +2 -4
  224. package/src/infrastructure/ui/components/templates/footer/Footer.test.tsx +15 -0
  225. package/src/infrastructure/ui/components/templates/footer/Footer.tsx +19 -0
  226. package/src/infrastructure/ui/components/templates/footer/__snapshots__/Footer.test.tsx.snap +1127 -0
  227. package/src/infrastructure/ui/components/templates/header/checkoutHeader/CheckoutHeader.tsx +2 -2
  228. package/src/infrastructure/ui/components/templates/header/checkoutHeader/__snapshots__/CheckoutHeader.test.tsx.snap +1 -1
  229. package/src/infrastructure/ui/components/templates/header/itemDetailHeader/ItemDetailHeader.tsx +2 -2
  230. package/src/infrastructure/ui/components/templates/header/itemDetailHeader/__snapshots__/ItemDetailHeader.test.tsx.snap +1 -1
  231. package/src/infrastructure/ui/components/templates/header/itemHeader/ItemHeader.tsx +5 -4
  232. package/src/infrastructure/ui/components/templates/header/itemHeader/__snapshots__/ItemHeader.test.tsx.snap +1 -1
  233. package/src/infrastructure/ui/hooks/{useSubmitCheckout.test.ts → useCheckoutFlow.test.ts} +1 -1
  234. package/src/infrastructure/ui/hooks/useCheckoutFlow.tsx +212 -0
  235. package/src/infrastructure/ui/hooks/usePaymentInstrumentEvents.ts +18 -60
  236. package/src/infrastructure/ui/hooks/useStaticInfo.tsx +4 -2
  237. package/src/infrastructure/ui/i18n/i18n.ts +2 -3
  238. package/src/infrastructure/ui/routing/CheckoutMiddleware.test.tsx +3 -3
  239. package/src/infrastructure/ui/routing/CheckoutMiddleware.tsx +3 -17
  240. package/src/infrastructure/ui/routing/Routing.tsx +25 -39
  241. package/src/infrastructure/ui/routing/routes.ts +0 -1
  242. package/src/infrastructure/ui/test/render.tsx +4 -10
  243. package/src/infrastructure/ui/views/App.tsx +5 -14
  244. package/src/infrastructure/ui/views/checkout/Checkout.style.ts +3 -0
  245. package/src/infrastructure/ui/views/checkout/Checkout.tsx +55 -18
  246. package/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.test.tsx +116 -121
  247. package/src/infrastructure/ui/views/checkout/components/deliveryBanner/DeliveryBanner.tsx +2 -2
  248. package/src/infrastructure/ui/views/checkout/components/deliveryBanner/__snapshots__/DeliveryBanner.test.tsx.snap +1 -1
  249. package/src/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.tsx +8 -8
  250. package/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.tsx +2 -2
  251. package/src/infrastructure/ui/views/item/Item.tsx +1 -2
  252. package/src/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.tsx +3 -3
  253. package/src/infrastructure/ui/views/item/components/banner/__snapshots__/CustomerDecissionBanner.test.tsx.snap +3 -3
  254. package/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.tsx +5 -11
  255. package/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/__snapshots__/GetOutOfCheckoutModal.test.tsx.snap +88 -160
  256. package/src/infrastructure/ui/views/item/components/itemActions/ItemActions.tsx +4 -4
  257. package/src/infrastructure/ui/views/item/components/itemActions/__snapshots__/ItemActions.test.tsx.snap +128 -244
  258. package/src/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.style.ts +1 -2
  259. package/src/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.tsx +3 -3
  260. package/src/infrastructure/ui/views/item/components/productVariantDescription/__snapshots__/ProductVariantDescription.test.tsx.snap +8 -10
  261. package/src/infrastructure/ui/views/item/components/productVariantSlider/__snapshots__/ProductVariantSlider.test.tsx.snap +30 -30
  262. package/src/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.tsx +2 -2
  263. package/src/infrastructure/ui/views/item/components/selectModal/__snapshots__/SelecModal.test.tsx.snap +1 -1
  264. package/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/SizeWithoutStockModal.tsx +4 -4
  265. package/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/__snapshots__/SizeWithoutStockModal.test.tsx.snap +41 -75
  266. package/src/infrastructure/ui/views/item/views/productVariant/__snapshots__/ProductVariant.test.tsx.snap +102 -105
  267. package/src/infrastructure/ui/views/return/components/price/Price.tsx +0 -3
  268. package/src/infrastructure/ui/views/return/components/price/__snapshots__/Price.test.tsx.snap +3 -3
  269. package/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.tsx +3 -3
  270. package/src/infrastructure/ui/views/return/components/productVariantPreview/__snapshots__/ProductVariantPreview.test.tsx.snap +1 -1
  271. package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.style.ts +1 -2
  272. package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +6 -6
  273. package/src/infrastructure/ui/views/shared/components/productVariant/ProductVariant.tsx +4 -4
  274. package/src/infrastructure/ui/views/shared/components/productVariant/__snapshots__/ProductVariant.test.tsx.snap +30 -30
  275. package/src/infrastructure/ui/views/summary/Summary.tsx +5 -6
  276. package/src/infrastructure/ui/views/summary/components/collapsiblePricing/CollapsiblePricing.tsx +2 -3
  277. package/src/infrastructure/ui/views/summary/components/collapsiblePricing/__snapshots__/CollapsiblePricing.test.tsx.snap +82 -154
  278. package/src/infrastructure/ui/views/summary/components/pricing/Pricing.tsx +6 -8
  279. package/src/infrastructure/ui/views/summaryTabs/SummaryTabs.tsx +1 -2
  280. package/src/infrastructure/ui/views/summaryTabs/components/checkoutItemsTabs/CheckoutItemsTabs.tsx +5 -5
  281. package/src/infrastructure/ui/views/summaryTabs/components/checkoutItemsTabs/__snapshots__/CheckoutItemsTabs.test.tsx.snap +62 -62
  282. package/src/projection/customer/customer.ts +2 -0
  283. package/src/projection/order/order.ts +1 -1
  284. package/src/projection/subscription/subscription.ts +1 -1
  285. package/src/infrastructure/ui/hooks/useSubmitCheckout.ts +0 -169
  286. package/src/infrastructure/ui/routing/useBasePath.test.tsx +0 -19
  287. package/src/infrastructure/ui/routing/useBasePath.tsx +0 -24
  288. package/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.tsx +0 -125
@@ -0,0 +1,51 @@
1
+ import { MatchersV3, PactV3 } from "@pact-foundation/pact";
2
+ import { fetchHttpGet } from "@lookiero/sty-psp-http";
3
+ import {
4
+ AUTH_TOKEN,
5
+ DEFAULT_PACT_OPTIONS,
6
+ DEFAULT_REQUEST_HEADERS,
7
+ DEFAULT_RESPONSE_HEADERS,
8
+ fromMockServerUrlToApiUrl,
9
+ } from "../../../../pact.config";
10
+ import { httpIsSizeChangeEnabledByCheckoutIdView } from "./httpIsSizeChangeEnabledByCheckoutIdView";
11
+
12
+ const provider = new PactV3({
13
+ ...DEFAULT_PACT_OPTIONS,
14
+ consumer: "STY-BOX_CHECKOUT-FRONT",
15
+ provider: "STY-BOX_CHECKOUT-BACK_ViewIsSizeChangeEnabledByCheckoutId",
16
+ });
17
+ const checkoutId = "fab61a4d-c94d-4e33-b098-1945294a5f75";
18
+ const isSizeChangeEnabledResponse = true;
19
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
20
+ // @ts-ignore
21
+ const EXPECTED_BODY = MatchersV3.like(isSizeChangeEnabledResponse);
22
+ describe("STY-BOX_CHECKOUT-BACK_ViewIsSizeChangeEnabledByCheckoutId API", () => {
23
+ it("returns is size-change enabled for the given checkout id", () => {
24
+ provider
25
+ .given("is size-change enabled for the given checkout id")
26
+ .uponReceiving("is size-change enabled")
27
+ .withRequest({
28
+ method: "GET",
29
+ path: `/api/is-size-change-enabled-by-checkout-id/${checkoutId}`,
30
+ headers: DEFAULT_REQUEST_HEADERS,
31
+ })
32
+ .willRespondWith({
33
+ status: 200,
34
+ headers: DEFAULT_RESPONSE_HEADERS,
35
+ body: EXPECTED_BODY,
36
+ });
37
+ return provider.executeTest(async (mockserver) => {
38
+ const httpGet = fetchHttpGet({
39
+ apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
40
+ getAuthToken: () => Promise.resolve(AUTH_TOKEN),
41
+ device: "web",
42
+ version: "1.0.0",
43
+ });
44
+ const response = await httpIsSizeChangeEnabledByCheckoutIdView({ httpGet })({
45
+ checkoutId,
46
+ signal: undefined,
47
+ });
48
+ expect(response).toStrictEqual(isSizeChangeEnabledResponse);
49
+ });
50
+ });
51
+ });
@@ -0,0 +1,13 @@
1
+ import { UseQueryFunctionResult } from "@lookiero/messaging-react";
2
+ import { IsCheckoutAccessibleByCustomerIdProjection } from "../../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
3
+
4
+ interface UseViewIsCheckoutAccessibleByCustomerIdFunctionArgs {
5
+ readonly customerId: string | undefined;
6
+ }
7
+ interface UseViewIsCheckoutAccessibleByCustomerIdFunction {
8
+ (
9
+ args: UseViewIsCheckoutAccessibleByCustomerIdFunctionArgs,
10
+ ): UseQueryFunctionResult<IsCheckoutAccessibleByCustomerIdProjection>;
11
+ }
12
+ declare const useViewIsCheckoutAccessibleByCustomerId: UseViewIsCheckoutAccessibleByCustomerIdFunction;
13
+ export { useViewIsCheckoutAccessibleByCustomerId };
@@ -0,0 +1,19 @@
1
+ import { useQuery } from "@lookiero/messaging-react";
2
+ import { isCheckoutFeedbackGiven } from "../../../../domain/checkoutFeedback/model/checkoutFeedbackGiven";
3
+ import { viewIsCheckoutAccessibleByCustomerId } from "../../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
4
+ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
5
+
6
+ const useViewIsCheckoutAccessibleByCustomerId = ({ customerId }) =>
7
+ useQuery({
8
+ query: viewIsCheckoutAccessibleByCustomerId({ customerId }),
9
+ contextId: MESSAGING_CONTEXT_ID,
10
+ invalidation: isCheckoutFeedbackGiven,
11
+ options: {
12
+ refetchOnMount: "always",
13
+ staleTime: Infinity,
14
+ retry: false,
15
+ refetchOnWindowFocus: false,
16
+ cacheTime: 0,
17
+ },
18
+ });
19
+ export { useViewIsCheckoutAccessibleByCustomerId };
@@ -0,0 +1,56 @@
1
+ import { MatchersV3, PactV3 } from "@pact-foundation/pact";
2
+ import { fetchHttpPost } from "@lookiero/sty-psp-http";
3
+ import {
4
+ AUTH_TOKEN,
5
+ DEFAULT_PACT_OPTIONS,
6
+ DEFAULT_REQUEST_HEADERS,
7
+ DEFAULT_RESPONSE_HEADERS,
8
+ fromMockServerUrlToApiUrl,
9
+ } from "../../../../pact.config";
10
+ import { checkoutBooking as checkoutBookingMock } from "./checkoutBooking.mock";
11
+ import { httpCheckoutBookingByIdView } from "./httpCheckoutBookingByIdView";
12
+
13
+ const provider = new PactV3({
14
+ ...DEFAULT_PACT_OPTIONS,
15
+ consumer: "STY-BOX_CHECKOUT-FRONT",
16
+ provider: "STY-BOX_CHECKOUT-BACK_ViewCheckoutBookingById",
17
+ });
18
+ const checkoutBookingProjection = checkoutBookingMock;
19
+ const checkoutBookingId = checkoutBookingProjection.id;
20
+ const checkoutBookingResponse = {
21
+ result: checkoutBookingProjection,
22
+ };
23
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
24
+ // @ts-ignore
25
+ const EXPECTED_BODY = MatchersV3.like(checkoutBookingResponse);
26
+ describe("STY-BOX_CHECKOUT-BACK_ViewCheckoutBookingById API", () => {
27
+ it("returns a valid checkout booking for the given id", () => {
28
+ provider
29
+ .given("a valid checkout booking for the given id")
30
+ .uponReceiving("checkout booking projection")
31
+ .withRequest({
32
+ method: "POST",
33
+ path: "/api/view-checkout-booking-by-id",
34
+ headers: DEFAULT_REQUEST_HEADERS,
35
+ body: { checkoutBookingId },
36
+ })
37
+ .willRespondWith({
38
+ status: 200,
39
+ headers: DEFAULT_RESPONSE_HEADERS,
40
+ body: EXPECTED_BODY,
41
+ });
42
+ return provider.executeTest(async (mockserver) => {
43
+ const httpPost = fetchHttpPost({
44
+ apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
45
+ getAuthToken: () => Promise.resolve(AUTH_TOKEN),
46
+ device: "web",
47
+ version: "1.0.0",
48
+ });
49
+ const response = await httpCheckoutBookingByIdView({ httpPost })({
50
+ checkoutBookingId,
51
+ signal: undefined,
52
+ });
53
+ expect(response).toStrictEqual(checkoutBookingResponse.result);
54
+ });
55
+ });
56
+ });
@@ -0,0 +1,57 @@
1
+ import { MatchersV3, PactV3 } from "@pact-foundation/pact";
2
+ import { fetchHttpPost } from "@lookiero/sty-psp-http";
3
+ import {
4
+ AUTH_TOKEN,
5
+ DEFAULT_PACT_OPTIONS,
6
+ DEFAULT_REQUEST_HEADERS,
7
+ DEFAULT_RESPONSE_HEADERS,
8
+ fromMockServerUrlToApiUrl,
9
+ } from "../../../../pact.config";
10
+ import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
11
+ import { checkoutItem } from "./checkoutItem.mock";
12
+ import { httpCheckoutItemByIdView } from "./httpCheckoutItemByIdView";
13
+
14
+ const provider = new PactV3({
15
+ ...DEFAULT_PACT_OPTIONS,
16
+ consumer: "STY-BOX_CHECKOUT-FRONT",
17
+ provider: "STY-BOX_CHECKOUT-BACK_ViewCheckoutItemById",
18
+ });
19
+ const checkoutItemProjection = checkoutItem({ status: CheckoutItemStatus.INITIAL });
20
+ const checkoutItemId = checkoutItemProjection.id;
21
+ const checkoutItemResponse = {
22
+ result: checkoutItemProjection,
23
+ };
24
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
25
+ // @ts-ignore
26
+ const EXPECTED_BODY = MatchersV3.like(checkoutItemResponse);
27
+ describe("STY-BOX_CHECKOUT-BACK_ViewCheckoutItemById API", () => {
28
+ it("returns a valid checkout item for the given id", () => {
29
+ provider
30
+ .given("a valid checkout item for the given id")
31
+ .uponReceiving("checkout item projection")
32
+ .withRequest({
33
+ method: "POST",
34
+ path: "/api/view-checkout-item-by-id",
35
+ headers: DEFAULT_REQUEST_HEADERS,
36
+ body: { checkoutItemId },
37
+ })
38
+ .willRespondWith({
39
+ status: 200,
40
+ headers: DEFAULT_RESPONSE_HEADERS,
41
+ body: EXPECTED_BODY,
42
+ });
43
+ return provider.executeTest(async (mockserver) => {
44
+ const httpPost = fetchHttpPost({
45
+ apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
46
+ getAuthToken: () => Promise.resolve(AUTH_TOKEN),
47
+ device: "web",
48
+ version: "1.0.0",
49
+ });
50
+ const response = await httpCheckoutItemByIdView({ httpPost })({
51
+ checkoutItemId,
52
+ signal: undefined,
53
+ });
54
+ expect(response).toStrictEqual(checkoutItemResponse.result);
55
+ });
56
+ });
57
+ });
@@ -0,0 +1,55 @@
1
+ import { MatchersV3, PactV3 } from "@pact-foundation/pact";
2
+ import { fetchHttpPost } from "@lookiero/sty-psp-http";
3
+ import {
4
+ AUTH_TOKEN,
5
+ DEFAULT_PACT_OPTIONS,
6
+ DEFAULT_REQUEST_HEADERS,
7
+ DEFAULT_RESPONSE_HEADERS,
8
+ fromMockServerUrlToApiUrl,
9
+ } from "../../../../pact.config";
10
+ import { checkoutQuestions } from "./checkoutQuestions.mock";
11
+ import { httpCheckoutQuestionsByCheckoutIdView } from "./httpCheckoutQuestionsByCheckoutIdView";
12
+
13
+ const provider = new PactV3({
14
+ ...DEFAULT_PACT_OPTIONS,
15
+ consumer: "STY-BOX_CHECKOUT-FRONT",
16
+ provider: "STY-BOX_CHECKOUT-BACK_ListCheckoutQuestionsByCheckoutId",
17
+ });
18
+ const checkoutId = "52440ae5-7a4c-498b-8b35-08ecfde15776";
19
+ const checkoutQuestionsResponse = {
20
+ result: checkoutQuestions,
21
+ };
22
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
23
+ // @ts-ignore
24
+ const EXPECTED_BODY = MatchersV3.like(checkoutQuestionsResponse);
25
+ describe("STY-BOX_CHECKOUT-BACK_ListCheckoutQuestionsByCheckoutId API", () => {
26
+ it("returns a valid checkout questions for the given checkout id", () => {
27
+ provider
28
+ .given("a valid checkout questions for the given checkout id")
29
+ .uponReceiving("checkout questions projection")
30
+ .withRequest({
31
+ method: "POST",
32
+ path: "/api/list-checkout-questions-by-checkout-id",
33
+ headers: DEFAULT_REQUEST_HEADERS,
34
+ body: { checkoutId },
35
+ })
36
+ .willRespondWith({
37
+ status: 200,
38
+ headers: DEFAULT_RESPONSE_HEADERS,
39
+ body: EXPECTED_BODY,
40
+ });
41
+ return provider.executeTest(async (mockserver) => {
42
+ const httpPost = fetchHttpPost({
43
+ apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
44
+ getAuthToken: () => Promise.resolve(AUTH_TOKEN),
45
+ device: "web",
46
+ version: "1.0.0",
47
+ });
48
+ const response = await httpCheckoutQuestionsByCheckoutIdView({ httpPost })({
49
+ checkoutId,
50
+ signal: undefined,
51
+ });
52
+ expect(response).toStrictEqual(checkoutQuestionsResponse.result);
53
+ });
54
+ });
55
+ });
@@ -0,0 +1,120 @@
1
+ import { MatchersV3, PactV3 } from "@pact-foundation/pact";
2
+ import { fetchHttpPost } from "@lookiero/sty-psp-http";
3
+ import {
4
+ AUTH_TOKEN,
5
+ DEFAULT_PACT_OPTIONS,
6
+ DEFAULT_REQUEST_HEADERS,
7
+ DEFAULT_RESPONSE_HEADERS,
8
+ fromMockServerUrlToApiUrl,
9
+ } from "../../../../pact.config";
10
+ import { httpPaymentFlowPayloadByCheckoutIdView } from "./httpPaymentFlowPayloadByCheckoutIdView";
11
+ import {
12
+ paymentFlowPayloadForKeptItems,
13
+ paymentFlowPayloadForReturnedItems,
14
+ paymentFlowPayloadForReplacedItems,
15
+ } from "./paymentFlowPayload.mock";
16
+
17
+ const provider = new PactV3({
18
+ ...DEFAULT_PACT_OPTIONS,
19
+ consumer: "STY-BOX_CHECKOUT-FRONT",
20
+ provider: "STY-BOX_CHECKOUT-BACK_ViewPaymentFlowPayloadByCheckoutId",
21
+ });
22
+ const checkoutId = "e2490de5-5bd3-43d5-b7c4-526e33f71304";
23
+ const paymentFlowPayloadForKeptItemsResponse = {
24
+ result: paymentFlowPayloadForKeptItems,
25
+ };
26
+ const paymentFlowPayloadForReturnedItemsResponse = {
27
+ result: paymentFlowPayloadForReturnedItems,
28
+ };
29
+ const paymentFlowPayloadForReplacedItemsResponse = {
30
+ result: paymentFlowPayloadForReplacedItems,
31
+ };
32
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
33
+ // @ts-ignore
34
+ const EXPECTED_BODY_FOR_KEPT_ITEMS = MatchersV3.like(paymentFlowPayloadForKeptItemsResponse);
35
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
36
+ // @ts-ignore
37
+ const EXPECTED_BODY_FOR_RETURNED_ITEMS = MatchersV3.like(paymentFlowPayloadForReturnedItemsResponse);
38
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
39
+ // @ts-ignore
40
+ const EXPECTED_BODY_FOR_REPLACED_ITEMS = MatchersV3.like(paymentFlowPayloadForReplacedItemsResponse);
41
+ describe("STY-BOX_CHECKOUT-BACK_ViewPaymentFlowPayloadByCheckoutId API", () => {
42
+ it("returns a valid payment-flow payload for the given checkout id [KEPT items] ", () => {
43
+ provider
44
+ .given("a valid payment-flow payload for the given checkout id [KEPT items] ")
45
+ .uponReceiving("payment-flow payload projection")
46
+ .withRequest({
47
+ method: "POST",
48
+ path: "/api/view-payment-flow-payload-by-checkout-id",
49
+ headers: DEFAULT_REQUEST_HEADERS,
50
+ body: { checkoutId },
51
+ })
52
+ .willRespondWith({
53
+ status: 200,
54
+ headers: DEFAULT_RESPONSE_HEADERS,
55
+ body: EXPECTED_BODY_FOR_KEPT_ITEMS,
56
+ });
57
+ return provider.executeTest(async (mockserver) => {
58
+ const httpPost = fetchHttpPost({
59
+ apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
60
+ getAuthToken: () => Promise.resolve(AUTH_TOKEN),
61
+ device: "web",
62
+ version: "1.0.0",
63
+ });
64
+ const response = await httpPaymentFlowPayloadByCheckoutIdView({ httpPost })({ checkoutId, signal: undefined });
65
+ expect(response).toStrictEqual(paymentFlowPayloadForKeptItemsResponse.result);
66
+ });
67
+ });
68
+ it("returns a valid payment-flow payload for the given checkout id [RETURNED items] ", () => {
69
+ provider
70
+ .given("a valid payment-flow payload for the given checkout id [RETURNED items] ")
71
+ .uponReceiving("payment-flow payload projection")
72
+ .withRequest({
73
+ method: "POST",
74
+ path: "/api/view-payment-flow-payload-by-checkout-id",
75
+ headers: DEFAULT_REQUEST_HEADERS,
76
+ body: { checkoutId },
77
+ })
78
+ .willRespondWith({
79
+ status: 200,
80
+ headers: DEFAULT_RESPONSE_HEADERS,
81
+ body: EXPECTED_BODY_FOR_RETURNED_ITEMS,
82
+ });
83
+ return provider.executeTest(async (mockserver) => {
84
+ const httpPost = fetchHttpPost({
85
+ apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
86
+ getAuthToken: () => Promise.resolve(AUTH_TOKEN),
87
+ device: "web",
88
+ version: "1.0.0",
89
+ });
90
+ const response = await httpPaymentFlowPayloadByCheckoutIdView({ httpPost })({ checkoutId, signal: undefined });
91
+ expect(response).toStrictEqual(paymentFlowPayloadForReturnedItemsResponse.result);
92
+ });
93
+ });
94
+ it("returns a valid payment-flow payload for the given checkout id [REPLACED items] ", () => {
95
+ provider
96
+ .given("a valid payment-flow payload for the given checkout id [REPLACED items] ")
97
+ .uponReceiving("payment-flow payload projection")
98
+ .withRequest({
99
+ method: "POST",
100
+ path: "/api/view-payment-flow-payload-by-checkout-id",
101
+ headers: DEFAULT_REQUEST_HEADERS,
102
+ body: { checkoutId },
103
+ })
104
+ .willRespondWith({
105
+ status: 200,
106
+ headers: DEFAULT_RESPONSE_HEADERS,
107
+ body: EXPECTED_BODY_FOR_REPLACED_ITEMS,
108
+ });
109
+ return provider.executeTest(async (mockserver) => {
110
+ const httpPost = fetchHttpPost({
111
+ apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
112
+ getAuthToken: () => Promise.resolve(AUTH_TOKEN),
113
+ device: "web",
114
+ version: "1.0.0",
115
+ });
116
+ const response = await httpPaymentFlowPayloadByCheckoutIdView({ httpPost })({ checkoutId, signal: undefined });
117
+ expect(response).toStrictEqual(paymentFlowPayloadForReplacedItemsResponse.result);
118
+ });
119
+ });
120
+ });
@@ -0,0 +1,55 @@
1
+ import { MatchersV3, PactV3 } from "@pact-foundation/pact";
2
+ import { fetchHttpPost } from "@lookiero/sty-psp-http";
3
+ import {
4
+ AUTH_TOKEN,
5
+ DEFAULT_PACT_OPTIONS,
6
+ DEFAULT_REQUEST_HEADERS,
7
+ DEFAULT_RESPONSE_HEADERS,
8
+ fromMockServerUrlToApiUrl,
9
+ } from "../../../../pact.config";
10
+ import { httpPricingByCheckoutIdView } from "./httpPricingByCheckoutIdView";
11
+ import { pricing } from "./pricing.mock";
12
+
13
+ const provider = new PactV3({
14
+ ...DEFAULT_PACT_OPTIONS,
15
+ consumer: "STY-BOX_CHECKOUT-FRONT",
16
+ provider: "STY-BOX_CHECKOUT-BACK_ViewPricingByCheckoutId",
17
+ });
18
+ const checkoutId = "6f720954-8039-4bed-9596-34fc5a02131b";
19
+ const pricingResponse = {
20
+ result: pricing(),
21
+ };
22
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
23
+ // @ts-ignore
24
+ const EXPECTED_BODY = MatchersV3.like(pricingResponse);
25
+ describe("STY-BOX_CHECKOUT-BACK_ViewPricingByCheckoutId API", () => {
26
+ it("returns a valid pricing for the given checkout", () => {
27
+ provider
28
+ .given("a valid pricing for the given checkout")
29
+ .uponReceiving("pricing projection")
30
+ .withRequest({
31
+ method: "POST",
32
+ path: "/api/view-pricing-by-checkout-id",
33
+ headers: DEFAULT_REQUEST_HEADERS,
34
+ body: { checkoutId },
35
+ })
36
+ .willRespondWith({
37
+ status: 200,
38
+ headers: DEFAULT_RESPONSE_HEADERS,
39
+ body: EXPECTED_BODY,
40
+ });
41
+ return provider.executeTest(async (mockserver) => {
42
+ const httpPost = fetchHttpPost({
43
+ apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
44
+ getAuthToken: () => Promise.resolve(AUTH_TOKEN),
45
+ device: "web",
46
+ version: "1.0.0",
47
+ });
48
+ const response = await httpPricingByCheckoutIdView({ httpPost })({
49
+ checkoutId,
50
+ signal: undefined,
51
+ });
52
+ expect(response).toStrictEqual(pricingResponse.result);
53
+ });
54
+ });
55
+ });
@@ -4,7 +4,7 @@ interface QueryOptions {
4
4
  readonly refetchOnMount?: boolean | "always";
5
5
  }
6
6
  interface UseViewPricingByCheckoutIdFunctionArgs {
7
- readonly checkoutId: string;
7
+ readonly checkoutId: string | undefined;
8
8
  readonly queryOptions?: QueryOptions;
9
9
  }
10
10
  interface UseViewPricingByCheckoutIdFunction {
@@ -13,7 +13,7 @@ const DEFAULT_QUERY_OPTIONS = {
13
13
  refetchOnMount: "always",
14
14
  };
15
15
  const useViewPricingByCheckoutId = ({ checkoutId, queryOptions = DEFAULT_QUERY_OPTIONS, }) => useQuery({
16
- query: viewPricingByCheckoutId({ checkoutId }),
16
+ query: viewPricingByCheckoutId({ checkoutId: checkoutId }),
17
17
  contextId: MESSAGING_CONTEXT_ID,
18
18
  invalidation: shouldInvalidate,
19
19
  options: {
@@ -21,6 +21,7 @@ const useViewPricingByCheckoutId = ({ checkoutId, queryOptions = DEFAULT_QUERY_O
21
21
  staleTime: Infinity,
22
22
  retry: false,
23
23
  refetchOnWindowFocus: false,
24
+ enabled: Boolean(checkoutId),
24
25
  },
25
26
  });
26
27
  export { useViewPricingByCheckoutId };
@@ -0,0 +1,55 @@
1
+ import { MatchersV3, PactV3 } from "@pact-foundation/pact";
2
+ import { fetchHttpPost } from "@lookiero/sty-psp-http";
3
+ import {
4
+ AUTH_TOKEN,
5
+ DEFAULT_PACT_OPTIONS,
6
+ DEFAULT_REQUEST_HEADERS,
7
+ DEFAULT_RESPONSE_HEADERS,
8
+ fromMockServerUrlToApiUrl,
9
+ } from "../../../../pact.config";
10
+ import { httpReturnQuestionsByCheckoutItemIdView } from "./httpReturnQuestionsByCheckoutItemIdView";
11
+ import { returnQuestions } from "./returnQuestions.mock";
12
+
13
+ const provider = new PactV3({
14
+ ...DEFAULT_PACT_OPTIONS,
15
+ consumer: "STY-BOX_CHECKOUT-FRONT",
16
+ provider: "STY-BOX_CHECKOUT-BACK_ListReturnQuestionsByCheckoutItemId",
17
+ });
18
+ const checkoutItemId = "52440ae5-7a4c-498b-8b35-08ecfde15776";
19
+ const returnQuestionsResponse = {
20
+ result: returnQuestions,
21
+ };
22
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
23
+ // @ts-ignore
24
+ const EXPECTED_BODY = MatchersV3.like(returnQuestionsResponse);
25
+ describe("STY-BOX_CHECKOUT-BACK_ListReturnQuestionsByCheckoutItemId API", () => {
26
+ it("returns a valid return questions for the given checkout item id", () => {
27
+ provider
28
+ .given("a valid return questions for the given checkout item id")
29
+ .uponReceiving("return questions projection")
30
+ .withRequest({
31
+ method: "POST",
32
+ path: "/api/list-return-questions-by-checkout-item-id",
33
+ headers: DEFAULT_REQUEST_HEADERS,
34
+ body: { checkoutItemId },
35
+ })
36
+ .willRespondWith({
37
+ status: 200,
38
+ headers: DEFAULT_RESPONSE_HEADERS,
39
+ body: EXPECTED_BODY,
40
+ });
41
+ return provider.executeTest(async (mockserver) => {
42
+ const httpPost = fetchHttpPost({
43
+ apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
44
+ getAuthToken: () => Promise.resolve(AUTH_TOKEN),
45
+ device: "web",
46
+ version: "1.0.0",
47
+ });
48
+ const response = await httpReturnQuestionsByCheckoutItemIdView({ httpPost })({
49
+ checkoutItemId,
50
+ signal: undefined,
51
+ });
52
+ expect(response).toStrictEqual(returnQuestionsResponse.result);
53
+ });
54
+ });
55
+ });
@@ -2,7 +2,7 @@ import { BaseTrackingEvent, TrackingEventCategory } from "@lookiero/sty-psp-trac
2
2
  import { CheckoutItemStatus } from "../../domain/checkoutItem/model/checkoutItem";
3
3
  import { Currency } from "../../domain/checkoutItem/model/currency";
4
4
  import { MediaPerspective } from "../../projection/checkoutItem/checkoutItem";
5
- import { Subscription } from "../../projection/subscription/subscription";
5
+ import { SubscriptionProjection } from "../../projection/subscription/subscription";
6
6
  declare const PROJECT = "checkout";
7
7
  declare enum TrackingPage {
8
8
  ITEM = "item",
@@ -96,7 +96,7 @@ interface CheckoutTrackingEvent extends CheckoutBaseTrackingEvent<TrackingEventN
96
96
  readonly actionField: {
97
97
  readonly items: number;
98
98
  readonly currencyCode: Currency;
99
- readonly subscription: Subscription;
99
+ readonly subscription: SubscriptionProjection;
100
100
  readonly coupon: string | null;
101
101
  readonly orderId: number;
102
102
  readonly value: number;
@@ -1,26 +1,19 @@
1
1
  import { Country } from "@lookiero/sty-psp-locale";
2
2
  import { Segment } from "@lookiero/sty-psp-segment";
3
- import { Currency } from "../../domain/checkoutItem/model/currency";
4
- import { Subscription } from "../../projection/subscription/subscription";
5
- import { TrackingPage } from "./tracking";
6
- interface TrackCheckoutFunctionArgs {
7
- readonly userId: string;
8
- readonly totalReplacedFor: number;
9
- readonly isFirstOrder: boolean;
10
- readonly totalCheckoutItemsKept: number;
11
- readonly currencyCode: Currency;
12
- readonly subscription: Subscription;
13
- readonly coupon: string | null;
14
- readonly orderNumber: number;
15
- readonly pendingToPay: number;
16
- }
3
+ import { CheckoutProjection } from "../../projection/checkout/checkout";
4
+ import { OrderProjection } from "../../projection/order/order";
5
+ import { PricingProjection } from "../../projection/pricing/pricing";
6
+ import { SubscriptionProjection } from "../../projection/subscription/subscription";
17
7
  interface TrackCheckoutFunction {
18
- (args: TrackCheckoutFunctionArgs): void;
8
+ (): void;
19
9
  }
20
10
  interface UseTrackCheckoutFunctionArgs {
21
- readonly page: TrackingPage;
11
+ readonly order: OrderProjection;
12
+ readonly checkout: CheckoutProjection | undefined;
13
+ readonly pricing: PricingProjection | undefined;
14
+ readonly subscription: SubscriptionProjection;
15
+ readonly userId: string;
22
16
  readonly country: Country;
23
- readonly checkoutId: string | undefined;
24
17
  readonly segment: Segment;
25
18
  }
26
19
  interface UseTrackCheckoutFunction {
@@ -1,38 +1,53 @@
1
1
  import { useCallback } from "react";
2
+ import invariant from "tiny-invariant";
2
3
  import { useEmitUserEvent } from "@lookiero/sty-psp-tracking";
3
- import { PROJECT } from "./tracking";
4
+ import { CheckoutItemStatus } from "../../domain/checkoutItem/model/checkoutItem";
5
+ import { PROJECT, TrackingPage } from "./tracking";
4
6
  import { TrackingEventName, TrackingEventCategory } from "./tracking";
5
- const useTrackCheckout = ({ page, country, checkoutId, segment }) => {
7
+ const useTrackCheckout = ({ order, checkout, pricing, subscription, segment, country, userId, }) => {
6
8
  const emitUserEvent = useEmitUserEvent();
7
- const trackCheckout = useCallback(({ coupon, currencyCode, isFirstOrder, orderNumber, pendingToPay, subscription, totalCheckoutItemsKept, totalReplacedFor, userId, }) => {
8
- if (!checkoutId) {
9
- return;
10
- }
9
+ const { coupon, isFirstOrder, orderNumber } = order;
10
+ const trackCheckout = useCallback(() => {
11
+ invariant(checkout, "Checkout must be defined to track checkout");
12
+ const checkoutItemsKept = checkout.items.filter((checkoutItem) => checkoutItem.status === CheckoutItemStatus.KEPT || checkoutItem.status === CheckoutItemStatus.REPLACED);
13
+ const totalReplacedFor = checkoutItemsKept?.filter(({ replacedFor }) => Boolean(replacedFor)).length || 0;
11
14
  const checkoutTrackingEvent = {
12
15
  event: TrackingEventName.CHECKOUT,
13
16
  eventCategory: TrackingEventCategory.ECOMMERCE,
14
- section: `${PROJECT}_${page}`,
17
+ section: `${PROJECT}_${TrackingPage.CHECKOUT}`,
15
18
  store: country,
16
19
  segment,
17
- checkoutId,
20
+ checkoutId: checkout.id,
18
21
  userId,
19
22
  sizeChanges: totalReplacedFor,
20
23
  isFirstOrder,
21
24
  ecommerce: {
22
25
  checkout: {
23
26
  actionField: {
24
- items: totalCheckoutItemsKept,
25
- currencyCode,
27
+ items: checkoutItemsKept.length || 0,
28
+ currencyCode: pricing?.pendingToPay.currency,
26
29
  subscription,
27
30
  coupon,
28
31
  orderId: orderNumber,
29
- value: pendingToPay,
32
+ value: pricing?.pendingToPay.amount / 100,
30
33
  },
31
34
  },
32
35
  },
33
36
  };
34
37
  emitUserEvent(checkoutTrackingEvent);
35
- }, [checkoutId, country, emitUserEvent, page, segment]);
38
+ }, [
39
+ checkout,
40
+ country,
41
+ coupon,
42
+ emitUserEvent,
43
+ isFirstOrder,
44
+ orderNumber,
45
+ pricing?.pendingToPay.amount,
46
+ pricing?.pendingToPay.currency,
47
+ segment,
48
+ subscription,
49
+ userId,
50
+ ]);
36
51
  return trackCheckout;
37
52
  };
38
53
  export { useTrackCheckout };