@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,30 @@
|
|
|
1
|
+
import { IQueryResultSettings } from "@msdyn365-commerce/retail-proxy";
|
|
2
|
+
|
|
3
|
+
const defaultQueryResultSettings: IQueryResultSettings = {
|
|
4
|
+
Paging: {
|
|
5
|
+
Top: 2,
|
|
6
|
+
Skip: 0,
|
|
7
|
+
},
|
|
8
|
+
Sorting: { Columns: [{ ColumnName: "Name", IsDescending: true }] },
|
|
9
|
+
count: true,
|
|
10
|
+
};
|
|
11
|
+
const context = {
|
|
12
|
+
requestContext: {
|
|
13
|
+
locale: "en-US",
|
|
14
|
+
apiSettings: {
|
|
15
|
+
baseUrl: "https://scui1e8d9zn85030208-rs.su.retail.dynamics.com/",
|
|
16
|
+
channelId: 68719478279,
|
|
17
|
+
oun: "128",
|
|
18
|
+
catalogId: 0,
|
|
19
|
+
baseImageUrl: "",
|
|
20
|
+
},
|
|
21
|
+
user: {
|
|
22
|
+
isAuthenticated: false,
|
|
23
|
+
token: "",
|
|
24
|
+
},
|
|
25
|
+
operationId: "1",
|
|
26
|
+
},
|
|
27
|
+
queryResultSettings: defaultQueryResultSettings,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { context };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ProductDimensionAvailabilitySearchCriteria } from "@msdyn365-commerce/retail-proxy";
|
|
2
|
+
/**
|
|
3
|
+
* Helper: Create search criteria for product dimension availability.
|
|
4
|
+
* @param dimensionTypeValue
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export const createDimSearchCriteria = (
|
|
8
|
+
dimensionTypeValue: number,
|
|
9
|
+
): ProductDimensionAvailabilitySearchCriteria => {
|
|
10
|
+
return {
|
|
11
|
+
RequestedDimensionTypeValue: dimensionTypeValue,
|
|
12
|
+
MatchingDimensionValues: [],
|
|
13
|
+
DefaultWarehouseOnly: true,
|
|
14
|
+
FilterByChannelFulfillmentGroup: true,
|
|
15
|
+
CatalogId: 0,
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { decode } from "next-auth/jwt";
|
|
3
|
+
import { getConfig } from "@config";
|
|
4
|
+
|
|
5
|
+
export async function decodeToken(token: string) {
|
|
6
|
+
const secret = getConfig().NEXTAUTH_SECRET;
|
|
7
|
+
if (!secret) {
|
|
8
|
+
throw new Error("Environment variable NEXTAUTH_SECRET is not set.");
|
|
9
|
+
}
|
|
10
|
+
return decode({ token: token, secret });
|
|
11
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { manuallyRetrieveSessionCookie } from "@/auth/next-auth-cookie-manager";
|
|
3
|
+
import { ICallerContext } from "@msdyn365-commerce/retail-proxy";
|
|
4
|
+
import { getLocale } from "next-intl/server";
|
|
5
|
+
import { cookies } from "next/headers";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves the D365 context from the "D365Context" cookie, enriches it with the current session token,
|
|
9
|
+
* locale, and a new operation ID, and returns it as an `ICallerContext` object.
|
|
10
|
+
*
|
|
11
|
+
* @returns {Promise<ICallerContext>} A promise that resolves to the enriched D365 caller context.
|
|
12
|
+
* @throws {Error} If the "D365Context" cookie is not found.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* - The function fetches the D365 context from cookies, parses it, and updates the request context with:
|
|
16
|
+
* - A new `operationId` (UUID).
|
|
17
|
+
* - The current user's authentication status and access token.
|
|
18
|
+
* - The current locale.
|
|
19
|
+
* - Relies on `manuallyRetrieveSessionCookie` and `getLocale` for session and locale information.
|
|
20
|
+
*/
|
|
21
|
+
export async function getContextFromCookie(): Promise<ICallerContext> {
|
|
22
|
+
const cookieStore = await cookies();
|
|
23
|
+
const d365Context = cookieStore.get("D365Context");
|
|
24
|
+
const token = await manuallyRetrieveSessionCookie();
|
|
25
|
+
const locale = await getLocale();
|
|
26
|
+
if (d365Context) {
|
|
27
|
+
const context = JSON.parse(d365Context.value) as ICallerContext;
|
|
28
|
+
context.requestContext.operationId = crypto.randomUUID();
|
|
29
|
+
context.requestContext.user = {
|
|
30
|
+
isAuthenticated: !!token?.accessToken,
|
|
31
|
+
token: token?.accessToken ?? "",
|
|
32
|
+
};
|
|
33
|
+
context.requestContext.locale = locale;
|
|
34
|
+
return context;
|
|
35
|
+
}
|
|
36
|
+
throw new Error("D365Context cookie not found");
|
|
37
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { SimpleProduct } from "@msdyn365-commerce/retail-proxy";
|
|
2
|
+
|
|
3
|
+
const testImageUrl = (url: string) => {
|
|
4
|
+
return new Promise<[string, boolean]>((resolve) => {
|
|
5
|
+
fetch(url, { method: "HEAD" })
|
|
6
|
+
.then((response) =>
|
|
7
|
+
response
|
|
8
|
+
.blob()
|
|
9
|
+
.then((buff) => resolve([url, buff.type.startsWith("image/")])),
|
|
10
|
+
)
|
|
11
|
+
.catch(() => resolve([url, false]));
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const testMedia = async (media: string[]) => {
|
|
16
|
+
const promises = media.map((m) => testImageUrl(m));
|
|
17
|
+
const validUrls = await Promise.all(promises).then((tuple) =>
|
|
18
|
+
tuple.filter((tp) => tp[1]).map((tp) => tp[0]),
|
|
19
|
+
);
|
|
20
|
+
return validUrls;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* validateAndSetMediaUrls - Validates and sets the media urls for the product
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
export const validateAndSetMediaUrls = async (
|
|
28
|
+
productData: SimpleProduct,
|
|
29
|
+
baseUrl: string,
|
|
30
|
+
) => {
|
|
31
|
+
const product = productData;
|
|
32
|
+
const primaryImageUrl = product?.PrimaryImageUrl;
|
|
33
|
+
if (!primaryImageUrl) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const urls = [];
|
|
37
|
+
for (let index = 1; index < 6; index++) {
|
|
38
|
+
const nextUrl = baseUrl + primaryImageUrl.replace("001", `00${index}`);
|
|
39
|
+
urls.push(nextUrl);
|
|
40
|
+
}
|
|
41
|
+
const validUrls = await testMedia(urls);
|
|
42
|
+
return validUrls;
|
|
43
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InventoryAvailabilitySearchCriteria,
|
|
3
|
+
SearchArea,
|
|
4
|
+
} from "@msdyn365-commerce/retail-proxy";
|
|
5
|
+
|
|
6
|
+
export enum DeliveryMode {
|
|
7
|
+
allWareHouses = 0,
|
|
8
|
+
shipping = 1,
|
|
9
|
+
pickup = 2,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const createInventoryAvailabilitySearchCriteria = (
|
|
13
|
+
productIds: number[],
|
|
14
|
+
isDefaultWarehouse: boolean,
|
|
15
|
+
filterbyChannelFulfillmentGroup: boolean,
|
|
16
|
+
serachArea: SearchArea,
|
|
17
|
+
defaultDeliveryMode: DeliveryMode,
|
|
18
|
+
) => {
|
|
19
|
+
const salesUnitType = 2; // Sales unit type is always 2 for product inventory
|
|
20
|
+
const deliveryMode = defaultDeliveryMode
|
|
21
|
+
? defaultDeliveryMode
|
|
22
|
+
: DeliveryMode.shipping;
|
|
23
|
+
|
|
24
|
+
const inventoryAvailabilitySearchCriteria: InventoryAvailabilitySearchCriteria =
|
|
25
|
+
{
|
|
26
|
+
ProductIds: productIds,
|
|
27
|
+
QuantityUnitTypeValue: salesUnitType,
|
|
28
|
+
SearchArea: serachArea,
|
|
29
|
+
FilterByChannelFulfillmentGroup: filterbyChannelFulfillmentGroup,
|
|
30
|
+
DefaultWarehouseOnly: isDefaultWarehouse,
|
|
31
|
+
DeliveryModeTypeFilterValue: deliveryMode,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return inventoryAvailabilitySearchCriteria;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { createInventoryAvailabilitySearchCriteria };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import getGraphqlClient from "../../lib/get-graphql-client";
|
|
2
|
+
import {
|
|
3
|
+
Address,
|
|
4
|
+
GetDeliveryOptionsInput,
|
|
5
|
+
GetStatesInput,
|
|
6
|
+
} from "@/api-manager/schemas/address.schema";
|
|
7
|
+
import {
|
|
8
|
+
CountryRegionInfo,
|
|
9
|
+
DeliveryOption,
|
|
10
|
+
StateProvinceInfo,
|
|
11
|
+
} from "@msdyn365-commerce/retail-proxy";
|
|
12
|
+
import { Shipping } from "./graphqlRequestSdk";
|
|
13
|
+
import * as translator from "./e4.translator";
|
|
14
|
+
import { addressMap } from "./e4.remaps";
|
|
15
|
+
import { merge } from "object-mapper";
|
|
16
|
+
|
|
17
|
+
const address = {
|
|
18
|
+
async getCountries(): Promise<CountryRegionInfo[]> {
|
|
19
|
+
const e4Api = await getGraphqlClient();
|
|
20
|
+
const { data, errors } = await e4Api.e4CountryList();
|
|
21
|
+
if (errors) {
|
|
22
|
+
throw new Error("Error getting countries");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return translator.countriesTransformValidate(data?.countries ?? []);
|
|
26
|
+
},
|
|
27
|
+
async getStates(input: GetStatesInput): Promise<StateProvinceInfo[]> {
|
|
28
|
+
const e4Api = await getGraphqlClient();
|
|
29
|
+
const { data, errors } = await e4Api.e4Country({
|
|
30
|
+
id: (await translator.getCountryId(input?.countryId || "")) ?? "",
|
|
31
|
+
});
|
|
32
|
+
if (errors) {
|
|
33
|
+
throw new Error("Error getting states");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const countryData = data?.country ?? {
|
|
37
|
+
id: "",
|
|
38
|
+
name: "",
|
|
39
|
+
isoAlpha2Code: "",
|
|
40
|
+
isoAlpha3Code: "",
|
|
41
|
+
state: [],
|
|
42
|
+
};
|
|
43
|
+
const result = translator.countryTransformValidate(countryData);
|
|
44
|
+
return Array.isArray(result) ? result : [];
|
|
45
|
+
},
|
|
46
|
+
async getDeliveryOptions(
|
|
47
|
+
input: GetDeliveryOptionsInput,
|
|
48
|
+
): Promise<DeliveryOption[]> {
|
|
49
|
+
const e4Api = await getGraphqlClient();
|
|
50
|
+
|
|
51
|
+
const { data, errors } = await e4Api.shippingbyCarrier({
|
|
52
|
+
id: input?.shippingAddress?.ThreeLetterISORegionName ?? "",
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (errors) {
|
|
56
|
+
throw new Error("Error getting shipping methods");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return translator.deliveryOptionsTransformValidate(
|
|
60
|
+
(data?.shippingbyCarrier as Shipping[]) ?? [],
|
|
61
|
+
) as DeliveryOption[];
|
|
62
|
+
},
|
|
63
|
+
async createAddress(address: Address): Promise<Address> {
|
|
64
|
+
const e4Api = await getGraphqlClient(true);
|
|
65
|
+
const e4Address = await translator.addressTransform(address);
|
|
66
|
+
const { data, errors } = await e4Api.e4AddressCreate({
|
|
67
|
+
address: e4Address,
|
|
68
|
+
});
|
|
69
|
+
if (errors) {
|
|
70
|
+
throw new Error("Error creating address");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
merge(
|
|
75
|
+
[data?.createAddress],
|
|
76
|
+
addressMap as unknown as Address[],
|
|
77
|
+
) as Address[]
|
|
78
|
+
)[0];
|
|
79
|
+
},
|
|
80
|
+
async updateAddress(address: Address): Promise<Address> {
|
|
81
|
+
const e4Api = await getGraphqlClient(true);
|
|
82
|
+
const e4Address = await translator.addressTransform(address);
|
|
83
|
+
const { data, errors } = await e4Api.e4AddressUpdate({
|
|
84
|
+
address: e4Address,
|
|
85
|
+
});
|
|
86
|
+
if (errors) {
|
|
87
|
+
throw new Error("Error updating address");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
merge(
|
|
92
|
+
[data?.updateAddress],
|
|
93
|
+
addressMap as unknown as Address[],
|
|
94
|
+
) as Address[]
|
|
95
|
+
)[0];
|
|
96
|
+
},
|
|
97
|
+
async deleteAddress(addressId: string): Promise<string> {
|
|
98
|
+
const e4Api = await getGraphqlClient(true);
|
|
99
|
+
const { data, errors } = await e4Api.e4AddressDelete({ id: addressId });
|
|
100
|
+
if (errors) {
|
|
101
|
+
throw new Error("Error deleting address");
|
|
102
|
+
}
|
|
103
|
+
return data?.deleteAddress ?? "";
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export default address;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import getGraphqlClient from "../../lib/get-graphql-client";
|
|
2
|
+
import * as cartSchema from "../../schemas/cart.schema";
|
|
3
|
+
import { Cart } from "../../schemas/cart.schema";
|
|
4
|
+
import * as translator from "./e4.translator";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
CardPaymentAcceptPoint,
|
|
8
|
+
CardPaymentAcceptResult,
|
|
9
|
+
LineDeliverySpecification,
|
|
10
|
+
} from "@msdyn365-commerce/retail-proxy";
|
|
11
|
+
import { CartApi } from "../../types/Datasource";
|
|
12
|
+
import { Cart as E4Cart } from "./graphqlRequestSdk";
|
|
13
|
+
import { SalesOrder } from "@/api-manager/schemas/order.schema";
|
|
14
|
+
|
|
15
|
+
const cart: CartApi = {
|
|
16
|
+
//For this data source, initCart does the same thing as getCart
|
|
17
|
+
async initCart(): Promise<Cart> {
|
|
18
|
+
const e4Api = await getGraphqlClient();
|
|
19
|
+
|
|
20
|
+
const { data, errors } = await e4Api.e4CartReadMD();
|
|
21
|
+
|
|
22
|
+
if (errors) {
|
|
23
|
+
throw new Error("Error reading cart");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const transformedData = translator.cartTransformValidate(
|
|
27
|
+
data?.cart as E4Cart,
|
|
28
|
+
);
|
|
29
|
+
return transformedData;
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
async addToCart(input: cartSchema.AddToCartInput): Promise<Cart> {
|
|
33
|
+
const e4Api = await getGraphqlClient();
|
|
34
|
+
|
|
35
|
+
const { cartLine } = input;
|
|
36
|
+
|
|
37
|
+
const { data, errors } = await e4Api.e4AddToCartMD({
|
|
38
|
+
productId:
|
|
39
|
+
cartLine[0].ProductId?.toString() ||
|
|
40
|
+
cartLine[0].Product?.RecordId.toString() ||
|
|
41
|
+
"",
|
|
42
|
+
quantity: cartLine[0].Quantity,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
if (errors) {
|
|
46
|
+
throw new Error("Error adding to cart");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const transformedData = translator.cartTransformValidate(
|
|
50
|
+
data?.addToCart?.cart as E4Cart,
|
|
51
|
+
);
|
|
52
|
+
return transformedData;
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
async updateCart(input: cartSchema.UpdateCartInput): Promise<Cart> {
|
|
56
|
+
const e4Api = await getGraphqlClient();
|
|
57
|
+
|
|
58
|
+
const { cart } = input;
|
|
59
|
+
|
|
60
|
+
if (cart.ReceiptEmail) {
|
|
61
|
+
const setEmail = await e4Api.e4OrderEmailSet({
|
|
62
|
+
email: cart.ReceiptEmail,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (setEmail.errors) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`Error updating cart - set order email unsuccessful. ${setEmail.errors}`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (cart.ShippingAddress) {
|
|
73
|
+
const address = cart.ShippingAddress;
|
|
74
|
+
const createAddress = await e4Api.e4CreateCartAddress({
|
|
75
|
+
address: await translator.addressTransform(address),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (createAddress.errors) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
`Error updating cart - create address unsuccessful. ${createAddress.errors}`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const { data, errors } = await e4Api.e4CartReadMD();
|
|
86
|
+
|
|
87
|
+
if (errors) {
|
|
88
|
+
throw new Error("Error getting cart information");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const transformedData = translator.cartTransformValidate(
|
|
92
|
+
data?.cart as E4Cart,
|
|
93
|
+
);
|
|
94
|
+
return transformedData;
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
async updateCartLines(input: cartSchema.UpdateCartLineInput): Promise<Cart> {
|
|
98
|
+
const e4Api = await getGraphqlClient();
|
|
99
|
+
|
|
100
|
+
const { cartLine } = input;
|
|
101
|
+
let cart;
|
|
102
|
+
|
|
103
|
+
for (const cl of cartLine) {
|
|
104
|
+
const { data, errors } = await e4Api.e4UpdateCartLineMD({
|
|
105
|
+
input: {
|
|
106
|
+
productId:
|
|
107
|
+
cl.ProductId?.toString() || cl.Product?.RecordId.toString() || "",
|
|
108
|
+
quantity: cl.Quantity,
|
|
109
|
+
unitOfMeasureId: "-1", // Set default value, UOM will be picked from product DB.
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
if (errors) {
|
|
114
|
+
throw new Error("Error updating cart lines");
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
cart = data.updateCartLine;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const transformedData = translator.cartTransformValidate(
|
|
121
|
+
cart?.cart as E4Cart,
|
|
122
|
+
);
|
|
123
|
+
return transformedData;
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
async deleteCartLine(input: cartSchema.DeleteCartLineInput): Promise<Cart> {
|
|
127
|
+
const e4Api = await getGraphqlClient();
|
|
128
|
+
|
|
129
|
+
const { cartLine } = input;
|
|
130
|
+
|
|
131
|
+
const { data, errors } = await e4Api.e4DeleteCartLineMD({
|
|
132
|
+
input: {
|
|
133
|
+
productId:
|
|
134
|
+
cartLine[0].ProductId?.toString() ||
|
|
135
|
+
cartLine[0].Product?.RecordId.toString() ||
|
|
136
|
+
"",
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
if (errors) {
|
|
141
|
+
throw new Error("Error updating cart");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const transformedData = translator.cartTransformValidate(
|
|
145
|
+
data?.deleteCartLine?.cart as E4Cart,
|
|
146
|
+
);
|
|
147
|
+
return transformedData;
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
async getCart(): Promise<Cart> {
|
|
151
|
+
const e4Api = await getGraphqlClient();
|
|
152
|
+
|
|
153
|
+
const { data, errors } = await e4Api.e4CartReadMD();
|
|
154
|
+
|
|
155
|
+
if (errors) {
|
|
156
|
+
throw new Error("Error reading cart");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const transformedData = translator.cartTransformValidate(
|
|
160
|
+
data?.cart as E4Cart,
|
|
161
|
+
);
|
|
162
|
+
return transformedData;
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
async addDiscountCode(): Promise<Cart> {
|
|
166
|
+
if (true) {
|
|
167
|
+
throw new Error("Error adding discount code");
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
async removeDiscountcode(): Promise<Cart> {
|
|
172
|
+
if (true) {
|
|
173
|
+
throw new Error("Error removing discount code");
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
async updateLineDeliveryMode(
|
|
178
|
+
input: cartSchema.UpdateCartLineDeliveryModeInput,
|
|
179
|
+
): Promise<Cart> {
|
|
180
|
+
const e4Api = await getGraphqlClient();
|
|
181
|
+
|
|
182
|
+
const { data, errors } = await e4Api.e4ShippingMethodUpdateMD({
|
|
183
|
+
shippingId:
|
|
184
|
+
(input.cartLineDeliverySpecification[0] as LineDeliverySpecification)
|
|
185
|
+
.DeliverySpecification?.DeliveryModeId ?? "",
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
if (errors) {
|
|
189
|
+
throw new Error(
|
|
190
|
+
"Error setting order shipping method in updateLineDeliveryMode",
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return translator.cartTransformValidate(
|
|
195
|
+
data?.setOrderShipping?.cart as E4Cart,
|
|
196
|
+
);
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
async removeLineDeliveryMode(): Promise<Cart> {
|
|
200
|
+
if (true) {
|
|
201
|
+
throw new Error("Error updating cart line delivery mode");
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
async getCardAcceptPoint(): Promise<CardPaymentAcceptPoint> {
|
|
206
|
+
if (true) {
|
|
207
|
+
throw new Error("Error getCardAcceptPoint");
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
async retrieveCardPaymentAcceptResult(): Promise<CardPaymentAcceptResult> {
|
|
212
|
+
if (true) {
|
|
213
|
+
throw new Error("Error retrieveCardPaymentAcceptResult");
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
async checkout(): Promise<SalesOrder> {
|
|
218
|
+
const e4Api = await getGraphqlClient();
|
|
219
|
+
|
|
220
|
+
// dummy payment
|
|
221
|
+
const generateToken = (length = 32) => {
|
|
222
|
+
const chars =
|
|
223
|
+
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
224
|
+
let token = "";
|
|
225
|
+
for (let i = 0; i < length; i++) {
|
|
226
|
+
token += chars[Math.floor(Math.random() * chars.length)];
|
|
227
|
+
}
|
|
228
|
+
return token;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const { data, errors } = await e4Api.e4CartCheckoutSubmit({
|
|
232
|
+
input: {
|
|
233
|
+
paymentToken: generateToken(),
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
if (errors) {
|
|
238
|
+
throw new Error("Error submitting order");
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return {
|
|
242
|
+
Id: data?.completeCart?.order?.id ?? "",
|
|
243
|
+
SalesLines: [],
|
|
244
|
+
};
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export { cart };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SalesOrderInput,
|
|
3
|
+
GetSalesOrderDetailsInput,
|
|
4
|
+
SalesOrder,
|
|
5
|
+
} from "@/api-manager/schemas/order.schema";
|
|
6
|
+
import getGraphqlClient from "../../lib/get-graphql-client";
|
|
7
|
+
import { orderDetailsMap, orderMap } from "./e4.remaps";
|
|
8
|
+
import { merge } from "object-mapper";
|
|
9
|
+
import { OrderApi } from "../../types/Datasource";
|
|
10
|
+
|
|
11
|
+
const order: OrderApi = {
|
|
12
|
+
async getSalesOrders(input: SalesOrderInput): Promise<SalesOrder[]> {
|
|
13
|
+
const e4Api = await getGraphqlClient(true);
|
|
14
|
+
|
|
15
|
+
const { data, errors } = await e4Api.e4OrderListSM({ id: input?.id });
|
|
16
|
+
|
|
17
|
+
if (errors) {
|
|
18
|
+
throw new Error("Error getting orders");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const orders = data?.getOrdersByUserId?.nodes || [];
|
|
22
|
+
return orders.map((order) => {
|
|
23
|
+
return merge(order, orderMap) as SalesOrder;
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
async getSalesOrderDetails(
|
|
27
|
+
input: GetSalesOrderDetailsInput,
|
|
28
|
+
): Promise<SalesOrder> {
|
|
29
|
+
const e4Api = await getGraphqlClient(true);
|
|
30
|
+
|
|
31
|
+
const { data, errors } = await e4Api.e4OrderReadMD({
|
|
32
|
+
id: input?.transactionId,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (errors) {
|
|
36
|
+
throw new Error("Error getting order details");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return merge(data?.getOrderById ?? {}, orderDetailsMap) as SalesOrder;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default order;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import { OrganizationApi } from "../../types/Datasource";
|
|
3
|
+
import { ChannelConfiguration } from "@/api-manager/schemas/organization.schema";
|
|
4
|
+
|
|
5
|
+
// Todo: implement these stubs
|
|
6
|
+
|
|
7
|
+
const organization: OrganizationApi = {
|
|
8
|
+
getChannelConfiguration: async (): Promise<ChannelConfiguration> => {
|
|
9
|
+
// @ts-ignore: Stub implementation, to be implemented later
|
|
10
|
+
return {};
|
|
11
|
+
},
|
|
12
|
+
// @ts-ignore: Stub implementation, to be implemented later
|
|
13
|
+
getStoresList(input) {
|
|
14
|
+
console.log(input);
|
|
15
|
+
return [];
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default organization;
|