@evenicanpm/storefront-core 1.2.2 → 1.4.0

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 (449) hide show
  1. package/.storybook/main.ts +1 -1
  2. package/.storybook/preview.tsx +5 -4
  3. package/__mocks__/countries.ts +1 -1
  4. package/__mocks__/create-query.ts +3 -2
  5. package/__mocks__/get-product-by-id.ts +0 -1
  6. package/__mocks__/query-client.ts +1 -1
  7. package/package.json +10 -2
  8. package/src/api-manager/datasources/d365/d365-address.datasource.ts +15 -13
  9. package/src/api-manager/datasources/d365/d365-base.datasource.ts +1 -1
  10. package/src/api-manager/datasources/d365/d365-cart.datasource.ts +41 -42
  11. package/src/api-manager/datasources/d365/d365-categories.datasource.ts +4 -4
  12. package/src/api-manager/datasources/d365/d365-order.datasource.ts +10 -9
  13. package/src/api-manager/datasources/d365/d365-organization.datasource.ts +10 -10
  14. package/src/api-manager/datasources/d365/d365-product.datasource.ts +49 -36
  15. package/src/api-manager/datasources/d365/d365-session.datasource.ts +7 -9
  16. package/src/api-manager/datasources/d365/d365-user.datasource.ts +34 -43
  17. package/src/api-manager/datasources/d365/d365.datasource.ts +15 -17
  18. package/src/api-manager/datasources/d365/index.ts +2 -4
  19. package/src/api-manager/datasources/d365/test-context.ts +1 -1
  20. package/src/api-manager/datasources/d365/utils/create-search-criteria.ts +1 -1
  21. package/src/api-manager/datasources/d365/utils/decode-jwt.ts +1 -2
  22. package/src/api-manager/datasources/d365/utils/get-context-cookie.ts +3 -3
  23. package/src/api-manager/datasources/d365/utils/parse-object.ts +1 -1
  24. package/src/api-manager/datasources/d365/utils/product-images-utils.ts +29 -10
  25. package/src/api-manager/datasources/d365/utils/product-inventory-utils.ts +1 -1
  26. package/src/api-manager/datasources/e4/address/e4-address.datasource.ts +5 -5
  27. package/src/api-manager/datasources/e4/address/e4-address.remaps.ts +4 -4
  28. package/src/api-manager/datasources/e4/address/e4-address.translator.ts +9 -9
  29. package/src/api-manager/datasources/e4/cart/e4-cart.datasource.ts +37 -37
  30. package/src/api-manager/datasources/e4/cart/e4-cart.remaps.ts +10 -9
  31. package/src/api-manager/datasources/e4/cart/e4-cart.translator.ts +4 -4
  32. package/src/api-manager/datasources/e4/categories/e4-categories.datasource.ts +4 -4
  33. package/src/api-manager/datasources/e4/categories/e4-categories.translator.ts +24 -24
  34. package/src/api-manager/datasources/e4/e4.datasource.ts +7 -7
  35. package/src/api-manager/datasources/e4/graphqlRequestSdk.ts +8103 -41393
  36. package/src/api-manager/datasources/e4/order/e4-order.datasource.ts +7 -7
  37. package/src/api-manager/datasources/e4/order/e4-order.remaps.ts +8 -7
  38. package/src/api-manager/datasources/e4/organization/e4-organization.datasource.ts +4 -9
  39. package/src/api-manager/datasources/e4/product/e4-product.datasource.ts +12 -11
  40. package/src/api-manager/datasources/e4/product/e4-product.remaps.ts +4 -4
  41. package/src/api-manager/datasources/e4/product/e4-product.translator.ts +27 -43
  42. package/src/api-manager/datasources/e4/session/e4-session.datasource.ts +3 -5
  43. package/src/api-manager/datasources/e4/session/e4-session.translator.ts +2 -2
  44. package/src/api-manager/datasources/e4/user/e4-user.datasource.ts +10 -10
  45. package/src/api-manager/datasources/e4/user/e4-user.remaps.ts +6 -8
  46. package/src/api-manager/datasources/e4/user/e4-user.translator.ts +6 -4
  47. package/src/api-manager/datasources/e4/utils/unwrap-e4-variants.ts +6 -6
  48. package/src/api-manager/index.ts +8 -8
  49. package/src/api-manager/lib/category-helpers.ts +4 -3
  50. package/src/api-manager/lib/get-dynamics-context.ts +1 -1
  51. package/src/api-manager/lib/get-graphql-client.ts +4 -6
  52. package/src/api-manager/schemas/address.schema.ts +1 -1
  53. package/src/api-manager/schemas/cart.schema.ts +1 -1
  54. package/src/api-manager/schemas/d365.schema.ts +207 -206
  55. package/src/api-manager/schemas/order.schema.ts +1 -1
  56. package/src/api-manager/schemas/organization.schema.ts +1 -1
  57. package/src/api-manager/schemas/product.schema.ts +4 -4
  58. package/src/api-manager/schemas/session.schema.ts +1 -1
  59. package/src/api-manager/schemas/user.schema.ts +1 -1
  60. package/src/api-manager/services/address/mutations/create-address.ts +3 -3
  61. package/src/api-manager/services/address/mutations/delete-address.ts +2 -2
  62. package/src/api-manager/services/address/mutations/get-delivery-options.ts +4 -4
  63. package/src/api-manager/services/address/mutations/update-address.ts +3 -3
  64. package/src/api-manager/services/address/queries/get-countries.ts +6 -4
  65. package/src/api-manager/services/address/queries/get-states.ts +3 -3
  66. package/src/api-manager/services/cart/mutations/add-discount-code.ts +6 -6
  67. package/src/api-manager/services/cart/mutations/add-to-cart.ts +6 -6
  68. package/src/api-manager/services/cart/mutations/checkout.ts +2 -2
  69. package/src/api-manager/services/cart/mutations/delete-cart-line.ts +2 -2
  70. package/src/api-manager/services/cart/mutations/get-payment-accept-result.ts +4 -4
  71. package/src/api-manager/services/cart/mutations/remove-cart-line-delivery-mode.ts +3 -3
  72. package/src/api-manager/services/cart/mutations/remove-discount-code.ts +2 -2
  73. package/src/api-manager/services/cart/mutations/update-cart-line-delivery-mode.ts +2 -2
  74. package/src/api-manager/services/cart/mutations/update-cart-lines.ts +3 -3
  75. package/src/api-manager/services/cart/mutations/update-cart.ts +2 -2
  76. package/src/api-manager/services/cart/queries/get-cart-lines-inventory.ts +2 -2
  77. package/src/api-manager/services/cart/queries/get-cart.ts +5 -3
  78. package/src/api-manager/services/cart/queries/get-payment-accept-point.ts +3 -3
  79. package/src/api-manager/services/categories/queries/get-categories.ts +1 -1
  80. package/src/api-manager/services/create-extension-query.ts +1 -1
  81. package/src/api-manager/services/create-mutation.ts +2 -2
  82. package/src/api-manager/services/create-query.ts +6 -6
  83. package/src/api-manager/services/get-query-client.ts +2 -2
  84. package/src/api-manager/services/order/queries/get-order-details.ts +2 -2
  85. package/src/api-manager/services/order/queries/get-orders.ts +1 -1
  86. package/src/api-manager/services/organization/queries/get-channel-configuration.ts +1 -1
  87. package/src/api-manager/services/organization/queries/get-stores.ts +1 -1
  88. package/src/api-manager/services/product/mutations/search-products.ts +3 -4
  89. package/src/api-manager/services/product/queries/get-product-availability.ts +2 -2
  90. package/src/api-manager/services/product/queries/get-product-by-id.ts +1 -1
  91. package/src/api-manager/services/product/queries/get-product-by-ids.ts +2 -2
  92. package/src/api-manager/services/product/queries/get-product-list.ts +1 -1
  93. package/src/api-manager/services/product/queries/get-product-prices.ts +2 -2
  94. package/src/api-manager/services/product/queries/get-related-products.ts +2 -2
  95. package/src/api-manager/services/product/queries/search-products.ts +2 -2
  96. package/src/api-manager/services/product/server/product.server.ts +4 -4
  97. package/src/api-manager/services/session/mutations/session-init.ts +2 -2
  98. package/src/api-manager/services/session/mutations/session-logout.ts +1 -1
  99. package/src/api-manager/services/session/queries/get-session.ts +1 -1
  100. package/src/api-manager/services/user/mutations/add-to-wishlist.ts +3 -3
  101. package/src/api-manager/services/user/mutations/copy-cart-to-wishlist.ts +3 -3
  102. package/src/api-manager/services/user/mutations/create-wishlist.ts +4 -4
  103. package/src/api-manager/services/user/mutations/delete-wishlist.ts +3 -3
  104. package/src/api-manager/services/user/mutations/remove-from-wishlist.ts +3 -3
  105. package/src/api-manager/services/user/mutations/update-user.ts +2 -2
  106. package/src/api-manager/services/user/mutations/update-wishlist.ts +2 -2
  107. package/src/api-manager/services/user/queries/get-user-counts.ts +1 -1
  108. package/src/api-manager/services/user/queries/get-user.ts +1 -1
  109. package/src/api-manager/services/user/queries/get-wishlist-details.ts +1 -1
  110. package/src/api-manager/services/user/queries/get-wishlists.ts +1 -1
  111. package/src/api-manager/types/Datasource.ts +23 -28
  112. package/src/auth/auth-options.test.ts +6 -63
  113. package/src/auth/auth-options.ts +6 -7
  114. package/src/auth/msal.ts +4 -1
  115. package/src/auth/next-auth-cookie-manager.ts +7 -8
  116. package/src/auth/refresh-token.ts +5 -7
  117. package/src/auth/signout.ts +1 -1
  118. package/src/cms/blocks/block-manager.tsx +13 -13
  119. package/src/cms/blocks/components/brand-logos-scroller.tsx +4 -4
  120. package/src/cms/blocks/components/category-card.tsx +3 -3
  121. package/src/cms/blocks/components/category-carousel/index.tsx +8 -10
  122. package/src/cms/blocks/components/feature-pill.tsx +5 -4
  123. package/src/cms/blocks/components/featured-categories.tsx +5 -2
  124. package/src/cms/blocks/components/featured-products.tsx +2 -2
  125. package/src/cms/blocks/components/footer/data/index.ts +6 -3
  126. package/src/cms/blocks/components/footer/index.tsx +9 -13
  127. package/src/cms/blocks/components/footer/sections/footer-app-store.tsx +2 -2
  128. package/src/cms/blocks/components/footer/sections/footer-contact.tsx +3 -3
  129. package/src/cms/blocks/components/footer/sections/footer-links.tsx +5 -5
  130. package/src/cms/blocks/components/footer/sections/footer-logo.tsx +4 -4
  131. package/src/cms/blocks/components/footer/sections/footer-social-links.tsx +19 -11
  132. package/src/cms/blocks/components/footer/styles/index.ts +1 -1
  133. package/src/cms/blocks/components/footer.tsx +4 -4
  134. package/src/cms/blocks/components/hero-carousel/index.tsx +32 -29
  135. package/src/cms/blocks/components/hero.tsx +4 -5
  136. package/src/cms/blocks/components/image.tsx +4 -5
  137. package/src/cms/blocks/components/media-card.tsx +3 -3
  138. package/src/cms/blocks/components/product-carousel/index.tsx +8 -9
  139. package/src/cms/blocks/components/product-section-fullwidth/index.tsx +18 -22
  140. package/src/cms/blocks/components/rich-text.tsx +2 -2
  141. package/src/cms/blocks/components/seo/index.tsx +7 -3
  142. package/src/cms/blocks/components/services/index.tsx +5 -5
  143. package/src/cms/blocks/components/services/service-card.tsx +8 -10
  144. package/src/cms/blocks/components/shared/featured-product-card.tsx +6 -3
  145. package/src/cms/blocks/components/shared/product-category-item.tsx +5 -6
  146. package/src/cms/blocks/components/shared/product-grid.tsx +9 -5
  147. package/src/cms/blocks/components/shared/top-categories-card.tsx +10 -7
  148. package/src/cms/blocks/components/shared/top-rating-product-card.tsx +4 -4
  149. package/src/cms/blocks/icons/components/category.tsx +3 -3
  150. package/src/cms/blocks/icons/components/dotted-star.tsx +1 -1
  151. package/src/cms/blocks/icons/components/fallback-icon.tsx +1 -1
  152. package/src/cms/blocks/icons/components/gift-box.tsx +1 -1
  153. package/src/cms/blocks/icons/components/light.tsx +1 -1
  154. package/src/cms/blocks/icons/components/new-arrival.tsx +1 -1
  155. package/src/cms/blocks/icons/components/rank-badge.tsx +1 -1
  156. package/src/cms/blocks/icons/index.ts +3 -3
  157. package/src/cms/blocks/index.tsx +6 -6
  158. package/src/cms/blog.ts +2 -2
  159. package/src/cms/endpoints.ts +1 -1
  160. package/src/components-v2/BazaarCard.stories.tsx +1 -1
  161. package/src/components-v2/BazaarCard.tsx +1 -1
  162. package/src/components-v2/BazaarImage.tsx +2 -2
  163. package/src/components-v2/BazaarMenu.stories.tsx +1 -1
  164. package/src/components-v2/BazaarMenu.tsx +4 -4
  165. package/src/components-v2/BazaarSwitch.tsx +1 -1
  166. package/src/components-v2/BazaarTextField.tsx +5 -5
  167. package/src/components-v2/BorderShadowCard.stories.tsx +2 -2
  168. package/src/components-v2/CountryInput.stories.tsx +2 -2
  169. package/src/components-v2/DropZone.stories.tsx +1 -1
  170. package/src/components-v2/DropZone.tsx +8 -9
  171. package/src/components-v2/HoverBox.stories.tsx +1 -1
  172. package/src/components-v2/ImageWithFallback.tsx +3 -2
  173. package/src/components-v2/LazyImage.tsx +10 -2
  174. package/src/components-v2/Loading.tsx +1 -2
  175. package/src/components-v2/SearchInput.stories.tsx +1 -1
  176. package/src/components-v2/SearchInput.tsx +2 -2
  177. package/src/components-v2/SnackbarProvider.tsx +1 -1
  178. package/src/components-v2/T/index.tsx +1 -1
  179. package/src/components-v2/Typography.stories.tsx +2 -2
  180. package/src/components-v2/Typography.tsx +13 -13
  181. package/src/components-v2/WhiteButton.tsx +2 -2
  182. package/src/components-v2/accordion/accordion-header.tsx +6 -6
  183. package/src/components-v2/carousel/Carousel.stories.tsx +1 -1
  184. package/src/components-v2/carousel/carousel.tsx +4 -4
  185. package/src/components-v2/carousel/components/carousel-arrows.tsx +4 -4
  186. package/src/components-v2/carousel/components/carousel-dots.tsx +2 -2
  187. package/src/components-v2/carousel-cards/carousel-card-1/carousel-card-1.tsx +4 -4
  188. package/src/components-v2/categories/Categories.stories.tsx +6 -5
  189. package/src/components-v2/categories/category-list/category-list.tsx +4 -5
  190. package/src/components-v2/categories/category-list/styles.ts +2 -9
  191. package/src/components-v2/categories/category-list-item/category-menu-item.tsx +6 -6
  192. package/src/components-v2/categories/category-menu.tsx +18 -15
  193. package/src/components-v2/categories/mega-menu/banner.tsx +4 -4
  194. package/src/components-v2/categories/mega-menu/column-list.tsx +6 -6
  195. package/src/components-v2/categories/mega-menu/mega-menu-1.tsx +8 -8
  196. package/src/components-v2/categories/mega-menu/mega-menu-2.tsx +5 -4
  197. package/src/components-v2/categories/types.ts +1 -1
  198. package/src/components-v2/countries-input.tsx +2 -2
  199. package/src/components-v2/flex-box/Flex.stories.tsx +1 -1
  200. package/src/components-v2/flex-box/flex-between.tsx +1 -1
  201. package/src/components-v2/flex-box/flex-box.tsx +1 -1
  202. package/src/components-v2/flex-box/flex-row-center.tsx +1 -1
  203. package/src/components-v2/flex-box/index.ts +1 -1
  204. package/src/components-v2/header/__tests__/user.test.tsx +3 -3
  205. package/src/components-v2/header/components/categories-menu.tsx +6 -6
  206. package/src/components-v2/header/components/mobile-header.tsx +17 -18
  207. package/src/components-v2/header/components/user.tsx +29 -28
  208. package/src/components-v2/header/header.tsx +9 -10
  209. package/src/components-v2/header/sticky-header.tsx +3 -3
  210. package/src/components-v2/header/styles/index.ts +3 -2
  211. package/src/components-v2/mini-cart/__tests__/cart-item.test.tsx +18 -18
  212. package/src/components-v2/mini-cart/__tests__/mini-cart.test.tsx +7 -7
  213. package/src/components-v2/mini-cart/components/bottom-actions.tsx +4 -3
  214. package/src/components-v2/mini-cart/components/cart-item.tsx +16 -15
  215. package/src/components-v2/mini-cart/components/empty-view.tsx +2 -1
  216. package/src/components-v2/mini-cart/components/top-header.tsx +8 -7
  217. package/src/components-v2/mini-cart/mini-cart-trigger.tsx +4 -4
  218. package/src/components-v2/mini-cart/mini-cart.tsx +11 -12
  219. package/src/components-v2/mobile-navigation/MobileNavigationBar.stories.tsx +2 -2
  220. package/src/components-v2/mobile-navigation/mobile-navigation-bar.tsx +15 -15
  221. package/src/components-v2/mobile-navigation/styles/index.ts +2 -2
  222. package/src/components-v2/nav-link/nav-link-2.tsx +2 -2
  223. package/src/components-v2/nav-link/nav-link-3.tsx +4 -4
  224. package/src/components-v2/nav-link/nav-link.tsx +4 -4
  225. package/src/components-v2/navbar/categories.tsx +8 -6
  226. package/src/components-v2/navbar/category-based-menu/category-based-menu.tsx +17 -16
  227. package/src/components-v2/navbar/category-based-menu/styles.ts +3 -3
  228. package/src/components-v2/navbar/category-based-menu/types.ts +1 -1
  229. package/src/components-v2/navbar/mega-menu/mega-menu.tsx +11 -10
  230. package/src/components-v2/navbar/mega-menu/styles.ts +2 -2
  231. package/src/components-v2/navbar/mobile-menu/mobile-menu.test.tsx +3 -3
  232. package/src/components-v2/navbar/mobile-menu/mobile-menu.tsx +21 -13
  233. package/src/components-v2/navbar/nav-list/cms-nav.test.tsx +4 -4
  234. package/src/components-v2/navbar/nav-list/nav-item-child.tsx +13 -14
  235. package/src/components-v2/navbar/nav-list/nav-list.tsx +128 -90
  236. package/src/components-v2/navbar/navbar.tsx +4 -5
  237. package/src/components-v2/navbar/styles.ts +4 -4
  238. package/src/components-v2/navbar/utils/transform-nav.test.ts +3 -3
  239. package/src/components-v2/navbar/utils/transform-nav.ts +3 -3
  240. package/src/components-v2/no-records.tsx +3 -3
  241. package/src/components-v2/product-cards/discount-chip.tsx +1 -1
  242. package/src/components-v2/product-cards/favorite-button.tsx +3 -3
  243. package/src/components-v2/product-cards/product-card/ProductCard.stories.tsx +2 -2
  244. package/src/components-v2/product-cards/product-card/product-card.tsx +43 -45
  245. package/src/components-v2/product-cards/product-card/styles/index.ts +2 -2
  246. package/src/components-v2/product-cards/product-card-plp/ProductCardPlp.stories.tsx +2 -2
  247. package/src/components-v2/product-cards/product-card-plp/product-card.tsx +25 -24
  248. package/src/components-v2/product-cards/product-card-plp-list/ProductCardPlpList.stories.tsx +1 -1
  249. package/src/components-v2/product-cards/product-card-plp-list/components/tags.tsx +1 -1
  250. package/src/components-v2/product-cards/product-card-plp-list/product-card.tsx +22 -19
  251. package/src/components-v2/product-cards/product-card-search/ProductCardSearch.stories.tsx +2 -2
  252. package/src/components-v2/product-cards/product-card-search/product-card.tsx +20 -18
  253. package/src/components-v2/product-cards/product-price.tsx +2 -2
  254. package/src/components-v2/product-cards/product-rating.tsx +4 -4
  255. package/src/components-v2/product-cards/product-title.tsx +2 -2
  256. package/src/components-v2/product-cards/quantity-buttons.tsx +6 -6
  257. package/src/components-v2/product-dialog/ProductDialog.stories.tsx +2 -2
  258. package/src/components-v2/product-dialog/compound/product-dialog.tsx +16 -16
  259. package/src/components-v2/product-dialog/index.tsx +1 -1
  260. package/src/components-v2/product-dimensions/Dimensions.stories.tsx +3 -2
  261. package/src/components-v2/product-dimensions/compound/dimensions-group-error.tsx +3 -3
  262. package/src/components-v2/product-dimensions/compound/dimensions-group-label.tsx +1 -1
  263. package/src/components-v2/product-dimensions/compound/dimensions-group-list-chip.tsx +5 -4
  264. package/src/components-v2/product-dimensions/compound/dimensions-group-list.tsx +7 -2
  265. package/src/components-v2/product-dimensions/compound/dimensions-group.tsx +3 -4
  266. package/src/components-v2/product-dimensions/compound/dimensions.tsx +6 -2
  267. package/src/components-v2/product-dimensions/index.tsx +4 -4
  268. package/src/components-v2/product-dimensions/utils/has-selected-dimension.ts +1 -1
  269. package/src/components-v2/product-quantity-buttons/ProductQuantity.stories.tsx +2 -1
  270. package/src/components-v2/product-quantity-buttons/compound/quantity-buttons-root.tsx +8 -8
  271. package/src/components-v2/product-quantity-buttons/index.tsx +5 -2
  272. package/src/components-v2/product-quantity-variants/ProductQuantity.stories.tsx +3 -2
  273. package/src/components-v2/product-quantity-variants/index.tsx +14 -15
  274. package/src/components-v2/products-view/ProductsGrid.stories.tsx +3 -2
  275. package/src/components-v2/products-view/ProductsList.stories.tsx +3 -4
  276. package/src/components-v2/products-view/compound/context.ts +4 -3
  277. package/src/components-v2/products-view/compound/products-grid-view.tsx +9 -8
  278. package/src/components-v2/products-view/compound/products-list-view.tsx +9 -8
  279. package/src/components-v2/products-view/compound/types.ts +2 -2
  280. package/src/components-v2/products-view/index.tsx +5 -5
  281. package/src/components-v2/progress/ProgressBar.stories.tsx +2 -2
  282. package/src/components-v2/progress/progress.tsx +4 -4
  283. package/src/components-v2/scrollbar/Scrollbar.stories.tsx +2 -1
  284. package/src/components-v2/scrollbar/scrollbar.tsx +4 -4
  285. package/src/components-v2/search-bar/SearchBarLarge.stories.tsx +2 -1
  286. package/src/components-v2/search-bar/compound/context.ts +2 -3
  287. package/src/components-v2/search-bar/compound/results-item-lg.tsx +3 -2
  288. package/src/components-v2/search-bar/compound/results-item-sm.tsx +10 -9
  289. package/src/components-v2/search-bar/compound/results-suspense.tsx +5 -6
  290. package/src/components-v2/search-bar/compound/results.tsx +11 -7
  291. package/src/components-v2/search-bar/compound/search-bar-root.tsx +10 -10
  292. package/src/components-v2/search-bar/compound/textfield-adornment-category.tsx +32 -33
  293. package/src/components-v2/search-bar/compound/textfield-adornment-search-icon.tsx +3 -2
  294. package/src/components-v2/search-bar/compound/textfield.tsx +5 -8
  295. package/src/components-v2/search-bar/hooks/use-search.ts +2 -3
  296. package/src/components-v2/search-bar/styles/index.ts +2 -2
  297. package/src/components-v2/search-bar/utils/findCategoryNameById.ts +1 -1
  298. package/src/components-v2/section/Section.stories.tsx +4 -4
  299. package/src/components-v2/section/compound/section-header.tsx +7 -7
  300. package/src/components-v2/section/compound/section.tsx +4 -3
  301. package/src/components-v2/side-nav/SideNav.stories.tsx +4 -4
  302. package/src/components-v2/side-nav/side-nav.tsx +3 -3
  303. package/src/components-v2/wishlist-dialogs/__tests__/create-new-list.test.tsx +5 -7
  304. package/src/components-v2/wishlist-dialogs/add-to-wishlist/AddToWishlist.stories.tsx +2 -2
  305. package/src/components-v2/wishlist-dialogs/add-to-wishlist/add-to-wishlist-button.tsx +2 -2
  306. package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/add-to-wishlist-bottom-ui.tsx +3 -3
  307. package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/add-to-wishlist-dialog.tsx +8 -9
  308. package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/add-to-wishlist-list.tsx +6 -7
  309. package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/context.ts +2 -1
  310. package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/wishlist-dialog-header.tsx +8 -10
  311. package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/wishlist-dialog-item.tsx +6 -6
  312. package/src/components-v2/wishlist-dialogs/add-to-wishlist/hooks/use-add-to-wishlist.ts +6 -6
  313. package/src/components-v2/wishlist-dialogs/add-to-wishlist/index.tsx +11 -13
  314. package/src/components-v2/wishlist-dialogs/create-wishlist/compound/create-wishlist-bottom-ui.tsx +3 -3
  315. package/src/components-v2/wishlist-dialogs/create-wishlist/compound/create-wishlist-dialog.tsx +11 -9
  316. package/src/components-v2/wishlist-dialogs/create-wishlist/compound/create-wishlist-form.tsx +6 -4
  317. package/src/components-v2/wishlist-dialogs/create-wishlist/create-wishlist-button.tsx +2 -2
  318. package/src/components-v2/wishlist-dialogs/styles.ts +4 -4
  319. package/src/hooks/use-cart.ts +1 -1
  320. package/src/hooks/use-nextauth-session.ts +65 -0
  321. package/src/hooks/use-overflow-detect.ts +1 -1
  322. package/src/hooks/use-settings.ts +1 -1
  323. package/src/hooks/use-variants.ts +29 -31
  324. package/src/lib/build-detail-url.ts +1 -1
  325. package/src/lib/build-product-detail-url.ts +1 -1
  326. package/src/lib/cart-cookie-handler.ts +1 -1
  327. package/src/lib/category-helpers.ts +4 -4
  328. package/src/lib/create-graphql-client.ts +1 -2
  329. package/src/lib/get-palette-color.ts +36 -16
  330. package/src/lib/graphqlRequestSdk.ts +2 -3
  331. package/src/lib/hexToLuma.ts +4 -4
  332. package/src/lib/product-list-types.ts +1 -1
  333. package/src/lib/refiner-utils.ts +1 -1
  334. package/src/lib/store-hours-helper.ts +6 -6
  335. package/src/pages-v2/account/account-navigation.tsx +13 -13
  336. package/src/pages-v2/account/addresses/address-form.tsx +26 -23
  337. package/src/pages-v2/account/addresses/address-item.tsx +14 -15
  338. package/src/pages-v2/account/dashboard-header.tsx +9 -9
  339. package/src/pages-v2/account/orders/order-progress.tsx +14 -14
  340. package/src/pages-v2/account/orders/order-row.tsx +11 -10
  341. package/src/pages-v2/account/orders/order-summary.tsx +7 -6
  342. package/src/pages-v2/account/orders/ordered-products.tsx +19 -18
  343. package/src/pages-v2/account/profile/profile-button.test.tsx +3 -3
  344. package/src/pages-v2/account/profile/profile-button.tsx +5 -4
  345. package/src/pages-v2/account/profile/user-info.tsx +8 -10
  346. package/src/pages-v2/account/styles.ts +1 -1
  347. package/src/pages-v2/account/wishlist/create-new-list.tsx +11 -9
  348. package/src/pages-v2/account/wishlist/create-wishlist-button.tsx +2 -2
  349. package/src/pages-v2/account/wishlist/wishlist-item.tsx +15 -14
  350. package/src/pages-v2/blog/blog-card.tsx +58 -0
  351. package/src/pages-v2/blog/pagination.tsx +1 -2
  352. package/src/pages-v2/cart/__tests__/cart-item.test.tsx +8 -10
  353. package/src/pages-v2/cart/__tests__/checkout-form.test.tsx +8 -16
  354. package/src/pages-v2/cart/__tests__/countries.json +19407 -0
  355. package/src/pages-v2/cart/__tests__/estimate-shipping.test.tsx +11 -11
  356. package/src/pages-v2/cart/cart-item.tsx +110 -100
  357. package/src/pages-v2/cart/checkout-form.tsx +20 -22
  358. package/src/pages-v2/cart/coupon-entry.tsx +12 -10
  359. package/src/pages-v2/cart/estimate-shipping.tsx +11 -10
  360. package/src/pages-v2/checkout/checkout-alt-form/checkout-form.tsx +19 -18
  361. package/src/pages-v2/checkout/checkout-alt-form/checkout-step.tsx +7 -7
  362. package/src/pages-v2/checkout/checkout-alt-form/step-heading.tsx +4 -4
  363. package/src/pages-v2/checkout/checkout-alt-form/steps/address/address-card.tsx +4 -4
  364. package/src/pages-v2/checkout/checkout-alt-form/steps/address/delivery-address.tsx +33 -31
  365. package/src/pages-v2/checkout/checkout-alt-form/steps/address/new-address-form.tsx +19 -21
  366. package/src/pages-v2/checkout/checkout-alt-form/steps/address/styles.ts +1 -1
  367. package/src/pages-v2/checkout/checkout-alt-form/steps/customer-info/customer-information.tsx +16 -17
  368. package/src/pages-v2/checkout/checkout-alt-form/steps/payment/payment-details.tsx +25 -28
  369. package/src/pages-v2/checkout/checkout-alt-form/steps/payment/safe-card-preview-data.tsx +2 -2
  370. package/src/pages-v2/checkout/checkout-alt-form/steps/shipping/delivery-date.tsx +5 -5
  371. package/src/pages-v2/checkout/checkout-alt-form/steps/shipping/delivery-options.tsx +33 -34
  372. package/src/pages-v2/checkout/checkout-alt-summary/cart-item.tsx +2 -2
  373. package/src/pages-v2/checkout/checkout-alt-summary/checkout-alt-summary.tsx +9 -9
  374. package/src/pages-v2/checkout/checkout-alt-summary/list-item.tsx +2 -2
  375. package/src/pages-v2/confirmation/address.tsx +4 -4
  376. package/src/pages-v2/confirmation/confirmation-summary.tsx +11 -10
  377. package/src/pages-v2/confirmation/ordered-products.tsx +12 -11
  378. package/src/pages-v2/product-details/available-shops.tsx +6 -6
  379. package/src/pages-v2/product-details/bopis/find-in-store-button.tsx +3 -3
  380. package/src/pages-v2/product-details/bopis/find-in-store-modal.tsx +16 -17
  381. package/src/pages-v2/product-details/bopis/pickup-option-select.tsx +5 -5
  382. package/src/pages-v2/product-details/bopis/search-header.tsx +3 -2
  383. package/src/pages-v2/product-details/bopis/store-card/shop-card.tsx +15 -16
  384. package/src/pages-v2/product-details/bopis/store-card/utils/getDaysResources.ts +1 -1
  385. package/src/pages-v2/product-details/checkbox-label.tsx +3 -3
  386. package/src/pages-v2/product-details/currency.ts +1 -0
  387. package/src/pages-v2/product-details/frequently-bought.tsx +12 -12
  388. package/src/pages-v2/product-details/frequently-product-card.tsx +5 -5
  389. package/src/pages-v2/product-details/product-comment.tsx +4 -4
  390. package/src/pages-v2/product-details/product-description.tsx +3 -3
  391. package/src/pages-v2/product-details/product-filter-card.tsx +17 -14
  392. package/src/pages-v2/product-details/product-intro/compound/context.ts +10 -5
  393. package/src/pages-v2/product-details/product-intro/compound/product-info.tsx +19 -19
  394. package/src/pages-v2/product-details/product-intro/compound/product-intro-images.tsx +39 -33
  395. package/src/pages-v2/product-details/product-intro/compound/product-intro.tsx +7 -7
  396. package/src/pages-v2/product-details/product-intro/compound/thumbnail-with-skeleton.tsx +2 -2
  397. package/src/pages-v2/product-details/product-intro/utils.ts +3 -5
  398. package/src/pages-v2/product-details/product-review.tsx +9 -9
  399. package/src/pages-v2/product-details/product-tabs.tsx +11 -8
  400. package/src/pages-v2/product-details/related-products.tsx +12 -9
  401. package/src/pages-v2/product-list/breadcrumbs.tsx +3 -3
  402. package/src/pages-v2/product-list/checkbox-label.tsx +3 -3
  403. package/src/pages-v2/product-list/facet-group.tsx +8 -8
  404. package/src/pages-v2/product-list/facet.tsx +4 -3
  405. package/src/pages-v2/product-list/list-filter.tsx +6 -6
  406. package/src/pages-v2/product-list/pagination.tsx +2 -2
  407. package/src/pages-v2/product-list/product-list-context.tsx +22 -18
  408. package/src/pages-v2/product-list/product-list-state.ts +14 -14
  409. package/src/pages-v2/product-list/product-list-view.tsx +18 -17
  410. package/src/pages-v2/product-list/product-rating.tsx +6 -3
  411. package/src/pages-v2/product-list/quick-view-dialog-content.tsx +21 -23
  412. package/src/pages-v2/product-list/quick-view-dialog.tsx +7 -3
  413. package/src/pages-v2/product-list/range-filter.tsx +5 -6
  414. package/src/pages-v2/product-list/scrollbar.tsx +4 -4
  415. package/src/pages-v2/product-list/search-bar.tsx +12 -12
  416. package/src/pages-v2/product-list/selected-facets.tsx +4 -4
  417. package/src/pages-v2/product-list/side-nav.tsx +2 -2
  418. package/src/pages-v2/product-list/swatch.tsx +15 -11
  419. package/src/pages-v2/product-list/utils/generate-breadcrumbs.ts +1 -1
  420. package/src/pages-v2/product-list/utils/getCategoryFilterFromSlug.ts +33 -68
  421. package/src/pages-v2/product-list/utils/product-list-helper.ts +5 -5
  422. package/src/pages-v2/product-list/utils/product-list-types.ts +1 -1
  423. package/src/pages-v2/product-list/utils/search-for-category.ts +4 -4
  424. package/src/pages-v2/product-list/utils/sort-options.ts +1 -1
  425. package/src/pages-v2/quickorder/order-upload.tsx +92 -78
  426. package/src/pages-v2/quickorder/provider.tsx +13 -10
  427. package/src/pages-v2/quickorder/quick-order-header.tsx +1 -1
  428. package/src/pages-v2/quickorder/quick-order-row.tsx +9 -8
  429. package/src/pages-v2/quickorder/quick-order-table.tsx +3 -3
  430. package/src/pages-v2/quickorder/quick-order.tsx +48 -43
  431. package/src/providers/nav-provider/index.tsx +3 -3
  432. package/src/providers/nav-provider/utils/createLink.ts +1 -1
  433. package/src/providers/notifications/notification-context.tsx +3 -4
  434. package/src/providers/notifications/use-notification.ts +1 -1
  435. package/tsconfig.json +1 -1
  436. package/src/components-v2/sticky/Sticky.stories.tsx +0 -88
  437. package/src/components-v2/sticky/index.ts +0 -1
  438. package/src/components-v2/sticky/sticky.tsx +0 -62
  439. package/src/components-v2/sticky/styles.ts +0 -38
  440. package/src/components-v2/utils/constants.ts +0 -8
  441. package/src/theme/build-mui-theme.ts +0 -104
  442. package/src/theme/components.ts +0 -163
  443. package/src/theme/emotion-cache.tsx +0 -101
  444. package/src/theme/theme-colors.ts +0 -205
  445. package/src/theme/theme-options-sample.ts +0 -69
  446. package/src/theme/theme-options.ts +0 -172
  447. package/src/theme/theme-provider.tsx +0 -44
  448. package/src/theme/typography.ts +0 -22
  449. package/src/theme/utils.ts +0 -17
@@ -1,38 +1,37 @@
1
+ import type { Cart } from "@evenicanpm/storefront-core/src/api-manager/schemas/cart.schema";
2
+ import type {
3
+ InventorySearchCriteriaInput,
4
+ ProductDetails,
5
+ } from "@evenicanpm/storefront-core/src/api-manager/schemas/product.schema";
6
+ import getProductAvailability from "@evenicanpm/storefront-core/src/api-manager/services/product/queries/get-product-availability";
1
7
  import { FlexBox } from "@evenicanpm/storefront-core/src/components-v2/flex-box";
8
+ import ImageWithFallback from "@evenicanpm/storefront-core/src/components-v2/ImageWithFallback";
9
+ import ProductDimensions from "@evenicanpm/storefront-core/src/components-v2/product-dimensions";
10
+ import QuantityButtons from "@evenicanpm/storefront-core/src/components-v2/product-quantity-buttons";
2
11
  import {
3
12
  H1,
4
13
  H2,
5
14
  H6,
6
15
  } from "@evenicanpm/storefront-core/src/components-v2/Typography";
7
- // import ImageWithFallback from "@app/_shared/ImageWithFallback";
8
- import ImageWithFallback from "@evenicanpm/storefront-core/src/components-v2/ImageWithFallback";
9
- import { ProductSearchResult } from "@msdyn365-commerce/retail-proxy";
16
+ import useCart, {
17
+ type AddToCartBopisInput,
18
+ } from "@evenicanpm/storefront-core/src/hooks/use-cart";
19
+ import useVariants from "@evenicanpm/storefront-core/src/hooks/use-variants";
20
+ import buildDetailUrl from "@evenicanpm/storefront-core/src/lib/build-detail-url";
21
+ import useCurrencyFormatter from "@evenicanpm/storefront-core/src/lib/currency-formatter";
22
+ import type { ProductSearchResult } from "@msdyn365-commerce/retail-proxy";
10
23
  import {
11
24
  Button,
12
25
  CircularProgress,
13
26
  DialogContent,
14
27
  Typography,
15
28
  } from "@mui/material";
16
- import Grid from "@mui/material/Grid";
17
29
  import Box from "@mui/material/Box";
18
- import ProductRating from "./product-rating";
19
- import useCart, {
20
- AddToCartBopisInput,
21
- } from "@evenicanpm/storefront-core/src/hooks/use-cart";
22
- import useCurrencyFormatter from "@evenicanpm/storefront-core/src/lib/currency-formatter";
23
- import ProductDimensions from "@evenicanpm/storefront-core/src/components-v2/product-dimensions";
24
- import QuantityButtons from "@evenicanpm/storefront-core/src/components-v2/product-quantity-buttons";
25
- import useVariants from "@evenicanpm/storefront-core/src/hooks/use-variants";
26
- import {
27
- InventorySearchCriteriaInput,
28
- ProductDetails,
29
- } from "@evenicanpm/storefront-core/src/api-manager/schemas/product.schema";
30
- import { Cart } from "@evenicanpm/storefront-core/src/api-manager/schemas/cart.schema";
31
- import { useMemo, useState } from "react";
32
- import getProductAvailability from "@evenicanpm/storefront-core/src/api-manager/services/product/queries/get-product-availability";
30
+ import Grid from "@mui/material/Grid";
33
31
  import Link from "next/link";
34
- import buildDetailUrl from "@evenicanpm/storefront-core/src/lib/build-detail-url";
35
32
  import { useTranslations } from "next-intl";
33
+ import { useMemo, useState } from "react";
34
+ import ProductRating from "./product-rating";
36
35
 
37
36
  interface Props {
38
37
  product: ProductSearchResult;
@@ -46,7 +45,7 @@ export default function QuickViewContent({
46
45
  cart,
47
46
  productDetails,
48
47
  handleClose,
49
- }: Props) {
48
+ }: Readonly<Props>) {
50
49
  const [showDimensionError, setShowDimensionError] = useState(false);
51
50
  const {
52
51
  selectedVariant,
@@ -106,8 +105,7 @@ export default function QuickViewContent({
106
105
 
107
106
  const getInventoryLabel = (): string | null => {
108
107
  const aggregate =
109
- shippingInventoryData?.AggregatedProductInventoryAvailabilities &&
110
- shippingInventoryData?.AggregatedProductInventoryAvailabilities[0];
108
+ shippingInventoryData?.AggregatedProductInventoryAvailabilities?.[0];
111
109
  if (aggregate) {
112
110
  const { TotalAvailableInventoryLevelLabel } = aggregate;
113
111
  return TotalAvailableInventoryLevelLabel || null;
@@ -1,7 +1,7 @@
1
- import { ProductSearchResult } from "@msdyn365-commerce/retail-proxy";
2
- import { CircularProgress, Dialog, DialogContent } from "@mui/material";
3
1
  import getCart from "@evenicanpm/storefront-core/src/api-manager/services/cart/queries/get-cart";
4
2
  import getProductById from "@evenicanpm/storefront-core/src/api-manager/services/product/queries/get-product-by-id";
3
+ import type { ProductSearchResult } from "@msdyn365-commerce/retail-proxy";
4
+ import { CircularProgress, Dialog, DialogContent } from "@mui/material";
5
5
  import QuickViewContent from "./quick-view-dialog-content";
6
6
 
7
7
  interface Props {
@@ -10,7 +10,11 @@ interface Props {
10
10
  product: ProductSearchResult;
11
11
  }
12
12
 
13
- export default function QuickView({ open, handleClose, product }: Props) {
13
+ export default function QuickView({
14
+ open,
15
+ handleClose,
16
+ product,
17
+ }: Readonly<Props>) {
14
18
  if (!open) {
15
19
  return;
16
20
  }
@@ -1,13 +1,13 @@
1
1
  "use client";
2
2
 
3
- import { useState, useEffect } from "react";
4
- import { Box, Typography, Slider, TextField } from "@mui/material";
5
- import { RenderedFacetProps } from "./facet-group";
6
3
  import {
7
4
  ProductRefinerSource,
8
- ProductRefinerValue,
5
+ type ProductRefinerValue,
9
6
  } from "@msdyn365-commerce/retail-proxy";
10
- import React from "react";
7
+ import { Box, Slider, TextField, Typography } from "@mui/material";
8
+ import type React from "react";
9
+ import { useEffect, useState } from "react";
10
+ import type { RenderedFacetProps } from "./facet-group";
11
11
 
12
12
  type Props = RenderedFacetProps & {
13
13
  selectedValues?: ProductRefinerValue;
@@ -44,7 +44,6 @@ export default function RangeFilter({
44
44
  setMaxVal(Number(selectedValues.RightValueBoundString));
45
45
  setTextMin(Number(selectedValues.LeftValueBoundString));
46
46
  setTextMax(Number(selectedValues.RightValueBoundString));
47
- } else {
48
47
  }
49
48
  }, [selectedValues]);
50
49
 
@@ -1,6 +1,6 @@
1
- import { ReactNode } from "react";
2
- import { SxProps, Theme } from "@mui/material/styles";
3
- import { Props } from "simplebar-react";
1
+ import type { SxProps, Theme } from "@mui/material/styles";
2
+ import type { ReactNode } from "react";
3
+ import type { Props } from "simplebar-react";
4
4
  import "simplebar-react/dist/simplebar.min.css";
5
5
  import { alpha, styled } from "@mui/material/styles";
6
6
  import SimpleBar from "simplebar-react";
@@ -29,7 +29,7 @@ export default function Scrollbar({
29
29
  autoHide = true,
30
30
  sx,
31
31
  ...props
32
- }: ScrollbarProps) {
32
+ }: Readonly<ScrollbarProps>) {
33
33
  return (
34
34
  <StyledScrollBar sx={sx} autoHide={autoHide} {...props}>
35
35
  {children}
@@ -1,24 +1,24 @@
1
1
  "use client";
2
- import React, { createContext, useContext, useEffect, useState } from "react";
2
+ import Apps from "@mui/icons-material/Apps";
3
+ import FilterList from "@mui/icons-material/FilterList";
4
+ import ViewList from "@mui/icons-material/ViewList";
3
5
  import {
4
6
  Box,
7
+ IconButton,
5
8
  MenuItem,
6
- Typography,
7
- ToggleButtonGroup,
8
- ToggleButton,
9
9
  TextField,
10
- IconButton,
10
+ ToggleButton,
11
+ ToggleButtonGroup,
12
+ Typography,
11
13
  } from "@mui/material";
12
- import Apps from "@mui/icons-material/Apps";
13
- import ViewList from "@mui/icons-material/ViewList";
14
- import FilterList from "@mui/icons-material/FilterList";
15
- import { Theme } from "@mui/material/styles";
14
+ import type { Theme } from "@mui/material/styles";
16
15
  import useMediaQuery from "@mui/material/useMediaQuery";
17
16
  import { useTranslations } from "next-intl";
18
-
19
- import useProductList from "./use-product-list";
20
- import { ViewMode } from "./utils/product-list-types";
17
+ import type React from "react";
18
+ import { createContext, useContext, useEffect, useState } from "react";
21
19
  import Sidenav from "./side-nav";
20
+ import useProductList from "./use-product-list";
21
+ import type { ViewMode } from "./utils/product-list-types";
22
22
 
23
23
  const sxView = {
24
24
  display: "flex",
@@ -1,12 +1,12 @@
1
+ import { Paragraph } from "@evenicanpm/storefront-core/src/components-v2/Typography";
1
2
  import {
2
3
  ProductRefinerSource,
3
- ProductRefinerValue,
4
+ type ProductRefinerValue,
4
5
  } from "@msdyn365-commerce/retail-proxy";
5
6
  import { Button, Chip, Stack } from "@mui/material";
6
- import { Paragraph } from "@evenicanpm/storefront-core/src/components-v2/Typography";
7
- import React, { useState, useEffect } from "react";
8
- import useProductList from "./use-product-list";
9
7
  import { useTranslations } from "next-intl";
8
+ import React, { useEffect, useState } from "react";
9
+ import useProductList from "./use-product-list";
10
10
 
11
11
  export default function SelectedFacets() {
12
12
  const t = useTranslations("ProductList.Facets");
@@ -1,5 +1,5 @@
1
- import { useEffect, useState, ReactNode } from "react";
2
1
  import Drawer from "@mui/material/Drawer";
2
+ import { type ReactNode, useEffect, useState } from "react";
3
3
  // GLOBAL CUSTOM COMPONENT
4
4
  import Scrollbar from "./scrollbar";
5
5
 
@@ -14,7 +14,7 @@ interface Props {
14
14
  }
15
15
  // ================================================================
16
16
 
17
- export default function SideNav(props: Props) {
17
+ export default function SideNav(props: Readonly<Props>) {
18
18
  const {
19
19
  position = "left",
20
20
  open = false,
@@ -1,11 +1,10 @@
1
1
  "use client";
2
2
 
3
- import { Box } from "@mui/material";
4
- import { ProductRefinerValue } from "@msdyn365-commerce/retail-proxy";
5
- import { Chip, useTheme } from "@mui/material";
6
- import { RenderedFacetProps } from "./facet-group";
3
+ import type { ProductRefinerValue } from "@msdyn365-commerce/retail-proxy";
4
+ import { Box, Chip, useTheme } from "@mui/material";
5
+ import type { RenderedFacetProps } from "./facet-group";
7
6
 
8
- type Props = RenderedFacetProps & NonNullable<unknown>;
7
+ type Props = RenderedFacetProps;
9
8
 
10
9
  const cssColorName = (color: string | undefined) => {
11
10
  if (!color) return false;
@@ -22,12 +21,21 @@ export default function Swatch({
22
21
  facet,
23
22
  handleRefinerSelect,
24
23
  isRefinerSelected,
25
- }: Props) {
24
+ }: Readonly<Props>) {
26
25
  const theme = useTheme();
27
26
 
28
27
  return (
29
28
  <Box mb={3}>
30
29
  {facet.Values?.map((colorItem: ProductRefinerValue) => {
30
+ const borderStyle = (() => {
31
+ if (checkWhite(colorItem.LeftValueBoundString)) {
32
+ return "1px solid black";
33
+ }
34
+ if (isRefinerSelected(colorItem)) {
35
+ return "2px solid";
36
+ }
37
+ return "2px solid transparent";
38
+ })();
31
39
  return (
32
40
  <Box
33
41
  key={colorItem.LeftValueBoundString}
@@ -49,11 +57,7 @@ export default function Swatch({
49
57
  : theme.palette.grey[300]),
50
58
  width: 32,
51
59
  height: 32,
52
- border: checkWhite(colorItem.LeftValueBoundString)
53
- ? "1px solid black"
54
- : isRefinerSelected(colorItem)
55
- ? "2px solid"
56
- : "2px solid transparent",
60
+ border: borderStyle,
57
61
  "&:hover": {
58
62
  backgroundColor:
59
63
  colorItem.SwatchColorHexCode ||
@@ -1,4 +1,4 @@
1
- import { CategoryHierarchy } from "@evenicanpm/storefront-core/src/lib/category-helpers";
1
+ import type { CategoryHierarchy } from "@evenicanpm/storefront-core/src/lib/category-helpers";
2
2
  import { searchCategory } from "./search-for-category";
3
3
 
4
4
  const generateBreadcrumbs = (
@@ -10,6 +10,23 @@ export type Category = {
10
10
  Children?: Category[];
11
11
  };
12
12
 
13
+ const matchesSlug = (cat: Category, slug: string) => {
14
+ const url = cat?.Url?.toLowerCase() || "";
15
+ const name = cat?.Name?.toLowerCase() || "";
16
+ const neutralName = cat?.NeutralizedNAME?.toLowerCase() || "";
17
+ const seoCrumb = cat?.seoCrumb?.toLowerCase() || "";
18
+
19
+ return (
20
+ url.includes(slug) ||
21
+ name === slug ||
22
+ neutralName === slug ||
23
+ seoCrumb === slug
24
+ );
25
+ };
26
+
27
+ const getCategoryId = (cat: Category, isD365: boolean) =>
28
+ isD365 ? cat.RecordId?.toString() : cat.id?.toString();
29
+
13
30
  export function getCategoryIdFromSlug(
14
31
  slug: string[],
15
32
  categories: Category[],
@@ -23,18 +40,9 @@ export function getCategoryIdFromSlug(
23
40
  const parentSlug = slug[0]?.toLowerCase();
24
41
  const childSlug = slug[1]?.toLowerCase();
25
42
 
26
- const parentCategory = categories.find((cat) => {
27
- const url = cat?.Url?.toLowerCase() || "";
28
- const name = cat?.Name?.toLowerCase() || "";
29
- const neutralName = cat?.NeutralizedNAME?.toLowerCase() || "";
30
- const seoCrumb = cat?.seoCrumb?.toLowerCase() || "";
31
- return (
32
- url.includes(parentSlug) ||
33
- name === parentSlug ||
34
- neutralName === parentSlug ||
35
- seoCrumb === parentSlug
36
- );
37
- });
43
+ const parentCategory = categories.find((cat) =>
44
+ matchesSlug(cat, parentSlug),
45
+ );
38
46
 
39
47
  if (!parentCategory) {
40
48
  console.warn(
@@ -44,74 +52,30 @@ export function getCategoryIdFromSlug(
44
52
  return undefined;
45
53
  }
46
54
 
47
- const childMatch = parentCategory.Children?.find((cat) => {
48
- const url = cat?.Url?.toLowerCase() || "";
49
- const name = cat?.Name?.toLowerCase() || "";
50
- const neutralName = cat?.NeutralizedNAME?.toLowerCase() || "";
51
- const seoCrumb = cat?.seoCrumb?.toLowerCase() || "";
52
- return (
53
- url.includes(childSlug) ||
54
- name === childSlug ||
55
- neutralName === childSlug ||
56
- seoCrumb === childSlug
57
- );
58
- });
59
- if (childMatch) {
60
- return isD365
61
- ? childMatch.RecordId?.toString()
62
- : childMatch.id?.toString();
63
- }
55
+ const childMatch = parentCategory.Children?.find((cat) =>
56
+ matchesSlug(cat, childSlug),
57
+ );
64
58
 
65
- return undefined;
59
+ return childMatch ? getCategoryId(childMatch, isD365) : undefined;
66
60
  }
67
61
 
68
62
  const slugValue = slug[0]?.toLowerCase();
69
63
 
70
- const topLevelMatch = categories.find((cat) => {
71
- const url = cat?.Url?.toLowerCase() || "";
72
- const name = cat?.Name?.toLowerCase() || "";
73
- const neutralName = cat?.NeutralizedNAME?.toLowerCase() || "";
74
- const seoCrumb = cat?.seoCrumb?.toLowerCase() || "";
75
- return (
76
- url.includes(slugValue) ||
77
- name === slugValue ||
78
- neutralName === slugValue ||
79
- seoCrumb === slugValue
80
- );
81
- });
64
+ const topLevelMatch = categories.find((cat) => matchesSlug(cat, slugValue));
82
65
 
83
66
  if (topLevelMatch) {
84
- return isD365
85
- ? topLevelMatch.RecordId?.toString()
86
- : topLevelMatch.id?.toString();
67
+ return getCategoryId(topLevelMatch, isD365);
87
68
  }
88
69
 
89
- let childMatch: Category | undefined;
90
70
  for (const topLevelCat of categories) {
91
- if (topLevelCat.Children && topLevelCat.Children.length > 0) {
92
- const child = topLevelCat.Children.find((cat) => {
93
- const url = cat?.Url?.toLowerCase() || "";
94
- const name = cat?.Name?.toLowerCase() || "";
95
- const neutralName = cat?.NeutralizedNAME?.toLowerCase() || "";
96
- const seoCrumb = cat?.seoCrumb?.toLowerCase() || "";
97
- return (
98
- url.includes(slugValue) ||
99
- name === slugValue ||
100
- neutralName === slugValue ||
101
- seoCrumb === slugValue
102
- );
103
- });
104
- if (child) {
105
- childMatch = child;
106
- break;
107
- }
71
+ const child = topLevelCat.Children?.find((cat) =>
72
+ matchesSlug(cat, slugValue),
73
+ );
74
+ if (child) {
75
+ return getCategoryId(child, isD365);
108
76
  }
109
77
  }
110
78
 
111
- if (childMatch) {
112
- return isD365 ? childMatch.RecordId?.toString() : childMatch.id?.toString();
113
- }
114
-
115
79
  return undefined;
116
80
  }
117
81
 
@@ -142,7 +106,8 @@ export function getCategoryFilterFromSlug(
142
106
  });
143
107
  if (children.length > 0) {
144
108
  return children
145
- .map((child) => (child.seoCrumb || child.Url || child.Name) as string)
109
+ .map((child) => child.seoCrumb || child.Url || child.Name)
110
+ .filter(Boolean)
146
111
  .join("|");
147
112
  }
148
113
  }
@@ -1,8 +1,8 @@
1
- import { IQueryResultSettings } from "@msdyn365-commerce/retail-proxy";
2
- import { PageKey, SortOption } from "./product-list-types";
3
- import getSortOptions from "./sort-options";
1
+ import type { SearchByCriteriaInput } from "@evenicanpm/storefront-core/src/api-manager/schemas/product.schema";
4
2
  import { convertParameterToRefiner } from "@evenicanpm/storefront-core/src/lib/refiner-utils";
5
- import { SearchByCriteriaInput } from "@evenicanpm/storefront-core/src/api-manager/schemas/product.schema";
3
+ import type { IQueryResultSettings } from "@msdyn365-commerce/retail-proxy";
4
+ import { PageKey, type SortOption } from "./product-list-types";
5
+ import getSortOptions from "./sort-options";
6
6
 
7
7
  const getDefaultValueByPageKey = (pageKey: PageKey) => {
8
8
  switch (pageKey) {
@@ -42,7 +42,7 @@ const getSelectedSortOption = (
42
42
  const getCategoryFromSlug = (slug: string[]) => {
43
43
  if (Array.isArray(slug)) {
44
44
  const categoryId = Number(slug.pop());
45
- if (!isNaN(categoryId)) {
45
+ if (!Number.isNaN(categoryId)) {
46
46
  return categoryId;
47
47
  }
48
48
  }
@@ -1,4 +1,4 @@
1
- import { ProductRefinerValue } from "@msdyn365-commerce/retail-proxy";
1
+ import type { ProductRefinerValue } from "@msdyn365-commerce/retail-proxy";
2
2
 
3
3
  export const PageKey = {
4
4
  TOP: "perPage",
@@ -1,6 +1,6 @@
1
- import { CategoryHierarchy } from "@evenicanpm/storefront-core/src/lib/category-helpers";
1
+ import type { CategoryHierarchy } from "@evenicanpm/storefront-core/src/lib/category-helpers";
2
2
  import { PageSlug } from "@evenicanpm/storefront-core/src/lib/page-slugs";
3
- import { TextValueTranslation } from "@msdyn365-commerce/retail-proxy";
3
+ import type { TextValueTranslation } from "@msdyn365-commerce/retail-proxy";
4
4
 
5
5
  const searchCategory = (
6
6
  locale: string,
@@ -53,11 +53,11 @@ const getCategoryTranslatedName = (
53
53
  (item) => item.Language?.toLowerCase() === locale.toLowerCase(),
54
54
  );
55
55
  }
56
- return nameTranslation && nameTranslation.Text;
56
+ return nameTranslation?.Text;
57
57
  };
58
58
 
59
59
  const normalizeCategoryName = (name: string) =>
60
- name.toLowerCase().replace(/ /g, "-");
60
+ name.toLowerCase().replaceAll(" ", "-");
61
61
 
62
62
  const getCategoryUrl = (category: CategoryHierarchy) => {
63
63
  const contentPageKey = PageSlug.Content;
@@ -1,4 +1,4 @@
1
- import { SortOption } from "./product-list-types";
1
+ import type { SortOption } from "./product-list-types";
2
2
 
3
3
  const sortOptions: SortOption[] = [
4
4
  {