@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,157 @@
|
|
|
1
|
+
import * as productSchema from "@/api-manager/schemas/product.schema";
|
|
2
|
+
import {
|
|
3
|
+
ProductSearchResult,
|
|
4
|
+
SimpleProduct,
|
|
5
|
+
} from "@msdyn365-commerce/retail-proxy";
|
|
6
|
+
import {
|
|
7
|
+
Attribute,
|
|
8
|
+
Product,
|
|
9
|
+
ProductLookupType,
|
|
10
|
+
CategoriesQuery,
|
|
11
|
+
} from "./graphqlRequestSdk";
|
|
12
|
+
import * as translator from "./e4.translator";
|
|
13
|
+
import getGraphqlClient from "../../lib/get-graphql-client";
|
|
14
|
+
import { ProductApi } from "../../types/Datasource";
|
|
15
|
+
import { generateCategoryFilterString } from "./e4.translator";
|
|
16
|
+
|
|
17
|
+
const product: ProductApi = {
|
|
18
|
+
async getProductById(
|
|
19
|
+
input: productSchema.GetProductByIdInput,
|
|
20
|
+
): Promise<productSchema.ProductDetails> {
|
|
21
|
+
const e4Api = await getGraphqlClient();
|
|
22
|
+
|
|
23
|
+
// fetch data
|
|
24
|
+
const { data, errors } = await e4Api.e4ProductReadLG({
|
|
25
|
+
id: String(input.id),
|
|
26
|
+
productLookupType: ProductLookupType.Id,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (errors) {
|
|
30
|
+
throw new Error("Error getting product");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const transformedData = translator.productTransformValidate(
|
|
34
|
+
data.product as Product,
|
|
35
|
+
);
|
|
36
|
+
return transformedData;
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
async getProductByIds(
|
|
40
|
+
input: productSchema.GetProductByIdsInput,
|
|
41
|
+
): Promise<SimpleProduct[]> {
|
|
42
|
+
const e4Api = await getGraphqlClient();
|
|
43
|
+
const { data, errors } = await e4Api.GetProductsByIds({
|
|
44
|
+
ids: input.id.map(String),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (errors) {
|
|
48
|
+
throw new Error("Error getting products");
|
|
49
|
+
}
|
|
50
|
+
return (
|
|
51
|
+
data?.getProductsByIds?.map((productData) =>
|
|
52
|
+
translator.productTransformValidate(productData as Product),
|
|
53
|
+
) || []
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
async searchProducts(
|
|
58
|
+
input: productSchema.searchProductsInput,
|
|
59
|
+
): Promise<ProductSearchResult[]> {
|
|
60
|
+
const e4Api = await getGraphqlClient();
|
|
61
|
+
const { data, errors } = await e4Api.productTypeaheadSearchByCategory({
|
|
62
|
+
input: {
|
|
63
|
+
search: input.searchText,
|
|
64
|
+
categoryId: await generateCategoryFilterString(input.category ?? 0),
|
|
65
|
+
top: 10,
|
|
66
|
+
skip: 0,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
if (errors) {
|
|
70
|
+
throw new Error("Error getting products");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const products = data?.productsTypeAhead
|
|
74
|
+
?.map((product) => {
|
|
75
|
+
const transformedProduct =
|
|
76
|
+
translator.productWithCategoryTransformValidate(product as Product);
|
|
77
|
+
|
|
78
|
+
// Ensure Price is always a number (not undefined)
|
|
79
|
+
if (transformedProduct) {
|
|
80
|
+
return {
|
|
81
|
+
...transformedProduct,
|
|
82
|
+
// Provide default value of 0 if Price is undefined
|
|
83
|
+
Price: transformedProduct.Price ?? 0,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
})
|
|
88
|
+
.filter(Boolean) as ProductSearchResult[];
|
|
89
|
+
return products as ProductSearchResult[];
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
async getProductsList(
|
|
93
|
+
input: productSchema.SearchByCriteriaInput,
|
|
94
|
+
): Promise<productSchema.SearchByCriteriaResponse> {
|
|
95
|
+
const e4Api = await getGraphqlClient();
|
|
96
|
+
|
|
97
|
+
const { data, errors } = await e4Api.e4ProductListMD(
|
|
98
|
+
await translator.productListInputTransform(input),
|
|
99
|
+
);
|
|
100
|
+
if (errors) {
|
|
101
|
+
throw new Error("Error getting products");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const rawProducts: Product[] = (data.products?.products || []).filter(
|
|
105
|
+
(prod): prod is Product => prod !== null,
|
|
106
|
+
);
|
|
107
|
+
const rawFilters: Attribute[] = (data.products?.filters || []).filter(
|
|
108
|
+
(filter): filter is Attribute => filter !== null,
|
|
109
|
+
);
|
|
110
|
+
const transformedProducts = rawProducts.map((prod) =>
|
|
111
|
+
translator.productTransformValidate(prod),
|
|
112
|
+
);
|
|
113
|
+
const transformedRefiners =
|
|
114
|
+
translator.refinersTransformValidate(rawFilters);
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
products: transformedProducts,
|
|
118
|
+
refiners: transformedRefiners,
|
|
119
|
+
count: data.products?.recordCount ?? 0,
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
async getCategoryList(): Promise<CategoriesQuery> {
|
|
124
|
+
const e4Api = await getGraphqlClient();
|
|
125
|
+
const { data, errors } = await e4Api.categories();
|
|
126
|
+
if (errors) {
|
|
127
|
+
throw new Error("Error reading categories in getCategoryList");
|
|
128
|
+
}
|
|
129
|
+
return data;
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
// Full BOPIS implementation
|
|
133
|
+
async getInventory(input) {
|
|
134
|
+
const e4Api = await getGraphqlClient();
|
|
135
|
+
const { data, errors } = await e4Api.e4ProductReadLG({
|
|
136
|
+
id: String(input.searchCriteria.productIds[0]),
|
|
137
|
+
productLookupType: ProductLookupType.Id,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
if (errors) {
|
|
141
|
+
throw new Error("Error retrieving e4 product inventory in getInventory");
|
|
142
|
+
}
|
|
143
|
+
// adding dummy properties to data just to satisfy front end BOPIS components
|
|
144
|
+
// src/app/[locale]/(default)/product/[name]/[id]/product-intro/product-intro.tsx:94
|
|
145
|
+
return {
|
|
146
|
+
TotalAvailable: data.product?.Available || 0,
|
|
147
|
+
AggregatedProductInventoryAvailabilities: ["IN STOCK"],
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
getRelatedProducts: function (
|
|
151
|
+
input: productSchema.GetRelatedProductsInput,
|
|
152
|
+
): Promise<ProductSearchResult[]> {
|
|
153
|
+
throw new Error(`Function not implemented.${input}`);
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export default product;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import getGraphqlClient from "../../lib/get-graphql-client";
|
|
2
|
+
import {
|
|
3
|
+
Session,
|
|
4
|
+
SessionInitInput,
|
|
5
|
+
} from "@/api-manager/schemas/session.schema";
|
|
6
|
+
import * as translator from "./e4.translator";
|
|
7
|
+
|
|
8
|
+
const session = {
|
|
9
|
+
async sessionInit(input: SessionInitInput): Promise<Session> {
|
|
10
|
+
const e4Api = await getGraphqlClient();
|
|
11
|
+
const { data, errors } = await e4Api.customerInitSession({
|
|
12
|
+
input: {
|
|
13
|
+
authToken: input.accessToken,
|
|
14
|
+
userName: input.email,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
if (errors) {
|
|
19
|
+
throw new Error("Error adding user to e4 session");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return translator.sessionTransformValidate(
|
|
23
|
+
data?.customerInitSession ?? { id: "" },
|
|
24
|
+
);
|
|
25
|
+
},
|
|
26
|
+
async sessionLogout(): Promise<boolean> {
|
|
27
|
+
const e4Api = await getGraphqlClient();
|
|
28
|
+
const { data, errors } = await e4Api.e4CustomerLogoutSession();
|
|
29
|
+
|
|
30
|
+
if (errors) {
|
|
31
|
+
throw new Error("Error e4 session logout");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return !!data?.customerLogout?.success;
|
|
35
|
+
},
|
|
36
|
+
async getSession(): Promise<Session> {
|
|
37
|
+
if (true) {
|
|
38
|
+
throw new Error("Error reading e4 session");
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default session;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import getGraphqlClient from "../../lib/get-graphql-client";
|
|
2
|
+
import { User, UserCounts } from "@/api-manager/schemas/user.schema";
|
|
3
|
+
import * as translator from "./e4.translator";
|
|
4
|
+
import { CreateWishListInput, WishList } from "./graphqlRequestSdk";
|
|
5
|
+
import { userMap } from "./e4.remaps";
|
|
6
|
+
import { merge } from "object-mapper";
|
|
7
|
+
|
|
8
|
+
const user = {
|
|
9
|
+
async updateUser(user: User): Promise<User> {
|
|
10
|
+
const e4Api = await getGraphqlClient(true);
|
|
11
|
+
|
|
12
|
+
const userInput = translator.userTransformInput(user);
|
|
13
|
+
|
|
14
|
+
const { data, errors } = await e4Api.e4UserUpdateMD({
|
|
15
|
+
user: userInput,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
if (errors) {
|
|
19
|
+
throw new Error("Error updating e4 user");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return merge(data?.updateUser ?? {}, userMap) as User;
|
|
23
|
+
},
|
|
24
|
+
async getUser(): Promise<User> {
|
|
25
|
+
const e4Api = await getGraphqlClient(true);
|
|
26
|
+
|
|
27
|
+
const { data, errors } = await e4Api.e4UserReadMD();
|
|
28
|
+
|
|
29
|
+
if (errors) {
|
|
30
|
+
throw new Error("Error reading e4 user");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return merge(data?.me ?? {}, userMap) as User;
|
|
34
|
+
},
|
|
35
|
+
async getUserCounts(userId: string): Promise<UserCounts> {
|
|
36
|
+
const e4Api = await getGraphqlClient(true);
|
|
37
|
+
|
|
38
|
+
const { data, errors } = await e4Api.e4UserCounts({ id: userId });
|
|
39
|
+
|
|
40
|
+
if (errors) {
|
|
41
|
+
throw new Error("Error getting user counts");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
orderCount: data?.getOrderCount ?? 0,
|
|
46
|
+
addressCount: data?.getAddressCount ?? 0,
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
async getWishlists(): Promise<WishList[]> {
|
|
50
|
+
const e4Api = await getGraphqlClient(true);
|
|
51
|
+
|
|
52
|
+
const { data, errors } = await e4Api.e4WishListListSM();
|
|
53
|
+
|
|
54
|
+
if (errors) {
|
|
55
|
+
throw new Error("Error getting wishlists");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return data?.wishlistList?.nodes ?? [];
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
async getWishlistDetails(id: string): Promise<WishList> {
|
|
62
|
+
const e4Api = await getGraphqlClient(true);
|
|
63
|
+
|
|
64
|
+
const { data, errors } = await e4Api.e4WishListReadMD({ id });
|
|
65
|
+
|
|
66
|
+
if (errors) {
|
|
67
|
+
throw new Error("Error getting wishlist details");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const wishList = data?.wishList;
|
|
71
|
+
|
|
72
|
+
if (!wishList) {
|
|
73
|
+
throw new Error("No wishlist found");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
...wishList,
|
|
78
|
+
products: {
|
|
79
|
+
edges: [],
|
|
80
|
+
...wishList.products,
|
|
81
|
+
},
|
|
82
|
+
} as unknown as WishList;
|
|
83
|
+
},
|
|
84
|
+
async createWishlist(wishlist: CreateWishListInput): Promise<WishList> {
|
|
85
|
+
if (!wishlist.name) {
|
|
86
|
+
throw new Error("Wishlist name is required");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const e4Api = await getGraphqlClient(true);
|
|
90
|
+
|
|
91
|
+
const { data, errors } = await e4Api.upsertWishlist({ wishlist });
|
|
92
|
+
|
|
93
|
+
if (errors) {
|
|
94
|
+
throw new Error("Error creating wishlist");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const wishList = data?.upsertWishlist;
|
|
98
|
+
|
|
99
|
+
if (!wishList) {
|
|
100
|
+
throw new Error("No wishlist found");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return wishList as WishList;
|
|
104
|
+
},
|
|
105
|
+
async deleteWishlist(id: string): Promise<string> {
|
|
106
|
+
const e4Api = await getGraphqlClient(true);
|
|
107
|
+
|
|
108
|
+
const { data, errors } = await e4Api.deleteWishList({ id });
|
|
109
|
+
|
|
110
|
+
if (errors) {
|
|
111
|
+
throw new Error("Error creating wishlist");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return data?.deleteWishList ?? "";
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export default user;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { PrimaryDatasource } from "../../types/Datasource";
|
|
2
|
+
import getGraphqlClient from "../../lib/get-graphql-client";
|
|
3
|
+
import { Category as E4Category } from "./graphqlRequestSdk";
|
|
4
|
+
import * as translator from "./e4.translator";
|
|
5
|
+
// Data source files
|
|
6
|
+
import user from "./e4-user.datasource";
|
|
7
|
+
import session from "./e4-session.datasource";
|
|
8
|
+
import { cart } from "./e4-cart.datasource";
|
|
9
|
+
import order from "./e4-order.datasource";
|
|
10
|
+
import address from "./e4-address.datasource";
|
|
11
|
+
import { CategoryHierarchy } from "../../lib/category-helpers";
|
|
12
|
+
import product from "./e4-product.datasource";
|
|
13
|
+
import organization from "./e4-organization.datasource";
|
|
14
|
+
|
|
15
|
+
const E4Datasource: PrimaryDatasource = {
|
|
16
|
+
name: "e4",
|
|
17
|
+
user,
|
|
18
|
+
session,
|
|
19
|
+
cart,
|
|
20
|
+
order,
|
|
21
|
+
address,
|
|
22
|
+
product,
|
|
23
|
+
organization,
|
|
24
|
+
categories: {
|
|
25
|
+
async getCategories(): Promise<CategoryHierarchy[]> {
|
|
26
|
+
const e4Api = await getGraphqlClient();
|
|
27
|
+
const { data: rawApiResult, errors } = await e4Api.categories();
|
|
28
|
+
|
|
29
|
+
if (errors) {
|
|
30
|
+
console.error(
|
|
31
|
+
"GraphQL errors reading categories (in categories.getCategories):",
|
|
32
|
+
errors,
|
|
33
|
+
);
|
|
34
|
+
throw new Error("Error getting categories");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const rawCategoryArray = rawApiResult?.categories?.category;
|
|
38
|
+
|
|
39
|
+
if (!Array.isArray(rawCategoryArray)) {
|
|
40
|
+
console.warn(
|
|
41
|
+
"Categories data at expected path not found or not an array in categories.getCategories:",
|
|
42
|
+
rawApiResult,
|
|
43
|
+
);
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const transformedHierarchicalData = translator.categoryTransformValidate(
|
|
48
|
+
rawApiResult?.categories?.category as E4Category[],
|
|
49
|
+
);
|
|
50
|
+
return transformedHierarchicalData;
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default E4Datasource;
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps E4 API responses to the D365 data structure.
|
|
3
|
+
*
|
|
4
|
+
* This file uses the `object-mapper` library to transform
|
|
5
|
+
* API responses into a format compatible with D365.
|
|
6
|
+
*
|
|
7
|
+
* https://github.com/wankdanker/node-object-mapper
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
Address,
|
|
13
|
+
Product as DynProduct,
|
|
14
|
+
} from "@msdyn365-commerce/retail-proxy";
|
|
15
|
+
import { merge } from "object-mapper";
|
|
16
|
+
import {
|
|
17
|
+
Image,
|
|
18
|
+
Product,
|
|
19
|
+
Address as E4Address,
|
|
20
|
+
CartLine,
|
|
21
|
+
OrderLine,
|
|
22
|
+
SelectedDimension,
|
|
23
|
+
Me,
|
|
24
|
+
} from "./graphqlRequestSdk";
|
|
25
|
+
import unwrapE4Variants from "./utils/unwrap-e4-variants";
|
|
26
|
+
|
|
27
|
+
/* PRODUCT REMAPS */
|
|
28
|
+
export const dimensionMap = {
|
|
29
|
+
AttributeId: "DimensionTypeValue",
|
|
30
|
+
Value: "DimensionValue.Value",
|
|
31
|
+
ValueId: "DimensionValue.RecordId",
|
|
32
|
+
_: {
|
|
33
|
+
key: "TotalAvailableInventoryLevelCode",
|
|
34
|
+
default: "AVAIL",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const productMap = {
|
|
39
|
+
sku: "ItemId",
|
|
40
|
+
name: "Name",
|
|
41
|
+
MasterProductId: "MasterProductId",
|
|
42
|
+
price: [
|
|
43
|
+
{ key: "Price", default: 0 },
|
|
44
|
+
{ key: "BasePrice", default: 0 },
|
|
45
|
+
{ key: "AdjustedPrice", default: 0 },
|
|
46
|
+
],
|
|
47
|
+
id: [
|
|
48
|
+
{
|
|
49
|
+
key: "RecordId",
|
|
50
|
+
transform: (id: string) => {
|
|
51
|
+
if (id !== null) return parseInt(id);
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
img: {
|
|
56
|
+
key: "PrimaryImageUrl",
|
|
57
|
+
transform: (img: Image[]) => {
|
|
58
|
+
if (Array.isArray(img) && img.length > 0) {
|
|
59
|
+
return img[0].cdnURL ?? null;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const productDetailsMap = {
|
|
67
|
+
...productMap,
|
|
68
|
+
MasterProductId: "MasterProductId",
|
|
69
|
+
"img[].cdnURL": "Images[]",
|
|
70
|
+
description: "Description",
|
|
71
|
+
"Dimensions[].AttributeId": "Dimensions[].DimensionTypeValue",
|
|
72
|
+
Variants: {
|
|
73
|
+
key: "DimensionValues",
|
|
74
|
+
transform: unwrapE4Variants,
|
|
75
|
+
},
|
|
76
|
+
"attributes[].Name": "Attributes[].Name",
|
|
77
|
+
"attributes[].Value": "Attributes[].TextValue",
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/* CART REMAPS */
|
|
81
|
+
export const cartLineMap = {
|
|
82
|
+
"[].product": {
|
|
83
|
+
key: "[].Product?",
|
|
84
|
+
transform: (product: Product) => {
|
|
85
|
+
// If cart is empty, prevents CartLines[] from having entries
|
|
86
|
+
if (!product) return;
|
|
87
|
+
|
|
88
|
+
// For some reason transform is run multiple times. This prevents merge from running multiple times and overwriting translation.
|
|
89
|
+
const translated = merge(product, productMap) as DynProduct & {
|
|
90
|
+
ProductTypeValue?: number;
|
|
91
|
+
};
|
|
92
|
+
if (!translated.RecordId) return product;
|
|
93
|
+
translated.ProductTypeValue = 4; // default for now. Type = Standalone
|
|
94
|
+
return translated;
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
"[].id": "[].LineId",
|
|
98
|
+
"[].product.id": {
|
|
99
|
+
key: "[].ProductId",
|
|
100
|
+
transform: (id: string) => {
|
|
101
|
+
if (id !== null) return parseInt(id);
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
"[].product.code": "[].ItemId",
|
|
105
|
+
"[].product.name": "[].Product.Name",
|
|
106
|
+
"[].quantity": "[].Quantity",
|
|
107
|
+
"[].price": [
|
|
108
|
+
{ key: "[].Price", default: 0 },
|
|
109
|
+
{ key: "[].Product.Price", default: 0 },
|
|
110
|
+
{ key: "[].Product.BasePrice", default: 0 },
|
|
111
|
+
{ key: "[].Product.AdjustedPrice", default: 0 },
|
|
112
|
+
],
|
|
113
|
+
"[].amount": [{ key: "[].TotalAmount" }, { key: "[].NetPrice" }],
|
|
114
|
+
"[].uom.name": {
|
|
115
|
+
key: "[].UnitOfMeasureSymbol",
|
|
116
|
+
transform: (name: string) => {
|
|
117
|
+
if (name !== null) {
|
|
118
|
+
if (name === "Each") return "ea";
|
|
119
|
+
return name;
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
"[].product.productType": {
|
|
124
|
+
key: "[].Product.ProductTypeValue",
|
|
125
|
+
default: 4,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const addressMap = {
|
|
130
|
+
"[].id": [
|
|
131
|
+
{ key: "[].Id" },
|
|
132
|
+
{
|
|
133
|
+
key: "[].RecordId",
|
|
134
|
+
transform: (id: string) => {
|
|
135
|
+
if (id !== null) return parseInt(id);
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
"[].name": "[].Name",
|
|
140
|
+
"[].isPrimary": "[].IsPrimary",
|
|
141
|
+
"[].addressType.id": {
|
|
142
|
+
key: "[].AddressTypeValue",
|
|
143
|
+
transform: (id: string) => {
|
|
144
|
+
if (id !== null) return parseInt(id);
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
"[].address1": "[].Street",
|
|
148
|
+
"[].city": "[].City",
|
|
149
|
+
"[].stateName": "[].State",
|
|
150
|
+
"[].countryName": "[].ThreeLetterISORegionName",
|
|
151
|
+
"[].postalCode": "[].ZipCode",
|
|
152
|
+
"[].phoneNumber": "[].Phone",
|
|
153
|
+
"[].address2": {
|
|
154
|
+
key: "[].FullAddress",
|
|
155
|
+
transform: (_val: string, _src: E4Address[], dest: Address) => {
|
|
156
|
+
return `${dest?.Street}, ${dest?.City} ${dest?.State} ${dest?.ZipCode}, ${dest?.ThreeLetterISORegionName}`;
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export const addressReverseMap = {
|
|
162
|
+
Name: "name",
|
|
163
|
+
Street: "address1",
|
|
164
|
+
City: "city",
|
|
165
|
+
ZipCode: "postalCode",
|
|
166
|
+
Phone: "phoneNumber",
|
|
167
|
+
Id: "id",
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export const userMap = {
|
|
171
|
+
id: {
|
|
172
|
+
key: "RecordId",
|
|
173
|
+
transform: (id: string) => {
|
|
174
|
+
return Number(id);
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
code: {
|
|
178
|
+
// we don't need AccountNumber in e4 storefront,
|
|
179
|
+
// if we need it bring account data and map accountId here.
|
|
180
|
+
key: "AccountNumber",
|
|
181
|
+
transform: () => {
|
|
182
|
+
return "";
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
firstName: "FirstName",
|
|
186
|
+
lastName: "LastName",
|
|
187
|
+
email: "Email",
|
|
188
|
+
defaultShippingAddressId: "DefaultShippingAddressId",
|
|
189
|
+
addresses: {
|
|
190
|
+
key: "Addresses",
|
|
191
|
+
transform: (addresses: E4Address[], source: Me) => {
|
|
192
|
+
if (!(addresses && addresses?.length)) return [];
|
|
193
|
+
const mapped = merge(addresses || [], addressMap) as Address[];
|
|
194
|
+
return mapped.map((address: Address) => ({
|
|
195
|
+
...address,
|
|
196
|
+
IsPrimary:
|
|
197
|
+
address?.IsPrimary ||
|
|
198
|
+
address?.Id === source?.defaultShippingAddressId,
|
|
199
|
+
}));
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export const countriesMap = {
|
|
205
|
+
isoAlpha3Code: "CountryRegionId",
|
|
206
|
+
isoAlpha2Code: "ISOCode",
|
|
207
|
+
name: "ShortName",
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export const countryMap = {
|
|
211
|
+
"state[].code": "[].StateId",
|
|
212
|
+
"state[].name": "[].StateName",
|
|
213
|
+
isoAlpha3Code: "[].CountryRegionId",
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export const deliveryOptionsMap = {
|
|
217
|
+
id: ["Code", "RecordId"],
|
|
218
|
+
name: "Description",
|
|
219
|
+
total: "TotalChargeAmount",
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export const cartMap = {
|
|
223
|
+
id: "Id",
|
|
224
|
+
itemCount: "TotalItems",
|
|
225
|
+
|
|
226
|
+
lines: {
|
|
227
|
+
key: "CartLines",
|
|
228
|
+
transform: (lines: CartLine[]) => {
|
|
229
|
+
if (lines.length === 0) return [];
|
|
230
|
+
return merge(lines, cartLineMap);
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
subtotal: "SubtotalAmountWithoutTax",
|
|
235
|
+
freightTotal: "ShippingChargeAmount",
|
|
236
|
+
taxTotal: "TaxAmount",
|
|
237
|
+
total: "TotalAmount",
|
|
238
|
+
email: "ReceiptEmail",
|
|
239
|
+
|
|
240
|
+
addresses: {
|
|
241
|
+
key: "ShippingAddress",
|
|
242
|
+
transform: (addresses: E4Address[]) => {
|
|
243
|
+
if (addresses.length === 0) return undefined;
|
|
244
|
+
const translated = merge(addresses, addressMap) as Address[];
|
|
245
|
+
return translated[addresses.length - 1];
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const STATUSES = ["Open", "Processing", "Complete", "On Hold", "Cancelled"];
|
|
251
|
+
|
|
252
|
+
export const orderMap = {
|
|
253
|
+
id: "Id",
|
|
254
|
+
orderNumber: "ChannelReferenceId",
|
|
255
|
+
orderStatus: {
|
|
256
|
+
key: "StatusValue",
|
|
257
|
+
transform: (orderStatus: string) => {
|
|
258
|
+
return STATUSES.indexOf(orderStatus) + 1;
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
orderDate: "TransactionDate",
|
|
262
|
+
freightTotal: "ShippingChargeAmount",
|
|
263
|
+
promotionTotal: "DiscountAmount",
|
|
264
|
+
subTotal: "SubtotalAmount",
|
|
265
|
+
taxTotal: "TaxAmount",
|
|
266
|
+
itemCount: "NumberOfItems",
|
|
267
|
+
total: "TotalAmount",
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
const salesLinesProduct = {
|
|
271
|
+
productId: "RecordId",
|
|
272
|
+
productCode: "ItemId",
|
|
273
|
+
productName: "Name",
|
|
274
|
+
amount: "TotalAmount",
|
|
275
|
+
img: {
|
|
276
|
+
key: "PrimaryImageUrl",
|
|
277
|
+
transform: (img: Image[]) => {
|
|
278
|
+
if (Array.isArray(img) && img.length > 0) {
|
|
279
|
+
return img[0].cdnURL ?? null;
|
|
280
|
+
}
|
|
281
|
+
return null;
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
selectedDimensions: {
|
|
285
|
+
key: "Dimensions",
|
|
286
|
+
transform: (dimensions: SelectedDimension[]) => {
|
|
287
|
+
if (!(dimensions && dimensions.length)) return [];
|
|
288
|
+
|
|
289
|
+
const typeMap: Record<string, number> = {
|
|
290
|
+
Color: 1,
|
|
291
|
+
Size: 3,
|
|
292
|
+
// extend as needed
|
|
293
|
+
// map to import { ProductDimensionType } from "@msdyn365-commerce/retail-proxy";
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
return dimensions.map((d) => ({
|
|
297
|
+
DimensionTypeValue: typeMap[d.name ?? ""] ?? 0,
|
|
298
|
+
DimensionValue: {
|
|
299
|
+
RecordId: Number(d.id),
|
|
300
|
+
Value: d.value,
|
|
301
|
+
DimensionId: d.name,
|
|
302
|
+
},
|
|
303
|
+
}));
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
export const orderDetailsMap = {
|
|
309
|
+
...orderMap,
|
|
310
|
+
lines: {
|
|
311
|
+
key: "SalesLines",
|
|
312
|
+
transform: (lines: OrderLine[]) => {
|
|
313
|
+
if (!(lines && lines.length)) return [];
|
|
314
|
+
return lines.map((line) => {
|
|
315
|
+
return {
|
|
316
|
+
Product: merge(line, salesLinesProduct),
|
|
317
|
+
Price: line?.price,
|
|
318
|
+
Quantity: line?.quantity,
|
|
319
|
+
};
|
|
320
|
+
});
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
addresses: {
|
|
324
|
+
key: "ShippingAddress",
|
|
325
|
+
transform: (addresses: E4Address[]) => {
|
|
326
|
+
if (addresses.length === 0) return undefined;
|
|
327
|
+
const translated = merge(addresses, addressMap) as Address[];
|
|
328
|
+
return translated[addresses.length - 1];
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
};
|