basklee-nuxt 0.0.0-stage → 0.8.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 +1190 -2
- package/bin/basklee-nuxt.mjs +173 -0
- package/package.json +69 -4
- package/runtime/api.mjs +14 -0
- package/runtime/domain.mjs +15 -0
- package/runtime/marketplace.mjs +905 -0
- package/runtime/seo.mjs +17 -0
- package/src/asset-loading-plugin.mjs +10 -0
- package/src/favicon-handler.mjs +12 -0
- package/src/install.mjs +361 -0
- package/src/migrate.mjs +124 -0
- package/src/module.d.ts +3 -0
- package/src/module.mjs +88 -0
- package/src/project-readme.mjs +702 -0
- package/src/service.mjs +186 -0
- package/src/setup.mjs +250 -0
- package/src/sitemap.mjs +93 -0
- package/src/update.mjs +54 -0
- package/src/validation.mjs +33 -0
- package/templates/.vscode/settings.json +5 -0
- package/templates/app/app.vue +52 -0
- package/templates/app/assets/css/basklee-tokens.css +21 -0
- package/templates/app/assets/css/basklee.css +28 -0
- package/templates/app/components/basklee/account/AccountActivity.README.md +31 -0
- package/templates/app/components/basklee/account/AccountActivity.vue +61 -0
- package/templates/app/components/basklee/account/AccountPromocodes.README.md +50 -0
- package/templates/app/components/basklee/account/AccountPromocodes.vue +267 -0
- package/templates/app/components/basklee/account/AccountSection.README.md +31 -0
- package/templates/app/components/basklee/account/AccountSection.vue +132 -0
- package/templates/app/components/basklee/account/ProfileAvatar.vue +139 -0
- package/templates/app/components/basklee/account/ProfileDeleteAccount.vue +161 -0
- package/templates/app/components/basklee/account/ProfileDetailsForm.vue +182 -0
- package/templates/app/components/basklee/account/ProfileEmailSettings.vue +269 -0
- package/templates/app/components/basklee/account/ProfilePasswordForm.vue +201 -0
- package/templates/app/components/basklee/account/ProfileSignIn.vue +446 -0
- package/templates/app/components/basklee/account/SignInHistory.README.md +27 -0
- package/templates/app/components/basklee/account/SignInHistory.vue +218 -0
- package/templates/app/components/basklee/account/StorefrontLogout.README.md +15 -0
- package/templates/app/components/basklee/account/StorefrontLogout.vue +109 -0
- package/templates/app/components/basklee/account/StorefrontProfile.README.md +145 -0
- package/templates/app/components/basklee/account/StorefrontProfile.vue +168 -0
- package/templates/app/components/basklee/account/account.css +1047 -0
- package/templates/app/components/basklee/account/profile.css +696 -0
- package/templates/app/components/basklee/address/AddressForm.README.md +67 -0
- package/templates/app/components/basklee/address/AddressForm.vue +537 -0
- package/templates/app/components/basklee/address/StorefrontAddresses.README.md +44 -0
- package/templates/app/components/basklee/address/StorefrontAddresses.vue +438 -0
- package/templates/app/components/basklee/banners/MainBanner.vue +171 -0
- package/templates/app/components/basklee/banners/examples/BannerExample.vue +6 -0
- package/templates/app/components/basklee/blog/BlogArticle.README.md +44 -0
- package/templates/app/components/basklee/blog/BlogArticle.vue +1023 -0
- package/templates/app/components/basklee/blog/BlogCommentForm.README.md +28 -0
- package/templates/app/components/basklee/blog/BlogCommentForm.vue +129 -0
- package/templates/app/components/basklee/blog/BlogComments.README.md +36 -0
- package/templates/app/components/basklee/blog/BlogComments.vue +373 -0
- package/templates/app/components/basklee/blog/BlogPostCard.vue +307 -0
- package/templates/app/components/basklee/blog/BlogPostGroup.vue +108 -0
- package/templates/app/components/basklee/blog/StorefrontJournal.README.md +42 -0
- package/templates/app/components/basklee/blog/StorefrontJournal.vue +670 -0
- package/templates/app/components/basklee/branding/BrandLogos.vue +25 -0
- package/templates/app/components/basklee/branding/examples/BrandLogosExample.vue +6 -0
- package/templates/app/components/basklee/cart/CartCheckoutDetails.README.md +85 -0
- package/templates/app/components/basklee/cart/CartCheckoutDetails.vue +377 -0
- package/templates/app/components/basklee/cart/CartDeliverySelector.README.md +95 -0
- package/templates/app/components/basklee/cart/CartDeliverySelector.vue +724 -0
- package/templates/app/components/basklee/cart/CartItemOptions.README.md +98 -0
- package/templates/app/components/basklee/cart/CartItemOptions.vue +693 -0
- package/templates/app/components/basklee/cart/CartLineItem.README.md +70 -0
- package/templates/app/components/basklee/cart/CartLineItem.vue +271 -0
- package/templates/app/components/basklee/cart/CartPreview.README.md +43 -0
- package/templates/app/components/basklee/cart/CartPreview.vue +263 -0
- package/templates/app/components/basklee/cart/DeliveryMap.README.md +48 -0
- package/templates/app/components/basklee/cart/DeliveryMap.vue +155 -0
- package/templates/app/components/basklee/cart/StorefrontCart.README.md +89 -0
- package/templates/app/components/basklee/cart/StorefrontCart.vue +689 -0
- package/templates/app/components/basklee/catalog/CatalogHeader.vue +681 -0
- package/templates/app/components/basklee/catalog/CatalogRepresentative.vue +59 -0
- package/templates/app/components/basklee/catalog/StorefrontCatalog.README.md +35 -0
- package/templates/app/components/basklee/catalog/StorefrontCatalog.vue +179 -0
- package/templates/app/components/basklee/catalog/examples/CatalogHeaderExample.vue +6 -0
- package/templates/app/components/basklee/categories/CategoryGroup.vue +125 -0
- package/templates/app/components/basklee/categories/StorefrontCategory.README.md +60 -0
- package/templates/app/components/basklee/categories/StorefrontCategory.vue +277 -0
- package/templates/app/components/basklee/categories/examples/CategoryGroupExample.vue +7 -0
- package/templates/app/components/basklee/contact/AboutPage.README.md +23 -0
- package/templates/app/components/basklee/contact/AboutPage.vue +409 -0
- package/templates/app/components/basklee/contact/ContactForm.README.md +29 -0
- package/templates/app/components/basklee/contact/ContactForm.vue +289 -0
- package/templates/app/components/basklee/contact/EmailUnsubscribe.README.md +27 -0
- package/templates/app/components/basklee/contact/EmailUnsubscribe.vue +95 -0
- package/templates/app/components/basklee/contact/StorefrontContact.README.md +18 -0
- package/templates/app/components/basklee/contact/StorefrontContact.vue +89 -0
- package/templates/app/components/basklee/contact/examples/ContactExample.vue +6 -0
- package/templates/app/components/basklee/currencies/MainCurrencySwitcher.vue +80 -0
- package/templates/app/components/basklee/currencies/examples/CurrencyExample.vue +6 -0
- package/templates/app/components/basklee/events/EventEnrollmentDialog.README.md +58 -0
- package/templates/app/components/basklee/events/EventEnrollmentDialog.vue +294 -0
- package/templates/app/components/basklee/events/EventsBlock.vue +138 -0
- package/templates/app/components/basklee/events/examples/EventsExample.vue +6 -0
- package/templates/app/components/basklee/legal/CookieNotice.README.md +34 -0
- package/templates/app/components/basklee/legal/CookieNotice.vue +84 -0
- package/templates/app/components/basklee/legal/StorefrontPrivacy.README.md +35 -0
- package/templates/app/components/basklee/legal/StorefrontPrivacy.vue +124 -0
- package/templates/app/components/basklee/locale/MainLanguageSwitcher.vue +506 -0
- package/templates/app/components/basklee/locale/examples/LocaleExample.vue +6 -0
- package/templates/app/components/basklee/manufacturers/ManufacturerIndex.README.md +36 -0
- package/templates/app/components/basklee/manufacturers/ManufacturerIndex.vue +495 -0
- package/templates/app/components/basklee/manufacturers/StorefrontManufacturers.README.md +30 -0
- package/templates/app/components/basklee/manufacturers/StorefrontManufacturers.vue +263 -0
- package/templates/app/components/basklee/orders/OrderDetails.README.md +39 -0
- package/templates/app/components/basklee/orders/OrderDetails.vue +1074 -0
- package/templates/app/components/basklee/orders/OrderPaymentForm.README.md +59 -0
- package/templates/app/components/basklee/orders/OrderPaymentForm.vue +73 -0
- package/templates/app/components/basklee/orders/StorefrontOrders.README.md +39 -0
- package/templates/app/components/basklee/orders/StorefrontOrders.vue +869 -0
- package/templates/app/components/basklee/orders/orders.css +612 -0
- package/templates/app/components/basklee/payments/PaymentPanel.README.md +76 -0
- package/templates/app/components/basklee/payments/PaymentPanel.vue +108 -0
- package/templates/app/components/basklee/products/HoverImageViewer.vue +190 -0
- package/templates/app/components/basklee/products/ProductCard.README.md +63 -0
- package/templates/app/components/basklee/products/ProductCard.vue +911 -0
- package/templates/app/components/basklee/products/ProductCardActions.README.md +33 -0
- package/templates/app/components/basklee/products/ProductCardActions.vue +412 -0
- package/templates/app/components/basklee/products/ProductCardBadges.vue +83 -0
- package/templates/app/components/basklee/products/ProductCardDescription.vue +46 -0
- package/templates/app/components/basklee/products/ProductCardFavorite.vue +99 -0
- package/templates/app/components/basklee/products/ProductCardPrice.vue +66 -0
- package/templates/app/components/basklee/products/ProductCardRating.vue +65 -0
- package/templates/app/components/basklee/products/ProductCardSeller.vue +66 -0
- package/templates/app/components/basklee/products/ProductCardStockNotice.vue +43 -0
- package/templates/app/components/basklee/products/ProductCardTitle.vue +46 -0
- package/templates/app/components/basklee/products/ProductCardVariants.vue +388 -0
- package/templates/app/components/basklee/products/ProductGroup.vue +259 -0
- package/templates/app/components/basklee/products/ProductPreorderDialog.README.md +22 -0
- package/templates/app/components/basklee/products/ProductPreorderDialog.vue +471 -0
- package/templates/app/components/basklee/products/ProductReviewForm.README.md +39 -0
- package/templates/app/components/basklee/products/ProductReviewForm.vue +312 -0
- package/templates/app/components/basklee/products/ProductReviewGallery.README.md +28 -0
- package/templates/app/components/basklee/products/ProductReviewGallery.vue +141 -0
- package/templates/app/components/basklee/products/ProductReviewImageViewer.README.md +52 -0
- package/templates/app/components/basklee/products/ProductReviewImageViewer.vue +425 -0
- package/templates/app/components/basklee/products/ProductReviews.README.md +70 -0
- package/templates/app/components/basklee/products/ProductReviews.vue +1025 -0
- package/templates/app/components/basklee/products/ProductSecondaryVariantModal.vue +460 -0
- package/templates/app/components/basklee/products/ProductSpecificationsDialog.README.md +65 -0
- package/templates/app/components/basklee/products/ProductSpecificationsDialog.vue +174 -0
- package/templates/app/components/basklee/products/StorefrontProduct.README.md +52 -0
- package/templates/app/components/basklee/products/StorefrontProduct.vue +1468 -0
- package/templates/app/components/basklee/products/StorefrontWishlist.README.md +33 -0
- package/templates/app/components/basklee/products/StorefrontWishlist.vue +290 -0
- package/templates/app/components/basklee/products/examples/FeaturedExample.vue +6 -0
- package/templates/app/components/basklee/products/examples/FeaturedHoverImageViewerExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardActionsExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardBadgesExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardDescriptionExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardFavoriteExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardPriceExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardRatingExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardSellerExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardStockNoticeExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardTitleExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/FeaturedProductCardVariantsExample.vue +14 -0
- package/templates/app/components/basklee/products/examples/ProductsExample.vue +6 -0
- package/templates/app/components/basklee/products/examples/ProductsHoverImageViewerExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardActionsExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardBadgesExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardDescriptionExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardFavoriteExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardPriceExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardRatingExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardSellerExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardStockNoticeExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardTitleExample.vue +13 -0
- package/templates/app/components/basklee/products/examples/ProductsProductCardVariantsExample.vue +13 -0
- package/templates/app/components/basklee/promo/PromoProducts.README.md +45 -0
- package/templates/app/components/basklee/promo/PromoProducts.vue +287 -0
- package/templates/app/components/basklee/search/MainSearch.vue +340 -0
- package/templates/app/components/basklee/search/ProductSearchResults.README.md +81 -0
- package/templates/app/components/basklee/search/ProductSearchResults.vue +506 -0
- package/templates/app/components/basklee/search/SearchFilters.vue +546 -0
- package/templates/app/components/basklee/search/examples/MainSearchExample.vue +6 -0
- package/templates/app/components/basklee/sellers/SellerFilters.README.md +32 -0
- package/templates/app/components/basklee/sellers/SellerFilters.vue +317 -0
- package/templates/app/components/basklee/sellers/SellerPhotoGallery.README.md +45 -0
- package/templates/app/components/basklee/sellers/SellerPhotoGallery.vue +406 -0
- package/templates/app/components/basklee/sellers/SellerSummary.README.md +33 -0
- package/templates/app/components/basklee/sellers/SellerSummary.vue +162 -0
- package/templates/app/components/basklee/sellers/StorefrontSellers.README.md +73 -0
- package/templates/app/components/basklee/sellers/StorefrontSellers.vue +300 -0
- package/templates/app/components/basklee/shared/BaskleeAvatar.README.md +30 -0
- package/templates/app/components/basklee/shared/BaskleeAvatar.vue +83 -0
- package/templates/app/components/basklee/shared/BaskleeBreadcrumbs.README.md +65 -0
- package/templates/app/components/basklee/shared/BaskleeBreadcrumbs.vue +118 -0
- package/templates/app/components/basklee/shared/BaskleeEmptyState.README.md +38 -0
- package/templates/app/components/basklee/shared/BaskleeEmptyState.vue +143 -0
- package/templates/app/components/basklee/shared/BaskleeImage.vue +84 -0
- package/templates/app/components/basklee/shared/BaskleeInfoHint.README.md +32 -0
- package/templates/app/components/basklee/shared/BaskleeInfoHint.vue +158 -0
- package/templates/app/components/basklee/shared/BaskleePasswordInput.README.md +30 -0
- package/templates/app/components/basklee/shared/BaskleePasswordInput.vue +197 -0
- package/templates/app/components/basklee/shared/BaskleeSearchSelect.README.md +38 -0
- package/templates/app/components/basklee/shared/BaskleeSearchSelect.vue +411 -0
- package/templates/app/components/basklee/shared/BaskleeSelect.README.md +31 -0
- package/templates/app/components/basklee/shared/BaskleeSelect.vue +525 -0
- package/templates/app/components/basklee/shared/StorefrontErrorPage.README.md +55 -0
- package/templates/app/components/basklee/shared/StorefrontErrorPage.vue +151 -0
- package/templates/app/components/basklee/shared/StorefrontPagination.README.md +50 -0
- package/templates/app/components/basklee/shared/StorefrontPagination.vue +148 -0
- package/templates/app/components/basklee/shared/dialogs.css +36 -0
- package/templates/app/components/basklee/shared/features.css +364 -0
- package/templates/app/components/basklee/social/SocialLinks.vue +72 -0
- package/templates/app/components/basklee/social/examples/SocialLinksExample.vue +6 -0
- package/templates/app/components/basklee/storefront/StorefrontAccount.README.md +47 -0
- package/templates/app/components/basklee/storefront/StorefrontAccount.vue +332 -0
- package/templates/app/components/basklee/storefront/StorefrontCartButton.vue +68 -0
- package/templates/app/components/basklee/storefront/StorefrontFooter.README.md +26 -0
- package/templates/app/components/basklee/storefront/StorefrontFooter.vue +236 -0
- package/templates/app/components/basklee/storefront/StorefrontHeader.README.md +93 -0
- package/templates/app/components/basklee/storefront/StorefrontHeader.vue +509 -0
- package/templates/app/components/basklee/storefront/StorefrontHome.README.md +79 -0
- package/templates/app/components/basklee/storefront/StorefrontHome.vue +315 -0
- package/templates/app/components/basklee/storefront/StorefrontWishlistButton.vue +105 -0
- package/templates/app/components/basklee/storefront/examples/StorefrontAccountExample.vue +7 -0
- package/templates/app/components/basklee/stores/StorefrontStores.README.md +41 -0
- package/templates/app/components/basklee/stores/StorefrontStores.vue +346 -0
- package/templates/app/components/basklee/subscriptions/StorefrontSubscriptions.README.md +151 -0
- package/templates/app/components/basklee/subscriptions/StorefrontSubscriptions.vue +851 -0
- package/templates/app/components/basklee/subscriptions/StorefrontTariff.README.md +38 -0
- package/templates/app/components/basklee/subscriptions/StorefrontTariff.vue +555 -0
- package/templates/app/components/basklee/subscriptions/StorefrontTariffs.README.md +36 -0
- package/templates/app/components/basklee/subscriptions/StorefrontTariffs.vue +416 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionCancelDialog.README.md +39 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionCancelDialog.vue +292 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionChangeDialog.README.md +85 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionChangeDialog.vue +874 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionExtendDialog.README.md +53 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionExtendDialog.vue +536 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionPlanSummary.README.md +101 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionPlanSummary.vue +286 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionRemoteDetails.README.md +138 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionRemoteDetails.vue +134 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionRenewalDialog.README.md +85 -0
- package/templates/app/components/basklee/subscriptions/SubscriptionRenewalDialog.vue +364 -0
- package/templates/app/components/basklee/support/StorefrontSupport.README.md +39 -0
- package/templates/app/components/basklee/support/StorefrontSupport.vue +484 -0
- package/templates/app/components/basklee/support/TicketConversation.README.md +38 -0
- package/templates/app/components/basklee/support/TicketConversation.vue +524 -0
- package/templates/app/components/basklee/support/TicketImage.README.md +27 -0
- package/templates/app/components/basklee/support/TicketImage.vue +186 -0
- package/templates/app/components/basklee/support/TicketItemCard.README.md +59 -0
- package/templates/app/components/basklee/support/TicketItemCard.vue +177 -0
- package/templates/app/components/basklee/support/TicketMessageForm.README.md +35 -0
- package/templates/app/components/basklee/support/TicketMessageForm.vue +258 -0
- package/templates/app/components/basklee/support/TicketSubscriptionCard.README.md +40 -0
- package/templates/app/components/basklee/support/TicketSubscriptionCard.vue +154 -0
- package/templates/app/components/basklee/tariffs/TariffCard.README.md +12 -0
- package/templates/app/components/basklee/tariffs/TariffCard.vue +251 -0
- package/templates/app/components/basklee/tariffs/TariffCardDescription.README.md +12 -0
- package/templates/app/components/basklee/tariffs/TariffCardDescription.vue +97 -0
- package/templates/app/components/basklee/tariffs/TariffCardFeatures.README.md +14 -0
- package/templates/app/components/basklee/tariffs/TariffCardFeatures.vue +172 -0
- package/templates/app/components/basklee/tariffs/TariffCardImage.README.md +12 -0
- package/templates/app/components/basklee/tariffs/TariffCardImage.vue +33 -0
- package/templates/app/components/basklee/tariffs/TariffCardPrices.README.md +12 -0
- package/templates/app/components/basklee/tariffs/TariffCardPrices.vue +300 -0
- package/templates/app/components/basklee/tariffs/TariffCardTitle.README.md +12 -0
- package/templates/app/components/basklee/tariffs/TariffCardTitle.vue +30 -0
- package/templates/app/components/basklee/tariffs/TariffCards.README.md +12 -0
- package/templates/app/components/basklee/tariffs/TariffCards.vue +94 -0
- package/templates/app/components/basklee/tariffs/TariffSubscriptionModal.README.md +31 -0
- package/templates/app/components/basklee/tariffs/TariffSubscriptionModal.vue +411 -0
- package/templates/app/components/basklee/tariffs/examples/TariffCardDescriptionExample.vue +13 -0
- package/templates/app/components/basklee/tariffs/examples/TariffCardExample.vue +13 -0
- package/templates/app/components/basklee/tariffs/examples/TariffCardFeaturesExample.vue +14 -0
- package/templates/app/components/basklee/tariffs/examples/TariffCardImageExample.vue +13 -0
- package/templates/app/components/basklee/tariffs/examples/TariffCardPricesExample.vue +13 -0
- package/templates/app/components/basklee/tariffs/examples/TariffCardTitleExample.vue +13 -0
- package/templates/app/components/basklee/tariffs/examples/TariffCardsExample.vue +6 -0
- package/templates/app/components/basklee/theme/BaskleeThemeProvider.vue +38 -0
- package/templates/app/components/basklee/units/UnitSwitcher.vue +71 -0
- package/templates/app/components/basklee/units/examples/LengthExample.vue +6 -0
- package/templates/app/components/basklee/units/examples/WeightExample.vue +6 -0
- package/templates/app/components/basklee/wallet/StorefrontWallet.README.md +117 -0
- package/templates/app/components/basklee/wallet/StorefrontWallet.vue +863 -0
- package/templates/app/components/basklee/wallet/WalletBalance.vue +47 -0
- package/templates/app/components/basklee/wallet/WalletTopUpForm.README.md +32 -0
- package/templates/app/components/basklee/wallet/WalletTopUpForm.vue +224 -0
- package/templates/app/components/basklee/wallet/examples/WalletExample.vue +6 -0
- package/templates/app/composables/useBaskleeActionMenu.ts +126 -0
- package/templates/app/composables/useBaskleeAddressEditor.ts +343 -0
- package/templates/app/composables/useBaskleeAddresses.ts +75 -0
- package/templates/app/composables/useBaskleeApi.ts +190 -0
- package/templates/app/composables/useBaskleeAppLoad.ts +83 -0
- package/templates/app/composables/useBaskleeBlogComments.ts +325 -0
- package/templates/app/composables/useBaskleeBlogReading.ts +270 -0
- package/templates/app/composables/useBaskleeCart.ts +226 -0
- package/templates/app/composables/useBaskleeCartPreview.ts +142 -0
- package/templates/app/composables/useBaskleeCategoryLink.ts +24 -0
- package/templates/app/composables/useBaskleeCategoryProducts.ts +16 -0
- package/templates/app/composables/useBaskleeFeature.ts +100 -0
- package/templates/app/composables/useBaskleeFeaturedProducts.ts +14 -0
- package/templates/app/composables/useBaskleeGeolocation.ts +28 -0
- package/templates/app/composables/useBaskleeHomeProducts.ts +90 -0
- package/templates/app/composables/useBaskleeManufacturerIndex.ts +83 -0
- package/templates/app/composables/useBaskleeMap.ts +240 -0
- package/templates/app/composables/useBaskleeMediaFormat.ts +24 -0
- package/templates/app/composables/useBaskleeMissingPage.ts +67 -0
- package/templates/app/composables/useBaskleeOrders.ts +185 -0
- package/templates/app/composables/useBaskleePageSeo.ts +133 -0
- package/templates/app/composables/useBaskleeProductActions.ts +116 -0
- package/templates/app/composables/useBaskleeProductLink.ts +24 -0
- package/templates/app/composables/useBaskleeProductSearch.ts +363 -0
- package/templates/app/composables/useBaskleeProductVariants.ts +176 -0
- package/templates/app/composables/useBaskleeProfile.ts +309 -0
- package/templates/app/composables/useBaskleeProgress.ts +89 -0
- package/templates/app/composables/useBaskleeReviews.ts +242 -0
- package/templates/app/composables/useBaskleeSearchHistory.ts +23 -0
- package/templates/app/composables/useBaskleeSearchScopeNames.ts +99 -0
- package/templates/app/composables/useBaskleeServerData.ts +72 -0
- package/templates/app/composables/useBaskleeSignIn.ts +66 -0
- package/templates/app/composables/useBaskleeStableHeight.ts +69 -0
- package/templates/app/composables/useBaskleeStorefront.ts +29 -0
- package/templates/app/composables/useBaskleeSubscriptions.ts +260 -0
- package/templates/app/composables/useBaskleeTheme.ts +27 -0
- package/templates/app/composables/useBaskleeTicketSubject.ts +180 -0
- package/templates/app/composables/useBaskleeTickets.ts +335 -0
- package/templates/app/composables/useBaskleeWallet.ts +166 -0
- package/templates/app/error.vue +108 -0
- package/templates/app/interfaces/basklee/accounts/IContact.ts +21 -0
- package/templates/app/interfaces/basklee/accounts/IEmailNotificationLocale.ts +17 -0
- package/templates/app/interfaces/basklee/accounts/IEmailVerification.ts +59 -0
- package/templates/app/interfaces/basklee/accounts/IProfileActions.ts +38 -0
- package/templates/app/interfaces/basklee/accounts/IProfileData.ts +125 -0
- package/templates/app/interfaces/basklee/accounts/IProfileMedia.ts +17 -0
- package/templates/app/interfaces/basklee/accounts/IStorefrontProfile.ts +54 -0
- package/templates/app/interfaces/basklee/address/IAddressCitySuggestion.ts +19 -0
- package/templates/app/interfaces/basklee/address/IAddressEditor.ts +9 -0
- package/templates/app/interfaces/basklee/address/IAddressLocationSuggestion.ts +22 -0
- package/templates/app/interfaces/basklee/address/IAddressRegionSearch.ts +30 -0
- package/templates/app/interfaces/basklee/address/IAddressSuggestion.ts +20 -0
- package/templates/app/interfaces/basklee/address/IUserAddress.ts +87 -0
- package/templates/app/interfaces/basklee/apiBase/TMethod.ts +1 -0
- package/templates/app/interfaces/basklee/appBase/IAppLoad.ts +16 -0
- package/templates/app/interfaces/basklee/appBase/IAppLoadCommon.ts +47 -0
- package/templates/app/interfaces/basklee/appBase/IApploadUserProfile.ts +15 -0
- package/templates/app/interfaces/basklee/appBase/IForm.ts +21 -0
- package/templates/app/interfaces/basklee/appBase/ISEO.ts +21 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonBanner.ts +11 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonContact.ts +8 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonCurrency.ts +15 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonEvents.ts +18 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonLocale.ts +14 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonLogos.ts +6 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonPath.ts +22 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonSEO.ts +26 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonSocial.ts +15 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonTariff.ts +7 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonUnit.ts +12 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonVariables.ts +8 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonVisualSettings.ts +11 -0
- package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonWalletValue.ts +3 -0
- package/templates/app/interfaces/basklee/blog/IBlogApi.ts +247 -0
- package/templates/app/interfaces/basklee/blog/IBlogPostPreview.ts +30 -0
- package/templates/app/interfaces/basklee/cart/ICartActions.ts +67 -0
- package/templates/app/interfaces/basklee/cart/ICartData.ts +382 -0
- package/templates/app/interfaces/basklee/cart/ICartDeliveryActions.ts +68 -0
- package/templates/app/interfaces/basklee/cart/ICartModal.ts +22 -0
- package/templates/app/interfaces/basklee/cart/IDeliveryMap.ts +29 -0
- package/templates/app/interfaces/basklee/catalog/ICatalogDirectory.ts +75 -0
- package/templates/app/interfaces/basklee/category/ICategory.ts +41 -0
- package/templates/app/interfaces/basklee/domains/IDomain.ts +13 -0
- package/templates/app/interfaces/basklee/forms/ICustomerSubfilter.ts +19 -0
- package/templates/app/interfaces/basklee/index.ts +57 -0
- package/templates/app/interfaces/basklee/marketing/IPromoActions.ts +51 -0
- package/templates/app/interfaces/basklee/orders/IOrderActions.ts +99 -0
- package/templates/app/interfaces/basklee/orders/IOrderHistory.ts +259 -0
- package/templates/app/interfaces/basklee/orders/IProductPreorder.ts +31 -0
- package/templates/app/interfaces/basklee/payments/IInvoice.ts +147 -0
- package/templates/app/interfaces/basklee/products/IProduct.ts +262 -0
- package/templates/app/interfaces/basklee/products/IProductFeedbackApi.ts +218 -0
- package/templates/app/interfaces/basklee/products/IProductSearchApi.ts +146 -0
- package/templates/app/interfaces/basklee/products/IProductSearchFacets.ts +35 -0
- package/templates/app/interfaces/basklee/products/IProductSecondaryVariantRequest.ts +15 -0
- package/templates/app/interfaces/basklee/products/IProductSpecification.ts +14 -0
- package/templates/app/interfaces/basklee/products/IWishlist.ts +22 -0
- package/templates/app/interfaces/basklee/sellers/ISellerDirectory.ts +70 -0
- package/templates/app/interfaces/basklee/shared/IBreadcrumb.ts +10 -0
- package/templates/app/interfaces/basklee/shared/IGeoCoordinates.ts +4 -0
- package/templates/app/interfaces/basklee/shared/IStorefrontControls.ts +13 -0
- package/templates/app/interfaces/basklee/shared/ITransformValue.ts +3 -0
- package/templates/app/interfaces/basklee/state.ts +4 -0
- package/templates/app/interfaces/basklee/stores/IStoreDirectory.ts +63 -0
- package/templates/app/interfaces/basklee/subscribeOptions/ISubscribeOption.ts +9 -0
- package/templates/app/interfaces/basklee/subscribeTariff/ISubscribeTariff.ts +56 -0
- package/templates/app/interfaces/basklee/subscribeTariff/ITariffSelection.ts +11 -0
- package/templates/app/interfaces/basklee/subscribes/ISubscribe.ts +28 -0
- package/templates/app/interfaces/basklee/subscribes/ISubscriptionApi.ts +127 -0
- package/templates/app/interfaces/basklee/tickets/ICustomerTicketApi.ts +223 -0
- package/templates/app/interfaces/basklee/transport.ts +34 -0
- package/templates/app/layouts/default.vue +382 -0
- package/templates/app/middleware/00.basklee.global.ts +27 -0
- package/templates/app/middleware/01.basklee-sellers.global.ts +15 -0
- package/templates/app/middleware/basklee-account.ts +40 -0
- package/templates/app/pages/activity.vue +19 -0
- package/templates/app/pages/addresses.vue +23 -0
- package/templates/app/pages/browse.vue +253 -0
- package/templates/app/pages/cart.vue +20 -0
- package/templates/app/pages/catalog.vue +17 -0
- package/templates/app/pages/category/[id].vue +150 -0
- package/templates/app/pages/contact.vue +17 -0
- package/templates/app/pages/featured.vue +152 -0
- package/templates/app/pages/index.vue +194 -0
- package/templates/app/pages/journal/[id].vue +164 -0
- package/templates/app/pages/journal/index.vue +74 -0
- package/templates/app/pages/logout.vue +71 -0
- package/templates/app/pages/manufacturers.vue +33 -0
- package/templates/app/pages/orders.vue +40 -0
- package/templates/app/pages/privacy.vue +17 -0
- package/templates/app/pages/product/[id].vue +150 -0
- package/templates/app/pages/profile.vue +118 -0
- package/templates/app/pages/promo/[id].vue +67 -0
- package/templates/app/pages/promocodes.vue +21 -0
- package/templates/app/pages/sellers.vue +203 -0
- package/templates/app/pages/stores.vue +36 -0
- package/templates/app/pages/subscriptions.vue +21 -0
- package/templates/app/pages/tariffs/[slug]/[id].vue +126 -0
- package/templates/app/pages/tariffs/index.vue +50 -0
- package/templates/app/pages/tickets.vue +56 -0
- package/templates/app/pages/unsubscribe.vue +32 -0
- package/templates/app/pages/wallet.vue +23 -0
- package/templates/app/pages/wishlist.vue +48 -0
- package/templates/app/stores/basklee.ts +493 -0
- package/templates/app/stores/baskleeBrowse.ts +79 -0
- package/templates/app/stores/baskleeCatalog.ts +141 -0
- package/templates/app/stores/baskleeDomainAccess.ts +55 -0
- package/templates/app/stores/baskleeProducts.ts +249 -0
- package/templates/app/stores/baskleeSelections.ts +132 -0
- package/templates/app/themes/basklee.ts +108 -0
- package/templates/app/utils/basklee/accountLabels.ts +29 -0
- package/templates/app/utils/basklee/activityLabels.ts +96 -0
- package/templates/app/utils/basklee/activityPresentation.ts +16 -0
- package/templates/app/utils/basklee/addressChanges.ts +26 -0
- package/templates/app/utils/basklee/addressRegions.ts +17 -0
- package/templates/app/utils/basklee/api.ts +333 -0
- package/templates/app/utils/basklee/blogArticleHtml.ts +318 -0
- package/templates/app/utils/basklee/blogComments.ts +133 -0
- package/templates/app/utils/basklee/blogImageViewer.ts +84 -0
- package/templates/app/utils/basklee/blogLabels.ts +167 -0
- package/templates/app/utils/basklee/blogLayout.ts +108 -0
- package/templates/app/utils/basklee/blogProductPlacements.ts +105 -0
- package/templates/app/utils/basklee/breadcrumbLabels.ts +14 -0
- package/templates/app/utils/basklee/browseLabels.ts +145 -0
- package/templates/app/utils/basklee/cartAddress.ts +94 -0
- package/templates/app/utils/basklee/cartLabels.ts +390 -0
- package/templates/app/utils/basklee/cartOptions.ts +143 -0
- package/templates/app/utils/basklee/cartPreview.ts +123 -0
- package/templates/app/utils/basklee/cartPromo.ts +150 -0
- package/templates/app/utils/basklee/cartShipment.ts +74 -0
- package/templates/app/utils/basklee/cartSnapshot.ts +20 -0
- package/templates/app/utils/basklee/catalog.ts +106 -0
- package/templates/app/utils/basklee/category.ts +52 -0
- package/templates/app/utils/basklee/categoryLabels.ts +44 -0
- package/templates/app/utils/basklee/contactLabels.ts +152 -0
- package/templates/app/utils/basklee/currency.ts +128 -0
- package/templates/app/utils/basklee/deliveryMap.ts +89 -0
- package/templates/app/utils/basklee/directoryLabels.ts +196 -0
- package/templates/app/utils/basklee/emptyStateArt.ts +231 -0
- package/templates/app/utils/basklee/errorPageLabels.ts +95 -0
- package/templates/app/utils/basklee/featureData.ts +25 -0
- package/templates/app/utils/basklee/featureLabels.ts +406 -0
- package/templates/app/utils/basklee/featuredLabels.ts +38 -0
- package/templates/app/utils/basklee/files.ts +71 -0
- package/templates/app/utils/basklee/footerLabels.ts +53 -0
- package/templates/app/utils/basklee/guestSession.ts +50 -0
- package/templates/app/utils/basklee/headerLabels.ts +98 -0
- package/templates/app/utils/basklee/homeContent.ts +129 -0
- package/templates/app/utils/basklee/homeLabels.ts +74 -0
- package/templates/app/utils/basklee/htmlText.ts +59 -0
- package/templates/app/utils/basklee/links.ts +14 -0
- package/templates/app/utils/basklee/manufacturerIndex.ts +108 -0
- package/templates/app/utils/basklee/modalWindow.ts +109 -0
- package/templates/app/utils/basklee/nativeApp.ts +361 -0
- package/templates/app/utils/basklee/notice.ts +22 -0
- package/templates/app/utils/basklee/orderLabels.ts +454 -0
- package/templates/app/utils/basklee/orderPresentation.ts +629 -0
- package/templates/app/utils/basklee/pageSeo.ts +662 -0
- package/templates/app/utils/basklee/paginationScroll.ts +131 -0
- package/templates/app/utils/basklee/phone.ts +22 -0
- package/templates/app/utils/basklee/presentation.ts +72 -0
- package/templates/app/utils/basklee/privacyLabels.ts +273 -0
- package/templates/app/utils/basklee/productActionLabels.ts +108 -0
- package/templates/app/utils/basklee/productActions.ts +574 -0
- package/templates/app/utils/basklee/productAvailability.ts +36 -0
- package/templates/app/utils/basklee/productGallery.ts +72 -0
- package/templates/app/utils/basklee/productLabels.ts +119 -0
- package/templates/app/utils/basklee/productListLocation.ts +130 -0
- package/templates/app/utils/basklee/productManufacturer.ts +30 -0
- package/templates/app/utils/basklee/productPage.ts +46 -0
- package/templates/app/utils/basklee/productPhotos.ts +67 -0
- package/templates/app/utils/basklee/productSearchScope.ts +237 -0
- package/templates/app/utils/basklee/productSeller.ts +51 -0
- package/templates/app/utils/basklee/productStructuredData.ts +221 -0
- package/templates/app/utils/basklee/profile.ts +148 -0
- package/templates/app/utils/basklee/profileLabels.ts +229 -0
- package/templates/app/utils/basklee/promoLabels.ts +111 -0
- package/templates/app/utils/basklee/promoPresentation.ts +381 -0
- package/templates/app/utils/basklee/reviewLabels.ts +256 -0
- package/templates/app/utils/basklee/reviewScope.ts +41 -0
- package/templates/app/utils/basklee/richText.ts +13 -0
- package/templates/app/utils/basklee/searchFilters.ts +99 -0
- package/templates/app/utils/basklee/searchHistory.ts +144 -0
- package/templates/app/utils/basklee/sellerDirectory.ts +134 -0
- package/templates/app/utils/basklee/seo.ts +52 -0
- package/templates/app/utils/basklee/serverCookies.ts +88 -0
- package/templates/app/utils/basklee/sessionLabels.ts +38 -0
- package/templates/app/utils/basklee/signInReturn.ts +89 -0
- package/templates/app/utils/basklee/storeDirectory.ts +50 -0
- package/templates/app/utils/basklee/subscriptionChanges.ts +167 -0
- package/templates/app/utils/basklee/subscriptionLabels.ts +100 -0
- package/templates/app/utils/basklee/subscriptionManageLabels.ts +424 -0
- package/templates/app/utils/basklee/subscriptionPlans.ts +162 -0
- package/templates/app/utils/basklee/subscriptionRemote.ts +110 -0
- package/templates/app/utils/basklee/subscriptionUsage.ts +82 -0
- package/templates/app/utils/basklee/tariffLabels.ts +182 -0
- package/templates/app/utils/basklee/tariffPage.ts +77 -0
- package/templates/app/utils/basklee/tariffVariables.ts +203 -0
- package/templates/app/utils/basklee/tariffs.ts +333 -0
- package/templates/app/utils/basklee/ticketItems.ts +87 -0
- package/templates/app/utils/basklee/ticketLabels.ts +428 -0
- package/templates/app/utils/basklee/ticketLocation.ts +79 -0
- package/templates/app/utils/basklee/walletTransaction.ts +135 -0
- package/templates/app/utils/baskleeAppLoad.ts +83 -0
- package/templates/basklee/COMPONENT-DOWNLOAD.md +40 -0
- package/templates/basklee/COMPONENTS.md +1993 -0
- package/templates/basklee/THEMES.md +94 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { IProduct } from '@/interfaces/basklee/products/IProduct';
|
|
2
|
+
import type {
|
|
3
|
+
ICartDelivery,
|
|
4
|
+
ICartOption,
|
|
5
|
+
ICartOptionGroup,
|
|
6
|
+
} from '@/interfaces/basklee/cart/ICartData';
|
|
7
|
+
|
|
8
|
+
/** One option product of a group, with the product the cart returned for it. */
|
|
9
|
+
export interface ICartOptionRow {
|
|
10
|
+
option: ICartOption;
|
|
11
|
+
product: IProduct;
|
|
12
|
+
maxQuantity: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Option rows shown as one card: the same product group, chosen by variant. */
|
|
16
|
+
export interface ICartOptionCard {
|
|
17
|
+
key: string;
|
|
18
|
+
rows: ICartOptionRow[];
|
|
19
|
+
productIds: number[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// The backend writes 0 into both group limits when the group has no such limit.
|
|
23
|
+
const NO_LIMIT = 0;
|
|
24
|
+
|
|
25
|
+
function quantityInOtherRows(group: ICartOptionGroup, option: ICartOption) {
|
|
26
|
+
return (group.options ?? [])
|
|
27
|
+
.filter(
|
|
28
|
+
(row) => row.id !== option.id && row.product?.id === option.product?.id,
|
|
29
|
+
)
|
|
30
|
+
.reduce((total, row) => total + row.quantity, 0);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Highest quantity `cart_customer_option_first_set` accepts for one row.
|
|
35
|
+
* `quantity_left` counts what is still free in the store besides this row,
|
|
36
|
+
* and both group limits cap the quantity when they are not 0.
|
|
37
|
+
*/
|
|
38
|
+
export function cartOptionMaxQuantity(
|
|
39
|
+
group: ICartOptionGroup,
|
|
40
|
+
option: ICartOption,
|
|
41
|
+
) {
|
|
42
|
+
const limits = [option.quantity + (option.quantity_left ?? 0)];
|
|
43
|
+
const perRow = group.limits?.c_max_product_quantity_in_group ?? NO_LIMIT;
|
|
44
|
+
const perProduct = group.limits?.c_max_products_quantity_for_group ?? NO_LIMIT;
|
|
45
|
+
|
|
46
|
+
if (perRow > NO_LIMIT) {
|
|
47
|
+
limits.push(perRow);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (perProduct > NO_LIMIT) {
|
|
51
|
+
limits.push(perProduct - quantityInOtherRows(group, option));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return Math.max(0, Math.floor(Math.min(...limits)));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Option rows that carry a product; a row without one cannot show a card. */
|
|
58
|
+
export function cartOptionRows(group: ICartOptionGroup): ICartOptionRow[] {
|
|
59
|
+
const rows = [];
|
|
60
|
+
|
|
61
|
+
for (const option of group.options ?? []) {
|
|
62
|
+
if (option.product) {
|
|
63
|
+
rows.push({
|
|
64
|
+
option,
|
|
65
|
+
product: option.product,
|
|
66
|
+
maxQuantity: cartOptionMaxQuantity(group, option),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return rows;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Products of the group, for registering them in the storefront store. */
|
|
75
|
+
export function cartOptionProducts(group: ICartOptionGroup) {
|
|
76
|
+
return cartOptionRows(group).map((row) => row.product);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Rows of one product group share a card: its variant choices switch between
|
|
81
|
+
* them. A product without a group, or the only product of its group, keeps
|
|
82
|
+
* its own card.
|
|
83
|
+
*/
|
|
84
|
+
export function cartOptionCards(group: ICartOptionGroup): ICartOptionCard[] {
|
|
85
|
+
const cards = new Map<string, ICartOptionCard>();
|
|
86
|
+
|
|
87
|
+
for (const row of cartOptionRows(group)) {
|
|
88
|
+
const productGroup = row.product.product_group_id;
|
|
89
|
+
const key =
|
|
90
|
+
Number.isInteger(productGroup) && Number(productGroup) > 0
|
|
91
|
+
? `group:${productGroup}`
|
|
92
|
+
: `product:${row.product.id}`;
|
|
93
|
+
const card = cards.get(key) ?? { key, rows: [], productIds: [] };
|
|
94
|
+
|
|
95
|
+
card.rows.push(row);
|
|
96
|
+
card.productIds.push(row.product.id);
|
|
97
|
+
cards.set(key, card);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return [...cards.values()];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The row a card shows: the chosen one, then a selected one, then the first. */
|
|
104
|
+
export function cartOptionActiveRow(card: ICartOptionCard, chosen?: number) {
|
|
105
|
+
return (
|
|
106
|
+
card.rows.find((row) => row.option.id === chosen) ??
|
|
107
|
+
card.rows.find((row) => row.option.quantity > 0) ??
|
|
108
|
+
card.rows[0]
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* True when the group holds what the order needs from it, as the backend
|
|
114
|
+
* checks a required group when the order is placed: text for a text option,
|
|
115
|
+
* a file for a file option, and at least one chosen product otherwise.
|
|
116
|
+
*/
|
|
117
|
+
export function cartOptionGroupFilled(group: ICartOptionGroup) {
|
|
118
|
+
const type = group.option_type?.option_type || '';
|
|
119
|
+
|
|
120
|
+
if (type === 'text' || type === 'textarea') {
|
|
121
|
+
return group.option_text_data.trim() !== '';
|
|
122
|
+
}
|
|
123
|
+
if (type === 'file') {
|
|
124
|
+
return Boolean(group.option_file_data);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return (group.options ?? []).some((option) => option.quantity > 0);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* True when every required option group of every line in the shipments is
|
|
132
|
+
* filled. The backend refuses the order otherwise, so the place-order button
|
|
133
|
+
* waits for it like it waits for the delivery and the payment.
|
|
134
|
+
*/
|
|
135
|
+
export function cartRequiredOptionsFilled(deliveries: ICartDelivery[]) {
|
|
136
|
+
return deliveries.every((delivery) =>
|
|
137
|
+
(delivery.product_items ?? []).every((product) =>
|
|
138
|
+
(product?.option_group ?? []).every(
|
|
139
|
+
(group) => !group.option_group_required || cartOptionGroupFilled(group),
|
|
140
|
+
),
|
|
141
|
+
),
|
|
142
|
+
);
|
|
143
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { ICartItemMutationResponse } from '@/interfaces/basklee/cart/ICartActions';
|
|
2
|
+
import type {
|
|
3
|
+
ICartModalResponse,
|
|
4
|
+
ICartPreviewState,
|
|
5
|
+
} from '@/interfaces/basklee/cart/ICartModal';
|
|
6
|
+
import type { IProduct } from '@/interfaces/basklee/products/IProduct';
|
|
7
|
+
import type { BaskleeApiResponse } from '@/utils/basklee/api';
|
|
8
|
+
|
|
9
|
+
export function cartPreviewState(): ICartPreviewState {
|
|
10
|
+
return {
|
|
11
|
+
open: false,
|
|
12
|
+
pending: false,
|
|
13
|
+
products: [],
|
|
14
|
+
error: '',
|
|
15
|
+
removing: [],
|
|
16
|
+
removeError: '',
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function cartPreviewProducts(
|
|
21
|
+
response: BaskleeApiResponse,
|
|
22
|
+
): IProduct[] {
|
|
23
|
+
const body = response.body as {
|
|
24
|
+
form_errors?: Record<string, unknown> | null;
|
|
25
|
+
success_message?: unknown;
|
|
26
|
+
error?: unknown;
|
|
27
|
+
page_data?: { cart_data?: IProduct[] } | null;
|
|
28
|
+
} | null;
|
|
29
|
+
if (
|
|
30
|
+
response.status < 200 ||
|
|
31
|
+
response.status >= 300 ||
|
|
32
|
+
!body ||
|
|
33
|
+
body.error ||
|
|
34
|
+
body.form_errors !== null ||
|
|
35
|
+
typeof body.success_message !== 'string' ||
|
|
36
|
+
!body.success_message ||
|
|
37
|
+
!Array.isArray(body.page_data?.cart_data) ||
|
|
38
|
+
!body.page_data.cart_data.every(
|
|
39
|
+
(item) => item && typeof item.id === 'number' && item.locale,
|
|
40
|
+
)
|
|
41
|
+
) {
|
|
42
|
+
throw new Error('Invalid cart preview response');
|
|
43
|
+
}
|
|
44
|
+
return body.page_data.cart_data;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// The preview response also carries the header's cart position counter.
|
|
48
|
+
export function cartPreviewCounter(
|
|
49
|
+
response: BaskleeApiResponse,
|
|
50
|
+
): number | undefined {
|
|
51
|
+
const body = response.body as ICartModalResponse | null;
|
|
52
|
+
const count = body?.page_data?.cart?.c_cart_positions;
|
|
53
|
+
|
|
54
|
+
return Number.isInteger(count) ? count : undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// A removal is confirmed only by a successful envelope with the new counter.
|
|
58
|
+
export function cartPreviewRemoval(
|
|
59
|
+
response: BaskleeApiResponse,
|
|
60
|
+
): NonNullable<ICartItemMutationResponse['page_data']> {
|
|
61
|
+
const body = response.body as ICartItemMutationResponse & {
|
|
62
|
+
error?: unknown;
|
|
63
|
+
} | null;
|
|
64
|
+
if (
|
|
65
|
+
response.status < 200 ||
|
|
66
|
+
response.status >= 300 ||
|
|
67
|
+
!body ||
|
|
68
|
+
body.error ||
|
|
69
|
+
body.form_errors !== null ||
|
|
70
|
+
typeof body.success_message !== 'string' ||
|
|
71
|
+
!body.success_message ||
|
|
72
|
+
!Number.isInteger(body.page_data?.c_cart_positions)
|
|
73
|
+
) {
|
|
74
|
+
throw new Error('Invalid cart removal response');
|
|
75
|
+
}
|
|
76
|
+
return body.page_data!;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function cartPreviewLabels(locale: string) {
|
|
80
|
+
if (locale.toLowerCase().startsWith('ru')) {
|
|
81
|
+
return {
|
|
82
|
+
title: 'Корзина',
|
|
83
|
+
quantity: 'Товаров',
|
|
84
|
+
pieces: (count: number) => `${count} шт.`,
|
|
85
|
+
empty: 'В корзине пока нет товаров',
|
|
86
|
+
loading: 'Загрузка корзины…',
|
|
87
|
+
failed: 'Не удалось загрузить корзину. Повторите запрос.',
|
|
88
|
+
unavailable: 'Просмотр корзины недоступен.',
|
|
89
|
+
retry: 'Повторить',
|
|
90
|
+
remove: 'Удалить из корзины',
|
|
91
|
+
removeFailed: 'Не удалось удалить товар. Повторите попытку.',
|
|
92
|
+
checkout: 'Перейти в корзину',
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (locale.toLowerCase().startsWith('es')) {
|
|
96
|
+
return {
|
|
97
|
+
title: 'Carrito',
|
|
98
|
+
quantity: 'Artículos',
|
|
99
|
+
pieces: (count: number) => `Cant. ${count}`,
|
|
100
|
+
empty: 'Tu carrito está vacío',
|
|
101
|
+
loading: 'Cargando el carrito…',
|
|
102
|
+
failed: 'No se ha podido cargar el carrito. Inténtalo de nuevo.',
|
|
103
|
+
unavailable: 'La vista previa del carrito no está disponible.',
|
|
104
|
+
retry: 'Reintentar',
|
|
105
|
+
remove: 'Quitar del carrito',
|
|
106
|
+
removeFailed: 'No se ha podido quitar el artículo. Inténtalo de nuevo.',
|
|
107
|
+
checkout: 'Ir al carrito',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
title: 'Cart',
|
|
112
|
+
quantity: 'Items',
|
|
113
|
+
pieces: (count: number) => `Qty ${count}`,
|
|
114
|
+
empty: 'Your cart is empty',
|
|
115
|
+
loading: 'Loading cart…',
|
|
116
|
+
failed: 'Could not load the cart. Please try again.',
|
|
117
|
+
unavailable: 'Cart preview is unavailable.',
|
|
118
|
+
retry: 'Retry',
|
|
119
|
+
remove: 'Remove from cart',
|
|
120
|
+
removeFailed: 'Could not remove the item. Please try again.',
|
|
121
|
+
checkout: 'Go to cart',
|
|
122
|
+
};
|
|
123
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { ECartPromoNoticeReason } from '@/interfaces/basklee/cart/ICartData';
|
|
2
|
+
import type { ICartPromoNotice } from '@/interfaces/basklee/cart/ICartData';
|
|
3
|
+
import type { IAppLoadCommonCurrency } from '@/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonCurrency';
|
|
4
|
+
import { formatDollarAmount } from '@/utils/basklee/currency';
|
|
5
|
+
import { fieldErrorText } from '@/utils/basklee/api';
|
|
6
|
+
|
|
7
|
+
interface IPromoNoticeLabels {
|
|
8
|
+
promoRemoved: string;
|
|
9
|
+
promoNotApplied: string;
|
|
10
|
+
promoMinimumOrder: string;
|
|
11
|
+
promoMissingAmount: string;
|
|
12
|
+
promoReasons: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** A refused `marketing_promo_promo_apply`: Basklee's text and its notice. */
|
|
16
|
+
export interface ICartPromoRefusal {
|
|
17
|
+
message: string;
|
|
18
|
+
notice: ICartPromoNotice | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** What the cart writes for a promo notice: one sentence each. */
|
|
22
|
+
export interface ICartPromoNoticeText {
|
|
23
|
+
title: string;
|
|
24
|
+
reason: string;
|
|
25
|
+
minimum: string;
|
|
26
|
+
missing: string;
|
|
27
|
+
text: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Reasons about the cart's items. A code with one of them and
|
|
31
|
+
// `is_removed: true` was refused when applied, so it was never in the cart.
|
|
32
|
+
const CART_REASONS = new Set<string>([
|
|
33
|
+
ECartPromoNoticeReason.NO_LINES,
|
|
34
|
+
ECartPromoNoticeReason.NOT_MATCHED,
|
|
35
|
+
ECartPromoNoticeReason.PRODUCT_DISCOUNTED,
|
|
36
|
+
ECartPromoNoticeReason.BELOW_MINIMUM,
|
|
37
|
+
ECartPromoNoticeReason.SUBSCRIPTIONS_ONLY,
|
|
38
|
+
ECartPromoNoticeReason.TOO_SMALL,
|
|
39
|
+
ECartPromoNoticeReason.NOTHING_TO_SHIP,
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The cart's promo notice in the customer's words: the package's own text
|
|
44
|
+
* for a known `reason` (Basklee's `message` otherwise), the code it is about
|
|
45
|
+
* when the cart removed or refused it, and for `below_minimum` the minimum
|
|
46
|
+
* order and the amount still missing. Both are dollar amounts: with
|
|
47
|
+
* `currencies` they read «$ 544 ≈ 40 256 ₽» while another currency is
|
|
48
|
+
* selected. A notice limited to other currencies (`currency_ids`) is not
|
|
49
|
+
* shown.
|
|
50
|
+
*/
|
|
51
|
+
export function cartPromoNotice(
|
|
52
|
+
notice: ICartPromoNotice | null | undefined,
|
|
53
|
+
labels: IPromoNoticeLabels,
|
|
54
|
+
currencyId: string,
|
|
55
|
+
currency: IAppLoadCommonCurrency | undefined,
|
|
56
|
+
locale: string,
|
|
57
|
+
currencies?: Record<string, IAppLoadCommonCurrency> | null,
|
|
58
|
+
): ICartPromoNoticeText | undefined {
|
|
59
|
+
if (!notice?.reason || !cartPromoNoticeShown(notice, currencyId)) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const reason = labels.promoReasons[notice.reason] || notice.message || '';
|
|
64
|
+
const heading = CART_REASONS.has(notice.reason)
|
|
65
|
+
? labels.promoNotApplied
|
|
66
|
+
: labels.promoRemoved;
|
|
67
|
+
const title = !notice.is_removed
|
|
68
|
+
? ''
|
|
69
|
+
: notice.promocode
|
|
70
|
+
? heading.replace('{code}', notice.promocode)
|
|
71
|
+
: heading.replace(' {code}', '');
|
|
72
|
+
const amount = formatDollarAmount(
|
|
73
|
+
notice.minimum_order_amount,
|
|
74
|
+
currencyId,
|
|
75
|
+
currency,
|
|
76
|
+
locale,
|
|
77
|
+
currencies,
|
|
78
|
+
);
|
|
79
|
+
const minimum = amount
|
|
80
|
+
? labels.promoMinimumOrder.replace('{amount}', amount)
|
|
81
|
+
: '';
|
|
82
|
+
const short = hasAmount(notice.missing_amount)
|
|
83
|
+
? formatDollarAmount(
|
|
84
|
+
notice.missing_amount,
|
|
85
|
+
currencyId,
|
|
86
|
+
currency,
|
|
87
|
+
locale,
|
|
88
|
+
currencies,
|
|
89
|
+
)
|
|
90
|
+
: '';
|
|
91
|
+
const missing = short
|
|
92
|
+
? labels.promoMissingAmount.replace('{amount}', short)
|
|
93
|
+
: '';
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
title,
|
|
97
|
+
reason,
|
|
98
|
+
minimum,
|
|
99
|
+
missing,
|
|
100
|
+
text: [title, reason, minimum, missing].filter(Boolean).join(' '),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* `currency_ids` limits a notice to some currencies, for example a fixed
|
|
106
|
+
* code that takes $10 off in dollars and nothing in rubles; `null` or an
|
|
107
|
+
* absent list means every currency.
|
|
108
|
+
*/
|
|
109
|
+
export function cartPromoNoticeShown(
|
|
110
|
+
notice: Pick<ICartPromoNotice, 'currency_ids'>,
|
|
111
|
+
currencyId: string,
|
|
112
|
+
): boolean {
|
|
113
|
+
const ids = notice.currency_ids;
|
|
114
|
+
|
|
115
|
+
return !Array.isArray(ids) || ids.map(String).includes(String(currencyId));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Basklee sends zero in every currency once the minimum is reached.
|
|
119
|
+
function hasAmount(amounts: ICartPromoNotice['missing_amount']): boolean {
|
|
120
|
+
return Object.values(amounts ?? {}).some(
|
|
121
|
+
(amount) => Number(amount?.transform_value) > 0,
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Basklee refuses a promo code with a field error: the code is unknown or no
|
|
127
|
+
* longer valid (`form_errors.promocode`), or it gives this cart nothing
|
|
128
|
+
* (`form_errors.__all__` with `page_data.promo_notice`). Anything else, such
|
|
129
|
+
* as a lost connection, is not a refusal.
|
|
130
|
+
*/
|
|
131
|
+
export function cartPromoRefusal(error: unknown): ICartPromoRefusal | undefined {
|
|
132
|
+
if (!error || typeof error !== 'object' || !('fields' in error)) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const fields = error.fields;
|
|
137
|
+
const message = fields && typeof fields === 'object'
|
|
138
|
+
? fieldErrorText(fields as Record<string, unknown>)
|
|
139
|
+
: '';
|
|
140
|
+
if (!message) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const data = 'data' in error ? error.data : undefined;
|
|
145
|
+
const notice = data && typeof data === 'object' && 'promo_notice' in data
|
|
146
|
+
? (data.promo_notice as ICartPromoNotice | null)
|
|
147
|
+
: null;
|
|
148
|
+
|
|
149
|
+
return { message, notice: notice?.reason ? notice : null };
|
|
150
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { getAvailableNestedValueFromObject } from '@/utils/basklee/presentation';
|
|
2
|
+
import type {
|
|
3
|
+
ICartDelivery,
|
|
4
|
+
ICartStore,
|
|
5
|
+
} from '@/interfaces/basklee/cart/ICartData';
|
|
6
|
+
|
|
7
|
+
export interface ICartShipmentOrigin {
|
|
8
|
+
digital: boolean;
|
|
9
|
+
name: string;
|
|
10
|
+
address: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface IShipmentLabels {
|
|
14
|
+
shipment: string;
|
|
15
|
+
of: string;
|
|
16
|
+
splitShipments: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
* At checkout the cart splits its items into delivery groups, one per store
|
|
21
|
+
* that holds them. `from_store` names that store; a store with
|
|
22
|
+
* `virtual_goods` holds digital items, which need no delivery method.
|
|
23
|
+
*/
|
|
24
|
+
export function cartShipmentOrigin(
|
|
25
|
+
store: ICartStore | null | undefined,
|
|
26
|
+
locale: string,
|
|
27
|
+
): ICartShipmentOrigin | undefined {
|
|
28
|
+
if (!store) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const city = getAvailableNestedValueFromObject(
|
|
33
|
+
store.locale,
|
|
34
|
+
locale,
|
|
35
|
+
'store_city',
|
|
36
|
+
);
|
|
37
|
+
const street = [store.line1, store.house_number]
|
|
38
|
+
.filter(Boolean)
|
|
39
|
+
.join(' ');
|
|
40
|
+
const address = [city, street, store.line2, store.postcode]
|
|
41
|
+
.filter(Boolean)
|
|
42
|
+
.join(', ');
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
digital: store.virtual_goods === true,
|
|
46
|
+
name: store.store_name || `#${store.id}`,
|
|
47
|
+
address: store.virtual_goods ? '' : address,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** “Shipment 2 of 3”, or an empty string when there is one group. */
|
|
52
|
+
export function cartShipmentTitle(
|
|
53
|
+
index: number,
|
|
54
|
+
total: number,
|
|
55
|
+
labels: IShipmentLabels,
|
|
56
|
+
) {
|
|
57
|
+
if (total < 2) {
|
|
58
|
+
return '';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return `${labels.shipment} ${index + 1} ${labels.of} ${total}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The line above split groups, or an empty string for one group. */
|
|
65
|
+
export function cartSplitNotice(
|
|
66
|
+
deliveries: ICartDelivery[],
|
|
67
|
+
labels: IShipmentLabels,
|
|
68
|
+
) {
|
|
69
|
+
const total = deliveries.length;
|
|
70
|
+
|
|
71
|
+
return total > 1
|
|
72
|
+
? labels.splitShipments.replace('{count}', String(total))
|
|
73
|
+
: '';
|
|
74
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ECartState } from '@/interfaces/basklee/cart/ICartActions';
|
|
2
|
+
import type { IProduct } from '@/interfaces/basklee/products/IProduct';
|
|
3
|
+
import type {
|
|
4
|
+
ICartDelivery,
|
|
5
|
+
ICartGetResponse,
|
|
6
|
+
} from '@/interfaces/basklee/cart/ICartData';
|
|
7
|
+
|
|
8
|
+
export function cartSnapshotProducts(
|
|
9
|
+
data: NonNullable<ICartGetResponse['page_data']>,
|
|
10
|
+
) {
|
|
11
|
+
const products =
|
|
12
|
+
data.cart.state === ECartState.STATE_CHECKOUT
|
|
13
|
+
? (data.cart_data as ICartDelivery[]).flatMap((delivery) =>
|
|
14
|
+
delivery.product_items.filter(
|
|
15
|
+
(item): item is NonNullable<typeof item> => item !== null,
|
|
16
|
+
),
|
|
17
|
+
)
|
|
18
|
+
: (data.cart_data as IProduct[]);
|
|
19
|
+
return [...products, ...(data.will_not_ship ?? [])];
|
|
20
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { ICategory } from '@/interfaces/basklee/category/ICategory';
|
|
2
|
+
import type { IProduct } from '@/interfaces/basklee/products/IProduct';
|
|
3
|
+
|
|
4
|
+
export function publicCatalogCategories(categories: ICategory[] = []) {
|
|
5
|
+
return categories.filter((category) => category.is_public);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function navigationCatalogCategories(
|
|
9
|
+
categories: ICategory[] = [],
|
|
10
|
+
): ICategory[] {
|
|
11
|
+
return publicCatalogCategories(categories).filter(
|
|
12
|
+
(category) => !category.exclude_from_tree,
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function findNavigationCategory(
|
|
17
|
+
categories: ICategory[],
|
|
18
|
+
id: number,
|
|
19
|
+
): ICategory | undefined {
|
|
20
|
+
for (const category of navigationCatalogCategories(categories)) {
|
|
21
|
+
if (category.id === id) {
|
|
22
|
+
return category;
|
|
23
|
+
}
|
|
24
|
+
const child = findNavigationCategory(category.childs ?? [], id);
|
|
25
|
+
if (child) {
|
|
26
|
+
return child;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function findCatalogCategory(
|
|
32
|
+
categories: ICategory[],
|
|
33
|
+
id: number,
|
|
34
|
+
): ICategory | undefined {
|
|
35
|
+
for (const category of publicCatalogCategories(categories)) {
|
|
36
|
+
if (category.id === id) {
|
|
37
|
+
return category;
|
|
38
|
+
}
|
|
39
|
+
const child = findCatalogCategory(category.childs ?? [], id);
|
|
40
|
+
if (child) {
|
|
41
|
+
return child;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function catalogCategoryTrail(categories: ICategory[], ids: number[]) {
|
|
47
|
+
const trail: ICategory[] = [];
|
|
48
|
+
let children = navigationCatalogCategories(categories);
|
|
49
|
+
for (const id of ids) {
|
|
50
|
+
const category = children.find((item) => item.id === id);
|
|
51
|
+
if (!category) {
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
trail.push(category);
|
|
55
|
+
children = navigationCatalogCategories(category.childs);
|
|
56
|
+
}
|
|
57
|
+
return trail;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The shown categories from a root down to `id`; empty when `id` is not shown. */
|
|
61
|
+
export function catalogCategoryPath(
|
|
62
|
+
categories: ICategory[],
|
|
63
|
+
id: number,
|
|
64
|
+
): ICategory[] {
|
|
65
|
+
for (const category of navigationCatalogCategories(categories)) {
|
|
66
|
+
if (category.id === id) {
|
|
67
|
+
return [category];
|
|
68
|
+
}
|
|
69
|
+
const path = catalogCategoryPath(category.childs ?? [], id);
|
|
70
|
+
if (path.length) {
|
|
71
|
+
return [category, ...path];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface CatalogProductReference {
|
|
78
|
+
product: IProduct;
|
|
79
|
+
collection: 'products' | 'featured';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function catalogRepresentatives(
|
|
83
|
+
category: ICategory | undefined,
|
|
84
|
+
products: IProduct[],
|
|
85
|
+
featured: IProduct[],
|
|
86
|
+
): CatalogProductReference[] {
|
|
87
|
+
const ids = [
|
|
88
|
+
...new Set([category?.product_rep_1_id, category?.product_rep_2_id]),
|
|
89
|
+
];
|
|
90
|
+
const result: CatalogProductReference[] = [];
|
|
91
|
+
for (const id of ids) {
|
|
92
|
+
if (typeof id !== 'number') {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const product = products.find((item) => item.id === id);
|
|
96
|
+
if (product) {
|
|
97
|
+
result.push({ product, collection: 'products' });
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const fallback = featured.find((item) => item.id === id);
|
|
101
|
+
if (fallback) {
|
|
102
|
+
result.push({ product: fallback, collection: 'featured' });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { cloneSearchFilters } from '@/utils/basklee/searchFilters';
|
|
2
|
+
import type { ICategory } from '@/interfaces/basklee/category/ICategory';
|
|
3
|
+
import type { IProductPagination } from '@/interfaces/basklee/products/IProduct';
|
|
4
|
+
import type { ProductFacetSelection } from '@/interfaces/basklee/products/IProductSearchFacets';
|
|
5
|
+
import { publicCatalogCategories } from '@/utils/basklee/catalog';
|
|
6
|
+
|
|
7
|
+
export function categoryTrail(
|
|
8
|
+
categories: ICategory[],
|
|
9
|
+
id: number,
|
|
10
|
+
): ICategory[] {
|
|
11
|
+
for (const category of publicCatalogCategories(categories)) {
|
|
12
|
+
if (category.id === id) {
|
|
13
|
+
return [category];
|
|
14
|
+
}
|
|
15
|
+
const children = categoryTrail(category.childs ?? [], id);
|
|
16
|
+
if (children.length) {
|
|
17
|
+
return [category, ...children];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function categoryBranchIds(category: ICategory): number[] {
|
|
24
|
+
return [
|
|
25
|
+
category.id,
|
|
26
|
+
...publicCatalogCategories(category.childs).flatMap(categoryBranchIds),
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function categorySearchRequest(
|
|
31
|
+
category: ICategory,
|
|
32
|
+
filters: ProductFacetSelection,
|
|
33
|
+
page: number,
|
|
34
|
+
) {
|
|
35
|
+
const selected = cloneSearchFilters(filters);
|
|
36
|
+
return {
|
|
37
|
+
filters: { ...selected, categories: categoryBranchIds(category) },
|
|
38
|
+
paginate: { page, pp_items: 12 },
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function mergeCategoryPagination(
|
|
43
|
+
previous: IProductPagination,
|
|
44
|
+
incoming: IProductPagination = {},
|
|
45
|
+
): IProductPagination {
|
|
46
|
+
return {
|
|
47
|
+
...previous,
|
|
48
|
+
...Object.fromEntries(
|
|
49
|
+
Object.entries(incoming).filter(([, value]) => value !== undefined),
|
|
50
|
+
),
|
|
51
|
+
};
|
|
52
|
+
}
|