@evenicanpm/storefront-core 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/api-manager/README.md +30 -22
- package/src/api-manager/datasources/e4/{e4-address.datasource.ts → address/e4-address.datasource.ts} +10 -10
- package/src/api-manager/datasources/e4/address/e4-address.remaps.ts +70 -0
- package/src/api-manager/datasources/e4/address/e4-address.translator.ts +98 -0
- package/src/api-manager/datasources/e4/{e4-cart.datasource.ts → cart/e4-cart.datasource.ts} +17 -16
- package/src/api-manager/datasources/e4/cart/e4-cart.remaps.ts +94 -0
- package/src/api-manager/datasources/e4/cart/e4-cart.translator.ts +23 -0
- package/src/api-manager/datasources/e4/categories/e4-categories.datasource.ts +38 -0
- package/src/api-manager/datasources/e4/categories/e4-categories.translator.ts +161 -0
- package/src/api-manager/datasources/e4/e4.datasource.ts +8 -39
- package/src/api-manager/datasources/e4/graphqlRequestSdk.ts +8427 -0
- package/src/api-manager/datasources/e4/{e4-order.datasource.ts → order/e4-order.datasource.ts} +3 -3
- package/src/api-manager/datasources/e4/order/e4-order.remaps.ts +101 -0
- package/src/api-manager/datasources/e4/{e4-organization.datasource.ts → organization/e4-organization.datasource.ts} +1 -1
- package/src/api-manager/datasources/e4/{e4-product.datasource.ts → product/e4-product.datasource.ts} +13 -11
- package/src/api-manager/datasources/e4/product/e4-product.remaps.ts +88 -0
- package/src/api-manager/datasources/e4/{e4.translator.ts → product/e4-product.translator.ts} +9 -329
- package/src/api-manager/datasources/e4/{e4-session.datasource.ts → session/e4-session.datasource.ts} +3 -3
- package/src/api-manager/datasources/e4/session/e4-session.translator.ts +18 -0
- package/src/api-manager/datasources/e4/user/e4-user.datasource.ts +13 -6
- package/src/api-manager/datasources/e4/user/e4-user.remaps.ts +49 -0
- package/src/api-manager/datasources/e4/user/e4-user.translator.ts +23 -2
- package/src/api-manager/datasources/e4/utils/unwrap-e4-variants.ts +1 -1
- package/src/api-manager/index.ts +11 -6
- package/src/api-manager/schemas/user.schema.ts +3 -1
- package/src/api-manager/services/cart/mutations/add-to-cart.ts +1 -1
- package/src/api-manager/services/cart/mutations/checkout.ts +1 -2
- package/src/api-manager/services/product/server/product.server.ts +4 -1
- package/src/api-manager/types/Datasource.ts +1 -5
- package/src/cms/blocks/BlockManager.tsx +67 -0
- package/src/cms/blocks/Components/BrandLogosScroller.tsx +72 -0
- package/src/cms/blocks/Components/CategoryCard.tsx +47 -0
- package/src/cms/blocks/Components/CategoryCarousel/index.tsx +60 -0
- package/src/cms/blocks/Components/FeaturePill.tsx +99 -0
- package/src/cms/blocks/Components/FeaturedCategories.tsx +41 -0
- package/src/cms/blocks/Components/FeaturedProducts.tsx +41 -0
- package/src/cms/blocks/Components/Footer/data/index.ts +32 -0
- package/src/cms/blocks/Components/Footer/index.tsx +88 -0
- package/src/cms/blocks/Components/Footer/interfaces.ts +37 -0
- package/src/cms/blocks/Components/Footer/sections/FooterAppStore.tsx +45 -0
- package/src/cms/blocks/Components/Footer/sections/FooterContact.tsx +36 -0
- package/src/cms/blocks/Components/Footer/sections/FooterLinks.tsx +30 -0
- package/src/cms/blocks/Components/Footer/sections/FooterLogo.tsx +26 -0
- package/src/cms/blocks/Components/Footer/sections/FooterSocialLinks.tsx +70 -0
- package/src/cms/blocks/Components/Footer/styles/index.ts +39 -0
- package/src/cms/blocks/Components/Footer.tsx +77 -0
- package/src/cms/blocks/Components/Hero.tsx +73 -0
- package/src/cms/blocks/Components/HeroCarousel/index.tsx +42 -0
- package/src/cms/blocks/Components/Image.tsx +39 -0
- package/src/cms/blocks/Components/MediaCard.tsx +41 -0
- package/src/cms/blocks/Components/ProductCarousel/index.tsx +82 -0
- package/src/cms/blocks/Components/ProductSectionFullWidth/index.tsx +103 -0
- package/src/cms/blocks/Components/RichText.tsx +19 -0
- package/src/cms/blocks/Components/Seo/index.tsx +48 -0
- package/src/cms/blocks/Components/Services/index.tsx +21 -0
- package/src/cms/blocks/Components/Services/service-card.tsx +73 -0
- package/src/cms/blocks/Components/shared/featured-product-card.tsx +29 -0
- package/src/cms/blocks/Components/shared/product-category-item.tsx +49 -0
- package/src/cms/blocks/Components/shared/product-grid.tsx +48 -0
- package/src/cms/blocks/Components/shared/top-categories-card.tsx +66 -0
- package/src/cms/blocks/Components/shared/top-rating-product-card.tsx +66 -0
- package/src/cms/blocks/Icons/Components/Category.tsx +14 -0
- package/src/cms/blocks/Icons/Components/DottedStar.tsx +40 -0
- package/src/cms/blocks/Icons/Components/FallbackIcon.tsx +33 -0
- package/src/cms/blocks/Icons/Components/GiftBox.tsx +18 -0
- package/src/cms/blocks/Icons/Components/Light.tsx +13 -0
- package/src/cms/blocks/Icons/Components/NewArrival.tsx +18 -0
- package/src/cms/blocks/Icons/Components/RankBadge.tsx +39 -0
- package/src/cms/blocks/Icons/index.ts +32 -0
- package/src/cms/blocks/index.tsx +16 -0
- package/src/cms/blocks/interfaces.ts +240 -0
- package/src/components/Notifications/README.md +1 -1
- package/src/components/Notifications/notification-context.tsx +1 -1
- package/src/components/README.md +3 -8
- package/src/components/_components/MiniCartClient.tsx +1 -1
- package/src/components/_components/navbar/category-based-menu/components/categories.tsx +1 -1
- package/src/components/_components/navbar/mega-menu/mega-menu.tsx +1 -1
- package/src/components/_components/navbar/nav-list/nav-item-child.tsx +2 -2
- package/src/components/_components/product-cards/product-card-1/product-card-1-wrapper.tsx +1 -1
- package/src/components/_components/products-view/product-view-dialog.tsx +1 -1
- package/src/components/_components/settings/setting.tsx +1 -1
- package/src/components/_components/wishlist/add-to-wishlist-dialog.tsx +1 -1
- package/src/components/_components/wishlist/components/create-new-list.tsx +1 -1
- package/src/components/_components/wishlist/remove-from-wishlist-dialog.tsx +1 -1
- package/src/components/_components/wishlist-modal/add-to-wishlist-dialog.tsx +1 -1
- package/src/components/_components/wishlist-modal/remove-from-wishlist-dialog.tsx +1 -1
- package/src/components/countries-input.tsx +0 -1
- package/src/components-v2/BazaarCard.tsx +21 -0
- package/src/components-v2/BazaarImage.tsx +12 -0
- package/src/components-v2/BazaarMenu.tsx +47 -0
- package/src/components-v2/BazaarSwitch.tsx +37 -0
- package/src/components-v2/BazaarTextField.tsx +73 -0
- package/src/components-v2/BoxShadowCard.tsx +16 -0
- package/src/components-v2/DropZone.tsx +86 -0
- package/src/components-v2/HoverBox.tsx +22 -0
- package/src/components-v2/Image.tsx +5 -0
- package/src/components-v2/ImageWithFallback.tsx +51 -0
- package/src/components-v2/LazyImage.tsx +12 -0
- package/src/components-v2/Loading.tsx +36 -0
- package/src/components-v2/MiniCartClient.tsx +65 -0
- package/src/components-v2/README.md +4 -0
- package/src/components-v2/SearchInput.tsx +28 -0
- package/src/components-v2/SnackbarProvider.tsx +32 -0
- package/src/components-v2/T/index.tsx +15 -0
- package/src/components-v2/Typography.tsx +227 -0
- package/src/components-v2/WhiteButton.tsx +20 -0
- package/src/components-v2/accordion/accordion-header.tsx +43 -0
- package/src/components-v2/accordion/index.ts +1 -0
- package/src/components-v2/bazaar-types.ts +84 -0
- package/src/components-v2/carousel/carousel.tsx +72 -0
- package/src/components-v2/carousel/components/carousel-arrows.tsx +60 -0
- package/src/components-v2/carousel/components/carousel-dots.tsx +21 -0
- package/src/components-v2/carousel/index.ts +3 -0
- package/src/components-v2/carousel/styles/index.ts +93 -0
- package/src/components-v2/carousel-cards/carousel-card-1/carousel-card-1.tsx +64 -0
- package/src/components-v2/carousel-cards/carousel-card-1/index.ts +1 -0
- package/src/components-v2/carousel-cards/carousel-card-1/styles.ts +34 -0
- package/src/components-v2/carousel-cards/carousel-card-2/carousel-card-2.tsx +78 -0
- package/src/components-v2/carousel-cards/carousel-card-2/index.ts +1 -0
- package/src/components-v2/carousel-cards/carousel-card-2/styles.ts +26 -0
- package/src/components-v2/carousel-cards/carousel-card-3/carousel-card-3.tsx +37 -0
- package/src/components-v2/carousel-cards/carousel-card-3/index.ts +1 -0
- package/src/components-v2/carousel-cards/carousel-card-3/styles.ts +28 -0
- package/src/components-v2/carousel-cards/carousel-card-4/carousel-card-4.tsx +81 -0
- package/src/components-v2/carousel-cards/carousel-card-4/index.ts +1 -0
- package/src/components-v2/carousel-cards/carousel-card-4/styles.ts +27 -0
- package/src/components-v2/categories/category-list/category-list.tsx +59 -0
- package/src/components-v2/categories/category-list/index.ts +1 -0
- package/src/components-v2/categories/category-list/styles.ts +29 -0
- package/src/components-v2/categories/category-list/types.ts +4 -0
- package/src/components-v2/categories/category-list-item/category-menu-item.tsx +37 -0
- package/src/components-v2/categories/category-list-item/index.ts +1 -0
- package/src/components-v2/categories/category-list-item/styles.ts +35 -0
- package/src/components-v2/categories/category-menu.tsx +51 -0
- package/src/components-v2/categories/mega-menu/banner.tsx +60 -0
- package/src/components-v2/categories/mega-menu/column-list.tsx +70 -0
- package/src/components-v2/categories/mega-menu/mega-menu-1.tsx +37 -0
- package/src/components-v2/categories/mega-menu/mega-menu-2.tsx +37 -0
- package/src/components-v2/categories/mega-menu/styles.ts +25 -0
- package/src/components-v2/categories/types.ts +16 -0
- package/src/components-v2/category-cards/category-card-1/category-card-1.tsx +21 -0
- package/src/components-v2/category-cards/category-card-1/index.ts +1 -0
- package/src/components-v2/category-cards/category-card-1/styles.ts +37 -0
- package/src/components-v2/countdown/count-box.tsx +19 -0
- package/src/components-v2/countdown/count-down.tsx +24 -0
- package/src/components-v2/countdown/index.tsx +2 -0
- package/src/components-v2/countdown/useCountDown.ts +41 -0
- package/src/components-v2/countries-input.tsx +73 -0
- package/src/components-v2/data-table/index.ts +2 -0
- package/src/components-v2/data-table/table-header.tsx +91 -0
- package/src/components-v2/data-table/table-pagination.tsx +36 -0
- package/src/components-v2/flex-box/flex-between.tsx +14 -0
- package/src/components-v2/flex-box/flex-box.tsx +9 -0
- package/src/components-v2/flex-box/flex-row-center.tsx +9 -0
- package/src/components-v2/flex-box/index.ts +5 -0
- package/src/components-v2/footer/components/about-links.tsx +23 -0
- package/src/components-v2/footer/components/app-store.tsx +38 -0
- package/src/components-v2/footer/components/customer-care-links.tsx +21 -0
- package/src/components-v2/footer/components/logo.tsx +23 -0
- package/src/components-v2/footer/components/social-links.tsx +43 -0
- package/src/components-v2/footer/data/index.ts +54 -0
- package/src/components-v2/footer/footer-1.tsx +62 -0
- package/src/components-v2/footer/footer-2.tsx +57 -0
- package/src/components-v2/footer/footer-3.tsx +53 -0
- package/src/components-v2/footer/footer-4.tsx +71 -0
- package/src/components-v2/footer/index.ts +4 -0
- package/src/components-v2/footer/styles/index.ts +42 -0
- package/src/components-v2/header/components/categories-menu.tsx +23 -0
- package/src/components-v2/header/components/mobile-header.tsx +75 -0
- package/src/components-v2/header/components/user.test.tsx +200 -0
- package/src/components-v2/header/components/user.tsx +204 -0
- package/src/components-v2/header/header.tsx +63 -0
- package/src/components-v2/header/hooks/use-header.ts +13 -0
- package/src/components-v2/header/index.ts +1 -0
- package/src/components-v2/header/sticky-header.tsx +17 -0
- package/src/components-v2/header/styles/index.ts +24 -0
- package/src/components-v2/icons/cart-bag.tsx +13 -0
- package/src/components-v2/icons/category-outline.tsx +29 -0
- package/src/components-v2/icons/category.tsx +12 -0
- package/src/components-v2/icons/home.tsx +19 -0
- package/src/components-v2/icons/search.tsx +13 -0
- package/src/components-v2/icons/shopping-bag-outlined.tsx +13 -0
- package/src/components-v2/icons/up-down.tsx +21 -0
- package/src/components-v2/icons/user.tsx +13 -0
- package/src/components-v2/icons/user2.tsx +14 -0
- package/src/components-v2/mini-cart/__tests__/cart-item.test.tsx +174 -0
- package/src/components-v2/mini-cart/__tests__/mini-cart.test.tsx +121 -0
- package/src/components-v2/mini-cart/__tests__/test-cart-empty.json +84 -0
- package/src/components-v2/mini-cart/__tests__/test-cart-with-item.json +244 -0
- package/src/components-v2/mini-cart/components/bottom-actions.tsx +27 -0
- package/src/components-v2/mini-cart/components/cart-item.tsx +147 -0
- package/src/components-v2/mini-cart/components/empty-view.tsx +29 -0
- package/src/components-v2/mini-cart/components/top-header.tsx +37 -0
- package/src/components-v2/mini-cart/index.ts +1 -0
- package/src/components-v2/mini-cart/mini-cart.tsx +107 -0
- package/src/components-v2/mobile-navigation/index.ts +3 -0
- package/src/components-v2/mobile-navigation/mobile-navigation-bar.tsx +73 -0
- package/src/components-v2/mobile-navigation/styles/index.ts +63 -0
- package/src/components-v2/nav-link/index.ts +5 -0
- package/src/components-v2/nav-link/nav-link-2.tsx +32 -0
- package/src/components-v2/nav-link/nav-link-3.tsx +67 -0
- package/src/components-v2/nav-link/nav-link.tsx +53 -0
- package/src/components-v2/navbar/categories.tsx +27 -0
- package/src/components-v2/navbar/category-based-menu/category-based-menu.tsx +52 -0
- package/src/components-v2/navbar/category-based-menu/components/categories.tsx +44 -0
- package/src/components-v2/navbar/category-based-menu/components/category-item.tsx +31 -0
- package/src/components-v2/navbar/category-based-menu/components/child-categories.tsx +38 -0
- package/src/components-v2/navbar/category-based-menu/index.ts +1 -0
- package/src/components-v2/navbar/category-based-menu/styles.ts +81 -0
- package/src/components-v2/navbar/category-based-menu/types.ts +18 -0
- package/src/components-v2/navbar/index.ts +1 -0
- package/src/components-v2/navbar/mega-menu/category-list.tsx +29 -0
- package/src/components-v2/navbar/mega-menu/index.ts +1 -0
- package/src/components-v2/navbar/mega-menu/mega-menu.tsx +71 -0
- package/src/components-v2/navbar/mega-menu/styles.ts +43 -0
- package/src/components-v2/navbar/mobile-menu/index.ts +1 -0
- package/src/components-v2/navbar/mobile-menu/mobile-menu.tsx +70 -0
- package/src/components-v2/navbar/mobile-menu/render-levels.test.tsx +71 -0
- package/src/components-v2/navbar/mobile-menu/render-levels.tsx +62 -0
- package/src/components-v2/navbar/nav-list/cms-nav.test.tsx +84 -0
- package/src/components-v2/navbar/nav-list/index.ts +1 -0
- package/src/components-v2/navbar/nav-list/nav-item-child.tsx +66 -0
- package/src/components-v2/navbar/nav-list/nav-list.tsx +119 -0
- package/src/components-v2/navbar/navbar.tsx +43 -0
- package/src/components-v2/navbar/styles.ts +90 -0
- package/src/components-v2/navbar/utils/transform-nav.test.ts +209 -0
- package/src/components-v2/navbar/utils/transform-nav.ts +43 -0
- package/src/components-v2/newsletter/index.ts +1 -0
- package/src/components-v2/newsletter/newsletter.tsx +112 -0
- package/src/components-v2/newsletter/social-icons.tsx +35 -0
- package/src/components-v2/newsletter/styles.ts +65 -0
- package/src/components-v2/page-sidenav/grocery-side-nav/components/link-item.tsx +21 -0
- package/src/components-v2/page-sidenav/grocery-side-nav/components/list-item.tsx +27 -0
- package/src/components-v2/page-sidenav/grocery-side-nav/components/nav-accordion.tsx +36 -0
- package/src/components-v2/page-sidenav/grocery-side-nav/components/render-child.tsx +26 -0
- package/src/components-v2/page-sidenav/grocery-side-nav/grocery-side-nav.tsx +32 -0
- package/src/components-v2/page-sidenav/grocery-side-nav/index.ts +1 -0
- package/src/components-v2/page-sidenav/grocery-side-nav/styles/index.ts +11 -0
- package/src/components-v2/page-sidenav/health-beauty-side-nav/components/list-item.tsx +27 -0
- package/src/components-v2/page-sidenav/health-beauty-side-nav/components/nav-accordion.tsx +44 -0
- package/src/components-v2/page-sidenav/health-beauty-side-nav/components/render-child.tsx +20 -0
- package/src/components-v2/page-sidenav/health-beauty-side-nav/health-beauty-side-nav.tsx +43 -0
- package/src/components-v2/page-sidenav/health-beauty-side-nav/index.ts +1 -0
- package/src/components-v2/page-sidenav/health-beauty-side-nav/styles/index.ts +27 -0
- package/src/components-v2/page-sidenav/side-navbar/components/list-item.tsx +25 -0
- package/src/components-v2/page-sidenav/side-navbar/components/nav-accordion.tsx +46 -0
- package/src/components-v2/page-sidenav/side-navbar/components/render-child.tsx +20 -0
- package/src/components-v2/page-sidenav/side-navbar/index.ts +1 -0
- package/src/components-v2/page-sidenav/side-navbar/side-nav-bar.tsx +77 -0
- package/src/components-v2/page-sidenav/side-navbar/styles/index.ts +73 -0
- package/src/components-v2/page-sidenav/side-navbar-2/components/button-content.tsx +32 -0
- package/src/components-v2/page-sidenav/side-navbar-2/components/sidebar-accordion.tsx +66 -0
- package/src/components-v2/page-sidenav/side-navbar-2/index.ts +1 -0
- package/src/components-v2/page-sidenav/side-navbar-2/side-navbar-2.tsx +63 -0
- package/src/components-v2/page-sidenav/side-navbar-2/styles/index.ts +68 -0
- package/src/components-v2/product-cards/discount-chip.tsx +43 -0
- package/src/components-v2/product-cards/product-card-1/components/hover-actions.tsx +37 -0
- package/src/components-v2/product-cards/product-card-1/components/quantity-buttons.tsx +65 -0
- package/src/components-v2/product-cards/product-card-1/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-1/product-card-1-wrapper.tsx +304 -0
- package/src/components-v2/product-cards/product-card-1/product-card.tsx +107 -0
- package/src/components-v2/product-cards/product-card-1/styles/index.ts +46 -0
- package/src/components-v2/product-cards/product-card-10/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-10/product-card.tsx +128 -0
- package/src/components-v2/product-cards/product-card-10/styles/index.ts +38 -0
- package/src/components-v2/product-cards/product-card-11/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-11/product-card.tsx +66 -0
- package/src/components-v2/product-cards/product-card-11/styles/index.ts +16 -0
- package/src/components-v2/product-cards/product-card-12/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-12/product-card.tsx +42 -0
- package/src/components-v2/product-cards/product-card-12/styles/index.ts +16 -0
- package/src/components-v2/product-cards/product-card-13/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-13/product-card.tsx +48 -0
- package/src/components-v2/product-cards/product-card-13/styles/index.ts +25 -0
- package/src/components-v2/product-cards/product-card-14/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-14/product-card.tsx +125 -0
- package/src/components-v2/product-cards/product-card-14/styles/index.ts +40 -0
- package/src/components-v2/product-cards/product-card-15/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-15/product-card.tsx +121 -0
- package/src/components-v2/product-cards/product-card-15/styles/index.ts +57 -0
- package/src/components-v2/product-cards/product-card-16/components/quantity-buttons.tsx +54 -0
- package/src/components-v2/product-cards/product-card-16/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-16/product-card.tsx +116 -0
- package/src/components-v2/product-cards/product-card-16/styles/index.ts +18 -0
- package/src/components-v2/product-cards/product-card-2/components/favorite-button.tsx +29 -0
- package/src/components-v2/product-cards/product-card-2/components/product-price.tsx +26 -0
- package/src/components-v2/product-cards/product-card-2/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-2/product-card.tsx +70 -0
- package/src/components-v2/product-cards/product-card-3/components/hover-actions.tsx +83 -0
- package/src/components-v2/product-cards/product-card-3/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-3/product-card.tsx +110 -0
- package/src/components-v2/product-cards/product-card-3/styles/index.ts +89 -0
- package/src/components-v2/product-cards/product-card-4/components/hover-actions.tsx +50 -0
- package/src/components-v2/product-cards/product-card-4/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-4/product-card.tsx +128 -0
- package/src/components-v2/product-cards/product-card-4/styles/index.ts +66 -0
- package/src/components-v2/product-cards/product-card-5/components/button-actions.tsx +49 -0
- package/src/components-v2/product-cards/product-card-5/components/hover-actions.tsx +50 -0
- package/src/components-v2/product-cards/product-card-5/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-5/product-card.tsx +137 -0
- package/src/components-v2/product-cards/product-card-5/styles/index.ts +94 -0
- package/src/components-v2/product-cards/product-card-6/components/hover-actions.tsx +50 -0
- package/src/components-v2/product-cards/product-card-6/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-6/product-card.tsx +121 -0
- package/src/components-v2/product-cards/product-card-6/styles/index.ts +63 -0
- package/src/components-v2/product-cards/product-card-7/components/product-status.tsx +18 -0
- package/src/components-v2/product-cards/product-card-7/components/quantity-buttons.tsx +47 -0
- package/src/components-v2/product-cards/product-card-7/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-7/product-card.tsx +139 -0
- package/src/components-v2/product-cards/product-card-7/styles/index.ts +98 -0
- package/src/components-v2/product-cards/product-card-8/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-8/product-card.tsx +151 -0
- package/src/components-v2/product-cards/product-card-8/styles/index.ts +61 -0
- package/src/components-v2/product-cards/product-card-9/components/add-to-cart.tsx +63 -0
- package/src/components-v2/product-cards/product-card-9/components/favorite-button.tsx +27 -0
- package/src/components-v2/product-cards/product-card-9/components/tags.tsx +33 -0
- package/src/components-v2/product-cards/product-card-9/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-9/product-card.tsx +169 -0
- package/src/components-v2/product-cards/product-card-wishlist/components/hover-actions.tsx +37 -0
- package/src/components-v2/product-cards/product-card-wishlist/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-wishlist/product-card.tsx +118 -0
- package/src/components-v2/product-cards/product-card-wishlist/styles/index.ts +53 -0
- package/src/components-v2/product-cards/product-price.tsx +26 -0
- package/src/components-v2/product-cards/product-rating.tsx +28 -0
- package/src/components-v2/product-cards/product-title.tsx +24 -0
- package/src/components-v2/product-cards/use-product.ts +35 -0
- package/src/components-v2/product-dimensions/components/dimensions-group-error.tsx +46 -0
- package/src/components-v2/product-dimensions/components/dimensions-group-label.tsx +27 -0
- package/src/components-v2/product-dimensions/components/dimensions-group-list-chip.tsx +78 -0
- package/src/components-v2/product-dimensions/components/dimensions-group-list.tsx +24 -0
- package/src/components-v2/product-dimensions/components/dimensions-group.tsx +55 -0
- package/src/components-v2/product-dimensions/components/dimensions.tsx +84 -0
- package/src/components-v2/product-dimensions/index.tsx +38 -0
- package/src/components-v2/product-dimensions/utils/has-selected-dimension.ts +20 -0
- package/src/components-v2/product-quantity-buttons/product-quantity-buttons.tsx +88 -0
- package/src/components-v2/products-view/product-view-dialog.tsx +218 -0
- package/src/components-v2/products-view/products-grid-view.tsx +52 -0
- package/src/components-v2/products-view/products-list-view.tsx +49 -0
- package/src/components-v2/progress/index.ts +1 -0
- package/src/components-v2/progress/progress.tsx +77 -0
- package/src/components-v2/scrollbar/index.ts +1 -0
- package/src/components-v2/scrollbar/scrollbar.tsx +27 -0
- package/src/components-v2/scrollbar/styles.ts +15 -0
- package/src/components-v2/search-box/__test__/search-input-category.test.tsx +110 -0
- package/src/components-v2/search-box/__test__/search-input.test.tsx +137 -0
- package/src/components-v2/search-box/__test__/search-results.json +165 -0
- package/src/components-v2/search-box/components/category-dropdown.tsx +61 -0
- package/src/components-v2/search-box/components/search-result.tsx +86 -0
- package/src/components-v2/search-box/hooks/use-search.ts +63 -0
- package/src/components-v2/search-box/index.ts +2 -0
- package/src/components-v2/search-box/search-input-category.test.tsx +110 -0
- package/src/components-v2/search-box/search-input-category.tsx +203 -0
- package/src/components-v2/search-box/search-input.test.tsx +41 -0
- package/src/components-v2/search-box/search-input.tsx +66 -0
- package/src/components-v2/search-box/styles/index.ts +47 -0
- package/src/components-v2/section-header/index.ts +2 -0
- package/src/components-v2/section-header/section-creator.tsx +29 -0
- package/src/components-v2/section-header/section-header.tsx +44 -0
- package/src/components-v2/service-cards/icon-component.tsx +18 -0
- package/src/components-v2/service-cards/service-card-1/index.ts +1 -0
- package/src/components-v2/service-cards/service-card-1/service-card-1.tsx +42 -0
- package/src/components-v2/service-cards/service-card-2/index.ts +1 -0
- package/src/components-v2/service-cards/service-card-2/service-card-2.tsx +37 -0
- package/src/components-v2/service-cards/service-card-3/index.ts +1 -0
- package/src/components-v2/service-cards/service-card-3/service-card-3.tsx +28 -0
- package/src/components-v2/service-cards/service-card-3/styles.ts +23 -0
- package/src/components-v2/settings/index.ts +1 -0
- package/src/components-v2/settings/setting.tsx +141 -0
- package/src/components-v2/settings/styles.ts +57 -0
- package/src/components-v2/shop-card/index.ts +1 -0
- package/src/components-v2/shop-card/shop-card.tsx +152 -0
- package/src/components-v2/shop-card/styles.ts +33 -0
- package/src/components-v2/side-nav/index.ts +1 -0
- package/src/components-v2/side-nav/side-nav.tsx +49 -0
- package/src/components-v2/site-logo.tsx +17 -0
- package/src/components-v2/sticky/Sticky.tsx +62 -0
- package/src/components-v2/sticky/index.ts +1 -0
- package/src/components-v2/sticky/styles.ts +38 -0
- package/src/components-v2/sticky-wrapper/index.ts +1 -0
- package/src/components-v2/sticky-wrapper/sticky-wrapper.tsx +21 -0
- package/src/components-v2/sticky-wrapper/styles.ts +25 -0
- package/src/components-v2/stories/story-content/index.ts +1 -0
- package/src/components-v2/stories/story-content/story-content.tsx +28 -0
- package/src/components-v2/stories/story-content/styles.ts +22 -0
- package/src/components-v2/stories/story-item/index.ts +1 -0
- package/src/components-v2/stories/story-item/story-item.tsx +24 -0
- package/src/components-v2/stories/story-item/styles.ts +11 -0
- package/src/components-v2/stories/story-viewer/index.ts +1 -0
- package/src/components-v2/stories/story-viewer/story-viewer.tsx +44 -0
- package/src/components-v2/stories/story-viewer/styles.ts +15 -0
- package/src/components-v2/subscribe-input/index.ts +1 -0
- package/src/components-v2/subscribe-input/styles.ts +14 -0
- package/src/components-v2/subscribe-input/subscribe-input.tsx +43 -0
- package/src/components-v2/topbar/index.ts +1 -0
- package/src/components-v2/topbar/styles.ts +55 -0
- package/src/components-v2/topbar/top-bar.tsx +115 -0
- package/src/components-v2/utils/constants.ts +8 -0
- package/src/components-v2/wishlist/add-to-wishlist-dialog.tsx +161 -0
- package/src/components-v2/wishlist/components/create-new-list.tsx +167 -0
- package/src/components-v2/wishlist/components/create-wishlist-button.tsx +40 -0
- package/src/components-v2/wishlist/components/dashboard-header.tsx +123 -0
- package/src/components-v2/wishlist/components/navigation.tsx +87 -0
- package/src/components-v2/wishlist/components/no-records.tsx +20 -0
- package/src/components-v2/wishlist/components/wishlist-modal-item.tsx +66 -0
- package/src/components-v2/wishlist/remove-from-wishlist-dialog.tsx +175 -0
- package/src/components-v2/wishlist/styles.ts +61 -0
- package/src/components-v2/wishlist-modal/TODO.md +10 -0
- package/src/components-v2/wishlist-modal/add-to-wishlist-button.tsx +69 -0
- package/src/components-v2/wishlist-modal/add-to-wishlist-dialog.tsx +161 -0
- package/src/components-v2/wishlist-modal/remove-from-wishlist-dialog.tsx +174 -0
- package/src/components-v2/wishlist-modal/wishlist-modal-item.tsx +65 -0
- package/src/pages/README.md +4 -0
- package/src/pages/product-details/product-intro/product-intro.tsx +3 -1
- package/src/pages/product-list/quick-view-dialog-content.tsx +4 -2
- package/src/pages-v2/README.md +4 -0
- package/src/pages-v2/account/addresses/address-form.tsx +289 -0
- package/src/pages-v2/account/addresses/address-item.tsx +104 -0
- package/src/pages-v2/account/dashboard-header.tsx +123 -0
- package/src/pages-v2/account/navigation.tsx +87 -0
- package/src/pages-v2/account/no-records.tsx +20 -0
- package/src/pages-v2/account/orders/icons/delivery.tsx +14 -0
- package/src/pages-v2/account/orders/icons/package-box.tsx +13 -0
- package/src/pages-v2/account/orders/icons/truck-filled.tsx +14 -0
- package/src/pages-v2/account/orders/order-progress.tsx +114 -0
- package/src/pages-v2/account/orders/order-row.tsx +64 -0
- package/src/pages-v2/account/orders/order-summary.tsx +87 -0
- package/src/pages-v2/account/orders/ordered-products.tsx +121 -0
- package/src/pages-v2/account/profile/profile-button.test.tsx +59 -0
- package/src/pages-v2/account/profile/profile-button.tsx +50 -0
- package/src/pages-v2/account/profile/user-info.tsx +62 -0
- package/src/pages-v2/account/styles.ts +32 -0
- package/src/pages-v2/account/table-row.tsx +19 -0
- package/src/pages-v2/account/wishlist/create-new-list.tsx +167 -0
- package/src/pages-v2/account/wishlist/create-wishlist-button.tsx +40 -0
- package/src/pages-v2/account/wishlist/wishlist-item.tsx +82 -0
- package/src/pages-v2/blog/pagination.tsx +38 -0
- package/src/pages-v2/cart/cart-item.tsx +312 -0
- package/src/pages-v2/cart/checkout-form.tsx +122 -0
- package/src/pages-v2/cart/coupon-entry.tsx +90 -0
- package/src/pages-v2/cart/estimate-shipping.tsx +183 -0
- package/src/pages-v2/cart/wrapper.tsx +30 -0
- package/src/pages-v2/checkout/checkout-alt-form/address-card.tsx +76 -0
- package/src/pages-v2/checkout/checkout-alt-form/checkout-form.tsx +131 -0
- package/src/pages-v2/checkout/checkout-alt-form/checkout-step.tsx +120 -0
- package/src/pages-v2/checkout/checkout-alt-form/customer-information.tsx +94 -0
- package/src/pages-v2/checkout/checkout-alt-form/delivery-address.tsx +174 -0
- package/src/pages-v2/checkout/checkout-alt-form/delivery-date.tsx +114 -0
- package/src/pages-v2/checkout/checkout-alt-form/delivery-options.tsx +190 -0
- package/src/pages-v2/checkout/checkout-alt-form/edit-address-form.tsx +130 -0
- package/src/pages-v2/checkout/checkout-alt-form/heading.tsx +50 -0
- package/src/pages-v2/checkout/checkout-alt-form/index.ts +1 -0
- package/src/pages-v2/checkout/checkout-alt-form/new-address-form.tsx +299 -0
- package/src/pages-v2/checkout/checkout-alt-form/node.tsx +9 -0
- package/src/pages-v2/checkout/checkout-alt-form/payment-details.tsx +347 -0
- package/src/pages-v2/checkout/checkout-alt-form/safe-card-preview-data.tsx +36 -0
- package/src/pages-v2/checkout/checkout-alt-form/types.ts +20 -0
- package/src/pages-v2/checkout/checkout-alt-summary/cart-item.tsx +42 -0
- package/src/pages-v2/checkout/checkout-alt-summary/checkout-alt-summary.tsx +42 -0
- package/src/pages-v2/checkout/checkout-alt-summary/index.ts +1 -0
- package/src/pages-v2/checkout/checkout-alt-summary/list-item.tsx +31 -0
- package/src/pages-v2/confirmation/address.tsx +25 -0
- package/src/pages-v2/confirmation/confirmation-summary.tsx +55 -0
- package/src/pages-v2/confirmation/ordered-products.tsx +115 -0
- package/src/pages-v2/product-details/available-shops.tsx +48 -0
- package/src/pages-v2/product-details/bopis/find-in-store-button.tsx +63 -0
- package/src/pages-v2/product-details/bopis/find-in-store-modal.tsx +257 -0
- package/src/pages-v2/product-details/bopis/pickup-option-select.tsx +127 -0
- package/src/pages-v2/product-details/bopis/search-header.tsx +69 -0
- package/src/pages-v2/product-details/checkbox-label.tsx +20 -0
- package/src/pages-v2/product-details/currency.ts +64 -0
- package/src/pages-v2/product-details/frequently-bought.tsx +97 -0
- package/src/pages-v2/product-details/frequently-product-card.tsx +63 -0
- package/src/pages-v2/product-details/product-comment.tsx +49 -0
- package/src/pages-v2/product-details/product-description.tsx +22 -0
- package/src/pages-v2/product-details/product-filter-card.tsx +265 -0
- package/src/pages-v2/product-details/product-intro/product-intro-images.tsx +90 -0
- package/src/pages-v2/product-details/product-intro/product-intro.tsx +256 -0
- package/src/pages-v2/product-details/product-review.tsx +131 -0
- package/src/pages-v2/product-details/product-tabs.tsx +51 -0
- package/src/pages-v2/product-details/related-products.tsx +42 -0
- package/src/pages-v2/product-details/types.ts +11 -0
- package/src/pages-v2/product-list/breadcrumbs.tsx +39 -0
- package/src/pages-v2/product-list/checkbox-label.tsx +20 -0
- package/src/pages-v2/product-list/facet-group.tsx +125 -0
- package/src/pages-v2/product-list/facet.tsx +36 -0
- package/src/pages-v2/product-list/list-filter.tsx +43 -0
- package/src/pages-v2/product-list/pagination.tsx +80 -0
- package/src/pages-v2/product-list/product-list-context.tsx +302 -0
- package/src/pages-v2/product-list/product-list-state.ts +187 -0
- package/src/pages-v2/product-list/product-rating.tsx +16 -0
- package/src/pages-v2/product-list/quick-view-dialog-content.tsx +207 -0
- package/src/pages-v2/product-list/quick-view-dialog.tsx +54 -0
- package/src/pages-v2/product-list/range-filter.tsx +125 -0
- package/src/pages-v2/product-list/scrollbar.tsx +38 -0
- package/src/pages-v2/product-list/search-bar.tsx +162 -0
- package/src/pages-v2/product-list/selected-facets.tsx +80 -0
- package/src/pages-v2/product-list/side-nav.tsx +49 -0
- package/src/pages-v2/product-list/swatch.tsx +80 -0
- package/src/pages-v2/product-list/types.ts +18 -0
- package/src/pages-v2/product-list/use-product-list.ts +12 -0
- package/src/pages-v2/product-list/useCategoryFilter.tsx +26 -0
- package/src/pages-v2/product-list/utils/facet-helpers.ts +5 -0
- package/src/pages-v2/product-list/utils/generate-breadcrumbs.ts +30 -0
- package/src/pages-v2/product-list/utils/getCategoryFilterFromSlug.ts +153 -0
- package/src/pages-v2/product-list/utils/product-list-helper.ts +111 -0
- package/src/pages-v2/product-list/utils/product-list-types.ts +41 -0
- package/src/pages-v2/product-list/utils/search-for-category.ts +76 -0
- package/src/pages-v2/product-list/utils/sort-options.ts +44 -0
- package/src/pages-v2/product-list/utils/use-previous-refiners.ts +14 -0
- package/src/pages-v2/quickorder/order-upload.tsx +150 -0
- package/src/pages-v2/quickorder/quick-order-form.tsx +346 -0
- package/src/pages-v2/quickorder/quick-order-row.tsx +144 -0
- package/src/providers/nav-provider/index.tsx +59 -0
- package/src/providers/nav-provider/utils/createLink.ts +15 -0
- package/src/providers/notifications/README.md +15 -0
- package/src/providers/notifications/notification-context.tsx +82 -0
- package/src/providers/notifications/use-notification.ts +12 -0
- package/tsconfig.json +3 -2
- package/typedoc.js +10 -0
- package/src/api-manager/api-manager.config.json +0 -12
- package/src/api-manager/datasources/e4/e4.remaps.ts +0 -355
- package/src/api-manager/datasources/e4/e4.translator.test.ts +0 -202
- /package/src/hooks/{use-cart.tsx → use-cart.ts} +0 -0
- /package/src/hooks/{use-variants.tsx → use-variants.ts} +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useEffect, useState, ReactNode } from "react";
|
|
2
|
+
import Drawer from "@mui/material/Drawer";
|
|
3
|
+
// GLOBAL CUSTOM COMPONENT
|
|
4
|
+
import Scrollbar from "./scrollbar";
|
|
5
|
+
|
|
6
|
+
// ================================================================
|
|
7
|
+
interface Props {
|
|
8
|
+
open?: boolean;
|
|
9
|
+
width?: number;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
toggle?: () => void;
|
|
12
|
+
position?: "left" | "right";
|
|
13
|
+
handler: (event: () => void) => ReactNode;
|
|
14
|
+
}
|
|
15
|
+
// ================================================================
|
|
16
|
+
|
|
17
|
+
export default function SideNav(props: Props) {
|
|
18
|
+
const {
|
|
19
|
+
position = "left",
|
|
20
|
+
open = false,
|
|
21
|
+
width = 280,
|
|
22
|
+
children,
|
|
23
|
+
handler,
|
|
24
|
+
toggle,
|
|
25
|
+
} = props;
|
|
26
|
+
|
|
27
|
+
const [sideNavOpen, setSideNavOpen] = useState(open);
|
|
28
|
+
const handleToggleSideNav = () => setSideNavOpen(!sideNavOpen);
|
|
29
|
+
|
|
30
|
+
useEffect(() => setSideNavOpen(open), [open]);
|
|
31
|
+
|
|
32
|
+
const handleClose = toggle || handleToggleSideNav;
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div>
|
|
36
|
+
<Drawer
|
|
37
|
+
anchor={position}
|
|
38
|
+
open={sideNavOpen}
|
|
39
|
+
onClose={handleClose}
|
|
40
|
+
SlideProps={{ style: { width } }}
|
|
41
|
+
sx={{ zIndex: 15001 }}
|
|
42
|
+
>
|
|
43
|
+
<Scrollbar autoHide={false}>{children}</Scrollbar>
|
|
44
|
+
</Drawer>
|
|
45
|
+
|
|
46
|
+
{handler(handleClose)}
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use client";
|
|
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";
|
|
7
|
+
|
|
8
|
+
type Props = RenderedFacetProps & NonNullable<unknown>;
|
|
9
|
+
|
|
10
|
+
const cssColorName = (color: string | undefined) => {
|
|
11
|
+
if (!color) return false;
|
|
12
|
+
const cssColorName = new Option().style;
|
|
13
|
+
cssColorName.color = color;
|
|
14
|
+
return cssColorName.color !== "";
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const checkWhite = (color: string | undefined) => {
|
|
18
|
+
return color?.trim().toLowerCase() === "white";
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default function Swatch({
|
|
22
|
+
facet,
|
|
23
|
+
handleRefinerSelect,
|
|
24
|
+
isRefinerSelected,
|
|
25
|
+
}: Props) {
|
|
26
|
+
const theme = useTheme();
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Box mb={3}>
|
|
30
|
+
{facet.Values?.map((colorItem: ProductRefinerValue) => {
|
|
31
|
+
return (
|
|
32
|
+
<Box
|
|
33
|
+
key={colorItem.LeftValueBoundString}
|
|
34
|
+
display="inline-block"
|
|
35
|
+
mr={3}
|
|
36
|
+
sx={{ textAlign: "center" }}
|
|
37
|
+
>
|
|
38
|
+
<Chip
|
|
39
|
+
clickable={true}
|
|
40
|
+
key={colorItem.LeftValueBoundString}
|
|
41
|
+
onClick={() => handleRefinerSelect(colorItem)}
|
|
42
|
+
sx={{
|
|
43
|
+
color: "black",
|
|
44
|
+
borderRadius: "100%",
|
|
45
|
+
backgroundColor:
|
|
46
|
+
colorItem.SwatchColorHexCode ||
|
|
47
|
+
(cssColorName(colorItem.LeftValueBoundString)
|
|
48
|
+
? colorItem.LeftValueBoundString?.toLowerCase()
|
|
49
|
+
: theme.palette.grey[300]),
|
|
50
|
+
width: 32,
|
|
51
|
+
height: 32,
|
|
52
|
+
border: checkWhite(colorItem.LeftValueBoundString)
|
|
53
|
+
? "1px solid black"
|
|
54
|
+
: isRefinerSelected(colorItem)
|
|
55
|
+
? "2px solid"
|
|
56
|
+
: "2px solid transparent",
|
|
57
|
+
"&:hover": {
|
|
58
|
+
backgroundColor:
|
|
59
|
+
colorItem.SwatchColorHexCode ||
|
|
60
|
+
(cssColorName(colorItem.LeftValueBoundString)
|
|
61
|
+
? colorItem.LeftValueBoundString?.toLowerCase()
|
|
62
|
+
: theme.palette.grey[300]),
|
|
63
|
+
},
|
|
64
|
+
".MuiChip-label": {
|
|
65
|
+
overflow: "visible",
|
|
66
|
+
},
|
|
67
|
+
}}
|
|
68
|
+
label={
|
|
69
|
+
!colorItem.SwatchColorHexCode &&
|
|
70
|
+
(colorItem.LeftValueBoundString || "0")[0].toUpperCase()
|
|
71
|
+
}
|
|
72
|
+
title={colorItem.LeftValueBoundString}
|
|
73
|
+
/>
|
|
74
|
+
<p>{colorItem.LeftValueBoundString}</p>
|
|
75
|
+
</Box>
|
|
76
|
+
);
|
|
77
|
+
})}
|
|
78
|
+
</Box>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface ProductFilters {
|
|
2
|
+
brand: string[];
|
|
3
|
+
color: string[];
|
|
4
|
+
sales: string[];
|
|
5
|
+
price: number[];
|
|
6
|
+
rating: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type ProductFilterKeys = keyof ProductFilters;
|
|
10
|
+
export type ProductFilterValues = ProductFilters[ProductFilterKeys];
|
|
11
|
+
|
|
12
|
+
export type SortOption = {
|
|
13
|
+
field: string;
|
|
14
|
+
isDefault?: boolean;
|
|
15
|
+
isDescending: boolean;
|
|
16
|
+
displayName: string;
|
|
17
|
+
defaultForSearch?: boolean;
|
|
18
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { ProductListContext } from "./product-list-context";
|
|
3
|
+
|
|
4
|
+
const useProductList = () => {
|
|
5
|
+
const context = useContext(ProductListContext);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new Error("Context must be used within a ProductListProvider");
|
|
8
|
+
}
|
|
9
|
+
return context;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default useProductList;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { notFound } from "next/navigation";
|
|
2
|
+
|
|
3
|
+
export type Category = {
|
|
4
|
+
id: string;
|
|
5
|
+
parentId: string | null;
|
|
6
|
+
seoCrumb?: string | null;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function getE4CategoryIdFromSlug(
|
|
10
|
+
slug: string[],
|
|
11
|
+
categories: Category[],
|
|
12
|
+
): string {
|
|
13
|
+
if (!slug || slug.length === 0) {
|
|
14
|
+
const home = categories.find(
|
|
15
|
+
(cat) => cat.seoCrumb?.toLowerCase() === "home",
|
|
16
|
+
);
|
|
17
|
+
return home ? home.id : "1";
|
|
18
|
+
}
|
|
19
|
+
const slugStr = slug.join("/").toLowerCase();
|
|
20
|
+
const found = categories.find(
|
|
21
|
+
(cat) => cat.seoCrumb?.toLowerCase() === slugStr,
|
|
22
|
+
);
|
|
23
|
+
if (found) return found.id;
|
|
24
|
+
notFound();
|
|
25
|
+
return "";
|
|
26
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CategoryHierarchy } from "@/lib/category-helpers";
|
|
2
|
+
import { searchCategory } from "./search-for-category";
|
|
3
|
+
|
|
4
|
+
const generateBreadcrumbs = (
|
|
5
|
+
selectedCategory: CategoryHierarchy | undefined,
|
|
6
|
+
categoryHierarchy: CategoryHierarchy[],
|
|
7
|
+
locale: string,
|
|
8
|
+
) => {
|
|
9
|
+
const breadcrumbs: CategoryHierarchy[] = [];
|
|
10
|
+
if (selectedCategory) {
|
|
11
|
+
breadcrumbs.push(selectedCategory);
|
|
12
|
+
}
|
|
13
|
+
let nextCategory: CategoryHierarchy | undefined =
|
|
14
|
+
selectedCategory ?? undefined;
|
|
15
|
+
while (nextCategory) {
|
|
16
|
+
nextCategory = searchCategory(
|
|
17
|
+
locale,
|
|
18
|
+
categoryHierarchy,
|
|
19
|
+
nextCategory?.ParentCategory,
|
|
20
|
+
);
|
|
21
|
+
if (nextCategory) {
|
|
22
|
+
breadcrumbs.push(nextCategory);
|
|
23
|
+
} else {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return breadcrumbs.reverse();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default generateBreadcrumbs;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
export type Category = {
|
|
2
|
+
id?: string;
|
|
3
|
+
RecordId?: number;
|
|
4
|
+
parentId?: string | null;
|
|
5
|
+
ParentCategory?: number;
|
|
6
|
+
seoCrumb?: string | null;
|
|
7
|
+
Url?: string;
|
|
8
|
+
Name?: string;
|
|
9
|
+
NeutralizedNAME?: string;
|
|
10
|
+
Children?: Category[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function getCategoryIdFromSlug(
|
|
14
|
+
slug: string[],
|
|
15
|
+
categories: Category[],
|
|
16
|
+
isD365: boolean,
|
|
17
|
+
): string | undefined {
|
|
18
|
+
if (!slug || slug.length === 0 || !categories || categories.length === 0) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (slug.length > 1) {
|
|
23
|
+
const parentSlug = slug[0]?.toLowerCase();
|
|
24
|
+
const childSlug = slug[1]?.toLowerCase();
|
|
25
|
+
|
|
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
|
+
});
|
|
38
|
+
|
|
39
|
+
if (!parentCategory) {
|
|
40
|
+
console.warn(
|
|
41
|
+
"getCategoryIdFromSlug: No parent category found for slug:",
|
|
42
|
+
parentSlug,
|
|
43
|
+
);
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
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
|
+
}
|
|
64
|
+
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const slugValue = slug[0]?.toLowerCase();
|
|
69
|
+
|
|
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
|
+
});
|
|
82
|
+
|
|
83
|
+
if (topLevelMatch) {
|
|
84
|
+
return isD365
|
|
85
|
+
? topLevelMatch.RecordId?.toString()
|
|
86
|
+
: topLevelMatch.id?.toString();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let childMatch: Category | undefined;
|
|
90
|
+
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
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (childMatch) {
|
|
112
|
+
return isD365 ? childMatch.RecordId?.toString() : childMatch.id?.toString();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function getCategoryFilterFromSlug(
|
|
119
|
+
slug: string[],
|
|
120
|
+
categories: Category[],
|
|
121
|
+
): string {
|
|
122
|
+
if (!slug || slug.length === 0) {
|
|
123
|
+
return "";
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const topLevelSlugs = ["men", "women", "accessories"];
|
|
127
|
+
|
|
128
|
+
if (slug.length === 1 && topLevelSlugs.includes(slug[0].toLowerCase())) {
|
|
129
|
+
const topCategory = categories.find((cat) => {
|
|
130
|
+
const seoCrumb =
|
|
131
|
+
cat?.seoCrumb?.toLowerCase() ||
|
|
132
|
+
cat?.Url?.toLowerCase() ||
|
|
133
|
+
cat?.Name?.toLowerCase();
|
|
134
|
+
return seoCrumb === slug[0].toLowerCase();
|
|
135
|
+
});
|
|
136
|
+
if (topCategory) {
|
|
137
|
+
const children = categories.filter((cat) => {
|
|
138
|
+
const parentIdMatch =
|
|
139
|
+
cat.parentId === topCategory.id ||
|
|
140
|
+
cat.ParentCategory === topCategory.RecordId;
|
|
141
|
+
return parentIdMatch && (cat.seoCrumb || cat.Url || cat.Name);
|
|
142
|
+
});
|
|
143
|
+
if (children.length > 0) {
|
|
144
|
+
return children
|
|
145
|
+
.map((child) => (child.seoCrumb || child.Url || child.Name) as string)
|
|
146
|
+
.join("|");
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return slug[0];
|
|
150
|
+
} else {
|
|
151
|
+
return slug.join("/");
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { IQueryResultSettings } from "@msdyn365-commerce/retail-proxy";
|
|
2
|
+
import { PageKey, SortOption } from "./product-list-types";
|
|
3
|
+
import getSortOptions from "./sort-options";
|
|
4
|
+
import { convertParameterToRefiner } from "@/lib/refiner-utils";
|
|
5
|
+
import { SearchByCriteriaInput } from "@/api-manager/schemas/product.schema";
|
|
6
|
+
|
|
7
|
+
const getDefaultValueByPageKey = (pageKey: PageKey) => {
|
|
8
|
+
switch (pageKey) {
|
|
9
|
+
case PageKey.TOP:
|
|
10
|
+
return 20;
|
|
11
|
+
case PageKey.PAGE:
|
|
12
|
+
return 1;
|
|
13
|
+
case PageKey.REFINEMENT:
|
|
14
|
+
case PageKey.SEARCH:
|
|
15
|
+
return "";
|
|
16
|
+
case PageKey.VIEW:
|
|
17
|
+
return "grid";
|
|
18
|
+
default:
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const getSelectedSortOption = (
|
|
24
|
+
sortOptions: SortOption[],
|
|
25
|
+
isSearch: boolean,
|
|
26
|
+
sortCode?: string,
|
|
27
|
+
) => {
|
|
28
|
+
let sortOption: SortOption | undefined;
|
|
29
|
+
if (sortCode) {
|
|
30
|
+
sortOption = sortOptions.find((s) => s.code === sortCode);
|
|
31
|
+
} else {
|
|
32
|
+
sortOption = sortOptions.find((s) =>
|
|
33
|
+
isSearch ? s.defaultForSearch : s.isDefault,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
if (!sortOption) {
|
|
37
|
+
sortOption = sortOptions[0];
|
|
38
|
+
}
|
|
39
|
+
return sortOption;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const getCategoryFromSlug = (slug: string[]) => {
|
|
43
|
+
if (Array.isArray(slug)) {
|
|
44
|
+
const categoryId = Number(slug.pop());
|
|
45
|
+
if (!isNaN(categoryId)) {
|
|
46
|
+
return categoryId;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const calculatePage = (searchState: IQueryResultSettings): number => {
|
|
53
|
+
const skip = searchState?.Paging?.Skip ?? 0;
|
|
54
|
+
const top = searchState?.Paging?.Top ?? 20;
|
|
55
|
+
|
|
56
|
+
return skip === 0 ? 1 : skip / top + 1;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const calculateSkip = (page: number, top: number) => (page - 1) * top;
|
|
60
|
+
|
|
61
|
+
const buildInitialState = (
|
|
62
|
+
params: string[],
|
|
63
|
+
top: number,
|
|
64
|
+
page: number,
|
|
65
|
+
sort: string,
|
|
66
|
+
refiner: string,
|
|
67
|
+
searchTerm: string | undefined,
|
|
68
|
+
) => {
|
|
69
|
+
const categoryId = getCategoryFromSlug(params);
|
|
70
|
+
|
|
71
|
+
const selectedSort = getSelectedSortOption(
|
|
72
|
+
getSortOptions(),
|
|
73
|
+
!!searchTerm,
|
|
74
|
+
sort || undefined,
|
|
75
|
+
);
|
|
76
|
+
const state: SearchByCriteriaInput = {
|
|
77
|
+
searchState: {
|
|
78
|
+
queryResultSettings: {
|
|
79
|
+
Paging: {
|
|
80
|
+
Top: top,
|
|
81
|
+
Skip: calculateSkip(page, top),
|
|
82
|
+
},
|
|
83
|
+
Sorting: {
|
|
84
|
+
Columns:
|
|
85
|
+
(selectedSort && [
|
|
86
|
+
{
|
|
87
|
+
ColumnName: selectedSort?.field,
|
|
88
|
+
IsDescending: selectedSort?.isDescending,
|
|
89
|
+
},
|
|
90
|
+
]) ||
|
|
91
|
+
[],
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
refinement: refiner
|
|
95
|
+
? refiner.split("||").map((r) => convertParameterToRefiner(r))
|
|
96
|
+
: [],
|
|
97
|
+
searchTerm: searchTerm,
|
|
98
|
+
},
|
|
99
|
+
categoryId: categoryId,
|
|
100
|
+
};
|
|
101
|
+
return state;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
getDefaultValueByPageKey,
|
|
106
|
+
getSelectedSortOption,
|
|
107
|
+
getCategoryFromSlug,
|
|
108
|
+
calculatePage,
|
|
109
|
+
calculateSkip,
|
|
110
|
+
buildInitialState,
|
|
111
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ProductRefinerValue } from "@msdyn365-commerce/retail-proxy";
|
|
2
|
+
|
|
3
|
+
export const PageKey = {
|
|
4
|
+
TOP: "perPage",
|
|
5
|
+
PAGE: "page",
|
|
6
|
+
REFINEMENT: "refiner",
|
|
7
|
+
VIEW: "view",
|
|
8
|
+
SORT: "sort",
|
|
9
|
+
SEARCH: "search",
|
|
10
|
+
} as const;
|
|
11
|
+
|
|
12
|
+
export type ProductListSearchParams = {
|
|
13
|
+
perPage?: typeof PageKey.TOP;
|
|
14
|
+
page?: typeof PageKey.PAGE;
|
|
15
|
+
refiner: typeof PageKey.REFINEMENT;
|
|
16
|
+
search: typeof PageKey.SEARCH;
|
|
17
|
+
sort: typeof PageKey.SORT;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type PageKey = (typeof PageKey)[keyof typeof PageKey];
|
|
21
|
+
|
|
22
|
+
export type ViewMode = "grid" | "list";
|
|
23
|
+
|
|
24
|
+
export type ProductListParamHandlers = {
|
|
25
|
+
handlePageChange: (page: number) => void;
|
|
26
|
+
handlePerPageChange: (perPage: number) => void;
|
|
27
|
+
handleRefinerChange: (refiner: ProductRefinerValue) => void;
|
|
28
|
+
handleSortChange: (sort: SortOption) => void;
|
|
29
|
+
handleViewChange: (view: ViewMode) => void;
|
|
30
|
+
handleSearchChange: (searchTerm: string) => void;
|
|
31
|
+
handleRefinersClear?: () => void;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type SortOption = {
|
|
35
|
+
field: string;
|
|
36
|
+
code: string;
|
|
37
|
+
isDefault?: boolean;
|
|
38
|
+
isDescending: boolean;
|
|
39
|
+
displayName: string;
|
|
40
|
+
defaultForSearch?: boolean;
|
|
41
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { CategoryHierarchy } from "@/lib/category-helpers";
|
|
2
|
+
import { PageSlug } from "@/lib/page-slugs";
|
|
3
|
+
import { TextValueTranslation } from "@msdyn365-commerce/retail-proxy";
|
|
4
|
+
|
|
5
|
+
const searchCategory = (
|
|
6
|
+
locale: string,
|
|
7
|
+
categoryHierarchy: CategoryHierarchy[],
|
|
8
|
+
categoryId?: number,
|
|
9
|
+
categoryName?: string,
|
|
10
|
+
): CategoryHierarchy | undefined => {
|
|
11
|
+
let foundCategory;
|
|
12
|
+
if (!Array.isArray(categoryHierarchy)) {
|
|
13
|
+
return foundCategory;
|
|
14
|
+
}
|
|
15
|
+
for (const cat of categoryHierarchy) {
|
|
16
|
+
if (categoryId === cat.RecordId) {
|
|
17
|
+
foundCategory = cat;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
let nameToCheck = getCategoryTranslatedName(locale, cat.NameTranslations);
|
|
21
|
+
if (!nameToCheck) {
|
|
22
|
+
nameToCheck = cat.Name;
|
|
23
|
+
}
|
|
24
|
+
if (
|
|
25
|
+
categoryName &&
|
|
26
|
+
nameToCheck &&
|
|
27
|
+
normalizeCategoryName(categoryName) === normalizeCategoryName(nameToCheck)
|
|
28
|
+
) {
|
|
29
|
+
foundCategory = cat;
|
|
30
|
+
}
|
|
31
|
+
if (cat.Children && cat.Children.length > 0) {
|
|
32
|
+
const matchingChild = searchCategory(
|
|
33
|
+
locale,
|
|
34
|
+
cat.Children,
|
|
35
|
+
categoryId,
|
|
36
|
+
categoryName,
|
|
37
|
+
);
|
|
38
|
+
if (matchingChild) {
|
|
39
|
+
foundCategory = matchingChild;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return foundCategory;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const getCategoryTranslatedName = (
|
|
47
|
+
locale?: string,
|
|
48
|
+
nameTranslations?: TextValueTranslation[],
|
|
49
|
+
): string | undefined => {
|
|
50
|
+
let nameTranslation: TextValueTranslation | undefined;
|
|
51
|
+
if (locale && nameTranslations && nameTranslations.length > 0) {
|
|
52
|
+
nameTranslation = nameTranslations.find(
|
|
53
|
+
(item) => item.Language?.toLowerCase() === locale.toLowerCase(),
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
return nameTranslation && nameTranslation.Text;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const normalizeCategoryName = (name: string) =>
|
|
60
|
+
name.toLowerCase().replace(/ /g, "-");
|
|
61
|
+
|
|
62
|
+
const getCategoryUrl = (category: CategoryHierarchy) => {
|
|
63
|
+
const contentPageKey = PageSlug.Content;
|
|
64
|
+
const productListPageKey = PageSlug.ProductList;
|
|
65
|
+
if (category.IsCMSPage) {
|
|
66
|
+
return `/${contentPageKey}/${category.Url}`;
|
|
67
|
+
}
|
|
68
|
+
return `/${productListPageKey}/${category.Url}`;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
searchCategory,
|
|
73
|
+
getCategoryTranslatedName,
|
|
74
|
+
normalizeCategoryName,
|
|
75
|
+
getCategoryUrl,
|
|
76
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SortOption } from "./product-list-types";
|
|
2
|
+
|
|
3
|
+
const sortOptions: SortOption[] = [
|
|
4
|
+
{
|
|
5
|
+
field: "Name",
|
|
6
|
+
code: "name-asc",
|
|
7
|
+
isDefault: true,
|
|
8
|
+
displayName: "Name A-Z",
|
|
9
|
+
isDescending: false,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
field: "Name",
|
|
13
|
+
code: "name-desc",
|
|
14
|
+
isDefault: false,
|
|
15
|
+
displayName: "Name Z-A",
|
|
16
|
+
isDescending: true,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
field: "Price",
|
|
20
|
+
code: "price-desc",
|
|
21
|
+
isDefault: false,
|
|
22
|
+
displayName: "Price High to Low",
|
|
23
|
+
isDescending: true,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
field: "Price",
|
|
27
|
+
code: "price-asc",
|
|
28
|
+
isDefault: false,
|
|
29
|
+
displayName: "Price Low to High",
|
|
30
|
+
isDescending: false,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
field: "Relevance",
|
|
34
|
+
code: "relevance",
|
|
35
|
+
isDefault: false,
|
|
36
|
+
displayName: "Relevance",
|
|
37
|
+
isDescending: true,
|
|
38
|
+
defaultForSearch: true,
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const getSortOptions = () => sortOptions;
|
|
43
|
+
|
|
44
|
+
export default getSortOptions;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
export const usePreviousRefiners = <T>(
|
|
4
|
+
value: T,
|
|
5
|
+
isValid: (val: T) => boolean,
|
|
6
|
+
): T => {
|
|
7
|
+
const ref = useRef<T>(value);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (isValid(value)) {
|
|
10
|
+
ref.current = value;
|
|
11
|
+
}
|
|
12
|
+
}, [value, isValid]);
|
|
13
|
+
return ref.current;
|
|
14
|
+
};
|