@evenicanpm/storefront-core 1.0.0-alpha
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/README.md +40 -0
- package/package.json +36 -0
- package/src/api-manager/README.md +38 -0
- package/src/api-manager/api-manager.config.json +12 -0
- package/src/api-manager/datasources/README.md +17 -0
- package/src/api-manager/datasources/d365/d365-address.datasource.ts +141 -0
- package/src/api-manager/datasources/d365/d365-base.datasource.ts +8 -0
- package/src/api-manager/datasources/d365/d365-cart.datasource.ts +374 -0
- package/src/api-manager/datasources/d365/d365-categories.datasource.ts +40 -0
- package/src/api-manager/datasources/d365/d365-order.datasource.ts +69 -0
- package/src/api-manager/datasources/d365/d365-organization.datasource.ts +92 -0
- package/src/api-manager/datasources/d365/d365-product.datasource.ts +272 -0
- package/src/api-manager/datasources/d365/d365-session.datasource.ts +25 -0
- package/src/api-manager/datasources/d365/d365-user.datasource.ts +132 -0
- package/src/api-manager/datasources/d365/d365.datasource.ts +45 -0
- package/src/api-manager/datasources/d365/index.ts +4 -0
- package/src/api-manager/datasources/d365/test-context.ts +30 -0
- package/src/api-manager/datasources/d365/utils/create-search-criteria.ts +17 -0
- package/src/api-manager/datasources/d365/utils/decode-jwt.ts +11 -0
- package/src/api-manager/datasources/d365/utils/get-context-cookie.ts +37 -0
- package/src/api-manager/datasources/d365/utils/parse-object.ts +9 -0
- package/src/api-manager/datasources/d365/utils/product-images-utils.ts +43 -0
- package/src/api-manager/datasources/d365/utils/product-inventory-utils.ts +37 -0
- package/src/api-manager/datasources/e4/e4-address.datasource.ts +107 -0
- package/src/api-manager/datasources/e4/e4-cart.datasource.ts +248 -0
- package/src/api-manager/datasources/e4/e4-order.datasource.ts +43 -0
- package/src/api-manager/datasources/e4/e4-organization.datasource.ts +19 -0
- package/src/api-manager/datasources/e4/e4-product.datasource.ts +157 -0
- package/src/api-manager/datasources/e4/e4-session.datasource.ts +43 -0
- package/src/api-manager/datasources/e4/e4-user.datasource.ts +118 -0
- package/src/api-manager/datasources/e4/e4.datasource.ts +55 -0
- package/src/api-manager/datasources/e4/e4.remaps.ts +331 -0
- package/src/api-manager/datasources/e4/e4.translator.test.ts +202 -0
- package/src/api-manager/datasources/e4/e4.translator.ts +648 -0
- package/src/api-manager/datasources/e4/graphqlRequestSdk.ts +43515 -0
- package/src/api-manager/datasources/e4/utils/unwrap-e4-variants.ts +65 -0
- package/src/api-manager/index.ts +71 -0
- package/src/api-manager/lib/cart-cookie-handler.ts +14 -0
- package/src/api-manager/lib/category-helpers.ts +113 -0
- package/src/api-manager/lib/get-dynamics-context.ts +34 -0
- package/src/api-manager/lib/get-graphql-client.test.ts +106 -0
- package/src/api-manager/lib/get-graphql-client.ts +53 -0
- package/src/api-manager/schemas/README.md +12 -0
- package/src/api-manager/schemas/address.schema.ts +46 -0
- package/src/api-manager/schemas/cart.schema.ts +92 -0
- package/src/api-manager/schemas/d365.schema.ts +7727 -0
- package/src/api-manager/schemas/order.schema.ts +30 -0
- package/src/api-manager/schemas/organization.schema.ts +32 -0
- package/src/api-manager/schemas/product.schema.ts +140 -0
- package/src/api-manager/schemas/session.schema.ts +17 -0
- package/src/api-manager/schemas/user.schema.ts +14 -0
- package/src/api-manager/services/address/mutations/create-address.ts +22 -0
- package/src/api-manager/services/address/mutations/delete-address.ts +21 -0
- package/src/api-manager/services/address/mutations/get-delivery-options.ts +22 -0
- package/src/api-manager/services/address/mutations/update-address.ts +21 -0
- package/src/api-manager/services/address/queries/get-countries.ts +16 -0
- package/src/api-manager/services/address/queries/get-states.ts +16 -0
- package/src/api-manager/services/cart/mutations/add-discount-code.ts +21 -0
- package/src/api-manager/services/cart/mutations/add-to-cart.ts +53 -0
- package/src/api-manager/services/cart/mutations/checkout.ts +11 -0
- package/src/api-manager/services/cart/mutations/delete-cart-line.ts +18 -0
- package/src/api-manager/services/cart/mutations/get-payment-accept-result.ts +20 -0
- package/src/api-manager/services/cart/mutations/remove-cart-line-delivery-mode.ts +24 -0
- package/src/api-manager/services/cart/mutations/remove-discount-code.ts +21 -0
- package/src/api-manager/services/cart/mutations/update-cart-line-delivery-mode.ts +24 -0
- package/src/api-manager/services/cart/mutations/update-cart-lines.ts +21 -0
- package/src/api-manager/services/cart/mutations/update-cart.ts +21 -0
- package/src/api-manager/services/cart/queries/get-cart.ts +12 -0
- package/src/api-manager/services/cart/queries/get-payment-accept-point.ts +18 -0
- package/src/api-manager/services/categories/queries/get-categories.ts +8 -0
- package/src/api-manager/services/create-mutation.ts +65 -0
- package/src/api-manager/services/create-query.ts +305 -0
- package/src/api-manager/services/get-query-client.ts +40 -0
- package/src/api-manager/services/order/queries/get-order-details.ts +17 -0
- package/src/api-manager/services/order/queries/get-orders.ts +14 -0
- package/src/api-manager/services/organization/queries/get-channel-configuration.ts +14 -0
- package/src/api-manager/services/organization/queries/get-stores.ts +17 -0
- package/src/api-manager/services/product/mutations/search-products.ts +23 -0
- package/src/api-manager/services/product/queries/get-product-availability.ts +15 -0
- package/src/api-manager/services/product/queries/get-product-by-id.ts +17 -0
- package/src/api-manager/services/product/queries/get-product-by-ids.ts +14 -0
- package/src/api-manager/services/product/queries/get-product-list.ts +16 -0
- package/src/api-manager/services/product/queries/get-related-products.ts +14 -0
- package/src/api-manager/services/product/queries/search-products.ts +10 -0
- package/src/api-manager/services/product/server/product.server.ts +13 -0
- package/src/api-manager/services/session/mutations/session-init.ts +22 -0
- package/src/api-manager/services/session/mutations/session-logout.ts +18 -0
- package/src/api-manager/services/session/queries/get-session.ts +10 -0
- package/src/api-manager/services/user/mutations/create-wishlist.ts +21 -0
- package/src/api-manager/services/user/mutations/delete-wishlist.ts +17 -0
- package/src/api-manager/services/user/mutations/update-user.ts +18 -0
- package/src/api-manager/services/user/queries/get-user-counts.ts +10 -0
- package/src/api-manager/services/user/queries/get-user.ts +10 -0
- package/src/api-manager/services/user/queries/get-wishlist-details.ts +10 -0
- package/src/api-manager/services/user/queries/get-wishlists.ts +10 -0
- package/src/api-manager/types/Datasource.ts +197 -0
- package/src/auth/auth-options.test.ts +127 -0
- package/src/auth/auth-options.ts +68 -0
- package/src/auth/msal.ts +65 -0
- package/src/auth/next-auth-cookie-manager.ts +86 -0
- package/src/auth/providers/aadb2c-provider.ts +33 -0
- package/src/auth/providers/authentik-provider.ts +24 -0
- package/src/auth/providers/index.ts +9 -0
- package/src/auth/providers/keycloak-provider.ts +22 -0
- package/src/auth/refresh-token-url-keys.ts +6 -0
- package/src/auth/refresh-token.ts +134 -0
- package/src/auth/signout.ts +46 -0
- package/src/auth/types/next-auth.d.ts +38 -0
- package/src/cms/blog.ts +229 -0
- package/src/cms/endpoints.ts +76 -0
- package/src/cms/interfaces/navigation.ts +52 -0
- package/src/cms/interfaces/productData.ts +83 -0
- package/src/cms/pages.ts +149 -0
- package/src/components/Blocks/BlockManager.tsx +67 -0
- package/src/components/Blocks/Components/BrandLogosScroller.tsx +72 -0
- package/src/components/Blocks/Components/CategoryCard.tsx +47 -0
- package/src/components/Blocks/Components/CategoryCarousel/index.tsx +60 -0
- package/src/components/Blocks/Components/FeaturePill.tsx +99 -0
- package/src/components/Blocks/Components/FeaturedCategories.tsx +41 -0
- package/src/components/Blocks/Components/FeaturedProducts.tsx +41 -0
- package/src/components/Blocks/Components/Footer.tsx +77 -0
- package/src/components/Blocks/Components/Hero.tsx +73 -0
- package/src/components/Blocks/Components/HeroCarousel/index.tsx +42 -0
- package/src/components/Blocks/Components/Image.tsx +39 -0
- package/src/components/Blocks/Components/MediaCard.tsx +41 -0
- package/src/components/Blocks/Components/ProductCarousel/index.tsx +82 -0
- package/src/components/Blocks/Components/ProductSectionFullWidth/index.tsx +103 -0
- package/src/components/Blocks/Components/RichText.tsx +19 -0
- package/src/components/Blocks/Components/Seo/index.tsx +48 -0
- package/src/components/Blocks/Components/Services/index.tsx +21 -0
- package/src/components/Blocks/Components/Services/service-card.tsx +70 -0
- package/src/components/Blocks/Components/shared/featured-product-card.tsx +29 -0
- package/src/components/Blocks/Components/shared/product-category-item.tsx +49 -0
- package/src/components/Blocks/Components/shared/product-grid.tsx +48 -0
- package/src/components/Blocks/Components/shared/top-categories-card.tsx +66 -0
- package/src/components/Blocks/Components/shared/top-rating-product-card.tsx +63 -0
- package/src/components/Blocks/Icons/Components/Category.tsx +14 -0
- package/src/components/Blocks/Icons/Components/DottedStar.tsx +40 -0
- package/src/components/Blocks/Icons/Components/FallbackIcon.tsx +33 -0
- package/src/components/Blocks/Icons/Components/GiftBox.tsx +18 -0
- package/src/components/Blocks/Icons/Components/Light.tsx +13 -0
- package/src/components/Blocks/Icons/Components/NewArrival.tsx +18 -0
- package/src/components/Blocks/Icons/Components/RankBadge.tsx +39 -0
- package/src/components/Blocks/Icons/index.ts +32 -0
- package/src/components/Blocks/index.tsx +16 -0
- package/src/components/Blocks/interfaces.ts +240 -0
- package/src/components/BoxShadowCard.tsx +16 -0
- package/src/components/Footer/data/index.ts +32 -0
- package/src/components/Footer/index.tsx +88 -0
- package/src/components/Footer/interfaces.ts +37 -0
- package/src/components/Footer/sections/FooterAppStore.tsx +45 -0
- package/src/components/Footer/sections/FooterContact.tsx +36 -0
- package/src/components/Footer/sections/FooterLinks.tsx +30 -0
- package/src/components/Footer/sections/FooterLogo.tsx +26 -0
- package/src/components/Footer/sections/FooterSocialLinks.tsx +70 -0
- package/src/components/Footer/styles/index.ts +39 -0
- package/src/components/GlobalLoading/index.tsx +102 -0
- package/src/components/ImageWithFallback.tsx +51 -0
- package/src/components/Loading/index.tsx +36 -0
- package/src/components/NavProvider/index.tsx +59 -0
- package/src/components/NavProvider/utils/createLink.ts +15 -0
- package/src/components/Notifications/README.md +15 -0
- package/src/components/Notifications/notification-context.tsx +82 -0
- package/src/components/Notifications/use-notification.ts +12 -0
- package/src/components/README.md +9 -0
- package/src/components/ReactQueryProvider/index.tsx +12 -0
- package/src/components/Shared/Image.tsx +5 -0
- package/src/components/T/index.tsx +15 -0
- package/src/components/_components/BazaarCard.tsx +21 -0
- package/src/components/_components/BazaarImage.tsx +12 -0
- package/src/components/_components/BazaarMenu.tsx +47 -0
- package/src/components/_components/BazaarSwitch.tsx +37 -0
- package/src/components/_components/BazaarTextField.tsx +73 -0
- package/src/components/_components/DropZone.tsx +86 -0
- package/src/components/_components/HoverBox.tsx +22 -0
- package/src/components/_components/LazyImage.tsx +9 -0
- package/src/components/_components/MiniCartClient.tsx +65 -0
- package/src/components/_components/SearchInput.tsx +28 -0
- package/src/components/_components/SnackbarProvider.tsx +32 -0
- package/src/components/_components/Typography.tsx +227 -0
- package/src/components/_components/WhiteButton.tsx +20 -0
- package/src/components/_components/accordion/accordion-header.tsx +43 -0
- package/src/components/_components/accordion/index.ts +1 -0
- package/src/components/_components/bazaar-types.ts +84 -0
- package/src/components/_components/carousel/carousel.tsx +72 -0
- package/src/components/_components/carousel/components/carousel-arrows.tsx +60 -0
- package/src/components/_components/carousel/components/carousel-dots.tsx +21 -0
- package/src/components/_components/carousel/index.ts +3 -0
- package/src/components/_components/carousel/styles/index.ts +93 -0
- package/src/components/_components/carousel-cards/carousel-card-1/carousel-card-1.tsx +64 -0
- package/src/components/_components/carousel-cards/carousel-card-1/index.ts +1 -0
- package/src/components/_components/carousel-cards/carousel-card-1/styles.ts +34 -0
- package/src/components/_components/carousel-cards/carousel-card-2/carousel-card-2.tsx +73 -0
- package/src/components/_components/carousel-cards/carousel-card-2/index.ts +1 -0
- package/src/components/_components/carousel-cards/carousel-card-2/styles.ts +26 -0
- package/src/components/_components/carousel-cards/carousel-card-3/carousel-card-3.tsx +34 -0
- package/src/components/_components/carousel-cards/carousel-card-3/index.ts +1 -0
- package/src/components/_components/carousel-cards/carousel-card-3/styles.ts +28 -0
- package/src/components/_components/carousel-cards/carousel-card-4/carousel-card-4.tsx +76 -0
- package/src/components/_components/carousel-cards/carousel-card-4/index.ts +1 -0
- package/src/components/_components/carousel-cards/carousel-card-4/styles.ts +27 -0
- package/src/components/_components/categories/category-list/category-list.tsx +59 -0
- package/src/components/_components/categories/category-list/index.ts +1 -0
- package/src/components/_components/categories/category-list/styles.ts +29 -0
- package/src/components/_components/categories/category-list/types.ts +4 -0
- package/src/components/_components/categories/category-list-item/category-menu-item.tsx +37 -0
- package/src/components/_components/categories/category-list-item/index.ts +1 -0
- package/src/components/_components/categories/category-list-item/styles.ts +35 -0
- package/src/components/_components/categories/category-menu.tsx +51 -0
- package/src/components/_components/categories/mega-menu/banner.tsx +56 -0
- package/src/components/_components/categories/mega-menu/column-list.tsx +70 -0
- package/src/components/_components/categories/mega-menu/mega-menu-1.tsx +37 -0
- package/src/components/_components/categories/mega-menu/mega-menu-2.tsx +37 -0
- package/src/components/_components/categories/mega-menu/styles.ts +25 -0
- package/src/components/_components/categories/types.ts +16 -0
- package/src/components/_components/category-cards/category-card-1/category-card-1.tsx +21 -0
- package/src/components/_components/category-cards/category-card-1/index.ts +1 -0
- package/src/components/_components/category-cards/category-card-1/styles.ts +37 -0
- package/src/components/_components/countdown/count-box.tsx +16 -0
- package/src/components/_components/countdown/count-down.tsx +24 -0
- package/src/components/_components/countdown/index.tsx +2 -0
- package/src/components/_components/countdown/useCountDown.ts +41 -0
- package/src/components/_components/data-table/index.ts +2 -0
- package/src/components/_components/data-table/table-header.tsx +91 -0
- package/src/components/_components/data-table/table-pagination.tsx +36 -0
- package/src/components/_components/flex-box/flex-between.tsx +14 -0
- package/src/components/_components/flex-box/flex-box.tsx +9 -0
- package/src/components/_components/flex-box/flex-row-center.tsx +9 -0
- package/src/components/_components/flex-box/index.ts +5 -0
- package/src/components/_components/footer/components/about-links.tsx +23 -0
- package/src/components/_components/footer/components/app-store.tsx +38 -0
- package/src/components/_components/footer/components/customer-care-links.tsx +21 -0
- package/src/components/_components/footer/components/logo.tsx +23 -0
- package/src/components/_components/footer/components/social-links.tsx +43 -0
- package/src/components/_components/footer/data/index.ts +54 -0
- package/src/components/_components/footer/footer-1.tsx +62 -0
- package/src/components/_components/footer/footer-2.tsx +57 -0
- package/src/components/_components/footer/footer-3.tsx +53 -0
- package/src/components/_components/footer/footer-4.tsx +71 -0
- package/src/components/_components/footer/index.ts +4 -0
- package/src/components/_components/footer/styles/index.ts +42 -0
- package/src/components/_components/header/components/categories-menu.tsx +23 -0
- package/src/components/_components/header/components/mobile-header.tsx +72 -0
- package/src/components/_components/header/components/user.test.tsx +200 -0
- package/src/components/_components/header/components/user.tsx +205 -0
- package/src/components/_components/header/header.tsx +63 -0
- package/src/components/_components/header/hooks/use-header.ts +13 -0
- package/src/components/_components/header/index.ts +1 -0
- package/src/components/_components/header/sticky-header.tsx +17 -0
- package/src/components/_components/header/styles/index.ts +24 -0
- package/src/components/_components/hooks/useOverflowDetect.ts +34 -0
- package/src/components/_components/hooks/useSettings.ts +16 -0
- package/src/components/_components/icons/cart-bag.tsx +13 -0
- package/src/components/_components/icons/category-outline.tsx +29 -0
- package/src/components/_components/icons/category.tsx +12 -0
- package/src/components/_components/icons/home.tsx +19 -0
- package/src/components/_components/icons/search.tsx +13 -0
- package/src/components/_components/icons/shopping-bag-outlined.tsx +13 -0
- package/src/components/_components/icons/up-down.tsx +21 -0
- package/src/components/_components/icons/user.tsx +13 -0
- package/src/components/_components/icons/user2.tsx +14 -0
- package/src/components/_components/mini-cart/__tests__/cart-item.test.tsx +174 -0
- package/src/components/_components/mini-cart/__tests__/mini-cart.test.tsx +121 -0
- package/src/components/_components/mini-cart/__tests__/test-cart-empty.json +84 -0
- package/src/components/_components/mini-cart/__tests__/test-cart-with-item.json +244 -0
- package/src/components/_components/mini-cart/components/bottom-actions.tsx +27 -0
- package/src/components/_components/mini-cart/components/cart-item.tsx +144 -0
- package/src/components/_components/mini-cart/components/empty-view.tsx +29 -0
- package/src/components/_components/mini-cart/components/top-header.tsx +34 -0
- package/src/components/_components/mini-cart/index.ts +1 -0
- package/src/components/_components/mini-cart/mini-cart.tsx +107 -0
- package/src/components/_components/mobile-navigation/index.ts +3 -0
- package/src/components/_components/mobile-navigation/mobile-navigation-bar.tsx +73 -0
- package/src/components/_components/mobile-navigation/styles/index.ts +63 -0
- package/src/components/_components/nav-link/index.ts +5 -0
- package/src/components/_components/nav-link/nav-link-2.tsx +32 -0
- package/src/components/_components/nav-link/nav-link-3.tsx +67 -0
- package/src/components/_components/nav-link/nav-link.tsx +53 -0
- package/src/components/_components/navbar/categories.tsx +27 -0
- package/src/components/_components/navbar/category-based-menu/category-based-menu.tsx +52 -0
- package/src/components/_components/navbar/category-based-menu/components/categories.tsx +44 -0
- package/src/components/_components/navbar/category-based-menu/components/category-item.tsx +31 -0
- package/src/components/_components/navbar/category-based-menu/components/child-categories.tsx +38 -0
- package/src/components/_components/navbar/category-based-menu/index.ts +1 -0
- package/src/components/_components/navbar/category-based-menu/styles.ts +81 -0
- package/src/components/_components/navbar/category-based-menu/types.ts +18 -0
- package/src/components/_components/navbar/index.ts +1 -0
- package/src/components/_components/navbar/mega-menu/category-list.tsx +29 -0
- package/src/components/_components/navbar/mega-menu/index.ts +1 -0
- package/src/components/_components/navbar/mega-menu/mega-menu.tsx +71 -0
- package/src/components/_components/navbar/mega-menu/styles.ts +43 -0
- package/src/components/_components/navbar/mobile-menu/index.ts +1 -0
- package/src/components/_components/navbar/mobile-menu/mobile-menu.tsx +70 -0
- package/src/components/_components/navbar/mobile-menu/render-levels.test.tsx +71 -0
- package/src/components/_components/navbar/mobile-menu/render-levels.tsx +62 -0
- package/src/components/_components/navbar/nav-list/cms-nav.test.tsx +84 -0
- package/src/components/_components/navbar/nav-list/index.ts +1 -0
- package/src/components/_components/navbar/nav-list/nav-item-child.tsx +66 -0
- package/src/components/_components/navbar/nav-list/nav-list.tsx +119 -0
- package/src/components/_components/navbar/navbar.tsx +43 -0
- package/src/components/_components/navbar/styles.ts +90 -0
- package/src/components/_components/navbar/utils/transform-nav.test.ts +209 -0
- package/src/components/_components/navbar/utils/transform-nav.ts +43 -0
- package/src/components/_components/newsletter/index.ts +1 -0
- package/src/components/_components/newsletter/newsletter.tsx +108 -0
- package/src/components/_components/newsletter/social-icons.tsx +35 -0
- package/src/components/_components/newsletter/styles.ts +65 -0
- package/src/components/_components/page-sidenav/grocery-side-nav/components/link-item.tsx +21 -0
- package/src/components/_components/page-sidenav/grocery-side-nav/components/list-item.tsx +27 -0
- package/src/components/_components/page-sidenav/grocery-side-nav/components/nav-accordion.tsx +36 -0
- package/src/components/_components/page-sidenav/grocery-side-nav/components/render-child.tsx +26 -0
- package/src/components/_components/page-sidenav/grocery-side-nav/grocery-side-nav.tsx +32 -0
- package/src/components/_components/page-sidenav/grocery-side-nav/index.ts +1 -0
- package/src/components/_components/page-sidenav/grocery-side-nav/styles/index.ts +11 -0
- package/src/components/_components/page-sidenav/health-beauty-side-nav/components/list-item.tsx +27 -0
- package/src/components/_components/page-sidenav/health-beauty-side-nav/components/nav-accordion.tsx +44 -0
- package/src/components/_components/page-sidenav/health-beauty-side-nav/components/render-child.tsx +20 -0
- package/src/components/_components/page-sidenav/health-beauty-side-nav/health-beauty-side-nav.tsx +43 -0
- package/src/components/_components/page-sidenav/health-beauty-side-nav/index.ts +1 -0
- package/src/components/_components/page-sidenav/health-beauty-side-nav/styles/index.ts +27 -0
- package/src/components/_components/page-sidenav/side-navbar/components/list-item.tsx +25 -0
- package/src/components/_components/page-sidenav/side-navbar/components/nav-accordion.tsx +46 -0
- package/src/components/_components/page-sidenav/side-navbar/components/render-child.tsx +20 -0
- package/src/components/_components/page-sidenav/side-navbar/index.ts +1 -0
- package/src/components/_components/page-sidenav/side-navbar/side-nav-bar.tsx +77 -0
- package/src/components/_components/page-sidenav/side-navbar/styles/index.ts +73 -0
- package/src/components/_components/page-sidenav/side-navbar-2/components/button-content.tsx +32 -0
- package/src/components/_components/page-sidenav/side-navbar-2/components/sidebar-accordion.tsx +66 -0
- package/src/components/_components/page-sidenav/side-navbar-2/index.ts +1 -0
- package/src/components/_components/page-sidenav/side-navbar-2/side-navbar-2.tsx +63 -0
- package/src/components/_components/page-sidenav/side-navbar-2/styles/index.ts +68 -0
- package/src/components/_components/product-cards/discount-chip.tsx +43 -0
- package/src/components/_components/product-cards/product-card-1/components/hover-actions.tsx +37 -0
- package/src/components/_components/product-cards/product-card-1/components/quantity-buttons.tsx +56 -0
- package/src/components/_components/product-cards/product-card-1/index.ts +1 -0
- package/src/components/_components/product-cards/product-card-1/product-card.tsx +146 -0
- package/src/components/_components/product-cards/product-card-1/styles/index.ts +46 -0
- package/src/components/_components/product-cards/product-card-10/index.ts +1 -0
- package/src/components/_components/product-cards/product-card-10/product-card.tsx +124 -0
- package/src/components/_components/product-cards/product-card-10/styles/index.ts +38 -0
- package/src/components/_components/product-cards/product-card-11/index.ts +1 -0
- package/src/components/_components/product-cards/product-card-11/product-card.tsx +63 -0
- package/src/components/_components/product-cards/product-card-11/styles/index.ts +16 -0
- package/src/components/_components/product-cards/product-card-12/index.ts +1 -0
- package/src/components/_components/product-cards/product-card-12/product-card.tsx +42 -0
- package/src/components/_components/product-cards/product-card-12/styles/index.ts +16 -0
- package/src/components/_components/product-cards/product-card-13/index.ts +1 -0
- package/src/components/_components/product-cards/product-card-13/product-card.tsx +45 -0
- package/src/components/_components/product-cards/product-card-13/styles/index.ts +25 -0
- package/src/components/_components/product-cards/product-card-14/index.ts +1 -0
- package/src/components/_components/product-cards/product-card-14/product-card.tsx +122 -0
- package/src/components/_components/product-cards/product-card-14/styles/index.ts +40 -0
- package/src/components/_components/product-cards/product-card-15/index.ts +1 -0
- package/src/components/_components/product-cards/product-card-15/product-card.tsx +118 -0
- package/src/components/_components/product-cards/product-card-15/styles/index.ts +57 -0
- package/src/components/_components/product-cards/product-card-16/components/quantity-buttons.tsx +56 -0
- package/src/components/_components/product-cards/product-card-16/index.ts +1 -0
- package/src/components/_components/product-cards/product-card-16/product-card.tsx +114 -0
- package/src/components/_components/product-cards/product-card-16/styles/index.ts +18 -0
- package/src/components/_components/product-cards/product-card-2/components/favorite-button.tsx +29 -0
- package/src/components/_components/product-cards/product-card-2/components/product-price.tsx +26 -0
- package/src/components/_components/product-cards/product-card-2/index.ts +1 -0
- package/src/components/_components/product-cards/product-card-2/product-card.tsx +70 -0
- package/src/components/_components/product-cards/product-card-3/components/hover-actions.tsx +83 -0
- package/src/components/_components/product-cards/product-card-3/index.ts +1 -0
- package/src/components/_components/product-cards/product-card-3/product-card.tsx +110 -0
- package/src/components/_components/product-cards/product-card-3/styles/index.ts +89 -0
- package/src/components/_components/product-cards/product-card-4/components/hover-actions.tsx +50 -0
- package/src/components/_components/product-cards/product-card-4/index.ts +1 -0
- package/src/components/_components/product-cards/product-card-4/product-card.tsx +128 -0
- package/src/components/_components/product-cards/product-card-4/styles/index.ts +66 -0
- package/src/components/_components/product-cards/product-card-5/components/button-actions.tsx +49 -0
- package/src/components/_components/product-cards/product-card-5/components/hover-actions.tsx +50 -0
- package/src/components/_components/product-cards/product-card-5/index.ts +1 -0
- package/src/components/_components/product-cards/product-card-5/product-card.tsx +137 -0
- package/src/components/_components/product-cards/product-card-5/styles/index.ts +94 -0
- package/src/components/_components/product-cards/product-card-6/components/hover-actions.tsx +50 -0
- package/src/components/_components/product-cards/product-card-6/index.ts +1 -0
- package/src/components/_components/product-cards/product-card-6/product-card.tsx +121 -0
- package/src/components/_components/product-cards/product-card-6/styles/index.ts +63 -0
- package/src/components/_components/product-cards/product-card-7/components/product-status.tsx +18 -0
- package/src/components/_components/product-cards/product-card-7/components/quantity-buttons.tsx +47 -0
- package/src/components/_components/product-cards/product-card-7/index.ts +1 -0
- package/src/components/_components/product-cards/product-card-7/product-card.tsx +136 -0
- package/src/components/_components/product-cards/product-card-7/styles/index.ts +98 -0
- package/src/components/_components/product-cards/product-card-8/index.ts +1 -0
- package/src/components/_components/product-cards/product-card-8/product-card.tsx +133 -0
- package/src/components/_components/product-cards/product-card-8/styles/index.ts +51 -0
- package/src/components/_components/product-cards/product-card-9/components/add-to-cart.tsx +60 -0
- package/src/components/_components/product-cards/product-card-9/components/favorite-button.tsx +27 -0
- package/src/components/_components/product-cards/product-card-9/components/tags.tsx +33 -0
- package/src/components/_components/product-cards/product-card-9/index.ts +1 -0
- package/src/components/_components/product-cards/product-card-9/product-card.tsx +169 -0
- package/src/components/_components/product-cards/product-price.tsx +26 -0
- package/src/components/_components/product-cards/product-rating.tsx +28 -0
- package/src/components/_components/product-cards/product-title.tsx +24 -0
- package/src/components/_components/product-cards/use-product.ts +35 -0
- package/src/components/_components/products-view/product-view-dialog.tsx +180 -0
- package/src/components/_components/products-view/products-grid-view.tsx +39 -0
- package/src/components/_components/products-view/products-list-view.tsx +35 -0
- package/src/components/_components/progress/index.ts +1 -0
- package/src/components/_components/progress/progress.tsx +77 -0
- package/src/components/_components/scrollbar/index.ts +1 -0
- package/src/components/_components/scrollbar/scrollbar.tsx +27 -0
- package/src/components/_components/scrollbar/styles.ts +15 -0
- package/src/components/_components/search-box/components/category-dropdown.tsx +61 -0
- package/src/components/_components/search-box/components/search-result.tsx +29 -0
- package/src/components/_components/search-box/hooks/use-search.ts +63 -0
- package/src/components/_components/search-box/index.ts +2 -0
- package/src/components/_components/search-box/search-input-category.test.tsx +110 -0
- package/src/components/_components/search-box/search-input-category.tsx +104 -0
- package/src/components/_components/search-box/search-input.test.tsx +41 -0
- package/src/components/_components/search-box/search-input.tsx +64 -0
- package/src/components/_components/search-box/styles/index.ts +45 -0
- package/src/components/_components/section-header/index.ts +2 -0
- package/src/components/_components/section-header/section-creator.tsx +28 -0
- package/src/components/_components/section-header/section-header.tsx +44 -0
- package/src/components/_components/service-cards/icon-component.tsx +18 -0
- package/src/components/_components/service-cards/service-card-1/index.ts +1 -0
- package/src/components/_components/service-cards/service-card-1/service-card-1.tsx +39 -0
- package/src/components/_components/service-cards/service-card-2/index.ts +1 -0
- package/src/components/_components/service-cards/service-card-2/service-card-2.tsx +34 -0
- package/src/components/_components/service-cards/service-card-3/index.ts +1 -0
- package/src/components/_components/service-cards/service-card-3/service-card-3.tsx +25 -0
- package/src/components/_components/service-cards/service-card-3/styles.ts +23 -0
- package/src/components/_components/settings/index.ts +1 -0
- package/src/components/_components/settings/setting.tsx +141 -0
- package/src/components/_components/settings/styles.ts +57 -0
- package/src/components/_components/shop-card/index.ts +1 -0
- package/src/components/_components/shop-card/shop-card.tsx +152 -0
- package/src/components/_components/shop-card/styles.ts +33 -0
- package/src/components/_components/side-nav/index.ts +1 -0
- package/src/components/_components/side-nav/side-nav.tsx +49 -0
- package/src/components/_components/site-logo.tsx +17 -0
- package/src/components/_components/sticky/Sticky.tsx +62 -0
- package/src/components/_components/sticky/index.ts +1 -0
- package/src/components/_components/sticky/styles.ts +38 -0
- package/src/components/_components/sticky-wrapper/index.ts +1 -0
- package/src/components/_components/sticky-wrapper/sticky-wrapper.tsx +21 -0
- package/src/components/_components/sticky-wrapper/styles.ts +25 -0
- package/src/components/_components/stories/story-content/index.ts +1 -0
- package/src/components/_components/stories/story-content/story-content.tsx +28 -0
- package/src/components/_components/stories/story-content/styles.ts +22 -0
- package/src/components/_components/stories/story-item/index.ts +1 -0
- package/src/components/_components/stories/story-item/story-item.tsx +24 -0
- package/src/components/_components/stories/story-item/styles.ts +11 -0
- package/src/components/_components/stories/story-viewer/index.ts +1 -0
- package/src/components/_components/stories/story-viewer/story-viewer.tsx +44 -0
- package/src/components/_components/stories/story-viewer/styles.ts +15 -0
- package/src/components/_components/subscribe-input/index.ts +1 -0
- package/src/components/_components/subscribe-input/styles.ts +14 -0
- package/src/components/_components/subscribe-input/subscribe-input.tsx +43 -0
- package/src/components/_components/topbar/index.ts +1 -0
- package/src/components/_components/topbar/styles.ts +55 -0
- package/src/components/_components/topbar/top-bar.tsx +112 -0
- package/src/components/_components/utils/constants.ts +8 -0
- package/src/components/countries-input.tsx +78 -0
- package/src/config.ts +47 -0
- package/src/lib/build-detail-url.ts +8 -0
- package/src/lib/build-product-detail-url.ts +12 -0
- package/src/lib/cart-cookie-client-handler.ts +12 -0
- package/src/lib/cart-cookie-handler.ts +14 -0
- package/src/lib/category-helpers.ts +113 -0
- package/src/lib/create-graphql-client.ts +32 -0
- package/src/lib/currency-formatter.ts +31 -0
- package/src/lib/get-palette-color.ts +50 -0
- package/src/lib/graphqlRequestSdk.ts +41234 -0
- package/src/lib/hexToLuma.ts +55 -0
- package/src/lib/lib.ts +61 -0
- package/src/lib/map-helper.ts +71 -0
- package/src/lib/page-slugs.ts +10 -0
- package/src/lib/refiner-utils.ts +32 -0
- package/src/lib/store-hours-helper.ts +274 -0
- package/src/lib/test-media.ts +23 -0
- package/tsconfig.json +27 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { SxProps, Theme } from "@mui/material/styles";
|
|
2
|
+
import TextField, { TextFieldProps } from "@mui/material/TextField";
|
|
3
|
+
// STYLED COMPONENT
|
|
4
|
+
import { StyledButton } from "./styles";
|
|
5
|
+
|
|
6
|
+
// ==============================================================
|
|
7
|
+
interface Props {
|
|
8
|
+
buttonText?: string;
|
|
9
|
+
buttonSx?: SxProps<Theme>;
|
|
10
|
+
}
|
|
11
|
+
// ==============================================================
|
|
12
|
+
|
|
13
|
+
export default function SubscribeInput({
|
|
14
|
+
fullWidth,
|
|
15
|
+
InputProps,
|
|
16
|
+
buttonSx = {},
|
|
17
|
+
variant = "outlined",
|
|
18
|
+
buttonText = "SUBSCRIBE",
|
|
19
|
+
placeholder = "Enter Your Mail Here",
|
|
20
|
+
...props
|
|
21
|
+
}: Props & TextFieldProps) {
|
|
22
|
+
const INPUT_PROPS = {
|
|
23
|
+
endAdornment: <StyledButton sx={buttonSx}>{buttonText}</StyledButton>,
|
|
24
|
+
sx: {
|
|
25
|
+
border: 0,
|
|
26
|
+
padding: 0,
|
|
27
|
+
borderRadius: 2,
|
|
28
|
+
backgroundColor: "white",
|
|
29
|
+
...InputProps?.sx,
|
|
30
|
+
},
|
|
31
|
+
...InputProps,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<TextField
|
|
36
|
+
variant={variant}
|
|
37
|
+
fullWidth={fullWidth}
|
|
38
|
+
placeholder={placeholder}
|
|
39
|
+
InputProps={INPUT_PROPS}
|
|
40
|
+
{...props}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./top-bar";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import Box from "@mui/material/Box";
|
|
2
|
+
import Chip from "@mui/material/Chip";
|
|
3
|
+
import Container from "@mui/material/Container";
|
|
4
|
+
import styled from "@mui/material/styles/styled";
|
|
5
|
+
|
|
6
|
+
import { layoutConstant } from "@/components/_components/utils/constants";
|
|
7
|
+
|
|
8
|
+
export const StyledRoot = styled(Box, {
|
|
9
|
+
shouldForwardProp: (prop) => prop !== "bgColor" && prop !== "expand",
|
|
10
|
+
})<{ bgColor?: string; expand: number }>(({ theme, bgColor, expand }) => ({
|
|
11
|
+
fontSize: 12,
|
|
12
|
+
height: layoutConstant.topbarHeight,
|
|
13
|
+
color: theme.palette.secondary.contrastText,
|
|
14
|
+
background: bgColor || theme.palette.grey[900],
|
|
15
|
+
transition: "height 300ms ease",
|
|
16
|
+
"& .menuItem": { minWidth: 100 },
|
|
17
|
+
"& .marginRight": { marginRight: "1.25rem" },
|
|
18
|
+
"& .expand": { display: "none", padding: 0 },
|
|
19
|
+
"& .handler": { height: layoutConstant.topbarHeight },
|
|
20
|
+
"& .menuTitle": { fontSize: 12, marginLeft: "0.5rem", fontWeight: 600 },
|
|
21
|
+
|
|
22
|
+
[theme.breakpoints.down("sm")]: {
|
|
23
|
+
height: expand ? 80 : layoutConstant.topbarHeight,
|
|
24
|
+
|
|
25
|
+
"& .MuiSvgIcon-root": { color: "white" },
|
|
26
|
+
|
|
27
|
+
"& .topbarRight": {
|
|
28
|
+
paddingBottom: 5,
|
|
29
|
+
display: expand ? "flex" : "none",
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
"& .expand": {
|
|
33
|
+
display: "block",
|
|
34
|
+
height: layoutConstant.topbarHeight,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
export const StyledContainer = styled(Container)(({ theme }) => ({
|
|
40
|
+
height: "100%",
|
|
41
|
+
display: "flex",
|
|
42
|
+
alignItems: "center",
|
|
43
|
+
justifyContent: "space-between",
|
|
44
|
+
[theme.breakpoints.down("sm")]: {
|
|
45
|
+
alignItems: "start",
|
|
46
|
+
flexDirection: "column",
|
|
47
|
+
},
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
export const StyledChip = styled(Chip)(({ theme }) => ({
|
|
51
|
+
color: "white",
|
|
52
|
+
fontWeight: 700,
|
|
53
|
+
backgroundColor: theme.palette.primary.main,
|
|
54
|
+
"& .MuiChip-label": { paddingInline: ".8rem" },
|
|
55
|
+
}));
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import Link from "next/link";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
// MUI
|
|
4
|
+
import MenuItem from "@mui/material/MenuItem";
|
|
5
|
+
import IconButton from "@mui/material/IconButton";
|
|
6
|
+
import TouchRipple from "@mui/material/ButtonBase";
|
|
7
|
+
// TRANSLATION
|
|
8
|
+
import { useTranslation } from "react-i18next";
|
|
9
|
+
// MUI ICON COMPONENTS
|
|
10
|
+
import Add from "@mui/icons-material/Add";
|
|
11
|
+
import Remove from "@mui/icons-material/Remove";
|
|
12
|
+
import Twitter from "@mui/icons-material/Twitter";
|
|
13
|
+
import Facebook from "@mui/icons-material/Facebook";
|
|
14
|
+
import Instagram from "@mui/icons-material/Instagram";
|
|
15
|
+
import ExpandMore from "@mui/icons-material/ExpandMore";
|
|
16
|
+
// GLOBAL CUSTOM COMPONENTS
|
|
17
|
+
import { Span } from "@/components/_components/Typography";
|
|
18
|
+
import BazaarMenu from "@/components/_components/BazaarMenu";
|
|
19
|
+
import { FlexBetween, FlexBox } from "@/components/_components/flex-box/index";
|
|
20
|
+
// STYLED COMPONENTS
|
|
21
|
+
import { StyledChip, StyledContainer, StyledRoot } from "./styles";
|
|
22
|
+
|
|
23
|
+
// ==============================================================
|
|
24
|
+
interface LanguageOption {
|
|
25
|
+
[key: string]: { title: string; value: string };
|
|
26
|
+
}
|
|
27
|
+
// ==============================================================
|
|
28
|
+
|
|
29
|
+
// LANGUAGE OPTIONS
|
|
30
|
+
const languageOptions: LanguageOption = {
|
|
31
|
+
en: { title: "EN", value: "en" },
|
|
32
|
+
es: { title: "DE", value: "de" },
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const socialLinks = [
|
|
36
|
+
{ id: 1, Icon: Twitter, url: "#" },
|
|
37
|
+
{ id: 2, Icon: Facebook, url: "#" },
|
|
38
|
+
{ id: 3, Icon: Instagram, url: "#" },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
// ===========================================
|
|
42
|
+
type Props = { bgColor?: string };
|
|
43
|
+
// ===========================================
|
|
44
|
+
|
|
45
|
+
export default function Topbar({ bgColor }: Props) {
|
|
46
|
+
const { i18n, t } = useTranslation();
|
|
47
|
+
const [expand, setExpand] = useState<boolean>(false);
|
|
48
|
+
|
|
49
|
+
const handleChangeLanguage = (language: string) => {
|
|
50
|
+
i18n.changeLanguage(language);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const selectedLanguage = languageOptions[i18n.language];
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<StyledRoot bgColor={bgColor} expand={expand ? 1 : 0}>
|
|
57
|
+
<StyledContainer>
|
|
58
|
+
<FlexBetween width="100%">
|
|
59
|
+
<FlexBox alignItems="center" gap={1}>
|
|
60
|
+
<StyledChip label={t("HOT")} size="small" />
|
|
61
|
+
<Span className="title">{t("Free Express Shipping")}</Span>
|
|
62
|
+
</FlexBox>
|
|
63
|
+
|
|
64
|
+
<IconButton
|
|
65
|
+
disableRipple
|
|
66
|
+
className="expand"
|
|
67
|
+
onClick={() => setExpand((state) => !state)}
|
|
68
|
+
>
|
|
69
|
+
{expand ? <Remove /> : <Add />}
|
|
70
|
+
</IconButton>
|
|
71
|
+
</FlexBetween>
|
|
72
|
+
|
|
73
|
+
<FlexBox className="topbarRight" alignItems="center">
|
|
74
|
+
{/* LANGUAGE MENU SELECTOR */}
|
|
75
|
+
<BazaarMenu
|
|
76
|
+
handler={(e) => (
|
|
77
|
+
<TouchRipple className="handler marginRight" onClick={e}>
|
|
78
|
+
<Span className="menuTitle">{selectedLanguage.title}</Span>
|
|
79
|
+
<ExpandMore fontSize="inherit" />
|
|
80
|
+
</TouchRipple>
|
|
81
|
+
)}
|
|
82
|
+
options={(onClose) => {
|
|
83
|
+
return Object.keys(languageOptions).map((language: string) => (
|
|
84
|
+
<MenuItem
|
|
85
|
+
className="menuItem"
|
|
86
|
+
key={languageOptions[language].title}
|
|
87
|
+
onClick={() => {
|
|
88
|
+
handleChangeLanguage(language);
|
|
89
|
+
onClose();
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
<Span className="menuTitle">
|
|
93
|
+
{languageOptions[language].title}
|
|
94
|
+
</Span>
|
|
95
|
+
</MenuItem>
|
|
96
|
+
));
|
|
97
|
+
}}
|
|
98
|
+
/>
|
|
99
|
+
|
|
100
|
+
{/* SOCIAL LINKS AREA */}
|
|
101
|
+
<FlexBox alignItems="center" gap={1.5}>
|
|
102
|
+
{socialLinks.map(({ id, Icon, url }) => (
|
|
103
|
+
<Link href={url} key={id}>
|
|
104
|
+
<Icon sx={{ fontSize: 16 }} />
|
|
105
|
+
</Link>
|
|
106
|
+
))}
|
|
107
|
+
</FlexBox>
|
|
108
|
+
</FlexBox>
|
|
109
|
+
</StyledContainer>
|
|
110
|
+
</StyledRoot>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { CountryRegionInfo } from "@msdyn365-commerce/retail-proxy";
|
|
2
|
+
import {
|
|
3
|
+
Autocomplete,
|
|
4
|
+
AutocompleteRenderInputParams,
|
|
5
|
+
Box,
|
|
6
|
+
InputProps,
|
|
7
|
+
TextField,
|
|
8
|
+
} from "@mui/material";
|
|
9
|
+
import React from "react";
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
countries: CountryRegionInfo[];
|
|
13
|
+
label: string;
|
|
14
|
+
selectedCountry: CountryRegionInfo | null;
|
|
15
|
+
setSelectedCountry: (country: CountryRegionInfo | null) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default function CountryInput({
|
|
19
|
+
countries,
|
|
20
|
+
label,
|
|
21
|
+
setSelectedCountry,
|
|
22
|
+
selectedCountry,
|
|
23
|
+
}: Props) {
|
|
24
|
+
const [countryInputValue, setCountryInputValue] = React.useState<string>("");
|
|
25
|
+
const handleAutoCompleteChange = (
|
|
26
|
+
_event: React.SyntheticEvent<Element, Event>,
|
|
27
|
+
value: string,
|
|
28
|
+
) => setCountryInputValue(value);
|
|
29
|
+
|
|
30
|
+
const renderOption = (
|
|
31
|
+
optionProps: React.HTMLAttributes<HTMLLIElement>,
|
|
32
|
+
option: CountryRegionInfo,
|
|
33
|
+
index: number,
|
|
34
|
+
) => {
|
|
35
|
+
return (
|
|
36
|
+
<Box key={index} component="li" {...optionProps}>
|
|
37
|
+
{option.ShortName}
|
|
38
|
+
</Box>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
const renderInput = (params: AutocompleteRenderInputParams) => (
|
|
42
|
+
<TextField
|
|
43
|
+
{...params}
|
|
44
|
+
size="small"
|
|
45
|
+
label={label}
|
|
46
|
+
variant="outlined"
|
|
47
|
+
placeholder="Select Country"
|
|
48
|
+
slotProps={{
|
|
49
|
+
input: {
|
|
50
|
+
"data-testid": "country-input",
|
|
51
|
+
} as InputProps,
|
|
52
|
+
}}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const getOptionLabel = (option: CountryRegionInfo) => option.ShortName || "";
|
|
57
|
+
|
|
58
|
+
const renderAutocomplete = () => (
|
|
59
|
+
<Autocomplete
|
|
60
|
+
fullWidth
|
|
61
|
+
value={selectedCountry}
|
|
62
|
+
options={countries}
|
|
63
|
+
onChange={(_event, newValue) => {
|
|
64
|
+
setSelectedCountry(newValue);
|
|
65
|
+
}}
|
|
66
|
+
data-testid="country-autocomplete"
|
|
67
|
+
inputValue={countryInputValue}
|
|
68
|
+
onInputChange={handleAutoCompleteChange}
|
|
69
|
+
renderOption={(props, option, state) =>
|
|
70
|
+
renderOption(props, option, state?.index)
|
|
71
|
+
}
|
|
72
|
+
renderInput={renderInput}
|
|
73
|
+
getOptionLabel={getOptionLabel}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return renderAutocomplete();
|
|
78
|
+
}
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
interface D365Config {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
catalogId: number;
|
|
4
|
+
oun: string;
|
|
5
|
+
baseImageUrl: string;
|
|
6
|
+
channelId: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface ApiManagerConfig {
|
|
10
|
+
primary: string;
|
|
11
|
+
secondary: string[];
|
|
12
|
+
overrides: Record<string, unknown>;
|
|
13
|
+
d365: D365Config;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type storefrontCoreConfig = {
|
|
17
|
+
AZURE_AD_B2C_POST_LOGOUT_REDIRECT: string;
|
|
18
|
+
AZURE_AD_B2C_KNOWN_AUTHORITY: string;
|
|
19
|
+
AZURE_AD_B2C_EDIT_AUTHORITY: string;
|
|
20
|
+
AZURE_AD_B2C_RESET_AUTHORITY: string;
|
|
21
|
+
AZURE_AD_B2C_CLIENTID: string;
|
|
22
|
+
AZURE_AD_B2C_API_PERMISSION: string;
|
|
23
|
+
AZURE_AD_B2C_LOGIN_AUTHORITY: string;
|
|
24
|
+
AZURE_AD_B2C_REDIRECT: string;
|
|
25
|
+
E4_API_ENDPOINT: string;
|
|
26
|
+
CMS_ENDPOINT: string;
|
|
27
|
+
NEXTAUTH_SECRET: string;
|
|
28
|
+
apiManagerConfig?: ApiManagerConfig;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// module-level singleton
|
|
32
|
+
let cachedConfig: storefrontCoreConfig | null = null;
|
|
33
|
+
|
|
34
|
+
// this is called from application entry point -> app/layout.tsx and api/route.ts
|
|
35
|
+
export function initConfig(config: storefrontCoreConfig) {
|
|
36
|
+
if (!cachedConfig) cachedConfig = config;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function getConfig(): storefrontCoreConfig {
|
|
40
|
+
if (!cachedConfig) {
|
|
41
|
+
console.error(
|
|
42
|
+
"Storefront core config is not initialized. The init config function must be called at every entry point in the application",
|
|
43
|
+
);
|
|
44
|
+
throw new Error("Storefront-core config has not been initialized");
|
|
45
|
+
}
|
|
46
|
+
return cachedConfig;
|
|
47
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PageSlug } from "./page-slugs";
|
|
2
|
+
|
|
3
|
+
const buildDetailUrl = (name: string, id: number) =>
|
|
4
|
+
`/${PageSlug.ProductDetail}/${normalizeName(name)}/${id}`;
|
|
5
|
+
|
|
6
|
+
const normalizeName = (name: string) => name.toLowerCase().replace(/ /g, "-");
|
|
7
|
+
|
|
8
|
+
export default buildDetailUrl;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProductSearchResult,
|
|
3
|
+
SimpleProduct,
|
|
4
|
+
} from "@msdyn365-commerce/retail-proxy";
|
|
5
|
+
|
|
6
|
+
export const getProductDetailUrl = (
|
|
7
|
+
product: SimpleProduct | ProductSearchResult,
|
|
8
|
+
) => {
|
|
9
|
+
return `/product/${product.Name}/${
|
|
10
|
+
product?.MasterProductId || product?.RecordId
|
|
11
|
+
}`;
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Use this to manually get cart id from cookie on the client.
|
|
5
|
+
* @returns {string | undefined} the cart id value
|
|
6
|
+
*/
|
|
7
|
+
export const getCartCookieClient = () => {
|
|
8
|
+
return document.cookie
|
|
9
|
+
.split(";")
|
|
10
|
+
.find((cookie) => cookie.includes("cart_cookie"))
|
|
11
|
+
?.split("=")[1];
|
|
12
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { cookies } from "next/headers";
|
|
3
|
+
|
|
4
|
+
const getCartCookie = async () => (await cookies()).get("cart_cookie")?.value;
|
|
5
|
+
|
|
6
|
+
const setCartCookie = async (cartId: string) => {
|
|
7
|
+
(await cookies()).set("cart_cookie", cartId);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const deleteCartCookie = async () => {
|
|
11
|
+
(await cookies()).delete("cart_cookie");
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { getCartCookie, setCartCookie, deleteCartCookie };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Category,
|
|
3
|
+
TextValueTranslation,
|
|
4
|
+
} from "@msdyn365-commerce/retail-proxy";
|
|
5
|
+
|
|
6
|
+
export interface CategoryHierarchy extends Category {
|
|
7
|
+
Children: CategoryHierarchy[];
|
|
8
|
+
Slug?: string;
|
|
9
|
+
Url?: string;
|
|
10
|
+
NeutralizedName?: string;
|
|
11
|
+
IsCMSPage?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type CategoryMap = {
|
|
15
|
+
[RecordId: number]: CategoryHierarchy;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const mapCategoryToHierarchy = (
|
|
19
|
+
categoryList: Category[],
|
|
20
|
+
locale?: string,
|
|
21
|
+
includeRootCategory?: boolean,
|
|
22
|
+
): CategoryHierarchy[] => {
|
|
23
|
+
if (!categoryList || categoryList.length === 0) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const categoryMap: CategoryMap = {};
|
|
28
|
+
|
|
29
|
+
for (const category of categoryList) {
|
|
30
|
+
const localName = getFriendlyName(locale, category.NameTranslations);
|
|
31
|
+
const categoryHierarchy = <CategoryHierarchy>{ ...category };
|
|
32
|
+
categoryHierarchy.NeutralizedName = category.Name;
|
|
33
|
+
categoryHierarchy.Name = localName || categoryHierarchy.NeutralizedName;
|
|
34
|
+
// Derive Slug from Url or Name for D365
|
|
35
|
+
categoryHierarchy.Slug =
|
|
36
|
+
(category as CategoryHierarchy).Url?.split("/")
|
|
37
|
+
.pop()
|
|
38
|
+
?.replace(/\d+$/, "") || normalizeCategoryName(category?.Name ?? "");
|
|
39
|
+
categoryMap[category.RecordId] = categoryHierarchy;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let rootCategory: CategoryHierarchy | undefined;
|
|
43
|
+
for (const category of Object.values(categoryMap)) {
|
|
44
|
+
const parentId = category.ParentCategory;
|
|
45
|
+
if (!category.Url) {
|
|
46
|
+
category.Url = generateUrl(categoryList, category, locale || "");
|
|
47
|
+
}
|
|
48
|
+
if (parentId === 0) {
|
|
49
|
+
rootCategory = category;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const parent = parentId && categoryMap[parentId];
|
|
54
|
+
if (parent) {
|
|
55
|
+
parent.Children = parent.Children || [];
|
|
56
|
+
parent.Children.push(category);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!rootCategory) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (includeRootCategory) {
|
|
65
|
+
const categoryHierarchy: CategoryHierarchy[] = [];
|
|
66
|
+
categoryHierarchy.push(rootCategory);
|
|
67
|
+
return categoryHierarchy;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return JSON.parse(JSON.stringify(rootCategory.Children)) ?? [];
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const generateUrl = (
|
|
74
|
+
categoryHierarchy: Category[],
|
|
75
|
+
currentCategory: CategoryHierarchy,
|
|
76
|
+
locale: string,
|
|
77
|
+
) => {
|
|
78
|
+
const categoryNames: string[] = [];
|
|
79
|
+
let nextCat: CategoryHierarchy | Category | undefined = currentCategory;
|
|
80
|
+
while (nextCat) {
|
|
81
|
+
const catName =
|
|
82
|
+
getFriendlyName(locale, nextCat.NameTranslations) || nextCat.Name || "";
|
|
83
|
+
categoryNames.push(normalizeCategoryName(catName));
|
|
84
|
+
nextCat = categoryHierarchy.find(
|
|
85
|
+
(c) => c.RecordId === nextCat?.ParentCategory,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
categoryNames.unshift(currentCategory.RecordId.toString());
|
|
89
|
+
return categoryNames.reverse().join("/");
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const getFriendlyName = (
|
|
93
|
+
locale?: string,
|
|
94
|
+
nameTranslations?: TextValueTranslation[],
|
|
95
|
+
): string | undefined => {
|
|
96
|
+
let nameTranslation: TextValueTranslation | undefined;
|
|
97
|
+
if (locale && nameTranslations && nameTranslations.length > 0) {
|
|
98
|
+
nameTranslation = nameTranslations.find(
|
|
99
|
+
(item) => item?.Language?.toLowerCase() === locale?.toLowerCase(),
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return nameTranslation && nameTranslation.Text;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const normalizeCategoryName = (string_: string) =>
|
|
106
|
+
string_.toLowerCase().replaceAll(" ", "-");
|
|
107
|
+
|
|
108
|
+
export {
|
|
109
|
+
mapCategoryToHierarchy,
|
|
110
|
+
generateUrl,
|
|
111
|
+
getFriendlyName,
|
|
112
|
+
normalizeCategoryName,
|
|
113
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { GraphQLClient } from "graphql-request";
|
|
2
|
+
|
|
3
|
+
// Note: We are keeping two separate versions of the graphqlRequestSdk
|
|
4
|
+
// currently. We need one in the api-manager client packages to get types
|
|
5
|
+
// and one here to isntantiate because graphql-request library must be same
|
|
6
|
+
// for this file and the sdk
|
|
7
|
+
import { getSdk } from "@/lib/graphqlRequestSdk";
|
|
8
|
+
import { getConfig } from "@config";
|
|
9
|
+
|
|
10
|
+
// typescript can't infer type without reference
|
|
11
|
+
export type E4Sdk = ReturnType<typeof getSdk>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Graphql Request Client
|
|
15
|
+
* @returns a new graphql request client with all of E4 queries and mutations
|
|
16
|
+
*/
|
|
17
|
+
const createGraphQLClient = async (): Promise<E4Sdk> => {
|
|
18
|
+
const API_URL = getConfig().E4_API_ENDPOINT;
|
|
19
|
+
const client = new GraphQLClient(API_URL, {
|
|
20
|
+
credentials: "include", // Ensures cookies are included
|
|
21
|
+
headers: {
|
|
22
|
+
"client-name": "storefront",
|
|
23
|
+
"client-version": "0.1.0",
|
|
24
|
+
"Content-Type": "application/json",
|
|
25
|
+
Accept: "application/json",
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return getSdk(client as GraphQLClient);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default createGraphQLClient;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useFormatter, useTranslations } from "next-intl";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
const useCurrencyFormatter = () => {
|
|
5
|
+
const { number } = useFormatter();
|
|
6
|
+
const t = useTranslations("Misc");
|
|
7
|
+
|
|
8
|
+
const formatCurrency = React.useCallback(
|
|
9
|
+
(value: number, showFreeText?: boolean) => {
|
|
10
|
+
if (!value) value = 0; // handle null, undefined values
|
|
11
|
+
|
|
12
|
+
if (value === 0 && showFreeText) {
|
|
13
|
+
return t("freeText");
|
|
14
|
+
}
|
|
15
|
+
// hardcoded to USD for now. Will fix with channel configurations
|
|
16
|
+
return number(value, { style: "currency", currency: "USD" });
|
|
17
|
+
},
|
|
18
|
+
[number, t],
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const value = React.useMemo(
|
|
22
|
+
() => ({
|
|
23
|
+
formatCurrency,
|
|
24
|
+
}),
|
|
25
|
+
[formatCurrency],
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return value;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default useCurrencyFormatter;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Theme } from "@mui/material";
|
|
2
|
+
|
|
3
|
+
// Define a union type for possible color values
|
|
4
|
+
type ColorValue = string | number | (() => string);
|
|
5
|
+
|
|
6
|
+
// Type-safe color getter function
|
|
7
|
+
const getPaletteColor = (
|
|
8
|
+
theme: Theme,
|
|
9
|
+
colorName: string,
|
|
10
|
+
shade?: number | string,
|
|
11
|
+
): string => {
|
|
12
|
+
const color = theme.palette[colorName as keyof typeof theme.palette];
|
|
13
|
+
|
|
14
|
+
// Check if color exists and is an object
|
|
15
|
+
if (!color || typeof color !== "object" || color === null) {
|
|
16
|
+
return typeof color === "string" ? color : ""; // If color is a string, return it directly
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Now we know color is an object
|
|
20
|
+
const colorObj = color as Record<string, ColorValue>;
|
|
21
|
+
|
|
22
|
+
// If shade is specified, try to get it
|
|
23
|
+
if (shade !== undefined) {
|
|
24
|
+
const shadeKey = shade.toString();
|
|
25
|
+
|
|
26
|
+
// Try to access the shade
|
|
27
|
+
if (shadeKey in colorObj) {
|
|
28
|
+
const value = colorObj[shadeKey];
|
|
29
|
+
// Handle possible function values
|
|
30
|
+
return typeof value === "function" ? value() : String(value);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Check if this is a PaletteColor with main/dark/light properties
|
|
34
|
+
if ("main" in colorObj) {
|
|
35
|
+
const mainValue = colorObj.main;
|
|
36
|
+
return typeof mainValue === "function" ? mainValue() : String(mainValue);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// If no shade specified but color has 'main' property
|
|
41
|
+
if ("main" in colorObj) {
|
|
42
|
+
const mainValue = colorObj.main;
|
|
43
|
+
return typeof mainValue === "function" ? mainValue() : String(mainValue);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Last resort fallback
|
|
47
|
+
return "";
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default getPaletteColor;
|