@evenicanpm/storefront-core 1.0.4 → 1.0.6

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 (343) hide show
  1. package/package.json +8 -10
  2. package/src/api-manager/datasources/d365/d365-address.datasource.ts +2 -2
  3. package/src/api-manager/datasources/d365/d365-cart.datasource.ts +3 -3
  4. package/src/api-manager/datasources/d365/d365-categories.datasource.ts +2 -2
  5. package/src/api-manager/datasources/d365/d365-order.datasource.ts +3 -3
  6. package/src/api-manager/datasources/d365/d365-organization.datasource.ts +2 -2
  7. package/src/api-manager/datasources/d365/d365-product.datasource.ts +5 -5
  8. package/src/api-manager/datasources/d365/d365-session.datasource.ts +2 -2
  9. package/src/api-manager/datasources/d365/d365-user.datasource.ts +2 -2
  10. package/src/api-manager/datasources/d365/d365.datasource.ts +8 -8
  11. package/src/api-manager/datasources/d365/index.ts +2 -2
  12. package/src/api-manager/datasources/e4/address/e4-address.datasource.ts +4 -4
  13. package/src/api-manager/datasources/e4/address/e4-address.remaps.ts +1 -1
  14. package/src/api-manager/datasources/e4/address/e4-address.translator.ts +7 -3
  15. package/src/api-manager/datasources/e4/cart/e4-cart.datasource.ts +7 -7
  16. package/src/api-manager/datasources/e4/cart/e4-cart.remaps.ts +7 -3
  17. package/src/api-manager/datasources/e4/cart/e4-cart.translator.ts +2 -2
  18. package/src/api-manager/datasources/e4/categories/e4-categories.datasource.ts +2 -2
  19. package/src/api-manager/datasources/e4/categories/e4-categories.translator.ts +1 -1
  20. package/src/api-manager/datasources/e4/e4.datasource.ts +9 -9
  21. package/src/api-manager/datasources/e4/graphqlRequestSdk.ts +2175 -138
  22. package/src/api-manager/datasources/e4/order/e4-order.datasource.ts +6 -3
  23. package/src/api-manager/datasources/e4/order/e4-order.remaps.ts +2 -2
  24. package/src/api-manager/datasources/e4/organization/e4-organization.datasource.ts +1 -1
  25. package/src/api-manager/datasources/e4/product/e4-product.datasource.ts +4 -4
  26. package/src/api-manager/datasources/e4/product/e4-product.remaps.ts +2 -2
  27. package/src/api-manager/datasources/e4/product/e4-product.translator.ts +3 -3
  28. package/src/api-manager/datasources/e4/session/e4-session.datasource.ts +2 -2
  29. package/src/api-manager/datasources/e4/session/e4-session.translator.ts +1 -1
  30. package/src/api-manager/datasources/e4/user/e4-user.datasource.ts +4 -4
  31. package/src/api-manager/datasources/e4/user/e4-user.remaps.ts +5 -2
  32. package/src/api-manager/datasources/e4/user/e4-user.translator.ts +5 -2
  33. package/src/api-manager/datasources/e4/utils/unwrap-e4-variants.ts +6 -2
  34. package/src/api-manager/index.ts +4 -4
  35. package/src/api-manager/lib/get-graphql-client.ts +1 -1
  36. package/src/api-manager/schemas/address.schema.ts +1 -1
  37. package/src/api-manager/schemas/cart.schema.ts +1 -1
  38. package/src/api-manager/schemas/order.schema.ts +1 -1
  39. package/src/api-manager/schemas/organization.schema.ts +1 -1
  40. package/src/api-manager/schemas/product.schema.ts +1 -1
  41. package/src/api-manager/schemas/session.schema.ts +2 -2
  42. package/src/api-manager/schemas/user.schema.ts +1 -1
  43. package/src/api-manager/services/address/mutations/create-address.ts +2 -2
  44. package/src/api-manager/services/address/mutations/delete-address.ts +2 -2
  45. package/src/api-manager/services/address/mutations/get-delivery-options.ts +2 -2
  46. package/src/api-manager/services/address/mutations/update-address.ts +2 -2
  47. package/src/api-manager/services/address/queries/get-countries.ts +2 -2
  48. package/src/api-manager/services/address/queries/get-states.ts +4 -1
  49. package/src/api-manager/services/cart/mutations/add-discount-code.ts +3 -3
  50. package/src/api-manager/services/cart/mutations/add-to-cart.ts +3 -3
  51. package/src/api-manager/services/cart/mutations/checkout.ts +2 -2
  52. package/src/api-manager/services/cart/mutations/delete-cart-line.ts +3 -3
  53. package/src/api-manager/services/cart/mutations/get-payment-accept-result.ts +2 -2
  54. package/src/api-manager/services/cart/mutations/remove-cart-line-delivery-mode.ts +3 -3
  55. package/src/api-manager/services/cart/mutations/remove-discount-code.ts +3 -3
  56. package/src/api-manager/services/cart/mutations/update-cart-line-delivery-mode.ts +3 -3
  57. package/src/api-manager/services/cart/mutations/update-cart-lines.ts +3 -3
  58. package/src/api-manager/services/cart/mutations/update-cart.ts +3 -3
  59. package/src/api-manager/services/cart/queries/get-cart-lines-inventory.ts +4 -1
  60. package/src/api-manager/services/cart/queries/get-cart.ts +2 -2
  61. package/src/api-manager/services/cart/queries/get-payment-accept-point.ts +4 -1
  62. package/src/api-manager/services/categories/queries/get-categories.ts +5 -2
  63. package/src/api-manager/services/create-mutation.ts +2 -2
  64. package/src/api-manager/services/create-query.ts +2 -2
  65. package/src/api-manager/services/order/queries/get-order-details.ts +4 -1
  66. package/src/api-manager/services/order/queries/get-orders.ts +4 -1
  67. package/src/api-manager/services/organization/queries/get-channel-configuration.ts +4 -1
  68. package/src/api-manager/services/organization/queries/get-stores.ts +4 -1
  69. package/src/api-manager/services/product/mutations/search-products.ts +1 -1
  70. package/src/api-manager/services/product/queries/get-product-availability.ts +4 -1
  71. package/src/api-manager/services/product/queries/get-product-by-id.ts +5 -2
  72. package/src/api-manager/services/product/queries/get-product-by-ids.ts +5 -2
  73. package/src/api-manager/services/product/queries/get-product-list.ts +4 -1
  74. package/src/api-manager/services/product/queries/get-product-prices.ts +4 -1
  75. package/src/api-manager/services/product/queries/get-related-products.ts +5 -2
  76. package/src/api-manager/services/product/queries/search-products.ts +4 -1
  77. package/src/api-manager/services/product/server/product.server.ts +2 -2
  78. package/src/api-manager/services/session/mutations/session-init.ts +2 -2
  79. package/src/api-manager/services/session/mutations/session-logout.ts +2 -2
  80. package/src/api-manager/services/session/queries/get-session.ts +4 -1
  81. package/src/api-manager/services/user/mutations/add-to-wishlist.ts +5 -3
  82. package/src/api-manager/services/user/mutations/copy-cart-to-wishlist.ts +2 -2
  83. package/src/api-manager/services/user/mutations/create-wishlist.ts +2 -2
  84. package/src/api-manager/services/user/mutations/delete-wishlist.ts +3 -3
  85. package/src/api-manager/services/user/mutations/remove-from-wishlist.ts +6 -4
  86. package/src/api-manager/services/user/mutations/update-user.ts +2 -2
  87. package/src/api-manager/services/user/mutations/update-wishlist.ts +2 -2
  88. package/src/api-manager/services/user/queries/get-user-counts.ts +4 -1
  89. package/src/api-manager/services/user/queries/get-user.ts +4 -1
  90. package/src/api-manager/services/user/queries/get-wishlist-details.ts +4 -1
  91. package/src/api-manager/services/user/queries/get-wishlists.ts +4 -1
  92. package/src/api-manager/types/Datasource.ts +2 -2
  93. package/src/auth/auth-options.test.ts +1 -1
  94. package/src/auth/auth-options.ts +1 -1
  95. package/src/auth/providers/index.ts +3 -3
  96. package/src/auth/refresh-token.ts +2 -2
  97. package/src/cms/blocks/{BlockManager.tsx → block-manager.tsx} +2 -2
  98. package/src/cms/blocks/{Components/BrandLogosScroller.tsx → components/brand-logos-scroller.tsx} +1 -1
  99. package/src/cms/blocks/{Components/CategoryCarousel → components/category-carousel}/index.tsx +3 -3
  100. package/src/cms/blocks/{Components/FeaturePill.tsx → components/feature-pill.tsx} +1 -1
  101. package/src/cms/blocks/{Components/FeaturedCategories.tsx → components/featured-categories.tsx} +2 -2
  102. package/src/cms/blocks/{Components/FeaturedProducts.tsx → components/featured-products.tsx} +2 -2
  103. package/src/cms/blocks/{Components/Footer → components/footer}/index.tsx +7 -4
  104. package/src/cms/blocks/{Components/Footer/sections/FooterContact.tsx → components/footer/sections/footer-contact.tsx} +3 -3
  105. package/src/cms/blocks/{Components/Footer/sections/FooterLinks.tsx → components/footer/sections/footer-links.tsx} +5 -2
  106. package/src/cms/blocks/{Components/Footer/sections/FooterSocialLinks.tsx → components/footer/sections/footer-social-links.tsx} +1 -1
  107. package/src/cms/blocks/{Components/Footer.tsx → components/footer.tsx} +1 -1
  108. package/src/cms/blocks/{Components/HeroCarousel → components/hero-carousel}/index.tsx +1 -1
  109. package/src/cms/blocks/{Components/Hero.tsx → components/hero.tsx} +1 -1
  110. package/src/cms/blocks/{Components/Image.tsx → components/image.tsx} +1 -1
  111. package/src/cms/blocks/{Components/ProductCarousel → components/product-carousel}/index.tsx +2 -2
  112. package/src/cms/blocks/{Components/ProductSectionFullWidth → components/product-section-fullwidth}/index.tsx +2 -2
  113. package/src/cms/blocks/{Components/Seo → components/seo}/index.tsx +1 -1
  114. package/src/cms/blocks/{Components/Services → components/services}/index.tsx +2 -2
  115. package/src/cms/blocks/{Components/Services → components/services}/service-card.tsx +1 -1
  116. package/src/cms/blocks/{Icons → icons}/index.ts +7 -7
  117. package/src/cms/blocks/index.tsx +15 -15
  118. package/src/cms/blog.ts +2 -2
  119. package/src/cms/endpoints.ts +1 -1
  120. package/src/cms/interfaces/navigation.ts +9 -9
  121. package/src/cms/pages.ts +1 -1
  122. package/src/components-v2/BazaarMenu.tsx +2 -0
  123. package/src/components-v2/BazaarTextField.tsx +1 -1
  124. package/src/components-v2/DropZone.tsx +4 -1
  125. package/src/components-v2/ImageWithFallback.tsx +1 -1
  126. package/src/components-v2/accordion/index.ts +1 -1
  127. package/src/components-v2/carousel/carousel.tsx +3 -3
  128. package/src/components-v2/carousel/components/carousel-arrows.tsx +1 -1
  129. package/src/components-v2/carousel/components/carousel-dots.tsx +4 -1
  130. package/src/components-v2/carousel/index.ts +1 -1
  131. package/src/components-v2/carousel-cards/carousel-card-1/carousel-card-1.tsx +1 -1
  132. package/src/components-v2/carousel-cards/carousel-card-1/index.ts +1 -1
  133. package/src/components-v2/categories/category-list/category-list.tsx +7 -4
  134. package/src/components-v2/categories/category-list/index.ts +1 -1
  135. package/src/components-v2/categories/category-list/styles.ts +1 -1
  136. package/src/components-v2/categories/category-list-item/category-menu-item.tsx +1 -1
  137. package/src/components-v2/categories/category-list-item/index.ts +1 -1
  138. package/src/components-v2/categories/category-menu.tsx +1 -1
  139. package/src/components-v2/categories/mega-menu/column-list.tsx +1 -1
  140. package/src/components-v2/categories/mega-menu/mega-menu-1.tsx +2 -2
  141. package/src/components-v2/categories/mega-menu/mega-menu-2.tsx +4 -4
  142. package/src/components-v2/flex-box/index.ts +3 -3
  143. package/src/components-v2/header/{components → __tests__}/user.test.tsx +51 -29
  144. package/src/components-v2/header/components/mobile-header.tsx +3 -3
  145. package/src/components-v2/header/components/user.tsx +8 -5
  146. package/src/components-v2/header/header.tsx +8 -5
  147. package/src/components-v2/header/index.ts +1 -1
  148. package/src/components-v2/header/sticky-header.tsx +1 -1
  149. package/src/components-v2/mini-cart/__tests__/cart-item.test.tsx +31 -40
  150. package/src/components-v2/mini-cart/__tests__/mini-cart.test.tsx +7 -8
  151. package/src/components-v2/mini-cart/index.ts +1 -1
  152. package/src/components-v2/mini-cart/mini-cart-trigger.tsx +1 -1
  153. package/src/components-v2/mini-cart/mini-cart.tsx +7 -7
  154. package/src/components-v2/mobile-navigation/index.ts +1 -1
  155. package/src/components-v2/mobile-navigation/mobile-navigation-bar.tsx +6 -1
  156. package/src/components-v2/nav-link/index.ts +3 -3
  157. package/src/components-v2/navbar/categories.tsx +1 -1
  158. package/src/components-v2/navbar/category-based-menu/category-based-menu.tsx +2 -2
  159. package/src/components-v2/navbar/category-based-menu/index.ts +1 -1
  160. package/src/components-v2/navbar/index.ts +1 -1
  161. package/src/components-v2/navbar/mega-menu/index.ts +1 -1
  162. package/src/components-v2/navbar/mega-menu/mega-menu.tsx +6 -1
  163. package/src/components-v2/navbar/mobile-menu/index.ts +1 -1
  164. package/src/components-v2/navbar/mobile-menu/mobile-menu.test.tsx +7 -13
  165. package/src/components-v2/navbar/mobile-menu/mobile-menu.tsx +1 -1
  166. package/src/components-v2/navbar/nav-list/cms-nav.test.tsx +16 -10
  167. package/src/components-v2/navbar/nav-list/index.ts +1 -1
  168. package/src/components-v2/navbar/nav-list/nav-item-child.tsx +4 -1
  169. package/src/components-v2/navbar/nav-list/nav-list.tsx +8 -4
  170. package/src/components-v2/navbar/navbar.tsx +6 -3
  171. package/src/components-v2/navbar/utils/transform-nav.test.ts +4 -1
  172. package/src/components-v2/product-cards/product-card/components/hover-actions.tsx +1 -1
  173. package/src/components-v2/product-cards/product-card/index.ts +1 -1
  174. package/src/components-v2/product-cards/product-card/product-card.tsx +10 -6
  175. package/src/components-v2/product-cards/product-card-plp/index.ts +1 -1
  176. package/src/components-v2/product-cards/product-card-plp/product-card.tsx +5 -5
  177. package/src/components-v2/product-cards/product-card-plp-list/index.ts +1 -1
  178. package/src/components-v2/product-cards/product-card-plp-list/product-card.tsx +7 -8
  179. package/src/components-v2/product-cards/product-card-search/index.ts +1 -1
  180. package/src/components-v2/product-cards/product-card-search/product-card.tsx +2 -2
  181. package/src/components-v2/product-dialog/compound/product-dialog.tsx +61 -45
  182. package/src/components-v2/product-dialog/index.tsx +1 -2
  183. package/src/components-v2/product-dimensions/compound/dimensions-group-error.tsx +3 -3
  184. package/src/components-v2/product-dimensions/compound/dimensions-group-label.tsx +1 -1
  185. package/src/components-v2/product-dimensions/compound/dimensions-group-list-chip.tsx +1 -1
  186. package/src/components-v2/product-dimensions/compound/dimensions-group-list.tsx +2 -2
  187. package/src/components-v2/product-dimensions/compound/dimensions-group.tsx +3 -3
  188. package/src/components-v2/product-dimensions/compound/dimensions.tsx +1 -1
  189. package/src/components-v2/product-dimensions/index.tsx +1 -1
  190. package/src/components-v2/product-quantity-buttons/compound/quantity-buttons-root.tsx +1 -1
  191. package/src/components-v2/product-quantity-buttons/index.tsx +2 -2
  192. package/src/components-v2/products-view/compound/products-grid-view.tsx +2 -2
  193. package/src/components-v2/products-view/compound/products-list-view.tsx +2 -2
  194. package/src/components-v2/products-view/compound/types.ts +1 -1
  195. package/src/components-v2/products-view/index.tsx +2 -2
  196. package/src/components-v2/progress/index.ts +1 -1
  197. package/src/components-v2/scrollbar/index.ts +1 -1
  198. package/src/components-v2/scrollbar/scrollbar.tsx +1 -1
  199. package/src/components-v2/search-bar/compound/results-item-lg.tsx +4 -1
  200. package/src/components-v2/search-bar/compound/results-item-sm.tsx +4 -1
  201. package/src/components-v2/search-bar/compound/results-suspense.tsx +4 -4
  202. package/src/components-v2/search-bar/compound/results.tsx +5 -2
  203. package/src/components-v2/search-bar/compound/search-bar-root.tsx +5 -5
  204. package/src/components-v2/search-bar/compound/textfield-adornment-category.tsx +2 -2
  205. package/src/components-v2/search-bar/compound/textfield.tsx +5 -5
  206. package/src/components-v2/search-bar/index.tsx +1 -1
  207. package/src/components-v2/section/compound/section-header.tsx +6 -3
  208. package/src/components-v2/section/compound/section.tsx +1 -1
  209. package/src/components-v2/section/index.ts +1 -1
  210. package/src/components-v2/side-nav/index.ts +1 -1
  211. package/src/components-v2/sticky/index.ts +1 -1
  212. package/src/components-v2/sticky/sticky.tsx +1 -1
  213. package/src/components-v2/wishlist-dialogs/__tests__/create-new-list.test.tsx +82 -0
  214. package/src/components-v2/wishlist-dialogs/__tests__/wishlistDetailData.json +280 -0
  215. package/src/components-v2/wishlist-dialogs/__tests__/wishlistsData.json +38 -0
  216. package/src/components-v2/wishlist-dialogs/add-to-wishlist/add-to-wishlist-button.tsx +1 -1
  217. package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/add-to-wishlist-bottom-ui.tsx +1 -1
  218. package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/add-to-wishlist-dialog.tsx +4 -4
  219. package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/add-to-wishlist-list.tsx +5 -2
  220. package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/context.ts +1 -1
  221. package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/wishlist-dialog-header.tsx +1 -1
  222. package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/wishlist-dialog-item.tsx +6 -3
  223. package/src/components-v2/wishlist-dialogs/add-to-wishlist/hooks/use-add-to-wishlist.ts +1 -1
  224. package/src/components-v2/wishlist-dialogs/add-to-wishlist/index.tsx +1 -1
  225. package/src/components-v2/wishlist-dialogs/create-wishlist/compound/create-wishlist-bottom-ui.tsx +1 -1
  226. package/src/components-v2/wishlist-dialogs/create-wishlist/compound/create-wishlist-dialog.tsx +2 -2
  227. package/src/components-v2/wishlist-dialogs/create-wishlist/compound/create-wishlist-form.tsx +2 -2
  228. package/src/components-v2/wishlist-dialogs/create-wishlist/create-wishlist-button.tsx +1 -1
  229. package/src/components-v2/wishlist-dialogs/create-wishlist/index.tsx +1 -1
  230. package/src/lib/build-detail-url.ts +1 -1
  231. package/src/lib/cart-cookie-handler.ts +1 -1
  232. package/src/pages-v2/account/account-navigation.tsx +183 -0
  233. package/src/pages-v2/account/addresses/address-form.tsx +187 -186
  234. package/src/pages-v2/account/addresses/address-item.tsx +118 -56
  235. package/src/pages-v2/account/dashboard-header.tsx +103 -76
  236. package/src/pages-v2/account/orders/order-progress.tsx +104 -65
  237. package/src/pages-v2/account/orders/order-row.tsx +69 -32
  238. package/src/pages-v2/account/orders/order-summary.tsx +96 -62
  239. package/src/pages-v2/account/orders/ordered-products.tsx +128 -87
  240. package/src/pages-v2/account/profile/profile-button.test.tsx +1 -1
  241. package/src/pages-v2/account/profile/user-info.tsx +59 -34
  242. package/src/pages-v2/account/wishlist/create-new-list.tsx +181 -127
  243. package/src/pages-v2/account/wishlist/create-wishlist-button.tsx +16 -3
  244. package/src/pages-v2/account/wishlist/wishlist-item.tsx +93 -42
  245. package/src/pages-v2/cart/__tests__/cart-item.test.tsx +225 -0
  246. package/src/pages-v2/cart/__tests__/cart-with-items.json +811 -0
  247. package/src/pages-v2/cart/__tests__/checkout-form.test.tsx +148 -0
  248. package/src/pages-v2/cart/__tests__/conutries.json +19407 -0
  249. package/src/pages-v2/cart/__tests__/estimate-shipping.test.tsx +86 -0
  250. package/src/pages-v2/cart/cart-item.tsx +387 -258
  251. package/src/pages-v2/cart/checkout-form.tsx +141 -48
  252. package/src/pages-v2/cart/coupon-entry.tsx +121 -58
  253. package/src/pages-v2/cart/estimate-shipping.tsx +174 -118
  254. package/src/pages-v2/checkout/checkout-alt-form/checkout-form.tsx +153 -76
  255. package/src/pages-v2/checkout/checkout-alt-form/checkout-step.tsx +128 -77
  256. package/src/pages-v2/checkout/checkout-alt-form/index.ts +1 -1
  257. package/src/pages-v2/checkout/checkout-alt-form/{heading.tsx → step-heading.tsx} +1 -1
  258. package/src/pages-v2/checkout/checkout-alt-form/steps/address/address-card.tsx +131 -0
  259. package/src/pages-v2/checkout/checkout-alt-form/steps/address/delivery-address.tsx +450 -0
  260. package/src/pages-v2/checkout/checkout-alt-form/steps/address/new-address-form.tsx +322 -0
  261. package/src/pages-v2/checkout/checkout-alt-form/steps/address/styles.ts +27 -0
  262. package/src/pages-v2/checkout/checkout-alt-form/steps/customer-info/customer-information.tsx +139 -0
  263. package/src/pages-v2/checkout/checkout-alt-form/{payment-details.tsx → steps/payment/payment-details.tsx} +123 -141
  264. package/src/pages-v2/checkout/checkout-alt-form/{delivery-date.tsx → steps/shipping/delivery-date.tsx} +3 -3
  265. package/src/pages-v2/checkout/checkout-alt-form/{delivery-options.tsx → steps/shipping/delivery-options.tsx} +97 -50
  266. package/src/pages-v2/checkout/checkout-alt-summary/cart-item.tsx +58 -28
  267. package/src/pages-v2/checkout/checkout-alt-summary/checkout-alt-summary.tsx +69 -22
  268. package/src/pages-v2/checkout/checkout-alt-summary/index.ts +1 -1
  269. package/src/pages-v2/checkout/checkout-alt-summary/list-item.tsx +56 -14
  270. package/src/pages-v2/confirmation/address.tsx +37 -15
  271. package/src/pages-v2/confirmation/confirmation-summary.tsx +80 -41
  272. package/src/pages-v2/confirmation/ordered-products.tsx +127 -95
  273. package/src/pages-v2/product-details/bopis/find-in-store-button.tsx +2 -2
  274. package/src/pages-v2/product-details/bopis/find-in-store-modal.tsx +4 -4
  275. package/src/pages-v2/product-details/bopis/pickup-option-select.tsx +1 -1
  276. package/src/pages-v2/product-details/bopis/store-card/index.ts +1 -1
  277. package/src/pages-v2/product-details/bopis/store-card/shop-card.tsx +3 -3
  278. package/src/pages-v2/product-details/frequently-bought.tsx +1 -1
  279. package/src/pages-v2/product-details/product-filter-card.tsx +2 -2
  280. package/src/pages-v2/product-details/product-intro/compound/context.ts +1 -4
  281. package/src/pages-v2/product-details/product-intro/compound/product-info.tsx +6 -3
  282. package/src/pages-v2/product-details/product-intro/compound/product-intro-images.tsx +6 -3
  283. package/src/pages-v2/product-details/product-intro/compound/product-intro.tsx +4 -4
  284. package/src/pages-v2/product-details/product-intro/utils.ts +0 -1
  285. package/src/pages-v2/product-details/product-review.tsx +5 -2
  286. package/src/pages-v2/product-details/product-tabs.tsx +1 -1
  287. package/src/pages-v2/quickorder/context.ts +39 -0
  288. package/src/pages-v2/quickorder/index.tsx +31 -0
  289. package/src/pages-v2/quickorder/order-upload.tsx +19 -26
  290. package/src/pages-v2/quickorder/provider.tsx +187 -0
  291. package/src/pages-v2/quickorder/quick-order-actions.tsx +30 -0
  292. package/src/pages-v2/quickorder/quick-order-header.tsx +22 -0
  293. package/src/pages-v2/quickorder/quick-order-row.tsx +8 -17
  294. package/src/pages-v2/quickorder/quick-order-table.tsx +63 -0
  295. package/src/pages-v2/quickorder/quick-order-upload.tsx +20 -0
  296. package/src/providers/nav-provider/index.tsx +1 -1
  297. package/src/providers/notifications/notification-context.tsx +1 -1
  298. package/src/providers/notifications/use-notification.ts +1 -1
  299. package/tsconfig.json +2 -1
  300. package/src/api-manager/lib/get-graphql-client.test.ts +0 -106
  301. package/src/components/_components/header/components/user.test.tsx +0 -200
  302. package/src/components/_components/mini-cart/__tests__/cart-item.test.tsx +0 -174
  303. package/src/components/_components/mini-cart/__tests__/mini-cart.test.tsx +0 -121
  304. package/src/components/_components/mini-cart/__tests__/test-cart-empty.json +0 -84
  305. package/src/components/_components/mini-cart/__tests__/test-cart-with-item.json +0 -244
  306. package/src/components/_components/navbar/mobile-menu/render-levels.test.tsx +0 -71
  307. package/src/components/_components/navbar/nav-list/cms-nav.test.tsx +0 -84
  308. package/src/components/_components/navbar/utils/transform-nav.test.ts +0 -209
  309. package/src/components/_components/search-box/__test__/search-input-category.test.tsx +0 -110
  310. package/src/components/_components/search-box/__test__/search-input.test.tsx +0 -137
  311. package/src/components/_components/search-box/__test__/search-results.json +0 -165
  312. package/src/components/_components/search-box/search-input-category.test.tsx +0 -110
  313. package/src/components/_components/search-box/search-input.test.tsx +0 -41
  314. package/src/components-v2/bazaar-types.ts +0 -84
  315. package/src/pages-v2/account/navigation.tsx +0 -87
  316. package/src/pages-v2/checkout/checkout-alt-form/address-card.tsx +0 -76
  317. package/src/pages-v2/checkout/checkout-alt-form/customer-information.tsx +0 -94
  318. package/src/pages-v2/checkout/checkout-alt-form/delivery-address.tsx +0 -174
  319. package/src/pages-v2/checkout/checkout-alt-form/edit-address-form.tsx +0 -130
  320. package/src/pages-v2/checkout/checkout-alt-form/new-address-form.tsx +0 -299
  321. package/src/pages-v2/quickorder/quick-order-form.tsx +0 -346
  322. /package/src/cms/blocks/{Components/CategoryCard.tsx → components/category-card.tsx} +0 -0
  323. /package/src/cms/blocks/{Components/Footer → components/footer}/data/index.ts +0 -0
  324. /package/src/cms/blocks/{Components/Footer → components/footer}/interfaces.ts +0 -0
  325. /package/src/cms/blocks/{Components/Footer/sections/FooterAppStore.tsx → components/footer/sections/footer-app-store.tsx} +0 -0
  326. /package/src/cms/blocks/{Components/Footer/sections/FooterLogo.tsx → components/footer/sections/footer-logo.tsx} +0 -0
  327. /package/src/cms/blocks/{Components/Footer → components/footer}/styles/index.ts +0 -0
  328. /package/src/cms/blocks/{Components/MediaCard.tsx → components/media-card.tsx} +0 -0
  329. /package/src/cms/blocks/{Components/RichText.tsx → components/rich-text.tsx} +0 -0
  330. /package/src/cms/blocks/{Components → components}/shared/featured-product-card.tsx +0 -0
  331. /package/src/cms/blocks/{Components → components}/shared/product-category-item.tsx +0 -0
  332. /package/src/cms/blocks/{Components → components}/shared/product-grid.tsx +0 -0
  333. /package/src/cms/blocks/{Components → components}/shared/top-categories-card.tsx +0 -0
  334. /package/src/cms/blocks/{Components → components}/shared/top-rating-product-card.tsx +0 -0
  335. /package/src/cms/blocks/{Icons/Components/Category.tsx → icons/components/category.tsx} +0 -0
  336. /package/src/cms/blocks/{Icons/Components/DottedStar.tsx → icons/components/dotted-star.tsx} +0 -0
  337. /package/src/cms/blocks/{Icons/Components/FallbackIcon.tsx → icons/components/fallback-icon.tsx} +0 -0
  338. /package/src/cms/blocks/{Icons/Components/GiftBox.tsx → icons/components/gift-box.tsx} +0 -0
  339. /package/src/cms/blocks/{Icons/Components/Light.tsx → icons/components/light.tsx} +0 -0
  340. /package/src/cms/blocks/{Icons/Components/NewArrival.tsx → icons/components/new-arrival.tsx} +0 -0
  341. /package/src/cms/blocks/{Icons/Components/RankBadge.tsx → icons/components/rank-badge.tsx} +0 -0
  342. /package/src/cms/interfaces/{productData.ts → product-data.ts} +0 -0
  343. /package/src/pages-v2/checkout/checkout-alt-form/{safe-card-preview-data.tsx → steps/payment/safe-card-preview-data.tsx} +0 -0
@@ -1,12 +1,12 @@
1
- import { useTranslations } from "next-intl";
2
- import { CheckoutStepComponentProps } from "./checkout-step";
3
1
  import React from "react";
4
- import { H6 } from "@evenicanpm/storefront-core/src/components-v2/Typography";
5
- import { Alert, Box, Card } from "@mui/material";
2
+ import { useTranslations } from "next-intl";
3
+ import { CheckoutStepComponentProps } from "@evenicanpm/storefront-core/src/pages-v2/checkout/checkout-alt-form/checkout-step";
6
4
  import {
5
+ H6,
7
6
  Paragraph,
8
7
  Small,
9
8
  } from "@evenicanpm/storefront-core/src/components-v2/Typography";
9
+ import { Alert, Box, Card } from "@mui/material";
10
10
  import { RetrieveCardPaymentAcceptResultInput } from "@/api-manager/schemas/cart.schema";
11
11
  import { CardPaymentAcceptResult } from "@msdyn365-commerce/retail-proxy";
12
12
  import usePaymentAcceptResult from "@/api-manager/services/cart/mutations/get-payment-accept-result";
@@ -37,16 +37,29 @@ type PaymentError = {
37
37
  Message: string;
38
38
  };
39
39
 
40
- export default function PaymentDetails(props: CheckoutStepComponentProps) {
40
+ type PaymentDetailsCompound = React.FC<CheckoutStepComponentProps> & {
41
+ Preview: React.FC<{ paymentAcceptResult: CardPaymentAcceptResult | null }>;
42
+ Form: React.FC<{
43
+ iframeReference: React.RefObject<HTMLIFrameElement>;
44
+ iframeHeight: number;
45
+ errorState: PaymentError[];
46
+ paymentAcceptPointData: any;
47
+ }>;
48
+ };
49
+
50
+ const PaymentDetails: PaymentDetailsCompound = (props) => {
41
51
  const {
42
52
  cart,
43
53
  setStepSubmissionState,
44
54
  stepSubmissionState,
45
55
  handleStepCompletion,
46
56
  stepViewState,
57
+ children,
47
58
  } = props;
59
+
48
60
  const [paymentAcceptResult, setPaymentAcceptResult] =
49
61
  React.useState<CardPaymentAcceptResult | null>(null);
62
+
50
63
  const t = useTranslations("Checkout.Payment");
51
64
  const { data: paymentAcceptPointData } = getPaymentAcceptPoint.useData({
52
65
  cartId: cart.Id,
@@ -57,14 +70,21 @@ export default function PaymentDetails(props: CheckoutStepComponentProps) {
57
70
  });
58
71
 
59
72
  const { mutateAsync: retrievePaymentAcceptResult } = usePaymentAcceptResult();
60
- const iframeReference: React.RefObject<HTMLIFrameElement> =
61
- React.useRef(null);
73
+ const iframeReference = React.useRef<HTMLIFrameElement>(null);
62
74
  const [iframeHeight, setIFrameHeight] = React.useState<number>(1);
63
75
  const [errorState, setErrorState] = React.useState<PaymentError[]>([]);
64
- // const [showOverlay, setShowOverlay] = React.useState(false);
76
+ // const [showOverlay, setShowOverlay] = React.useState(false);
77
+
78
+ const paymentConnectorMessage = (
79
+ data: string,
80
+ messageType: PaymentConnectorPostMessageType,
81
+ ): PaymentConnectorPostMessage => ({
82
+ message: JSON.stringify({ type: messageType, value: data }),
83
+ targetOrigin: "*",
84
+ });
65
85
 
66
86
  const handleResultsAccessCode = React.useCallback(
67
- async (accessCode: string): Promise<void> => {
87
+ async (accessCode: string) => {
68
88
  const input: RetrieveCardPaymentAcceptResultInput = {
69
89
  cartId: cart.Id,
70
90
  resultAccessCode: accessCode,
@@ -94,29 +114,22 @@ export default function PaymentDetails(props: CheckoutStepComponentProps) {
94
114
  );
95
115
 
96
116
  const onIFrameMessage = React.useCallback(
97
- async (event: MessageEvent): Promise<void> => {
117
+ async (event: MessageEvent) => {
98
118
  let result;
99
119
  try {
100
- if (typeof event.data !== "string") {
101
- return;
102
- }
120
+ if (typeof event.data !== "string") return;
103
121
  result = JSON.parse(event.data);
104
122
  } catch (error) {
105
123
  console.error(error);
106
124
  return;
107
125
  }
108
126
 
109
- if (!result || !result.type) {
110
- return;
111
- }
127
+ if (!result?.type || !cart.TotalAmount) return;
112
128
  const { type, value } = result;
113
- if (!cart.TotalAmount) {
114
- return;
115
- }
116
129
 
117
130
  switch (type) {
118
131
  case PaymentConnectorPostMessageType.Height: {
119
- // The payment connector will post height after it completes initialization
132
+ // Payment connector posts height after initialization
120
133
  setIFrameHeight(value as number);
121
134
  postMessageToIframe(
122
135
  paymentConnectorMessage(
@@ -137,12 +150,6 @@ export default function PaymentDetails(props: CheckoutStepComponentProps) {
137
150
  setErrorState([{ Code: 500, Message: t("cardErrorMessage") }]);
138
151
  setStepSubmissionState("error");
139
152
  }
140
- // executeGetPaymentAcceptResults(value);
141
- // Handle Payment Result
142
- return;
143
- }
144
- case PaymentConnectorPostMessageType.CardPrefix: {
145
- // Handle Card Prefix
146
153
  return;
147
154
  }
148
155
  case PaymentConnectorPostMessageType.Error: {
@@ -157,24 +164,10 @@ export default function PaymentDetails(props: CheckoutStepComponentProps) {
157
164
  }
158
165
  return;
159
166
  }
160
- case PaymentConnectorPostMessageType.Redirect: {
161
- // Handle Redirect (Not used in this implementation)
162
- return;
163
- }
164
- case PaymentConnectorPostMessageType.Showoverlay: {
165
- // Handle Show overlay (used for PP)
166
- // setShowOverlay(true);
167
- return;
168
- }
169
- case PaymentConnectorPostMessageType.Hideoverlay: {
170
- // Hide Overlay
171
- // setShowOverlay(false);
172
- return;
173
- }
167
+ // Other message types intentionally left unimplemented
174
168
  default: {
175
169
  return;
176
170
  }
177
- // Do nothing
178
171
  }
179
172
  },
180
173
  [
@@ -189,11 +182,7 @@ export default function PaymentDetails(props: CheckoutStepComponentProps) {
189
182
 
190
183
  const onEvent = React.useCallback(
191
184
  (event: MessageEvent) => {
192
- // const requestHost = window.location.origin;
193
- // const messageHost = getHostName(paymentAcceptPointData?.MessageOrigin);
194
- // Important: security check
195
- // check actual origin matches with expected origin
196
- //Needs to be put in
185
+ // TODO: Security check -> validate event.origin matches expected
197
186
  onIFrameMessage(event);
198
187
  },
199
188
  [onIFrameMessage],
@@ -201,9 +190,7 @@ export default function PaymentDetails(props: CheckoutStepComponentProps) {
201
190
 
202
191
  React.useEffect(() => {
203
192
  window.addEventListener("message", onEvent);
204
- return () => {
205
- window.removeEventListener("message", onEvent);
206
- };
193
+ return () => window.removeEventListener("message", onEvent);
207
194
  }, [onEvent]);
208
195
 
209
196
  const postSubmitMessage = React.useCallback(() => {
@@ -214,18 +201,13 @@ export default function PaymentDetails(props: CheckoutStepComponentProps) {
214
201
 
215
202
  React.useEffect(() => {
216
203
  if (stepSubmissionState === "submitting") {
217
- // * INFO: This will be confusing. This listens for the stepSubmissionState to change to 'submitting' and then calls the postSubmitMessage function.
218
- // * INFO: The postSubmitMessage function will then call the postMessageToIframe function with the paymentConnectorMessage function as an argument.
219
- // * INFO: The paymentConnectorMessage function will return an object with a message and targetOrigin property.
220
- // * INFO: We have to listen for an event of that message which will tell us what to do with the payment. It's a chain of listeners with no function returns.
204
+ // INFO: This listens for `submitting` state, then posts submit message to iframe
221
205
  postSubmitMessage();
222
206
  }
223
207
  }, [postSubmitMessage, stepSubmissionState]);
224
208
 
225
209
  React.useEffect(() => {
226
- if (!paymentAcceptPointData || stepViewState !== "active") {
227
- return;
228
- }
210
+ if (!paymentAcceptPointData || stepViewState !== "active") return;
229
211
  if (
230
212
  !paymentAcceptPointData.AcceptPageUrl?.length &&
231
213
  paymentAcceptPointData.AcceptPageContent?.length &&
@@ -240,26 +222,87 @@ export default function PaymentDetails(props: CheckoutStepComponentProps) {
240
222
  }
241
223
  }, [paymentAcceptPointData, stepViewState]);
242
224
 
243
- const paymentConnectorMessage = (
244
- data: string,
245
- messageType: PaymentConnectorPostMessageType,
246
- ): PaymentConnectorPostMessage => {
247
- return {
248
- message: JSON.stringify({
249
- type: messageType,
250
- value: data,
251
- }),
252
- targetOrigin: "*",
253
- };
254
- };
225
+ if (stepViewState === "pending") return null;
226
+
227
+ return (
228
+ <>
229
+ {children ? (
230
+ children
231
+ ) : stepViewState === "preview" ? (
232
+ <PaymentDetails.Preview paymentAcceptResult={paymentAcceptResult} />
233
+ ) : (
234
+ <PaymentDetails.Form
235
+ iframeReference={iframeReference}
236
+ iframeHeight={iframeHeight}
237
+ errorState={errorState}
238
+ paymentAcceptPointData={paymentAcceptPointData}
239
+ />
240
+ )}
241
+ </>
242
+ );
243
+ };
255
244
 
256
- // const getHostName = (url: string = ""): string => {
257
- // return (
258
- // url.includes("//") ? url.split("/")[2] : url.split("/")[0]
259
- // ).toLowerCase();
260
- // };
245
+ PaymentDetails.Preview = ({ paymentAcceptResult }) => {
246
+ const t = useTranslations("Checkout.Payment");
247
+ if (!paymentAcceptResult) return null;
261
248
 
262
- const renderPaymentWindow = () => (
249
+ return (
250
+ <FlexBox flexDirection={"column"} sx={{ m: 2 }}>
251
+ <H6 sx={{ mb: 2 }}>{t("cardPaymentDetails")}</H6>
252
+ <Card
253
+ sx={{
254
+ padding: 2,
255
+ boxShadow: "none",
256
+ cursor: "pointer",
257
+ border: "1px solid",
258
+ position: "relative",
259
+ backgroundColor: "grey.100",
260
+ borderColor: "secondary.main",
261
+ }}
262
+ >
263
+ <Paragraph>
264
+ {paymentAcceptResult.TokenizedPaymentCard?.NameOnCard}
265
+ </Paragraph>
266
+ <Paragraph>
267
+ {paymentAcceptResult.TokenizedPaymentCard?.CardTypeId}
268
+ </Paragraph>
269
+ <Paragraph>
270
+ {
271
+ paymentAcceptResult.TokenizedPaymentCard?.CardTokenInfo
272
+ ?.MaskedCardNumber
273
+ }
274
+ </Paragraph>
275
+ <Paragraph>
276
+ {`${paymentAcceptResult.TokenizedPaymentCard?.ExpirationMonth}/${paymentAcceptResult.TokenizedPaymentCard?.ExpirationYear}`}
277
+ </Paragraph>
278
+ </Card>
279
+ </FlexBox>
280
+ );
281
+ };
282
+
283
+ PaymentDetails.Form = ({
284
+ iframeReference,
285
+ iframeHeight,
286
+ errorState,
287
+ paymentAcceptPointData,
288
+ }) => {
289
+ const t = useTranslations("Checkout.Payment");
290
+
291
+ const renderErrorMessages = () =>
292
+ errorState.length > 0 ? (
293
+ <Alert severity="error">
294
+ <Paragraph color={"error"} fontWeight={"bold"}>
295
+ {t("errorMessage")}
296
+ </Paragraph>
297
+ {errorState.map((message, index) => (
298
+ <Small color={"error"} key={`${message.Code}-${index}`}>
299
+ {message.Message}
300
+ </Small>
301
+ ))}
302
+ </Alert>
303
+ ) : null;
304
+
305
+ return (
263
306
  <Box sx={{ m: 2 }}>
264
307
  <H6 sx={{ mb: 2 }}>{t("cardFormHeader")}</H6>
265
308
  {paymentAcceptPointData && (
@@ -274,74 +317,13 @@ export default function PaymentDetails(props: CheckoutStepComponentProps) {
274
317
  />
275
318
  )}
276
319
  {renderErrorMessages()}
277
- {/* <Button variant={"contained"} onClick={postSubmitMessage}>
320
+ {/*
321
+ <Button variant={"contained"} onClick={postSubmitMessage}>
278
322
  {t("cardFormSaveButtonText")}
279
- </Button> */}
323
+ </Button>
324
+ */}
280
325
  </Box>
281
326
  );
327
+ };
282
328
 
283
- const renderErrorMessages = () =>
284
- errorState.length > 0 ? (
285
- <Alert severity="error">
286
- <Paragraph color={"error"} fontWeight={"bold"}>
287
- {t("errorMessage")}
288
- </Paragraph>
289
- {errorState.map((message, index) => (
290
- <Small color={"error"} key={`${message.Code}-${index}`}>
291
- {message.Message}
292
- </Small>
293
- ))}
294
- </Alert>
295
- ) : undefined;
296
-
297
- // const handleChangeButtonClick = () => {
298
- // getNewPaymentAcceptPoint();
299
- // };
300
-
301
- const renderSafeCardData = () => {
302
- if (!paymentAcceptResult) {
303
- return null;
304
- }
305
- return (
306
- <FlexBox flexDirection={"column"} sx={{ m: 2 }}>
307
- <H6 sx={{ mb: 2 }}>{t("cardPaymentDetails")}</H6>
308
- <Card
309
- sx={{
310
- padding: 2,
311
- boxShadow: "none",
312
- cursor: "pointer",
313
- border: "1px solid",
314
- position: "relative",
315
- backgroundColor: "grey.100",
316
- borderColor: "secondary.main",
317
- }}
318
- >
319
- <Paragraph>
320
- {paymentAcceptResult.TokenizedPaymentCard?.NameOnCard}
321
- </Paragraph>
322
- <Paragraph>
323
- {paymentAcceptResult.TokenizedPaymentCard?.CardTypeId}
324
- </Paragraph>
325
- <Paragraph>
326
- {
327
- paymentAcceptResult.TokenizedPaymentCard?.CardTokenInfo
328
- ?.MaskedCardNumber
329
- }
330
- </Paragraph>
331
- <Paragraph>
332
- {`${paymentAcceptResult.TokenizedPaymentCard?.ExpirationMonth}/${paymentAcceptResult.TokenizedPaymentCard?.ExpirationYear}`}
333
- </Paragraph>
334
- </Card>
335
- </FlexBox>
336
- );
337
- };
338
-
339
- if (stepViewState === "pending") {
340
- return null;
341
- }
342
- if (stepViewState === "preview") {
343
- return renderSafeCardData();
344
- }
345
- <pre>{stepViewState}</pre>;
346
- return renderPaymentWindow();
347
- }
329
+ export default PaymentDetails;
@@ -6,8 +6,8 @@ import MenuItem from "@mui/material/MenuItem";
6
6
  import TextField from "@mui/material/TextField";
7
7
  import { FormikErrors, FormikTouched } from "formik";
8
8
  import { format } from "date-fns";
9
- import Heading from "./heading";
10
- import { InitialValues } from "./types";
9
+ import StepHeading from "@evenicanpm/storefront-core/src/pages-v2/checkout/checkout-alt-form/step-heading";
10
+ import { InitialValues } from "@evenicanpm/storefront-core/src/pages-v2/checkout/checkout-alt-form/types";
11
11
 
12
12
  // ==============================================================
13
13
  interface Props {
@@ -60,7 +60,7 @@ export default function DeliveryDate({
60
60
 
61
61
  return (
62
62
  <Card sx={{ p: 3, mb: 3 }}>
63
- <Heading
63
+ <StepHeading
64
64
  number={1}
65
65
  title="Delivery Date and Time"
66
66
  stepViewState={"active"}
@@ -1,3 +1,4 @@
1
+ import React from "react";
1
2
  import {
2
3
  Box,
3
4
  FormControl,
@@ -20,46 +21,63 @@ import {
20
21
  Span,
21
22
  } from "@evenicanpm/storefront-core/src/components-v2/Typography";
22
23
  import useCurrencyFormatter from "@/lib/currency-formatter";
23
- import { CheckoutStepComponentProps } from "./checkout-step";
24
+ import { CheckoutStepComponentProps } from "@evenicanpm/storefront-core/src/pages-v2/checkout/checkout-alt-form/checkout-step";
24
25
  import useGetDeliveryOptions from "@/api-manager/services/address/mutations/get-delivery-options";
25
- import React from "react";
26
26
  import useUpdateCartLineDeliveryMode from "@/api-manager/services/cart/mutations/update-cart-line-delivery-mode";
27
27
  import { cloneDeep } from "lodash";
28
28
  import useRemoveCartLineDeliveryMode from "@/api-manager/services/cart/mutations/remove-cart-line-delivery-mode";
29
29
 
30
- export default function DeliveryOptions(props: CheckoutStepComponentProps) {
31
- const { cart, stepViewState, stepSubmissionState, setStepSubmissionState } =
32
- props;
30
+ type DeliveryOptionsCompound = React.FC<CheckoutStepComponentProps> & {
31
+ Preview: React.FC<PreviewProps>;
32
+ Form: React.FC<FormProps>;
33
+ };
34
+
35
+ type PreviewProps = {
36
+ deliveryOptions: DeliveryOption[];
37
+ selectedOption: string | null;
38
+ };
39
+
40
+ type FormProps = {
41
+ deliveryOptions: DeliveryOption[];
42
+ deliveryUnavailable: boolean;
43
+ selectedOption: string | null;
44
+ onChange: (value: string) => void;
45
+ };
46
+
47
+ const DeliveryOptions: DeliveryOptionsCompound = (props) => {
48
+ const {
49
+ cart,
50
+ stepViewState,
51
+ stepSubmissionState,
52
+ setStepSubmissionState,
53
+ children,
54
+ } = props;
33
55
  const [deliveryOptions, setDeliveryOptions] = React.useState<
34
56
  DeliveryOption[]
35
57
  >([]);
36
- const [deliveryUnavailable, setDeliveryUnavailable] =
37
- React.useState<boolean>(false);
58
+ const [deliveryUnavailable, setDeliveryUnavailable] = React.useState(false);
38
59
  const [selectedOption, setSelectedOption] = React.useState<string | null>(
39
60
  null,
40
61
  );
41
62
  const [currentShippingAddress, setCurrentShippingAddress] =
42
63
  React.useState<Address | null>(null);
43
- const t = useTranslations("Checkout.DeliveryOptions");
44
- const { formatCurrency } = useCurrencyFormatter();
64
+
45
65
  const { mutateAsync: getDeliveryOptions } = useGetDeliveryOptions();
46
66
  const { mutateAsync: updateDeliveryOption } = useUpdateCartLineDeliveryMode();
47
67
  const { mutate: removeDeliveryOption } = useRemoveCartLineDeliveryMode();
48
68
 
49
69
  const handleUpdateDeliveryOption = React.useCallback(() => {
50
- const cartLineDeliverySpecification: LineDeliverySpecification[] = [];
51
70
  if (cart.CartLines && selectedOption) {
52
- for (const cl of cart.CartLines) {
53
- const lineSpec: LineDeliverySpecification = {
71
+ const cartLineDeliverySpecification: LineDeliverySpecification[] =
72
+ cart.CartLines.map((cl) => ({
54
73
  LineId: cl.LineId,
55
74
  DeliverySpecification: {
56
75
  DeliveryModeId: selectedOption,
57
76
  DeliveryPreferenceTypeValue: DeliveryPreferenceType.ShipToAddress,
58
77
  DeliveryAddress: cart.ShippingAddress,
59
78
  },
60
- };
61
- cartLineDeliverySpecification.push(lineSpec);
62
- }
79
+ }));
80
+
63
81
  updateDeliveryOption({ cartId: cart.Id, cartLineDeliverySpecification })
64
82
  .then(() => {
65
83
  props.handleStepCompletion();
@@ -78,6 +96,7 @@ export default function DeliveryOptions(props: CheckoutStepComponentProps) {
78
96
  props,
79
97
  setStepSubmissionState,
80
98
  ]);
99
+
81
100
  React.useEffect(() => {
82
101
  if (stepSubmissionState === "submitting") {
83
102
  handleUpdateDeliveryOption();
@@ -88,7 +107,7 @@ export default function DeliveryOptions(props: CheckoutStepComponentProps) {
88
107
  if (stepViewState === "active") {
89
108
  const cartLines = cloneDeep(cart.CartLines);
90
109
  if (cartLines.map((cl) => cl.DeliveryMode).some((mode) => mode !== "")) {
91
- removeDeliveryOption({ cart: cart });
110
+ removeDeliveryOption({ cart });
92
111
  }
93
112
  }
94
113
  }, [cart, removeDeliveryOption, stepViewState]);
@@ -96,9 +115,7 @@ export default function DeliveryOptions(props: CheckoutStepComponentProps) {
96
115
  React.useEffect(() => {
97
116
  if (currentShippingAddress) {
98
117
  const { Id, CartLines } = cart;
99
- const cartLineIds = CartLines.map((cl) => cl.LineId).filter(
100
- (line) => line !== undefined,
101
- );
118
+ const cartLineIds = CartLines.map((cl) => cl.LineId).filter(Boolean);
102
119
  getDeliveryOptions({
103
120
  cartId: Id,
104
121
  cartLineIds,
@@ -112,23 +129,69 @@ export default function DeliveryOptions(props: CheckoutStepComponentProps) {
112
129
 
113
130
  React.useEffect(() => {
114
131
  if (cart.ShippingAddress) {
115
- if (currentShippingAddress) {
116
- //Deep equals the address
117
- if (
118
- JSON.stringify(currentShippingAddress) ===
132
+ if (
133
+ currentShippingAddress &&
134
+ JSON.stringify(currentShippingAddress) ===
119
135
  JSON.stringify(cart.ShippingAddress)
120
- ) {
121
- return;
122
- }
136
+ ) {
137
+ return;
123
138
  }
124
- // If the address has changed, change the local state which will trigger the effect to get the delivery options
125
139
  setCurrentShippingAddress(cart.ShippingAddress);
126
140
  }
127
141
  }, [cart.ShippingAddress, currentShippingAddress]);
128
142
 
129
- const handleOptionChange = (event: React.ChangeEvent<HTMLInputElement>) => {
130
- setSelectedOption(event.target.value);
143
+ const handleOptionChange = (value: string) => {
144
+ setSelectedOption(value);
131
145
  };
146
+
147
+ if (stepViewState === "pending") return null;
148
+
149
+ return (
150
+ <>
151
+ {children ? (
152
+ children
153
+ ) : stepViewState === "preview" ? (
154
+ <DeliveryOptions.Preview
155
+ deliveryOptions={deliveryOptions}
156
+ selectedOption={selectedOption}
157
+ />
158
+ ) : (
159
+ <DeliveryOptions.Form
160
+ deliveryOptions={deliveryOptions}
161
+ deliveryUnavailable={deliveryUnavailable}
162
+ selectedOption={selectedOption}
163
+ onChange={handleOptionChange}
164
+ />
165
+ )}
166
+ </>
167
+ );
168
+ };
169
+
170
+ DeliveryOptions.Preview = ({ deliveryOptions, selectedOption }) => {
171
+ const { formatCurrency } = useCurrencyFormatter();
172
+ const deliveryOption = deliveryOptions.find(
173
+ (dlv) => dlv.Code === selectedOption,
174
+ );
175
+
176
+ if (!deliveryOption) return null;
177
+
178
+ return (
179
+ <Box mt={2}>
180
+ <H4>{deliveryOption.Description}</H4>
181
+ <Span>{formatCurrency(deliveryOption.TotalChargeAmount || 0)}</Span>
182
+ </Box>
183
+ );
184
+ };
185
+
186
+ DeliveryOptions.Form = ({
187
+ deliveryOptions,
188
+ deliveryUnavailable,
189
+ selectedOption,
190
+ onChange,
191
+ }) => {
192
+ const t = useTranslations("Checkout.DeliveryOptions");
193
+ const { formatCurrency } = useCurrencyFormatter();
194
+
132
195
  const renderChargeLine = (dlvOption: DeliveryOption) => (
133
196
  <Grid container justifyContent={"space-between"}>
134
197
  <Paragraph>{dlvOption.Description}</Paragraph>
@@ -136,23 +199,6 @@ export default function DeliveryOptions(props: CheckoutStepComponentProps) {
136
199
  </Grid>
137
200
  );
138
201
 
139
- if (stepViewState === "pending") {
140
- return;
141
- }
142
-
143
- if (stepViewState === "preview") {
144
- const deliveryOption = deliveryOptions.find(
145
- (dlv) => dlv.Code === selectedOption,
146
- );
147
- if (deliveryOption) {
148
- return (
149
- <Box mt={2}>
150
- <H4>{deliveryOption.Description}</H4>
151
- <Span>{formatCurrency(deliveryOption.TotalChargeAmount || 0)}</Span>
152
- </Box>
153
- );
154
- }
155
- }
156
202
  return (
157
203
  <Box mb={3.5}>
158
204
  <Grid container spacing={1}>
@@ -164,14 +210,13 @@ export default function DeliveryOptions(props: CheckoutStepComponentProps) {
164
210
  {t("noDeliveryOptionsFound")}
165
211
  </Paragraph>
166
212
  )}
167
- {/* <FormLabel id={"deliveryOptions"}>{t("deliveryOptionsLabel")}</FormLabel> */}
168
213
  <RadioGroup
169
214
  aria-labelledby={"deliveryOptions"}
170
215
  name={"Delivery-Options"}
171
- onChange={handleOptionChange}
216
+ onChange={(event) => onChange(event.target.value)}
172
217
  value={selectedOption}
173
218
  >
174
- {deliveryOptions?.map((dlv) => (
219
+ {deliveryOptions.map((dlv) => (
175
220
  <FormControlLabel
176
221
  sx={{ ".MuiFormControlLabel-label": { width: "100%" } }}
177
222
  key={dlv.Code}
@@ -187,4 +232,6 @@ export default function DeliveryOptions(props: CheckoutStepComponentProps) {
187
232
  </Grid>
188
233
  </Box>
189
234
  );
190
- }
235
+ };
236
+
237
+ export default DeliveryOptions;