@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,40 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
|
+
import { CategoryApi } from "../../types/Datasource";
|
|
4
|
+
import {
|
|
5
|
+
CategoryHierarchy,
|
|
6
|
+
mapCategoryToHierarchy,
|
|
7
|
+
} from "@/lib/category-helpers";
|
|
8
|
+
import { getCategoriesAsync } from "@msdyn365-commerce/retail-proxy/dist/DataActions/CategoriesDataActions.g";
|
|
9
|
+
import { D365DatasourceBase } from "./d365-base.datasource";
|
|
10
|
+
|
|
11
|
+
class D365CategoriesDatasource
|
|
12
|
+
extends D365DatasourceBase
|
|
13
|
+
implements CategoryApi
|
|
14
|
+
{
|
|
15
|
+
async getCategories(): Promise<CategoryHierarchy[]> {
|
|
16
|
+
const context = this.context;
|
|
17
|
+
try {
|
|
18
|
+
const categories = await getCategoriesAsync(
|
|
19
|
+
context as any,
|
|
20
|
+
context.requestContext.apiSettings.channelId,
|
|
21
|
+
0,
|
|
22
|
+
);
|
|
23
|
+
return (
|
|
24
|
+
mapCategoryToHierarchy(
|
|
25
|
+
categories,
|
|
26
|
+
context.requestContext.locale,
|
|
27
|
+
false,
|
|
28
|
+
) || []
|
|
29
|
+
);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error(
|
|
32
|
+
"Error fetching categories:",
|
|
33
|
+
JSON.stringify(error, null, 2),
|
|
34
|
+
);
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default D365CategoriesDatasource;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
|
+
import { OrderApi } from "../../types/Datasource";
|
|
4
|
+
import {
|
|
5
|
+
SalesOrder as DynSalesOrder,
|
|
6
|
+
SearchLocation,
|
|
7
|
+
ICallerContext,
|
|
8
|
+
} from "@msdyn365-commerce/retail-proxy";
|
|
9
|
+
import { getSalesOrderDetailsByTransactionIdAsync } from "@msdyn365-commerce/retail-proxy/dist/DataActions/SalesOrdersDataActions.g";
|
|
10
|
+
import {
|
|
11
|
+
GetSalesOrderDetailsInput,
|
|
12
|
+
SalesOrder,
|
|
13
|
+
} from "@/api-manager/schemas/order.schema";
|
|
14
|
+
import { D365ProductDatasource } from "./d365-product.datasource";
|
|
15
|
+
import uniq from "lodash/uniq";
|
|
16
|
+
import { D365DatasourceBase } from "./d365-base.datasource";
|
|
17
|
+
class D365OrderDatasource extends D365DatasourceBase implements OrderApi {
|
|
18
|
+
getSalesOrders(): Promise<any> {
|
|
19
|
+
throw new Error("Method not implemented.");
|
|
20
|
+
}
|
|
21
|
+
async getSalesOrderDetails(
|
|
22
|
+
input: GetSalesOrderDetailsInput,
|
|
23
|
+
): Promise<SalesOrder> {
|
|
24
|
+
const context = this.context;
|
|
25
|
+
const { transactionId } = input;
|
|
26
|
+
try {
|
|
27
|
+
const data = await getSalesOrderDetailsByTransactionIdAsync(
|
|
28
|
+
context as any,
|
|
29
|
+
transactionId,
|
|
30
|
+
SearchLocation.All,
|
|
31
|
+
);
|
|
32
|
+
const mergedData = await mergeOrderWithProducts(data, this.context);
|
|
33
|
+
return mergedData;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error(error);
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const mergeOrderWithProducts = async (
|
|
42
|
+
salesOrder: DynSalesOrder,
|
|
43
|
+
context: ICallerContext,
|
|
44
|
+
): Promise<SalesOrder> => {
|
|
45
|
+
const _salesOrder = { ...salesOrder } as SalesOrder;
|
|
46
|
+
if (_salesOrder.SalesLines?.length) {
|
|
47
|
+
//Get products
|
|
48
|
+
const productIds = _salesOrder.SalesLines.map(
|
|
49
|
+
(line) => line.ProductId,
|
|
50
|
+
).filter((p) => p !== undefined);
|
|
51
|
+
if (productIds.length) {
|
|
52
|
+
const productDataSource = new D365ProductDatasource(context);
|
|
53
|
+
const products = await productDataSource.getProductByIds({
|
|
54
|
+
id: uniq(productIds),
|
|
55
|
+
});
|
|
56
|
+
if (products) {
|
|
57
|
+
_salesOrder.SalesLines.forEach((line) => {
|
|
58
|
+
const product = products.find((p) => p.RecordId === line.ProductId);
|
|
59
|
+
if (product) {
|
|
60
|
+
line.Product = product;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return _salesOrder;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export default D365OrderDatasource;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
|
+
import { OrganizationApi } from "../../types/Datasource";
|
|
4
|
+
import {
|
|
5
|
+
getChannelDeliveryOptionsAsync,
|
|
6
|
+
getOrgUnitConfigurationAsync,
|
|
7
|
+
getStoreHoursAsync,
|
|
8
|
+
} from "@msdyn365-commerce/retail-proxy/dist/DataActions/OrgUnitsDataActions.g";
|
|
9
|
+
import {
|
|
10
|
+
ChannelConfiguration,
|
|
11
|
+
GetOrgUnitLocationsByAreaInput,
|
|
12
|
+
OrgUnitLocation,
|
|
13
|
+
OrgUnitLocationReturnType,
|
|
14
|
+
} from "@/api-manager/schemas/organization.schema";
|
|
15
|
+
import { getOrgUnitLocationsByAreaAsync } from "@msdyn365-commerce/retail-proxy/dist/DataActions/OrgUnitsDataActions.g";
|
|
16
|
+
import {
|
|
17
|
+
ChannelDeliveryOption,
|
|
18
|
+
ICallerContext,
|
|
19
|
+
} from "@msdyn365-commerce/retail-proxy";
|
|
20
|
+
import { D365DatasourceBase } from "./d365-base.datasource";
|
|
21
|
+
|
|
22
|
+
class D365OrganizationDatasource
|
|
23
|
+
extends D365DatasourceBase
|
|
24
|
+
implements OrganizationApi
|
|
25
|
+
{
|
|
26
|
+
async getStoresList(
|
|
27
|
+
input: GetOrgUnitLocationsByAreaInput,
|
|
28
|
+
): Promise<OrgUnitLocationReturnType[]> {
|
|
29
|
+
const context = this.context;
|
|
30
|
+
const { queryResultSettings, searchArea, deliveryModeTypeFilter } = input;
|
|
31
|
+
const ctx = { ...context } as any;
|
|
32
|
+
ctx.queryResultSettings = queryResultSettings;
|
|
33
|
+
const locations = await getOrgUnitLocationsByAreaAsync(
|
|
34
|
+
ctx as any,
|
|
35
|
+
searchArea,
|
|
36
|
+
deliveryModeTypeFilter,
|
|
37
|
+
);
|
|
38
|
+
const channelList = locations
|
|
39
|
+
.map((location) => location.ChannelId)
|
|
40
|
+
.filter((id) => id !== undefined);
|
|
41
|
+
const locationPickupList = await this.getChannelDeliveryOptions(
|
|
42
|
+
context,
|
|
43
|
+
channelList,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const locationHoursPromiseList = locations.map((location) => {
|
|
47
|
+
const locationDeliveryOption = locationPickupList?.find(
|
|
48
|
+
(channelDeliveryOption) =>
|
|
49
|
+
channelDeliveryOption.ChannelId === location.ChannelId,
|
|
50
|
+
);
|
|
51
|
+
return this.getStoreHours(location, locationDeliveryOption, context);
|
|
52
|
+
});
|
|
53
|
+
const locationHours = await Promise.all(locationHoursPromiseList);
|
|
54
|
+
return locationHours;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async getChannelConfiguration(): Promise<ChannelConfiguration> {
|
|
58
|
+
const context = this.context;
|
|
59
|
+
return getOrgUnitConfigurationAsync(context as any);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async getStoreHours(
|
|
63
|
+
store: OrgUnitLocation,
|
|
64
|
+
channelDeliveryOption: ChannelDeliveryOption | undefined,
|
|
65
|
+
context: ICallerContext,
|
|
66
|
+
): Promise<OrgUnitLocationReturnType> {
|
|
67
|
+
const storeHours = await getStoreHoursAsync(
|
|
68
|
+
context as any,
|
|
69
|
+
store.OrgUnitNumber,
|
|
70
|
+
);
|
|
71
|
+
return {
|
|
72
|
+
location: store,
|
|
73
|
+
storeHours: storeHours,
|
|
74
|
+
pickupOptions: channelDeliveryOption?.DeliveryOptions,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async getChannelDeliveryOptions(
|
|
79
|
+
context: ICallerContext,
|
|
80
|
+
channelList: number[],
|
|
81
|
+
): Promise<ChannelDeliveryOption[] | undefined> {
|
|
82
|
+
const DELIVERY_OPTION_TYPE = 4; //This is to get all pickup modes, not sure where the number comes from.
|
|
83
|
+
const channelDeliveryOptions = await getChannelDeliveryOptionsAsync(
|
|
84
|
+
context as any,
|
|
85
|
+
channelList,
|
|
86
|
+
DELIVERY_OPTION_TYPE,
|
|
87
|
+
);
|
|
88
|
+
return channelDeliveryOptions;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default D365OrganizationDatasource;
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
|
+
import { ProductApi } from "../../types/Datasource";
|
|
4
|
+
import {
|
|
5
|
+
InventoryAvailabilitySearchCriteria,
|
|
6
|
+
IQueryResultSettings,
|
|
7
|
+
ProductRefinerSource,
|
|
8
|
+
ProductSearchCriteria,
|
|
9
|
+
ProductSearchResult,
|
|
10
|
+
SimpleProduct,
|
|
11
|
+
} from "@msdyn365-commerce/retail-proxy";
|
|
12
|
+
import {
|
|
13
|
+
getByIdAsync,
|
|
14
|
+
getByIdsAsync,
|
|
15
|
+
searchByCriteriaAsync,
|
|
16
|
+
getRelatedProductsAsync,
|
|
17
|
+
getDimensionValuesWithEstimatedAvailabilitiesAsync,
|
|
18
|
+
getAttributeValuesAsync,
|
|
19
|
+
getProductSearchRefinersAsync,
|
|
20
|
+
getEstimatedAvailabilityAsync,
|
|
21
|
+
} from "@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g";
|
|
22
|
+
import {
|
|
23
|
+
GetProductByIdInput,
|
|
24
|
+
GetProductByIdsInput,
|
|
25
|
+
GetRelatedProductsInput,
|
|
26
|
+
SearchByCriteriaInput,
|
|
27
|
+
SearchByCriteriaResponse,
|
|
28
|
+
searchProductsInput,
|
|
29
|
+
} from "@/api-manager/schemas/product.schema";
|
|
30
|
+
import { createDimSearchCriteria } from "./utils/create-search-criteria";
|
|
31
|
+
import {
|
|
32
|
+
testMedia,
|
|
33
|
+
validateAndSetMediaUrls,
|
|
34
|
+
} from "./utils/product-images-utils";
|
|
35
|
+
import D365CategoriesDatasource from "./d365-categories.datasource";
|
|
36
|
+
import { InventorySearchCriteriaInput } from "@/api-manager/schemas/product.schema";
|
|
37
|
+
|
|
38
|
+
import { D365DatasourceBase } from "./d365-base.datasource";
|
|
39
|
+
|
|
40
|
+
const setFullProductImgUrl = async (
|
|
41
|
+
product: SimpleProduct | ProductSearchResult,
|
|
42
|
+
baseImgUrl: string,
|
|
43
|
+
) => {
|
|
44
|
+
let imgUrl = `${baseImgUrl}${product.PrimaryImageUrl}`;
|
|
45
|
+
const isValidImg = (await testMedia([imgUrl])).length > 0;
|
|
46
|
+
if (isValidImg) {
|
|
47
|
+
product.PrimaryImageUrl = imgUrl;
|
|
48
|
+
} else {
|
|
49
|
+
imgUrl = `${baseImgUrl}Products/${product.ItemId}_000_001.png`;
|
|
50
|
+
}
|
|
51
|
+
product.PrimaryImageUrl = imgUrl;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// const getProductRefinersByCollection = async (context: ICallerContext, categoryId: number) => {
|
|
55
|
+
// const searchCriteria = getSearchCriteriaFromInput(context, categoryId);
|
|
56
|
+
// const ctx: any = { ...context };
|
|
57
|
+
// try {
|
|
58
|
+
// const refiners = await getProductSearchRefinersAsync(ctx, searchCriteria);
|
|
59
|
+
// if (!refiners) {
|
|
60
|
+
// console.warn('getProductSearchRefinersAsync returned no refiners');
|
|
61
|
+
// return [];
|
|
62
|
+
// }
|
|
63
|
+
// return refiners as any[];
|
|
64
|
+
// } catch (error) {
|
|
65
|
+
// console.warn('Failed to fetch refiners, returning empty array:', error);
|
|
66
|
+
// return [];
|
|
67
|
+
// }
|
|
68
|
+
// };
|
|
69
|
+
|
|
70
|
+
class D365ProductDatasource extends D365DatasourceBase implements ProductApi {
|
|
71
|
+
/**
|
|
72
|
+
* Gets product by id, sets full image url and dimension values
|
|
73
|
+
* @params input GetProductByIdInput
|
|
74
|
+
* @returns simple product with full image url and dimension values under property DimensionValues
|
|
75
|
+
*/
|
|
76
|
+
async getProductById(input: GetProductByIdInput) {
|
|
77
|
+
const context = this.context;
|
|
78
|
+
const channelId = context.requestContext.apiSettings.channelId;
|
|
79
|
+
|
|
80
|
+
const product = await getByIdAsync(
|
|
81
|
+
context as any,
|
|
82
|
+
Number(input.id),
|
|
83
|
+
channelId,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const images = await validateAndSetMediaUrls(
|
|
87
|
+
product,
|
|
88
|
+
context.requestContext.apiSettings.baseImageUrl,
|
|
89
|
+
);
|
|
90
|
+
//setFullProductImgUrl(product, context.requestContext.apiSettings.baseImageUrl);
|
|
91
|
+
|
|
92
|
+
const dimensionPromises =
|
|
93
|
+
product?.Dimensions?.map(async ({ DimensionTypeValue }) => {
|
|
94
|
+
return getDimensionValuesWithEstimatedAvailabilitiesAsync(
|
|
95
|
+
context as any,
|
|
96
|
+
product?.RecordId,
|
|
97
|
+
createDimSearchCriteria(DimensionTypeValue),
|
|
98
|
+
);
|
|
99
|
+
}) || [];
|
|
100
|
+
|
|
101
|
+
const attributesPromise = getAttributeValuesAsync(
|
|
102
|
+
context as any,
|
|
103
|
+
product?.RecordId,
|
|
104
|
+
channelId,
|
|
105
|
+
0,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const dimensionsValues = await Promise.all(dimensionPromises);
|
|
109
|
+
const attributes = await attributesPromise;
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
...product,
|
|
113
|
+
DimensionValues: dimensionsValues,
|
|
114
|
+
Attributes: attributes,
|
|
115
|
+
PrimaryImageUrl: images?.[0],
|
|
116
|
+
Images: images || [],
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async getProductByIds(input: GetProductByIdsInput) {
|
|
121
|
+
const context = this.context;
|
|
122
|
+
const products = await getByIdsAsync(
|
|
123
|
+
context as any,
|
|
124
|
+
context.requestContext.apiSettings.channelId,
|
|
125
|
+
input?.id.map(Number),
|
|
126
|
+
);
|
|
127
|
+
const promises = [];
|
|
128
|
+
for (const product of products) {
|
|
129
|
+
promises.push(
|
|
130
|
+
setFullProductImgUrl(
|
|
131
|
+
product,
|
|
132
|
+
context.requestContext.apiSettings.baseImageUrl,
|
|
133
|
+
),
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
await Promise.all(promises);
|
|
137
|
+
return products;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async getProductsList(
|
|
141
|
+
input: SearchByCriteriaInput,
|
|
142
|
+
): Promise<SearchByCriteriaResponse> {
|
|
143
|
+
const context = this.context;
|
|
144
|
+
const {
|
|
145
|
+
searchState: { queryResultSettings, refinement, searchTerm },
|
|
146
|
+
categoryId,
|
|
147
|
+
} = input;
|
|
148
|
+
|
|
149
|
+
const searchCriteria: ProductSearchCriteria = {
|
|
150
|
+
Context: {
|
|
151
|
+
CatalogId: context.requestContext.apiSettings.catalogId || 0,
|
|
152
|
+
ChannelId: context.requestContext.apiSettings.channelId,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
if (searchCriteria) searchCriteria.SearchCondition = searchTerm;
|
|
157
|
+
|
|
158
|
+
if (refinement) searchCriteria.Refinement = refinement;
|
|
159
|
+
|
|
160
|
+
if (categoryId) {
|
|
161
|
+
searchCriteria.CategoryIds = [categoryId];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const refinerSearchSettings = { ...searchCriteria };
|
|
165
|
+
|
|
166
|
+
//Remove the price refiner from the refinement to stop the price adjustment
|
|
167
|
+
refinerSearchSettings.Refinement = refinerSearchSettings.Refinement?.filter(
|
|
168
|
+
(r) => r.RefinerSourceValue !== ProductRefinerSource.Price,
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
const ctx = { ...context } as any;
|
|
172
|
+
ctx.queryResultSettings = queryResultSettings;
|
|
173
|
+
const productSearchPromise = searchByCriteriaAsync(ctx, searchCriteria);
|
|
174
|
+
const refinersPRomise = getProductSearchRefinersAsync(
|
|
175
|
+
ctx,
|
|
176
|
+
refinerSearchSettings,
|
|
177
|
+
);
|
|
178
|
+
const [productResults, refinerResults] = await Promise.all([
|
|
179
|
+
productSearchPromise,
|
|
180
|
+
refinersPRomise,
|
|
181
|
+
]);
|
|
182
|
+
const count = productSearchPromise.metadata?.count || 500; //Set to high number for pagination
|
|
183
|
+
const promises = [];
|
|
184
|
+
for (const product of productResults) {
|
|
185
|
+
promises.push(
|
|
186
|
+
setFullProductImgUrl(
|
|
187
|
+
product,
|
|
188
|
+
context.requestContext.apiSettings.baseImageUrl,
|
|
189
|
+
),
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
await Promise.all(promises);
|
|
193
|
+
return {
|
|
194
|
+
products: productResults,
|
|
195
|
+
refiners: refinerResults,
|
|
196
|
+
count,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async searchProducts(input: searchProductsInput) {
|
|
201
|
+
const context = this.context;
|
|
202
|
+
const ctx = { ...context } as any;
|
|
203
|
+
const queryResultSettings: IQueryResultSettings = {
|
|
204
|
+
Paging: {
|
|
205
|
+
Skip: 0,
|
|
206
|
+
Top: 10,
|
|
207
|
+
},
|
|
208
|
+
count: true,
|
|
209
|
+
};
|
|
210
|
+
ctx.queryResultSettings = queryResultSettings;
|
|
211
|
+
const searchCriteria: ProductSearchCriteria = {
|
|
212
|
+
Context: {
|
|
213
|
+
CatalogId: 0,
|
|
214
|
+
ChannelId: context.requestContext.apiSettings.channelId,
|
|
215
|
+
},
|
|
216
|
+
SearchCondition: input.searchText,
|
|
217
|
+
};
|
|
218
|
+
if (input.category && input.category !== 0) {
|
|
219
|
+
searchCriteria.CategoryIds = [input.category];
|
|
220
|
+
}
|
|
221
|
+
if (input.itemIds?.length) {
|
|
222
|
+
searchCriteria.ItemIds = input.itemIds.map((id) => ({
|
|
223
|
+
ItemId: id,
|
|
224
|
+
}));
|
|
225
|
+
}
|
|
226
|
+
const results = await searchByCriteriaAsync(ctx as any, searchCriteria);
|
|
227
|
+
const parsed = JSON.parse(JSON.stringify(results));
|
|
228
|
+
return parsed;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
async getCategoryList(): Promise<any> {
|
|
232
|
+
// TODO ? Why is the get category list here and calling the category data source. Can we decide if we want to have a separate one for categories or remove this?
|
|
233
|
+
// agree with above statement - sam
|
|
234
|
+
const categoriesDatasource = new D365CategoriesDatasource(this.context);
|
|
235
|
+
const categories = await categoriesDatasource.getCategories();
|
|
236
|
+
return { categories: { category: categories } };
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
async getRelatedProducts(input: GetRelatedProductsInput) {
|
|
240
|
+
const context = this.context;
|
|
241
|
+
return getRelatedProductsAsync(
|
|
242
|
+
context as any,
|
|
243
|
+
context.requestContext.apiSettings.channelId,
|
|
244
|
+
input.id,
|
|
245
|
+
0,
|
|
246
|
+
1,
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
async getInventory(input: InventorySearchCriteriaInput) {
|
|
251
|
+
const context = this.context;
|
|
252
|
+
try {
|
|
253
|
+
const searchCriteria: InventoryAvailabilitySearchCriteria = {
|
|
254
|
+
ProductIds: input.searchCriteria.productIds,
|
|
255
|
+
QuantityUnitTypeValue: 2, // Sales Type
|
|
256
|
+
DefaultWarehouseOnly: input.searchCriteria.defaultWarehouseOnly,
|
|
257
|
+
SearchArea: input.searchCriteria.searchArea,
|
|
258
|
+
FilterByChannelFulfillmentGroup: true,
|
|
259
|
+
};
|
|
260
|
+
const data = await getEstimatedAvailabilityAsync(
|
|
261
|
+
context as any,
|
|
262
|
+
searchCriteria,
|
|
263
|
+
);
|
|
264
|
+
return data;
|
|
265
|
+
} catch (error) {
|
|
266
|
+
console.error("Error getting inventory:", error);
|
|
267
|
+
throw error;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export { D365ProductDatasource };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
|
+
import { SessionApi } from "../../types/Datasource";
|
|
4
|
+
//import { Customer, ICallerContext } from "@msdyn365-commerce/retail-proxy";
|
|
5
|
+
//import { readAsync } from "@msdyn365-commerce/retail-proxy/dist/DataActions/CustomersDataActions.g";
|
|
6
|
+
import { Session } from "@/api-manager/schemas/session.schema";
|
|
7
|
+
//import { getContextFromCookie } from "./utils/get-context-cookie";
|
|
8
|
+
import { D365DatasourceBase } from "./d365-base.datasource";
|
|
9
|
+
|
|
10
|
+
class D365SessionDatasource extends D365DatasourceBase implements SessionApi {
|
|
11
|
+
async sessionInit(): Promise<Session> {
|
|
12
|
+
console.warn("sessionInit not implemented");
|
|
13
|
+
return Promise.resolve({} as Session);
|
|
14
|
+
}
|
|
15
|
+
async sessionLogout(): Promise<boolean> {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
getSession(): Promise<Session> {
|
|
19
|
+
//throw new Error("Method not implemented");
|
|
20
|
+
console.warn("getSession not implemented on d365");
|
|
21
|
+
return Promise.resolve({} as Session);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default D365SessionDatasource;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { UserApi } from "@/api-manager/types/Datasource";
|
|
3
|
+
import { User, UserCounts } from "@/schemas/user.schema";
|
|
4
|
+
import {
|
|
5
|
+
Customer,
|
|
6
|
+
CommerceProperty,
|
|
7
|
+
ICallerContext,
|
|
8
|
+
} from "@msdyn365-commerce/retail-proxy";
|
|
9
|
+
import {
|
|
10
|
+
createCustomerAsync,
|
|
11
|
+
readAsync,
|
|
12
|
+
updateAsync,
|
|
13
|
+
} from "@msdyn365-commerce/retail-proxy/dist/DataActions/CustomersDataActions.g";
|
|
14
|
+
import jwt from "jsonwebtoken";
|
|
15
|
+
import { WishList } from "../e4/graphqlRequestSdk";
|
|
16
|
+
import { D365DatasourceBase } from "./d365-base.datasource";
|
|
17
|
+
|
|
18
|
+
class D365UserDatasource extends D365DatasourceBase implements UserApi {
|
|
19
|
+
getUserCounts(): Promise<UserCounts> {
|
|
20
|
+
throw new Error("Method not implemented.");
|
|
21
|
+
}
|
|
22
|
+
getWishlists(): Promise<WishList[]> {
|
|
23
|
+
throw new Error("Method not implemented.");
|
|
24
|
+
}
|
|
25
|
+
getWishlistDetails(): Promise<WishList> {
|
|
26
|
+
throw new Error("Method not implemented.");
|
|
27
|
+
}
|
|
28
|
+
createWishlist(): Promise<WishList> {
|
|
29
|
+
throw new Error("Method not implemented.");
|
|
30
|
+
}
|
|
31
|
+
deleteWishlist(): Promise<string> {
|
|
32
|
+
throw new Error("Method not implemented.");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async updateUser(user: User): Promise<User> {
|
|
36
|
+
const context = this.context;
|
|
37
|
+
const existing: Customer = await readAsync(context as any, "");
|
|
38
|
+
existing.Addresses ??= [];
|
|
39
|
+
existing.Addresses = existing.Addresses.map((addr) => ({
|
|
40
|
+
...addr,
|
|
41
|
+
IsPrimary: addr.RecordId?.toString() === user.DefaultShippingAddressId,
|
|
42
|
+
}));
|
|
43
|
+
const propKey = "DefaultShippingAddressId";
|
|
44
|
+
existing.ExtensionProperties = existing.ExtensionProperties ?? [];
|
|
45
|
+
existing.ExtensionProperties = existing.ExtensionProperties.filter(
|
|
46
|
+
(p: CommerceProperty) => p.Key !== propKey,
|
|
47
|
+
);
|
|
48
|
+
existing.ExtensionProperties.push({
|
|
49
|
+
Key: propKey,
|
|
50
|
+
Value: { StringValue: user.DefaultShippingAddressId } as any,
|
|
51
|
+
});
|
|
52
|
+
const updated: Customer = await updateAsync(
|
|
53
|
+
context as any,
|
|
54
|
+
existing as any,
|
|
55
|
+
);
|
|
56
|
+
const mappedAddresses = (updated.Addresses ?? []).map((a) => ({
|
|
57
|
+
...a,
|
|
58
|
+
Id: a.RecordId?.toString() ?? "",
|
|
59
|
+
}));
|
|
60
|
+
return {
|
|
61
|
+
...updated,
|
|
62
|
+
Addresses: mappedAddresses,
|
|
63
|
+
} as User;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async getUser(): Promise<User | null> {
|
|
67
|
+
const context = this.context;
|
|
68
|
+
if (!context.requestContext.user.isAuthenticated) return null;
|
|
69
|
+
|
|
70
|
+
let customer: Customer | null;
|
|
71
|
+
try {
|
|
72
|
+
customer = await readAsync(context as any, "");
|
|
73
|
+
} catch (error) {
|
|
74
|
+
//For now, we assume this error means the user does not exist
|
|
75
|
+
//So we create a new user
|
|
76
|
+
console.warn(JSON.stringify(error));
|
|
77
|
+
const token = jwt.decode(context.requestContext.user.token) as TokenData;
|
|
78
|
+
customer = await createUser(context as any, token);
|
|
79
|
+
return customer;
|
|
80
|
+
}
|
|
81
|
+
const mappedAddresses = (customer.Addresses ?? []).map((a) => ({
|
|
82
|
+
...a,
|
|
83
|
+
Id: a.RecordId?.toString() ?? "",
|
|
84
|
+
}));
|
|
85
|
+
return {
|
|
86
|
+
...customer,
|
|
87
|
+
Addresses: mappedAddresses,
|
|
88
|
+
} as User;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const createUser = async (context: ICallerContext, token: TokenData) => {
|
|
93
|
+
const firstName = token.given_name;
|
|
94
|
+
let lastName = token.family_name;
|
|
95
|
+
let email;
|
|
96
|
+
if (token.emails && Array.isArray(token.emails)) {
|
|
97
|
+
email = token.emails[0];
|
|
98
|
+
} else if (token.hasOwnProperty("email")) {
|
|
99
|
+
email = token.email;
|
|
100
|
+
}
|
|
101
|
+
if (!lastName) {
|
|
102
|
+
lastName = ".";
|
|
103
|
+
}
|
|
104
|
+
const userPromise = createCustomerAsync(context as any, {
|
|
105
|
+
AccountNumber: "",
|
|
106
|
+
Email: email,
|
|
107
|
+
FirstName: firstName,
|
|
108
|
+
LastName: lastName,
|
|
109
|
+
});
|
|
110
|
+
const user = await userPromise;
|
|
111
|
+
return user;
|
|
112
|
+
};
|
|
113
|
+
export default D365UserDatasource;
|
|
114
|
+
|
|
115
|
+
type TokenData = {
|
|
116
|
+
aud: string;
|
|
117
|
+
iss: string;
|
|
118
|
+
exp: number;
|
|
119
|
+
nbf: number;
|
|
120
|
+
oid: string;
|
|
121
|
+
sub: string;
|
|
122
|
+
emails: string[];
|
|
123
|
+
email?: string;
|
|
124
|
+
newUser: boolean;
|
|
125
|
+
given_name: string;
|
|
126
|
+
family_name: string;
|
|
127
|
+
tfp: string;
|
|
128
|
+
scp: string;
|
|
129
|
+
azp: string;
|
|
130
|
+
ver: string;
|
|
131
|
+
iat: number;
|
|
132
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AddressApi,
|
|
3
|
+
CategoryApi,
|
|
4
|
+
Datasource,
|
|
5
|
+
OrderApi,
|
|
6
|
+
OrganizationApi,
|
|
7
|
+
PrimaryDatasource,
|
|
8
|
+
ProductApi,
|
|
9
|
+
SessionApi,
|
|
10
|
+
UserApi,
|
|
11
|
+
} from "../../types/Datasource";
|
|
12
|
+
import { D365ProductDatasource } from ".";
|
|
13
|
+
import { D365CartDatasource } from "./d365-cart.datasource";
|
|
14
|
+
import D365AddressDatasource from "./d365-address.datasource";
|
|
15
|
+
import D365CategoriesDatasource from "./d365-categories.datasource";
|
|
16
|
+
import D365OrganizationDatasource from "./d365-organization.datasource";
|
|
17
|
+
import D365OrderDatasource from "./d365-order.datasource";
|
|
18
|
+
import D365SessionDatasource from "./d365-session.datasource";
|
|
19
|
+
import D365UserDatasource from "./d365-user.datasource";
|
|
20
|
+
import { ICallerContext } from "@msdyn365-commerce/retail-proxy";
|
|
21
|
+
|
|
22
|
+
export class D365Datasource extends Datasource implements PrimaryDatasource {
|
|
23
|
+
user: UserApi;
|
|
24
|
+
product: ProductApi;
|
|
25
|
+
categories: CategoryApi;
|
|
26
|
+
order: OrderApi;
|
|
27
|
+
address: AddressApi;
|
|
28
|
+
organization: OrganizationApi;
|
|
29
|
+
session: SessionApi;
|
|
30
|
+
cart: D365CartDatasource;
|
|
31
|
+
constructor(name: string, context: ICallerContext) {
|
|
32
|
+
super(name);
|
|
33
|
+
this.cart = new D365CartDatasource(context);
|
|
34
|
+
this.categories = new D365CategoriesDatasource(context);
|
|
35
|
+
this.order = new D365OrderDatasource(context);
|
|
36
|
+
this.address = new D365AddressDatasource(context);
|
|
37
|
+
this.product = new D365ProductDatasource(context);
|
|
38
|
+
this.organization = new D365OrganizationDatasource(context);
|
|
39
|
+
this.session = new D365SessionDatasource(context);
|
|
40
|
+
this.user = new D365UserDatasource(context);
|
|
41
|
+
}
|
|
42
|
+
// Datasources
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// export default d365Datasource;
|