@se-faststore/components 0.0.0-stage → 0.12.0
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/LICENSE +21 -0
- package/README.md +129 -2
- package/dist/b2b/SeActionHubBulletinBoard/index.d.ts +2 -0
- package/dist/b2b/SeActionHubBulletinBoard/index.d.ts.map +1 -0
- package/dist/b2b/SeActionHubBulletinBoard/index.js +18 -0
- package/dist/b2b/SeActionHubBulletinBoard/index.js.map +1 -0
- package/dist/b2b/SeActionHubBulletinBoard/types.d.ts +24 -0
- package/dist/b2b/SeActionHubBulletinBoard/types.d.ts.map +1 -0
- package/dist/b2b/SeActionHubBulletinBoard/types.js +3 -0
- package/dist/b2b/SeActionHubBulletinBoard/types.js.map +1 -0
- package/dist/b2b/SeAddToPurchaseList/addToPurchaseListUtils.d.ts +24 -0
- package/dist/b2b/SeAddToPurchaseList/addToPurchaseListUtils.d.ts.map +1 -0
- package/dist/b2b/SeAddToPurchaseList/addToPurchaseListUtils.js +28 -0
- package/dist/b2b/SeAddToPurchaseList/addToPurchaseListUtils.js.map +1 -0
- package/dist/b2b/SeAddToPurchaseList/index.d.ts +3 -0
- package/dist/b2b/SeAddToPurchaseList/index.d.ts.map +1 -0
- package/dist/b2b/SeAddToPurchaseList/index.js +19 -0
- package/dist/b2b/SeAddToPurchaseList/index.js.map +1 -0
- package/dist/b2b/SeAddToPurchaseList/useAddToPurchaseList.d.ts +29 -0
- package/dist/b2b/SeAddToPurchaseList/useAddToPurchaseList.d.ts.map +1 -0
- package/dist/b2b/SeAddToPurchaseList/useAddToPurchaseList.js +86 -0
- package/dist/b2b/SeAddToPurchaseList/useAddToPurchaseList.js.map +1 -0
- package/dist/b2b/SeAddressSelector/index.d.ts +2 -0
- package/dist/b2b/SeAddressSelector/index.d.ts.map +1 -0
- package/dist/b2b/SeAddressSelector/index.js +18 -0
- package/dist/b2b/SeAddressSelector/index.js.map +1 -0
- package/dist/b2b/SeAddressSelector/useAddressSelector.d.ts +34 -0
- package/dist/b2b/SeAddressSelector/useAddressSelector.d.ts.map +1 -0
- package/dist/b2b/SeAddressSelector/useAddressSelector.js +127 -0
- package/dist/b2b/SeAddressSelector/useAddressSelector.js.map +1 -0
- package/dist/b2b/SeCategoryBanners/index.d.ts +2 -0
- package/dist/b2b/SeCategoryBanners/index.d.ts.map +1 -0
- package/dist/b2b/SeCategoryBanners/index.js +18 -0
- package/dist/b2b/SeCategoryBanners/index.js.map +1 -0
- package/dist/b2b/SeCategoryBanners/types.d.ts +9 -0
- package/dist/b2b/SeCategoryBanners/types.d.ts.map +1 -0
- package/dist/b2b/SeCategoryBanners/types.js +3 -0
- package/dist/b2b/SeCategoryBanners/types.js.map +1 -0
- package/dist/b2b/SeCheckStockAndPricing/checkStockAndPricingUtils.d.ts +114 -0
- package/dist/b2b/SeCheckStockAndPricing/checkStockAndPricingUtils.d.ts.map +1 -0
- package/dist/b2b/SeCheckStockAndPricing/checkStockAndPricingUtils.js +85 -0
- package/dist/b2b/SeCheckStockAndPricing/checkStockAndPricingUtils.js.map +1 -0
- package/dist/b2b/SeCheckStockAndPricing/index.d.ts +4 -0
- package/dist/b2b/SeCheckStockAndPricing/index.d.ts.map +1 -0
- package/dist/b2b/SeCheckStockAndPricing/index.js +20 -0
- package/dist/b2b/SeCheckStockAndPricing/index.js.map +1 -0
- package/dist/b2b/SeCheckStockAndPricing/stockCsv.d.ts +22 -0
- package/dist/b2b/SeCheckStockAndPricing/stockCsv.d.ts.map +1 -0
- package/dist/b2b/SeCheckStockAndPricing/stockCsv.js +79 -0
- package/dist/b2b/SeCheckStockAndPricing/stockCsv.js.map +1 -0
- package/dist/b2b/SeCheckStockAndPricing/useCheckStockAndPricing.d.ts +54 -0
- package/dist/b2b/SeCheckStockAndPricing/useCheckStockAndPricing.d.ts.map +1 -0
- package/dist/b2b/SeCheckStockAndPricing/useCheckStockAndPricing.js +209 -0
- package/dist/b2b/SeCheckStockAndPricing/useCheckStockAndPricing.js.map +1 -0
- package/dist/b2b/SeCustomCrossSellingShelf/index.d.ts +2 -0
- package/dist/b2b/SeCustomCrossSellingShelf/index.d.ts.map +1 -0
- package/dist/b2b/SeCustomCrossSellingShelf/index.js +18 -0
- package/dist/b2b/SeCustomCrossSellingShelf/index.js.map +1 -0
- package/dist/b2b/SeCustomCrossSellingShelf/useCrossSellingShelfOverride.d.ts +19 -0
- package/dist/b2b/SeCustomCrossSellingShelf/useCrossSellingShelfOverride.d.ts.map +1 -0
- package/dist/b2b/SeCustomCrossSellingShelf/useCrossSellingShelfOverride.js +21 -0
- package/dist/b2b/SeCustomCrossSellingShelf/useCrossSellingShelfOverride.js.map +1 -0
- package/dist/b2b/SeCustomProductCard/index.d.ts +3 -0
- package/dist/b2b/SeCustomProductCard/index.d.ts.map +1 -0
- package/dist/b2b/SeCustomProductCard/index.js +19 -0
- package/dist/b2b/SeCustomProductCard/index.js.map +1 -0
- package/dist/b2b/SeCustomProductCard/types.d.ts +30 -0
- package/dist/b2b/SeCustomProductCard/types.d.ts.map +1 -0
- package/dist/b2b/SeCustomProductCard/types.js +3 -0
- package/dist/b2b/SeCustomProductCard/types.js.map +1 -0
- package/dist/b2b/SeCustomProductCard/useB2bProductCard.d.ts +21 -0
- package/dist/b2b/SeCustomProductCard/useB2bProductCard.d.ts.map +1 -0
- package/dist/b2b/SeCustomProductCard/useB2bProductCard.js +33 -0
- package/dist/b2b/SeCustomProductCard/useB2bProductCard.js.map +1 -0
- package/dist/b2b/SeCustomShelfProduct/index.d.ts +3 -0
- package/dist/b2b/SeCustomShelfProduct/index.d.ts.map +1 -0
- package/dist/b2b/SeCustomShelfProduct/index.js +19 -0
- package/dist/b2b/SeCustomShelfProduct/index.js.map +1 -0
- package/dist/b2b/SeCustomShelfProduct/types.d.ts +6 -0
- package/dist/b2b/SeCustomShelfProduct/types.d.ts.map +1 -0
- package/dist/b2b/SeCustomShelfProduct/types.js +3 -0
- package/dist/b2b/SeCustomShelfProduct/types.js.map +1 -0
- package/dist/b2b/SeCustomShelfProduct/useB2bShelfProducts.d.ts +15 -0
- package/dist/b2b/SeCustomShelfProduct/useB2bShelfProducts.d.ts.map +1 -0
- package/dist/b2b/SeCustomShelfProduct/useB2bShelfProducts.js +19 -0
- package/dist/b2b/SeCustomShelfProduct/useB2bShelfProducts.js.map +1 -0
- package/dist/b2b/SeDashboards/index.d.ts +2 -0
- package/dist/b2b/SeDashboards/index.d.ts.map +1 -0
- package/dist/b2b/SeDashboards/index.js +18 -0
- package/dist/b2b/SeDashboards/index.js.map +1 -0
- package/dist/b2b/SeDashboards/useDashboards.d.ts +51 -0
- package/dist/b2b/SeDashboards/useDashboards.d.ts.map +1 -0
- package/dist/b2b/SeDashboards/useDashboards.js +172 -0
- package/dist/b2b/SeDashboards/useDashboards.js.map +1 -0
- package/dist/b2b/SeFooterB2B/index.d.ts +3 -0
- package/dist/b2b/SeFooterB2B/index.d.ts.map +1 -0
- package/dist/b2b/SeFooterB2B/index.js +19 -0
- package/dist/b2b/SeFooterB2B/index.js.map +1 -0
- package/dist/b2b/SeFooterB2B/types.d.ts +39 -0
- package/dist/b2b/SeFooterB2B/types.d.ts.map +1 -0
- package/dist/b2b/SeFooterB2B/types.js +3 -0
- package/dist/b2b/SeFooterB2B/types.js.map +1 -0
- package/dist/b2b/SeFooterB2B/useNewsletterSubscription.d.ts +16 -0
- package/dist/b2b/SeFooterB2B/useNewsletterSubscription.d.ts.map +1 -0
- package/dist/b2b/SeFooterB2B/useNewsletterSubscription.js +34 -0
- package/dist/b2b/SeFooterB2B/useNewsletterSubscription.js.map +1 -0
- package/dist/b2b/SeProductGalleryB2B/index.d.ts +2 -0
- package/dist/b2b/SeProductGalleryB2B/index.d.ts.map +1 -0
- package/dist/b2b/SeProductGalleryB2B/index.js +18 -0
- package/dist/b2b/SeProductGalleryB2B/index.js.map +1 -0
- package/dist/b2b/SeProductGalleryB2B/useProductGalleryB2B.d.ts +123 -0
- package/dist/b2b/SeProductGalleryB2B/useProductGalleryB2B.d.ts.map +1 -0
- package/dist/b2b/SeProductGalleryB2B/useProductGalleryB2B.js +159 -0
- package/dist/b2b/SeProductGalleryB2B/useProductGalleryB2B.js.map +1 -0
- package/dist/b2b/SePurchaseLists/index.d.ts +3 -0
- package/dist/b2b/SePurchaseLists/index.d.ts.map +1 -0
- package/dist/b2b/SePurchaseLists/index.js +19 -0
- package/dist/b2b/SePurchaseLists/index.js.map +1 -0
- package/dist/b2b/SePurchaseLists/purchaseListsUtils.d.ts +103 -0
- package/dist/b2b/SePurchaseLists/purchaseListsUtils.d.ts.map +1 -0
- package/dist/b2b/SePurchaseLists/purchaseListsUtils.js +69 -0
- package/dist/b2b/SePurchaseLists/purchaseListsUtils.js.map +1 -0
- package/dist/b2b/SePurchaseLists/usePurchaseLists.d.ts +57 -0
- package/dist/b2b/SePurchaseLists/usePurchaseLists.d.ts.map +1 -0
- package/dist/b2b/SePurchaseLists/usePurchaseLists.js +292 -0
- package/dist/b2b/SePurchaseLists/usePurchaseLists.js.map +1 -0
- package/dist/b2b/SeRecentOrdersSpendOverview/index.d.ts +3 -0
- package/dist/b2b/SeRecentOrdersSpendOverview/index.d.ts.map +1 -0
- package/dist/b2b/SeRecentOrdersSpendOverview/index.js +19 -0
- package/dist/b2b/SeRecentOrdersSpendOverview/index.js.map +1 -0
- package/dist/b2b/SeRecentOrdersSpendOverview/recentOrdersSpendOverviewUtils.d.ts +58 -0
- package/dist/b2b/SeRecentOrdersSpendOverview/recentOrdersSpendOverviewUtils.d.ts.map +1 -0
- package/dist/b2b/SeRecentOrdersSpendOverview/recentOrdersSpendOverviewUtils.js +133 -0
- package/dist/b2b/SeRecentOrdersSpendOverview/recentOrdersSpendOverviewUtils.js.map +1 -0
- package/dist/b2b/SeRecentOrdersSpendOverview/useRecentOrdersSpendOverview.d.ts +21 -0
- package/dist/b2b/SeRecentOrdersSpendOverview/useRecentOrdersSpendOverview.d.ts.map +1 -0
- package/dist/b2b/SeRecentOrdersSpendOverview/useRecentOrdersSpendOverview.js +134 -0
- package/dist/b2b/SeRecentOrdersSpendOverview/useRecentOrdersSpendOverview.js.map +1 -0
- package/dist/b2b/SeRequestToBuy/index.d.ts +2 -0
- package/dist/b2b/SeRequestToBuy/index.d.ts.map +1 -0
- package/dist/b2b/SeRequestToBuy/index.js +18 -0
- package/dist/b2b/SeRequestToBuy/index.js.map +1 -0
- package/dist/b2b/SeRequestToBuy/useRequestToBuyForm.d.ts +23 -0
- package/dist/b2b/SeRequestToBuy/useRequestToBuyForm.d.ts.map +1 -0
- package/dist/b2b/SeRequestToBuy/useRequestToBuyForm.js +64 -0
- package/dist/b2b/SeRequestToBuy/useRequestToBuyForm.js.map +1 -0
- package/dist/b2b/SeWelcomeBackMessage/index.d.ts +2 -0
- package/dist/b2b/SeWelcomeBackMessage/index.d.ts.map +1 -0
- package/dist/b2b/SeWelcomeBackMessage/index.js +18 -0
- package/dist/b2b/SeWelcomeBackMessage/index.js.map +1 -0
- package/dist/b2b/SeWelcomeBackMessage/useB2bSession.d.ts +11 -0
- package/dist/b2b/SeWelcomeBackMessage/useB2bSession.d.ts.map +1 -0
- package/dist/b2b/SeWelcomeBackMessage/useB2bSession.js +15 -0
- package/dist/b2b/SeWelcomeBackMessage/useB2bSession.js.map +1 -0
- package/dist/b2b/index.d.ts +15 -0
- package/dist/b2b/index.d.ts.map +1 -0
- package/dist/b2b/index.js +31 -0
- package/dist/b2b/index.js.map +1 -0
- package/dist/b2c/SeAssemblySet/assemblySetUtils.d.ts +41 -0
- package/dist/b2c/SeAssemblySet/assemblySetUtils.d.ts.map +1 -0
- package/dist/b2c/SeAssemblySet/assemblySetUtils.js +57 -0
- package/dist/b2c/SeAssemblySet/assemblySetUtils.js.map +1 -0
- package/dist/b2c/SeAssemblySet/index.d.ts +4 -0
- package/dist/b2c/SeAssemblySet/index.d.ts.map +1 -0
- package/dist/b2c/SeAssemblySet/index.js +20 -0
- package/dist/b2c/SeAssemblySet/index.js.map +1 -0
- package/dist/b2c/SeAssemblySet/types.d.ts +52 -0
- package/dist/b2c/SeAssemblySet/types.d.ts.map +1 -0
- package/dist/b2c/SeAssemblySet/types.js +3 -0
- package/dist/b2c/SeAssemblySet/types.js.map +1 -0
- package/dist/b2c/SeAssemblySet/useAssemblySet.d.ts +38 -0
- package/dist/b2c/SeAssemblySet/useAssemblySet.d.ts.map +1 -0
- package/dist/b2c/SeAssemblySet/useAssemblySet.js +134 -0
- package/dist/b2c/SeAssemblySet/useAssemblySet.js.map +1 -0
- package/dist/b2c/SeBanner/buildResponsiveImage.d.ts +18 -0
- package/dist/b2c/SeBanner/buildResponsiveImage.d.ts.map +1 -0
- package/dist/b2c/SeBanner/buildResponsiveImage.js +32 -0
- package/dist/b2c/SeBanner/buildResponsiveImage.js.map +1 -0
- package/dist/b2c/SeBanner/getImageUrl.d.ts +3 -0
- package/dist/b2c/SeBanner/getImageUrl.d.ts.map +1 -0
- package/dist/b2c/SeBanner/getImageUrl.js +7 -0
- package/dist/b2c/SeBanner/getImageUrl.js.map +1 -0
- package/dist/b2c/SeBanner/index.d.ts +8 -0
- package/dist/b2c/SeBanner/index.d.ts.map +1 -0
- package/dist/b2c/SeBanner/index.js +24 -0
- package/dist/b2c/SeBanner/index.js.map +1 -0
- package/dist/b2c/SeBanner/types.d.ts +34 -0
- package/dist/b2c/SeBanner/types.d.ts.map +1 -0
- package/dist/b2c/SeBanner/types.js +27 -0
- package/dist/b2c/SeBanner/types.js.map +1 -0
- package/dist/b2c/SeBanner/useBannerContext.d.ts +4 -0
- package/dist/b2c/SeBanner/useBannerContext.d.ts.map +1 -0
- package/dist/b2c/SeBanner/useBannerContext.js +14 -0
- package/dist/b2c/SeBanner/useBannerContext.js.map +1 -0
- package/dist/b2c/SeBanner/useBannerStyles.d.ts +21 -0
- package/dist/b2c/SeBanner/useBannerStyles.d.ts.map +1 -0
- package/dist/b2c/SeBanner/useBannerStyles.js +87 -0
- package/dist/b2c/SeBanner/useBannerStyles.js.map +1 -0
- package/dist/b2c/SeBanner/useIsMobile.d.ts +4 -0
- package/dist/b2c/SeBanner/useIsMobile.d.ts.map +1 -0
- package/dist/b2c/SeBanner/useIsMobile.js +23 -0
- package/dist/b2c/SeBanner/useIsMobile.js.map +1 -0
- package/dist/b2c/SeBanner/useSanitizedHtml.d.ts +13 -0
- package/dist/b2c/SeBanner/useSanitizedHtml.d.ts.map +1 -0
- package/dist/b2c/SeBanner/useSanitizedHtml.js +45 -0
- package/dist/b2c/SeBanner/useSanitizedHtml.js.map +1 -0
- package/dist/b2c/SeBannerCarousel/index.d.ts +5 -0
- package/dist/b2c/SeBannerCarousel/index.d.ts.map +1 -0
- package/dist/b2c/SeBannerCarousel/index.js +21 -0
- package/dist/b2c/SeBannerCarousel/index.js.map +1 -0
- package/dist/b2c/SeBannerCarousel/types.d.ts +17 -0
- package/dist/b2c/SeBannerCarousel/types.d.ts.map +1 -0
- package/dist/b2c/SeBannerCarousel/types.js +3 -0
- package/dist/b2c/SeBannerCarousel/types.js.map +1 -0
- package/dist/b2c/SeBannerCarousel/useCarousel.d.ts +30 -0
- package/dist/b2c/SeBannerCarousel/useCarousel.d.ts.map +1 -0
- package/dist/b2c/SeBannerCarousel/useCarousel.js +53 -0
- package/dist/b2c/SeBannerCarousel/useCarousel.js.map +1 -0
- package/dist/b2c/SeBannerCarousel/useCarouselContext.d.ts +4 -0
- package/dist/b2c/SeBannerCarousel/useCarouselContext.d.ts.map +1 -0
- package/dist/b2c/SeBannerCarousel/useCarouselContext.js +14 -0
- package/dist/b2c/SeBannerCarousel/useCarouselContext.js.map +1 -0
- package/dist/b2c/SeBannerCarousel/useSwipeNavigation.d.ts +19 -0
- package/dist/b2c/SeBannerCarousel/useSwipeNavigation.d.ts.map +1 -0
- package/dist/b2c/SeBannerCarousel/useSwipeNavigation.js +37 -0
- package/dist/b2c/SeBannerCarousel/useSwipeNavigation.js.map +1 -0
- package/dist/b2c/SeCardsCarousel/index.d.ts +3 -0
- package/dist/b2c/SeCardsCarousel/index.d.ts.map +1 -0
- package/dist/b2c/SeCardsCarousel/index.js +19 -0
- package/dist/b2c/SeCardsCarousel/index.js.map +1 -0
- package/dist/b2c/SeCardsCarousel/types.d.ts +8 -0
- package/dist/b2c/SeCardsCarousel/types.d.ts.map +1 -0
- package/dist/b2c/SeCardsCarousel/types.js +3 -0
- package/dist/b2c/SeCardsCarousel/types.js.map +1 -0
- package/dist/b2c/SeCardsCarousel/useCardsCarouselLayout.d.ts +10 -0
- package/dist/b2c/SeCardsCarousel/useCardsCarouselLayout.d.ts.map +1 -0
- package/dist/b2c/SeCardsCarousel/useCardsCarouselLayout.js +13 -0
- package/dist/b2c/SeCardsCarousel/useCardsCarouselLayout.js.map +1 -0
- package/dist/b2c/SeEditorialSplit/index.d.ts +2 -0
- package/dist/b2c/SeEditorialSplit/index.d.ts.map +1 -0
- package/dist/b2c/SeEditorialSplit/index.js +18 -0
- package/dist/b2c/SeEditorialSplit/index.js.map +1 -0
- package/dist/b2c/SeEditorialSplit/types.d.ts +13 -0
- package/dist/b2c/SeEditorialSplit/types.d.ts.map +1 -0
- package/dist/b2c/SeEditorialSplit/types.js +3 -0
- package/dist/b2c/SeEditorialSplit/types.js.map +1 -0
- package/dist/b2c/SeFooter/index.d.ts +3 -0
- package/dist/b2c/SeFooter/index.d.ts.map +1 -0
- package/dist/b2c/SeFooter/index.js +19 -0
- package/dist/b2c/SeFooter/index.js.map +1 -0
- package/dist/b2c/SeFooter/types.d.ts +52 -0
- package/dist/b2c/SeFooter/types.d.ts.map +1 -0
- package/dist/b2c/SeFooter/types.js +3 -0
- package/dist/b2c/SeFooter/types.js.map +1 -0
- package/dist/b2c/SeFooter/utils.d.ts +6 -0
- package/dist/b2c/SeFooter/utils.d.ts.map +1 -0
- package/dist/b2c/SeFooter/utils.js +11 -0
- package/dist/b2c/SeFooter/utils.js.map +1 -0
- package/dist/b2c/SeGridContent/index.d.ts +2 -0
- package/dist/b2c/SeGridContent/index.d.ts.map +1 -0
- package/dist/b2c/SeGridContent/index.js +18 -0
- package/dist/b2c/SeGridContent/index.js.map +1 -0
- package/dist/b2c/SeGridContent/types.d.ts +20 -0
- package/dist/b2c/SeGridContent/types.d.ts.map +1 -0
- package/dist/b2c/SeGridContent/types.js +3 -0
- package/dist/b2c/SeGridContent/types.js.map +1 -0
- package/dist/b2c/SeHeader/index.d.ts +2 -0
- package/dist/b2c/SeHeader/index.d.ts.map +1 -0
- package/dist/b2c/SeHeader/index.js +18 -0
- package/dist/b2c/SeHeader/index.js.map +1 -0
- package/dist/b2c/SeHeader/types.d.ts +35 -0
- package/dist/b2c/SeHeader/types.d.ts.map +1 -0
- package/dist/b2c/SeHeader/types.js +3 -0
- package/dist/b2c/SeHeader/types.js.map +1 -0
- package/dist/b2c/SeHeroSection/index.d.ts +2 -0
- package/dist/b2c/SeHeroSection/index.d.ts.map +1 -0
- package/dist/b2c/SeHeroSection/index.js +18 -0
- package/dist/b2c/SeHeroSection/index.js.map +1 -0
- package/dist/b2c/SeHeroSection/types.d.ts +10 -0
- package/dist/b2c/SeHeroSection/types.d.ts.map +1 -0
- package/dist/b2c/SeHeroSection/types.js +3 -0
- package/dist/b2c/SeHeroSection/types.js.map +1 -0
- package/dist/b2c/SeImageTiles/index.d.ts +2 -0
- package/dist/b2c/SeImageTiles/index.d.ts.map +1 -0
- package/dist/b2c/SeImageTiles/index.js +18 -0
- package/dist/b2c/SeImageTiles/index.js.map +1 -0
- package/dist/b2c/SeImageTiles/types.d.ts +13 -0
- package/dist/b2c/SeImageTiles/types.d.ts.map +1 -0
- package/dist/b2c/SeImageTiles/types.js +3 -0
- package/dist/b2c/SeImageTiles/types.js.map +1 -0
- package/dist/b2c/SeLearnMoreSection/index.d.ts +2 -0
- package/dist/b2c/SeLearnMoreSection/index.d.ts.map +1 -0
- package/dist/b2c/SeLearnMoreSection/index.js +18 -0
- package/dist/b2c/SeLearnMoreSection/index.js.map +1 -0
- package/dist/b2c/SeLearnMoreSection/types.d.ts +10 -0
- package/dist/b2c/SeLearnMoreSection/types.d.ts.map +1 -0
- package/dist/b2c/SeLearnMoreSection/types.js +3 -0
- package/dist/b2c/SeLearnMoreSection/types.js.map +1 -0
- package/dist/b2c/SeMegaMenu/index.d.ts +6 -0
- package/dist/b2c/SeMegaMenu/index.d.ts.map +1 -0
- package/dist/b2c/SeMegaMenu/index.js +22 -0
- package/dist/b2c/SeMegaMenu/index.js.map +1 -0
- package/dist/b2c/SeMegaMenu/types.d.ts +27 -0
- package/dist/b2c/SeMegaMenu/types.d.ts.map +1 -0
- package/dist/b2c/SeMegaMenu/types.js +3 -0
- package/dist/b2c/SeMegaMenu/types.js.map +1 -0
- package/dist/b2c/SeMegaMenu/useCloseMenuOnEscape.d.ts +6 -0
- package/dist/b2c/SeMegaMenu/useCloseMenuOnEscape.d.ts.map +1 -0
- package/dist/b2c/SeMegaMenu/useCloseMenuOnEscape.js +21 -0
- package/dist/b2c/SeMegaMenu/useCloseMenuOnEscape.js.map +1 -0
- package/dist/b2c/SeMegaMenu/useMegaMenuHoverState.d.ts +15 -0
- package/dist/b2c/SeMegaMenu/useMegaMenuHoverState.d.ts.map +1 -0
- package/dist/b2c/SeMegaMenu/useMegaMenuHoverState.js +21 -0
- package/dist/b2c/SeMegaMenu/useMegaMenuHoverState.js.map +1 -0
- package/dist/b2c/SeMegaMenu/useMegaMenuMobileNavigation.d.ts +29 -0
- package/dist/b2c/SeMegaMenu/useMegaMenuMobileNavigation.d.ts.map +1 -0
- package/dist/b2c/SeMegaMenu/useMegaMenuMobileNavigation.js +71 -0
- package/dist/b2c/SeMegaMenu/useMegaMenuMobileNavigation.js.map +1 -0
- package/dist/b2c/SeMegaMenu/useNavbarHamburgerTrigger.d.ts +12 -0
- package/dist/b2c/SeMegaMenu/useNavbarHamburgerTrigger.d.ts.map +1 -0
- package/dist/b2c/SeMegaMenu/useNavbarHamburgerTrigger.js +29 -0
- package/dist/b2c/SeMegaMenu/useNavbarHamburgerTrigger.js.map +1 -0
- package/dist/b2c/SeProductCardWithButton/index.d.ts +3 -0
- package/dist/b2c/SeProductCardWithButton/index.d.ts.map +1 -0
- package/dist/b2c/SeProductCardWithButton/index.js +19 -0
- package/dist/b2c/SeProductCardWithButton/index.js.map +1 -0
- package/dist/b2c/SeProductCardWithButton/types.d.ts +20 -0
- package/dist/b2c/SeProductCardWithButton/types.d.ts.map +1 -0
- package/dist/b2c/SeProductCardWithButton/types.js +3 -0
- package/dist/b2c/SeProductCardWithButton/types.js.map +1 -0
- package/dist/b2c/SeProductCardWithButton/useFormattedPrice.d.ts +13 -0
- package/dist/b2c/SeProductCardWithButton/useFormattedPrice.d.ts.map +1 -0
- package/dist/b2c/SeProductCardWithButton/useFormattedPrice.js +25 -0
- package/dist/b2c/SeProductCardWithButton/useFormattedPrice.js.map +1 -0
- package/dist/b2c/SeProductImageGrid/index.d.ts +2 -0
- package/dist/b2c/SeProductImageGrid/index.d.ts.map +1 -0
- package/dist/b2c/SeProductImageGrid/index.js +18 -0
- package/dist/b2c/SeProductImageGrid/index.js.map +1 -0
- package/dist/b2c/SeProductImageGrid/types.d.ts +15 -0
- package/dist/b2c/SeProductImageGrid/types.d.ts.map +1 -0
- package/dist/b2c/SeProductImageGrid/types.js +3 -0
- package/dist/b2c/SeProductImageGrid/types.js.map +1 -0
- package/dist/b2c/SeProductListing/index.d.ts +3 -0
- package/dist/b2c/SeProductListing/index.d.ts.map +1 -0
- package/dist/b2c/SeProductListing/index.js +19 -0
- package/dist/b2c/SeProductListing/index.js.map +1 -0
- package/dist/b2c/SeProductListing/types.d.ts +40 -0
- package/dist/b2c/SeProductListing/types.d.ts.map +1 -0
- package/dist/b2c/SeProductListing/types.js +3 -0
- package/dist/b2c/SeProductListing/types.js.map +1 -0
- package/dist/b2c/SeProductListing/useSeProductListing.d.ts +8 -0
- package/dist/b2c/SeProductListing/useSeProductListing.d.ts.map +1 -0
- package/dist/b2c/SeProductListing/useSeProductListing.js +27 -0
- package/dist/b2c/SeProductListing/useSeProductListing.js.map +1 -0
- package/dist/b2c/SeProductReviews/index.d.ts +3 -0
- package/dist/b2c/SeProductReviews/index.d.ts.map +1 -0
- package/dist/b2c/SeProductReviews/index.js +19 -0
- package/dist/b2c/SeProductReviews/index.js.map +1 -0
- package/dist/b2c/SeProductReviews/types.d.ts +30 -0
- package/dist/b2c/SeProductReviews/types.d.ts.map +1 -0
- package/dist/b2c/SeProductReviews/types.js +3 -0
- package/dist/b2c/SeProductReviews/types.js.map +1 -0
- package/dist/b2c/SeProductReviews/useSeProductReviews.d.ts +9 -0
- package/dist/b2c/SeProductReviews/useSeProductReviews.d.ts.map +1 -0
- package/dist/b2c/SeProductReviews/useSeProductReviews.js +34 -0
- package/dist/b2c/SeProductReviews/useSeProductReviews.js.map +1 -0
- package/dist/b2c/SeValuePropCards/index.d.ts +3 -0
- package/dist/b2c/SeValuePropCards/index.d.ts.map +1 -0
- package/dist/b2c/SeValuePropCards/index.js +19 -0
- package/dist/b2c/SeValuePropCards/index.js.map +1 -0
- package/dist/b2c/SeValuePropCards/types.d.ts +26 -0
- package/dist/b2c/SeValuePropCards/types.d.ts.map +1 -0
- package/dist/b2c/SeValuePropCards/types.js +3 -0
- package/dist/b2c/SeValuePropCards/types.js.map +1 -0
- package/dist/b2c/SeValuePropCards/useSeValuePropCardsFilter.d.ts +8 -0
- package/dist/b2c/SeValuePropCards/useSeValuePropCardsFilter.d.ts.map +1 -0
- package/dist/b2c/SeValuePropCards/useSeValuePropCardsFilter.js +36 -0
- package/dist/b2c/SeValuePropCards/useSeValuePropCardsFilter.js.map +1 -0
- package/dist/b2c/SeVideoHero/index.d.ts +4 -0
- package/dist/b2c/SeVideoHero/index.d.ts.map +1 -0
- package/dist/b2c/SeVideoHero/index.js +20 -0
- package/dist/b2c/SeVideoHero/index.js.map +1 -0
- package/dist/b2c/SeVideoHero/types.d.ts +19 -0
- package/dist/b2c/SeVideoHero/types.d.ts.map +1 -0
- package/dist/b2c/SeVideoHero/types.js +3 -0
- package/dist/b2c/SeVideoHero/types.js.map +1 -0
- package/dist/b2c/SeVideoHero/useSeVideoHeroPlayback.d.ts +40 -0
- package/dist/b2c/SeVideoHero/useSeVideoHeroPlayback.d.ts.map +1 -0
- package/dist/b2c/SeVideoHero/useSeVideoHeroPlayback.js +135 -0
- package/dist/b2c/SeVideoHero/useSeVideoHeroPlayback.js.map +1 -0
- package/dist/b2c/SeVideoHero/videoSource.d.ts +25 -0
- package/dist/b2c/SeVideoHero/videoSource.d.ts.map +1 -0
- package/dist/b2c/SeVideoHero/videoSource.js +78 -0
- package/dist/b2c/SeVideoHero/videoSource.js.map +1 -0
- package/dist/b2c/index.d.ts +19 -0
- package/dist/b2c/index.d.ts.map +1 -0
- package/dist/b2c/index.js +35 -0
- package/dist/b2c/index.js.map +1 -0
- package/dist/b2c/shared/filterItemsWithImage.d.ts +8 -0
- package/dist/b2c/shared/filterItemsWithImage.d.ts.map +1 -0
- package/dist/b2c/shared/filterItemsWithImage.js +11 -0
- package/dist/b2c/shared/filterItemsWithImage.js.map +1 -0
- package/dist/b2c/shared/index.d.ts +2 -0
- package/dist/b2c/shared/index.d.ts.map +1 -0
- package/dist/b2c/shared/index.js +18 -0
- package/dist/b2c/shared/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/package.json +82 -3
- package/src/b2b/SeActionHubBulletinBoard/index.ts +1 -0
- package/src/b2b/SeActionHubBulletinBoard/types.ts +27 -0
- package/src/b2b/SeAddToPurchaseList/addToPurchaseListUtils.ts +40 -0
- package/src/b2b/SeAddToPurchaseList/index.ts +2 -0
- package/src/b2b/SeAddToPurchaseList/useAddToPurchaseList.ts +130 -0
- package/src/b2b/SeAddressSelector/index.ts +1 -0
- package/src/b2b/SeAddressSelector/useAddressSelector.ts +157 -0
- package/src/b2b/SeCategoryBanners/index.ts +1 -0
- package/src/b2b/SeCategoryBanners/types.ts +8 -0
- package/src/b2b/SeCheckStockAndPricing/checkStockAndPricingUtils.ts +126 -0
- package/src/b2b/SeCheckStockAndPricing/index.ts +3 -0
- package/src/b2b/SeCheckStockAndPricing/stockCsv.ts +77 -0
- package/src/b2b/SeCheckStockAndPricing/useCheckStockAndPricing.ts +272 -0
- package/src/b2b/SeCustomCrossSellingShelf/index.ts +1 -0
- package/src/b2b/SeCustomCrossSellingShelf/useCrossSellingShelfOverride.ts +25 -0
- package/src/b2b/SeCustomProductCard/index.ts +2 -0
- package/src/b2b/SeCustomProductCard/types.ts +16 -0
- package/src/b2b/SeCustomProductCard/useB2bProductCard.ts +53 -0
- package/src/b2b/SeCustomShelfProduct/index.ts +2 -0
- package/src/b2b/SeCustomShelfProduct/types.ts +14 -0
- package/src/b2b/SeCustomShelfProduct/useB2bShelfProducts.ts +31 -0
- package/src/b2b/SeDashboards/index.ts +1 -0
- package/src/b2b/SeDashboards/useDashboards.ts +211 -0
- package/src/b2b/SeFooterB2B/index.ts +2 -0
- package/src/b2b/SeFooterB2B/types.ts +42 -0
- package/src/b2b/SeFooterB2B/useNewsletterSubscription.ts +41 -0
- package/src/b2b/SeProductGalleryB2B/index.ts +1 -0
- package/src/b2b/SeProductGalleryB2B/useProductGalleryB2B.ts +217 -0
- package/src/b2b/SePurchaseLists/index.ts +2 -0
- package/src/b2b/SePurchaseLists/purchaseListsUtils.ts +106 -0
- package/src/b2b/SePurchaseLists/usePurchaseLists.ts +401 -0
- package/src/b2b/SeRecentOrdersSpendOverview/index.ts +2 -0
- package/src/b2b/SeRecentOrdersSpendOverview/recentOrdersSpendOverviewUtils.ts +162 -0
- package/src/b2b/SeRecentOrdersSpendOverview/useRecentOrdersSpendOverview.ts +159 -0
- package/src/b2b/SeRequestToBuy/index.ts +1 -0
- package/src/b2b/SeRequestToBuy/useRequestToBuyForm.ts +96 -0
- package/src/b2b/SeWelcomeBackMessage/index.ts +1 -0
- package/src/b2b/SeWelcomeBackMessage/useB2bSession.ts +16 -0
- package/src/b2b/index.ts +14 -0
- package/src/b2c/SeAssemblySet/assemblySetUtils.ts +67 -0
- package/src/b2c/SeAssemblySet/index.ts +3 -0
- package/src/b2c/SeAssemblySet/types.ts +51 -0
- package/src/b2c/SeAssemblySet/useAssemblySet.ts +198 -0
- package/src/b2c/SeBanner/buildResponsiveImage.ts +44 -0
- package/src/b2c/SeBanner/getImageUrl.ts +9 -0
- package/src/b2c/SeBanner/index.ts +7 -0
- package/src/b2c/SeBanner/types.ts +40 -0
- package/src/b2c/SeBanner/useBannerContext.ts +12 -0
- package/src/b2c/SeBanner/useBannerStyles.ts +120 -0
- package/src/b2c/SeBanner/useIsMobile.ts +24 -0
- package/src/b2c/SeBanner/useSanitizedHtml.ts +49 -0
- package/src/b2c/SeBannerCarousel/index.ts +4 -0
- package/src/b2c/SeBannerCarousel/types.ts +17 -0
- package/src/b2c/SeBannerCarousel/useCarousel.ts +83 -0
- package/src/b2c/SeBannerCarousel/useCarouselContext.ts +12 -0
- package/src/b2c/SeBannerCarousel/useSwipeNavigation.ts +54 -0
- package/src/b2c/SeCardsCarousel/index.ts +2 -0
- package/src/b2c/SeCardsCarousel/types.ts +7 -0
- package/src/b2c/SeCardsCarousel/useCardsCarouselLayout.ts +9 -0
- package/src/b2c/SeEditorialSplit/index.ts +1 -0
- package/src/b2c/SeEditorialSplit/types.ts +15 -0
- package/src/b2c/SeFooter/index.ts +2 -0
- package/src/b2c/SeFooter/types.ts +54 -0
- package/src/b2c/SeFooter/utils.ts +10 -0
- package/src/b2c/SeGridContent/index.ts +1 -0
- package/src/b2c/SeGridContent/types.ts +22 -0
- package/src/b2c/SeHeader/index.ts +1 -0
- package/src/b2c/SeHeader/types.ts +40 -0
- package/src/b2c/SeHeroSection/index.ts +1 -0
- package/src/b2c/SeHeroSection/types.ts +10 -0
- package/src/b2c/SeImageTiles/index.ts +1 -0
- package/src/b2c/SeImageTiles/types.ts +15 -0
- package/src/b2c/SeLearnMoreSection/index.ts +1 -0
- package/src/b2c/SeLearnMoreSection/types.ts +10 -0
- package/src/b2c/SeMegaMenu/index.ts +5 -0
- package/src/b2c/SeMegaMenu/types.ts +31 -0
- package/src/b2c/SeMegaMenu/useCloseMenuOnEscape.ts +18 -0
- package/src/b2c/SeMegaMenu/useMegaMenuHoverState.ts +29 -0
- package/src/b2c/SeMegaMenu/useMegaMenuMobileNavigation.ts +96 -0
- package/src/b2c/SeMegaMenu/useNavbarHamburgerTrigger.ts +29 -0
- package/src/b2c/SeProductCardWithButton/index.ts +2 -0
- package/src/b2c/SeProductCardWithButton/types.ts +21 -0
- package/src/b2c/SeProductCardWithButton/useFormattedPrice.ts +31 -0
- package/src/b2c/SeProductImageGrid/index.ts +1 -0
- package/src/b2c/SeProductImageGrid/types.ts +15 -0
- package/src/b2c/SeProductListing/index.ts +2 -0
- package/src/b2c/SeProductListing/types.ts +44 -0
- package/src/b2c/SeProductListing/useSeProductListing.ts +26 -0
- package/src/b2c/SeProductReviews/index.ts +2 -0
- package/src/b2c/SeProductReviews/types.ts +34 -0
- package/src/b2c/SeProductReviews/useSeProductReviews.ts +52 -0
- package/src/b2c/SeValuePropCards/index.ts +2 -0
- package/src/b2c/SeValuePropCards/types.ts +27 -0
- package/src/b2c/SeValuePropCards/useSeValuePropCardsFilter.ts +44 -0
- package/src/b2c/SeVideoHero/index.ts +3 -0
- package/src/b2c/SeVideoHero/types.ts +22 -0
- package/src/b2c/SeVideoHero/useSeVideoHeroPlayback.ts +159 -0
- package/src/b2c/SeVideoHero/videoSource.ts +88 -0
- package/src/b2c/index.ts +18 -0
- package/src/b2c/shared/filterItemsWithImage.ts +9 -0
- package/src/b2c/shared/index.ts +1 -0
- package/src/global.d.ts +74 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
2
|
+
import { gql } from '@faststore/core/api'
|
|
3
|
+
import { useBuyButton_unstable, useLazyQuery_unstable, useSession_unstable } from '@faststore/core/experimental'
|
|
4
|
+
import { SE_SKU_AVAILABILITY_QUERY, SE_SKU_SEARCH_QUERY } from '@se-faststore/resolvers/b2b'
|
|
5
|
+
import {
|
|
6
|
+
findSkuByRefId,
|
|
7
|
+
formatStockMoney,
|
|
8
|
+
matchSkus,
|
|
9
|
+
stockStatus,
|
|
10
|
+
toCartItem,
|
|
11
|
+
type StockMoneyFormat,
|
|
12
|
+
type StockProduct,
|
|
13
|
+
type StockRow,
|
|
14
|
+
type StockSku,
|
|
15
|
+
} from './checkStockAndPricingUtils'
|
|
16
|
+
import { parseStockCsv, type StockCsvError } from './stockCsv'
|
|
17
|
+
|
|
18
|
+
const SKU_SEARCH_QUERY = gql(SE_SKU_SEARCH_QUERY)
|
|
19
|
+
const SKU_AVAILABILITY_QUERY = gql(SE_SKU_AVAILABILITY_QUERY)
|
|
20
|
+
|
|
21
|
+
const SEARCH_RESULTS = 10
|
|
22
|
+
const MIN_SEARCH_LENGTH = 3
|
|
23
|
+
const SEARCH_DEBOUNCE = 300
|
|
24
|
+
const IMPORT_CONCURRENCY = 4
|
|
25
|
+
|
|
26
|
+
type SearchResponse = { search?: { products?: { edges?: Array<{ node: StockProduct }> } } | null }
|
|
27
|
+
type AvailabilityResponse = {
|
|
28
|
+
seSkuAvailability?: Array<{ id: string; availability?: string | null; availableQuantity?: number | null }> | null
|
|
29
|
+
}
|
|
30
|
+
type AvailabilityVariables = { items: Array<{ id: string; seller: string }>; country: string; postalCode?: string | null }
|
|
31
|
+
|
|
32
|
+
type Session = {
|
|
33
|
+
person?: { id?: string } | null
|
|
34
|
+
country?: string
|
|
35
|
+
postalCode?: string | null
|
|
36
|
+
locale?: string
|
|
37
|
+
currency?: { code?: string }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type StockImportReport = {
|
|
41
|
+
found: Array<{ line: number; refId: string; quantity: number; product: StockProduct; sku: StockSku }>
|
|
42
|
+
errors: StockCsvError[]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The latest value behind a stable ref (FastStore's lazy `execute` changes every render). */
|
|
46
|
+
function useLatest<T>(value: T) {
|
|
47
|
+
const ref = useRef(value)
|
|
48
|
+
ref.current = value
|
|
49
|
+
return ref
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Runs `task` over `items` with at most `limit` in flight. */
|
|
53
|
+
async function mapWithConcurrency<T, R>(items: T[], limit: number, task: (item: T) => Promise<R>): Promise<R[]> {
|
|
54
|
+
const results: R[] = new Array(items.length)
|
|
55
|
+
let next = 0
|
|
56
|
+
const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
57
|
+
while (next < items.length) {
|
|
58
|
+
const index = next++
|
|
59
|
+
results[index] = await task(items[index] as T)
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
await Promise.all(workers)
|
|
63
|
+
return results
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The "check stock and pricing" worksheet: SKUs added by reference-code search or CSV import,
|
|
68
|
+
* each with its session price and live stock (cart simulation), quantities, totals, and one
|
|
69
|
+
* add-to-cart for all of it.
|
|
70
|
+
*
|
|
71
|
+
* Replaces the kit's queue of chained effects (one search and one simulation per row, in
|
|
72
|
+
* series) with plain async calls: an import searches a few reference codes at a time and
|
|
73
|
+
* simulates every new SKU in one request.
|
|
74
|
+
*/
|
|
75
|
+
export function useCheckStockAndPricing({ lowStockThreshold = 50 }: { lowStockThreshold?: number } = {}) {
|
|
76
|
+
const session = useSession_unstable() as Session
|
|
77
|
+
const money: StockMoneyFormat = { locale: session?.locale ?? 'en-US', currency: session?.currency?.code ?? 'USD' }
|
|
78
|
+
const [rows, setRows] = useState<StockRow[]>([])
|
|
79
|
+
|
|
80
|
+
const [searchExecute] = useLazyQuery_unstable<SearchResponse, { term: string; first: number }>(SKU_SEARCH_QUERY, {
|
|
81
|
+
term: '',
|
|
82
|
+
first: SEARCH_RESULTS,
|
|
83
|
+
})
|
|
84
|
+
const [availabilityExecute] = useLazyQuery_unstable<AvailabilityResponse, AvailabilityVariables>(
|
|
85
|
+
SKU_AVAILABILITY_QUERY,
|
|
86
|
+
{ items: [], country: '' },
|
|
87
|
+
)
|
|
88
|
+
const rowsRef = useLatest(rows)
|
|
89
|
+
const searchRef = useLatest(searchExecute)
|
|
90
|
+
const availabilityRef = useLatest(availabilityExecute)
|
|
91
|
+
const sessionRef = useLatest(session)
|
|
92
|
+
|
|
93
|
+
const searchProducts = useCallback(
|
|
94
|
+
async (term: string): Promise<StockProduct[]> => {
|
|
95
|
+
const result: SearchResponse | null | undefined = await searchRef.current({ term, first: SEARCH_RESULTS })
|
|
96
|
+
return result?.search?.products?.edges?.map((edge) => edge.node) ?? []
|
|
97
|
+
},
|
|
98
|
+
[searchRef],
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
/** Simulates every given SKU in one request and stores the result on its row. */
|
|
102
|
+
const checkAvailability = useCallback(
|
|
103
|
+
async (skus: StockSku[]) => {
|
|
104
|
+
const items = skus.filter((sku) => sku.sellerId).map((sku) => ({ id: sku.itemId, seller: sku.sellerId as string }))
|
|
105
|
+
const ids = new Set(skus.map((sku) => sku.itemId))
|
|
106
|
+
// Rows are added before their stock is known; once it is, cap the quantity to it (an
|
|
107
|
+
// out-of-stock SKU drops to 0 instead of silently counting toward the total).
|
|
108
|
+
const settle = (byId: Map<string, StockRow['availability']>) =>
|
|
109
|
+
setRows((current) =>
|
|
110
|
+
current.map((row) => {
|
|
111
|
+
if (!ids.has(row.sku.itemId)) return row
|
|
112
|
+
const availability = byId.get(row.sku.itemId) ?? null
|
|
113
|
+
const max = availability?.quantity ?? (availability?.status === 'Out of Stock' ? 0 : row.quantity)
|
|
114
|
+
return { ...row, availability, quantity: Math.min(row.quantity, max) }
|
|
115
|
+
}),
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
const { country, postalCode } = sessionRef.current
|
|
119
|
+
if (items.length === 0 || !country) {
|
|
120
|
+
settle(new Map())
|
|
121
|
+
return
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
const result: AvailabilityResponse | null | undefined = await availabilityRef.current({ items, country, postalCode })
|
|
126
|
+
settle(
|
|
127
|
+
new Map(
|
|
128
|
+
(result?.seSkuAvailability ?? []).map((entry) => [entry.id, stockStatus(entry, lowStockThreshold)] as const),
|
|
129
|
+
),
|
|
130
|
+
)
|
|
131
|
+
} catch {
|
|
132
|
+
settle(new Map())
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
[availabilityRef, sessionRef, lowStockThreshold],
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
/** Adds SKUs (or raises the quantity of ones already listed), then checks stock for the new ones. */
|
|
139
|
+
const addSkus = useCallback(
|
|
140
|
+
(entries: Array<{ product: StockProduct; sku: StockSku; quantity: number }>) => {
|
|
141
|
+
// Decided from the rows as last rendered, not inside the updater below: React may run an
|
|
142
|
+
// updater later (during the next render), so it can't be relied on to report what it added.
|
|
143
|
+
const listed = new Set(rowsRef.current.map((row) => row.sku.itemId))
|
|
144
|
+
const added = new Map<string, StockSku>()
|
|
145
|
+
for (const entry of entries) if (!listed.has(entry.sku.itemId)) added.set(entry.sku.itemId, entry.sku)
|
|
146
|
+
|
|
147
|
+
setRows((current) => {
|
|
148
|
+
const next = [...current]
|
|
149
|
+
for (const entry of entries) {
|
|
150
|
+
const existing = next.findIndex((row) => row.sku.itemId === entry.sku.itemId)
|
|
151
|
+
if (existing === -1) {
|
|
152
|
+
next.push({ product: entry.product, sku: entry.sku, quantity: entry.quantity })
|
|
153
|
+
} else {
|
|
154
|
+
const row = next[existing] as StockRow
|
|
155
|
+
next[existing] = { ...row, quantity: row.quantity + entry.quantity }
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return next
|
|
159
|
+
})
|
|
160
|
+
if (added.size > 0) void checkAvailability([...added.values()])
|
|
161
|
+
},
|
|
162
|
+
[checkAvailability, rowsRef],
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
const setQuantity = useCallback((itemId: string, quantity: number) => {
|
|
166
|
+
setRows((current) =>
|
|
167
|
+
current.map((row) => {
|
|
168
|
+
if (row.sku.itemId !== itemId) return row
|
|
169
|
+
const max = row.availability?.quantity ?? Number.POSITIVE_INFINITY
|
|
170
|
+
const clamped = Math.max(0, Math.min(Number.isFinite(quantity) ? Math.floor(quantity) : 0, max))
|
|
171
|
+
return { ...row, quantity: clamped }
|
|
172
|
+
}),
|
|
173
|
+
)
|
|
174
|
+
}, [])
|
|
175
|
+
|
|
176
|
+
const remove = useCallback((itemId: string) => {
|
|
177
|
+
setRows((current) => current.filter((row) => row.sku.itemId !== itemId))
|
|
178
|
+
}, [])
|
|
179
|
+
|
|
180
|
+
const clear = useCallback(() => setRows([]), [])
|
|
181
|
+
|
|
182
|
+
/** Resolves every CSV row to a SKU by exact reference code; nothing is added until `confirmImport`. */
|
|
183
|
+
const importCsv = useCallback(
|
|
184
|
+
async (text: string): Promise<StockImportReport> => {
|
|
185
|
+
const { rows: csvRows, errors } = parseStockCsv(text)
|
|
186
|
+
const lookups = await mapWithConcurrency(csvRows, IMPORT_CONCURRENCY, async (row) => {
|
|
187
|
+
try {
|
|
188
|
+
return { row, match: findSkuByRefId(await searchProducts(row.refId), row.refId) }
|
|
189
|
+
} catch {
|
|
190
|
+
return { row, match: undefined }
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
const report: StockImportReport = { found: [], errors: [...errors] }
|
|
195
|
+
for (const { row, match } of lookups) {
|
|
196
|
+
if (match) report.found.push({ ...row, ...match })
|
|
197
|
+
else report.errors.push({ line: row.line, refId: row.refId, message: 'SKU not found' })
|
|
198
|
+
}
|
|
199
|
+
report.errors.sort((a, b) => a.line - b.line)
|
|
200
|
+
return report
|
|
201
|
+
},
|
|
202
|
+
[searchProducts],
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
const confirmImport = useCallback(
|
|
206
|
+
(report: StockImportReport) => addSkus(report.found.map(({ product, sku, quantity }) => ({ product, sku, quantity }))),
|
|
207
|
+
[addSkus],
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
const purchasable = rows.filter((row) => row.quantity > 0 && typeof row.sku.price === 'number' && row.sku.sellerId)
|
|
211
|
+
const cartItems = useMemo(() => purchasable.map(toCartItem), [purchasable])
|
|
212
|
+
// `as never`: matches the store's generated CartItem shape, built field by field in toCartItem.
|
|
213
|
+
const buyButton = useBuyButton_unstable(cartItems as never)
|
|
214
|
+
const totalItems = purchasable.reduce((sum, row) => sum + row.quantity, 0)
|
|
215
|
+
const totalValue = purchasable.reduce((sum, row) => sum + row.quantity * (row.sku.price ?? 0), 0)
|
|
216
|
+
|
|
217
|
+
return {
|
|
218
|
+
isLoggedIn: Boolean(session?.person),
|
|
219
|
+
money,
|
|
220
|
+
rows,
|
|
221
|
+
searchProducts,
|
|
222
|
+
addSkus,
|
|
223
|
+
setQuantity,
|
|
224
|
+
remove,
|
|
225
|
+
clear,
|
|
226
|
+
importCsv,
|
|
227
|
+
confirmImport,
|
|
228
|
+
totalItems,
|
|
229
|
+
total: formatStockMoney(totalValue, money),
|
|
230
|
+
addAllToCart: (event: { preventDefault(): void }) => {
|
|
231
|
+
buyButton.onClick(event)
|
|
232
|
+
setRows([])
|
|
233
|
+
},
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** Debounced reference-code search for the worksheet's search box (three characters minimum). */
|
|
238
|
+
export function useStockSkuSearch(searchProducts: (term: string) => Promise<StockProduct[]>, term: string) {
|
|
239
|
+
const [results, setResults] = useState<Array<{ product: StockProduct; sku: StockSku }>>([])
|
|
240
|
+
const [searching, setSearching] = useState(false)
|
|
241
|
+
|
|
242
|
+
useEffect(() => {
|
|
243
|
+
const trimmed = term.trim()
|
|
244
|
+
if (trimmed.length < MIN_SEARCH_LENGTH) {
|
|
245
|
+
setResults([])
|
|
246
|
+
setSearching(false)
|
|
247
|
+
return
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
let cancelled = false
|
|
251
|
+
setSearching(true)
|
|
252
|
+
const timer = setTimeout(() => {
|
|
253
|
+
searchProducts(trimmed)
|
|
254
|
+
.then((products) => {
|
|
255
|
+
if (!cancelled) setResults(matchSkus(products, trimmed))
|
|
256
|
+
})
|
|
257
|
+
.catch(() => {
|
|
258
|
+
if (!cancelled) setResults([])
|
|
259
|
+
})
|
|
260
|
+
.finally(() => {
|
|
261
|
+
if (!cancelled) setSearching(false)
|
|
262
|
+
})
|
|
263
|
+
}, SEARCH_DEBOUNCE)
|
|
264
|
+
|
|
265
|
+
return () => {
|
|
266
|
+
cancelled = true
|
|
267
|
+
clearTimeout(timer)
|
|
268
|
+
}
|
|
269
|
+
}, [term, searchProducts])
|
|
270
|
+
|
|
271
|
+
return { results, searching, minLength: MIN_SEARCH_LENGTH }
|
|
272
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useCrossSellingShelfOverride'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useMemo, type ReactElement } from 'react'
|
|
2
|
+
import { CrossSellingShelfSection, getOverriddenSection } from '@faststore/core'
|
|
3
|
+
import type { SeProductSummary } from '../SeCustomProductCard/types'
|
|
4
|
+
|
|
5
|
+
export type CrossSellingProductCard = (props: { product: SeProductSummary; index: number }) => ReactElement | null
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* FastStore's native `CrossSellingShelf` section (it reads the PDP context and queries "who
|
|
9
|
+
* bought/saw also..." itself) with only its product card swapped out. Memoized so the section
|
|
10
|
+
* isn't re-created — and its data re-fetched — on every render; pass a stable (module-level)
|
|
11
|
+
* `ProductCard`.
|
|
12
|
+
*/
|
|
13
|
+
export function useCrossSellingShelfOverride(ProductCard: CrossSellingProductCard, className?: string) {
|
|
14
|
+
return useMemo(
|
|
15
|
+
() =>
|
|
16
|
+
getOverriddenSection({
|
|
17
|
+
Section: CrossSellingShelfSection,
|
|
18
|
+
className,
|
|
19
|
+
components: {
|
|
20
|
+
__experimentalProductCard: { Component: ProductCard },
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
[ProductCard, className],
|
|
24
|
+
)
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The subset of FastStore's `ProductSummary_product` fragment (what `useProductsQuery` and the
|
|
3
|
+
* native shelves hand to a product card) that the B2B card actually reads. Typed locally because
|
|
4
|
+
* the real generated type only exists inside a consuming FastStore project's codegen output.
|
|
5
|
+
*/
|
|
6
|
+
export type SeProductSummary = {
|
|
7
|
+
id: string
|
|
8
|
+
slug: string
|
|
9
|
+
sku: string
|
|
10
|
+
name: string
|
|
11
|
+
gtin?: string
|
|
12
|
+
brand?: { name?: string }
|
|
13
|
+
isVariantOf: { productGroupID: string; name: string }
|
|
14
|
+
image?: Array<{ url?: string; alternateName?: string }>
|
|
15
|
+
offers: { offers: Array<{ price: number; listPrice?: number }> }
|
|
16
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useFormattedPrice_unstable,
|
|
3
|
+
useProductLink_unstable,
|
|
4
|
+
useSession_unstable,
|
|
5
|
+
} from '@faststore/core/experimental'
|
|
6
|
+
import type { SeProductSummary } from './types'
|
|
7
|
+
|
|
8
|
+
export type B2bProductCard = {
|
|
9
|
+
name: string
|
|
10
|
+
imageUrl?: string
|
|
11
|
+
imageAlt: string
|
|
12
|
+
href: string
|
|
13
|
+
onClick: () => void
|
|
14
|
+
/** Prices are login-gated: only signed-in shoppers see them. */
|
|
15
|
+
isLoggedIn: boolean
|
|
16
|
+
/** Formatted with the session's own locale/currency. Equal when there's one price only. */
|
|
17
|
+
minPrice: string
|
|
18
|
+
maxPrice: string
|
|
19
|
+
hasPriceRange: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Derives what the login-gated B2B product card shows. Ported from the kit's
|
|
24
|
+
* `CustomProductCard`, which hardcoded `en-US`/`USD` through its own `formatPrice`; this formats
|
|
25
|
+
* through FastStore's `useFormattedPrice_unstable` so it follows the session currency instead.
|
|
26
|
+
*/
|
|
27
|
+
export function useB2bProductCard(product: SeProductSummary, index = 0): B2bProductCard {
|
|
28
|
+
const { person } = useSession_unstable()
|
|
29
|
+
const { href, onClick } = useProductLink_unstable({ product, selectedOffer: 0, index })
|
|
30
|
+
|
|
31
|
+
const prices = (product.offers?.offers ?? []).map((offer) => offer.price).filter((price) => price > 0)
|
|
32
|
+
const min = prices.length ? Math.min(...prices) : 0
|
|
33
|
+
const max = prices.length ? Math.max(...prices) : 0
|
|
34
|
+
|
|
35
|
+
// Both hooks always run (fixed hook order), even when the range collapses to one price.
|
|
36
|
+
const minPrice = useFormattedPrice_unstable(min)
|
|
37
|
+
const maxPrice = useFormattedPrice_unstable(max)
|
|
38
|
+
|
|
39
|
+
const image = product.image?.[0]
|
|
40
|
+
const name = product.isVariantOf?.name ?? product.name
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
name,
|
|
44
|
+
imageUrl: image?.url?.trim() || undefined,
|
|
45
|
+
imageAlt: image?.alternateName || name,
|
|
46
|
+
href,
|
|
47
|
+
onClick,
|
|
48
|
+
isLoggedIn: Boolean(person),
|
|
49
|
+
minPrice,
|
|
50
|
+
maxPrice,
|
|
51
|
+
hasPriceRange: min !== max,
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useProductsQuery } from '@faststore/core'
|
|
2
|
+
import type { SeProductSummary } from '../SeCustomProductCard/types'
|
|
3
|
+
import type { SeShelfFacet, SeShelfSort } from './types'
|
|
4
|
+
|
|
5
|
+
export type B2bShelfQuery = {
|
|
6
|
+
numberOfItems?: number
|
|
7
|
+
sort?: SeShelfSort
|
|
8
|
+
term?: string
|
|
9
|
+
selectedFacets?: SeShelfFacet[]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Products for a B2B shelf through FastStore's own `useProductsQuery` — a native query, so
|
|
14
|
+
* there's no custom GraphQL here and no copy-paste distribution needed. Facets missing a key or
|
|
15
|
+
* value are dropped (a half-filled CMS row would otherwise be sent as an empty facet).
|
|
16
|
+
*/
|
|
17
|
+
export function useB2bShelfProducts({
|
|
18
|
+
numberOfItems = 10,
|
|
19
|
+
sort = 'score_desc',
|
|
20
|
+
term = '',
|
|
21
|
+
selectedFacets = [],
|
|
22
|
+
}: B2bShelfQuery): SeProductSummary[] {
|
|
23
|
+
const data = useProductsQuery({
|
|
24
|
+
first: numberOfItems,
|
|
25
|
+
term,
|
|
26
|
+
sort,
|
|
27
|
+
selectedFacets: selectedFacets.filter((facet) => facet?.key && facet?.value),
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
return (data?.search?.products?.edges ?? []).map((edge) => edge.node as SeProductSummary)
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useDashboards'
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react'
|
|
2
|
+
import { gql } from '@faststore/core/api'
|
|
3
|
+
import { useLazyQuery_unstable, useSession_unstable } from '@faststore/core/experimental'
|
|
4
|
+
import { SE_DASHBOARD_SUMMARY_QUERY, SE_LOW_STOCK_ITEMS_QUERY } from '@se-faststore/resolvers/b2b'
|
|
5
|
+
|
|
6
|
+
const DASHBOARD_SUMMARY_QUERY = gql(SE_DASHBOARD_SUMMARY_QUERY)
|
|
7
|
+
const LOW_STOCK_ITEMS_QUERY = gql(SE_LOW_STOCK_ITEMS_QUERY)
|
|
8
|
+
|
|
9
|
+
const CACHE_MAX_AGE = 3 * 60 * 60 * 1000
|
|
10
|
+
const SUMMARY_CACHE_KEY = 'seDashboardSummaryCache'
|
|
11
|
+
const LOW_STOCK_CACHE_KEY = 'seLowStockCache'
|
|
12
|
+
|
|
13
|
+
/** The low-stock service answers null while it's still computing. */
|
|
14
|
+
const LOW_STOCK_MAX_RETRIES = 5
|
|
15
|
+
const LOW_STOCK_RETRY_DELAY = 1500
|
|
16
|
+
|
|
17
|
+
export type DashboardBudget = { id: string; balance: { amount: number; remaining: number } }
|
|
18
|
+
|
|
19
|
+
export type DashboardSummary = {
|
|
20
|
+
openOrders: number | null
|
|
21
|
+
pendingApproval: number | null
|
|
22
|
+
/** Percentage of the unit's active budgets still unspent, 0–100; null when unknown. */
|
|
23
|
+
budgetRemainingPercent: number | null
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type LowStockItem = {
|
|
27
|
+
total: number
|
|
28
|
+
sku: { id: string; name: string; imageUrl: string | null; detailUrl: string | null }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type LowStockItems = { lowStockCount: number; minimumStock: number; stockBySku: LowStockItem[] }
|
|
32
|
+
|
|
33
|
+
export type DashboardLoadState = 'loading' | 'ready' | 'error'
|
|
34
|
+
|
|
35
|
+
type SummaryResponse = {
|
|
36
|
+
seOpenOrdersCount?: number | null
|
|
37
|
+
seOrdersPendingApprovalCount?: number | null
|
|
38
|
+
seBudgets?: DashboardBudget[] | null
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type LowStockResponse = { seLowStockItems?: LowStockItems | null }
|
|
42
|
+
|
|
43
|
+
type SessionWithB2b = {
|
|
44
|
+
b2b?: { userEmail?: string; unitId?: string; customerId?: string } | null
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The B2B session fields the dashboard tiles need; all undefined outside a B2B session. */
|
|
48
|
+
export function useDashboardsSession() {
|
|
49
|
+
const b2b = (useSession_unstable() as SessionWithB2b)?.b2b
|
|
50
|
+
return { userEmail: b2b?.userEmail, unitId: b2b?.unitId, customerId: b2b?.customerId }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Sum of every active budget's remaining balance over their total, as a 0–100 percentage. */
|
|
54
|
+
export function budgetRemainingPercent(budgets: DashboardBudget[] | null | undefined): number | null {
|
|
55
|
+
if (!budgets) return null
|
|
56
|
+
const totals = budgets.reduce(
|
|
57
|
+
(acc, { balance }) => ({ amount: acc.amount + balance.amount, remaining: acc.remaining + balance.remaining }),
|
|
58
|
+
{ amount: 0, remaining: 0 },
|
|
59
|
+
)
|
|
60
|
+
if (totals.amount <= 0) return 0
|
|
61
|
+
return Math.max(0, Math.min(100, (totals.remaining / totals.amount) * 100))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** "37%" or "37.25%". */
|
|
65
|
+
export function formatPercent(value: number): string {
|
|
66
|
+
return `${value % 1 === 0 ? value : value.toFixed(2)}%`
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Low-stock SKUs point at the IO app's `detailUrl` (`/{slug}/p`); FastStore PDPs are
|
|
71
|
+
* `/{slug}-{skuId}/p`.
|
|
72
|
+
*/
|
|
73
|
+
export function lowStockProductHref({ sku }: LowStockItem): string | undefined {
|
|
74
|
+
return sku.detailUrl ? sku.detailUrl.replace(/\/p$/, `-${sku.id}/p`) : undefined
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
type CacheEntry<T> = { data: T; timestamp: number; userEmail: string }
|
|
78
|
+
|
|
79
|
+
function readCache<T>(key: string, userEmail: string): T | undefined {
|
|
80
|
+
try {
|
|
81
|
+
const raw = window.localStorage.getItem(key)
|
|
82
|
+
if (!raw) return undefined
|
|
83
|
+
const entry = JSON.parse(raw) as CacheEntry<T>
|
|
84
|
+
if (entry.userEmail !== userEmail || Date.now() - entry.timestamp > CACHE_MAX_AGE) return undefined
|
|
85
|
+
return entry.data
|
|
86
|
+
} catch {
|
|
87
|
+
return undefined
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function writeCache<T>(key: string, userEmail: string, data: T): void {
|
|
92
|
+
try {
|
|
93
|
+
window.localStorage.setItem(key, JSON.stringify({ data, timestamp: Date.now(), userEmail } as CacheEntry<T>))
|
|
94
|
+
} catch {
|
|
95
|
+
// Storage full or disabled: the tiles still work, they just refetch next time.
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The latest `execute` behind a stable ref: FastStore's real `useLazyQuery_unstable` returns a
|
|
101
|
+
* new one every render, so it can't be an effect dependency (see useRecentOrdersSpendOverview.ts).
|
|
102
|
+
*/
|
|
103
|
+
function useLatest<T>(value: T) {
|
|
104
|
+
const ref = useRef(value)
|
|
105
|
+
ref.current = value
|
|
106
|
+
return ref
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Open / pending-approval order counts and budget usage, cached per shopper for three hours. */
|
|
110
|
+
export function useDashboardSummary(userEmail: string | undefined, unitId: string | undefined) {
|
|
111
|
+
const [summary, setSummary] = useState<DashboardSummary | undefined>()
|
|
112
|
+
const [fetchSummary] = useLazyQuery_unstable<SummaryResponse, { unitId: string }>(DASHBOARD_SUMMARY_QUERY, {
|
|
113
|
+
unitId: unitId ?? '',
|
|
114
|
+
})
|
|
115
|
+
const fetchSummaryRef = useLatest(fetchSummary)
|
|
116
|
+
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
if (!userEmail || !unitId) return
|
|
119
|
+
let cancelled = false
|
|
120
|
+
|
|
121
|
+
const cached = readCache<DashboardSummary>(SUMMARY_CACHE_KEY, userEmail)
|
|
122
|
+
if (cached) {
|
|
123
|
+
setSummary(cached)
|
|
124
|
+
return
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
fetchSummaryRef
|
|
128
|
+
.current({ unitId })
|
|
129
|
+
.then((result: SummaryResponse | null | undefined) => {
|
|
130
|
+
if (cancelled) return
|
|
131
|
+
const next: DashboardSummary = {
|
|
132
|
+
openOrders: result?.seOpenOrdersCount ?? null,
|
|
133
|
+
pendingApproval: result?.seOrdersPendingApprovalCount ?? null,
|
|
134
|
+
budgetRemainingPercent: budgetRemainingPercent(result?.seBudgets),
|
|
135
|
+
}
|
|
136
|
+
// Don't pin a total failure in the cache for three hours.
|
|
137
|
+
if (next.openOrders !== null || next.pendingApproval !== null || next.budgetRemainingPercent !== null) {
|
|
138
|
+
writeCache(SUMMARY_CACHE_KEY, userEmail, next)
|
|
139
|
+
}
|
|
140
|
+
setSummary(next)
|
|
141
|
+
})
|
|
142
|
+
.catch(() => {
|
|
143
|
+
if (!cancelled) setSummary({ openOrders: null, pendingApproval: null, budgetRemainingPercent: null })
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
return () => {
|
|
147
|
+
cancelled = true
|
|
148
|
+
}
|
|
149
|
+
}, [userEmail, unitId, fetchSummaryRef])
|
|
150
|
+
|
|
151
|
+
return summary
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** SKUs under the minimum-stock threshold, cached per shopper; retried while the service is still computing. */
|
|
155
|
+
export function useLowStockItems(userEmail: string | undefined) {
|
|
156
|
+
const [items, setItems] = useState<LowStockItems | undefined>()
|
|
157
|
+
const [state, setState] = useState<DashboardLoadState>('loading')
|
|
158
|
+
const retries = useRef(0)
|
|
159
|
+
const [fetchLowStock] = useLazyQuery_unstable<LowStockResponse, Record<string, never>>(
|
|
160
|
+
LOW_STOCK_ITEMS_QUERY,
|
|
161
|
+
{},
|
|
162
|
+
)
|
|
163
|
+
const fetchLowStockRef = useLatest(fetchLowStock)
|
|
164
|
+
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
if (!userEmail) return
|
|
167
|
+
let cancelled = false
|
|
168
|
+
let retryTimer: ReturnType<typeof setTimeout> | undefined
|
|
169
|
+
|
|
170
|
+
const cached = readCache<LowStockItems>(LOW_STOCK_CACHE_KEY, userEmail)
|
|
171
|
+
if (cached) {
|
|
172
|
+
setItems(cached)
|
|
173
|
+
setState('ready')
|
|
174
|
+
return
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const load = () => {
|
|
178
|
+
fetchLowStockRef
|
|
179
|
+
.current({})
|
|
180
|
+
.then((result: LowStockResponse | null | undefined) => {
|
|
181
|
+
if (cancelled) return
|
|
182
|
+
const lowStock = result?.seLowStockItems
|
|
183
|
+
if (!lowStock) {
|
|
184
|
+
if (retries.current >= LOW_STOCK_MAX_RETRIES) {
|
|
185
|
+
setState('error')
|
|
186
|
+
return
|
|
187
|
+
}
|
|
188
|
+
retries.current += 1
|
|
189
|
+
retryTimer = setTimeout(load, LOW_STOCK_RETRY_DELAY)
|
|
190
|
+
return
|
|
191
|
+
}
|
|
192
|
+
retries.current = 0
|
|
193
|
+
writeCache(LOW_STOCK_CACHE_KEY, userEmail, lowStock)
|
|
194
|
+
setItems(lowStock)
|
|
195
|
+
setState('ready')
|
|
196
|
+
})
|
|
197
|
+
.catch(() => {
|
|
198
|
+
if (!cancelled) setState('error')
|
|
199
|
+
})
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
load()
|
|
203
|
+
|
|
204
|
+
return () => {
|
|
205
|
+
cancelled = true
|
|
206
|
+
if (retryTimer) clearTimeout(retryTimer)
|
|
207
|
+
}
|
|
208
|
+
}, [userEmail, fetchLowStockRef])
|
|
209
|
+
|
|
210
|
+
return { items, state }
|
|
211
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type FooterB2BLink = {
|
|
2
|
+
text?: string
|
|
3
|
+
url?: string
|
|
4
|
+
newTab?: boolean
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type FooterB2BColumn = {
|
|
8
|
+
title?: string
|
|
9
|
+
links?: FooterB2BLink[]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type FooterB2BNewsletter = {
|
|
13
|
+
title?: string
|
|
14
|
+
text?: string
|
|
15
|
+
placeholder?: string
|
|
16
|
+
/** Button label. */
|
|
17
|
+
submitLabel?: string
|
|
18
|
+
successMessage?: string
|
|
19
|
+
errorMessage?: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type FooterB2BSocialLink = {
|
|
23
|
+
/** Icon image URL (CMS media gallery). */
|
|
24
|
+
icon?: string
|
|
25
|
+
alt?: string
|
|
26
|
+
url?: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type FooterB2BBottomBar = {
|
|
30
|
+
logo?: {
|
|
31
|
+
src?: string
|
|
32
|
+
alt?: string
|
|
33
|
+
link?: {
|
|
34
|
+
url?: string
|
|
35
|
+
title?: string
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
contactCopyright?: {
|
|
39
|
+
contact?: string
|
|
40
|
+
copyright?: string
|
|
41
|
+
}
|
|
42
|
+
}
|