@revenexx/cover 0.1.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 +39 -0
- package/app/api/account.ts +8 -0
- package/app/api/categories.ts +3 -0
- package/app/api/checkout.ts +6 -0
- package/app/api/images.ts +4 -0
- package/app/api/markets.ts +3 -0
- package/app/api/product.ts +3 -0
- package/app/api/products.ts +4 -0
- package/app/api/search.ts +4 -0
- package/app/app.config.ts +29 -0
- package/app/assets/css/cover.css +25 -0
- package/app/components/account/AccountMenu.vue +30 -0
- package/app/components/account/AccountShell.vue +18 -0
- package/app/components/account/AccountSidebar.vue +90 -0
- package/app/components/account/address/AccountAddressCard.vue +287 -0
- package/app/components/account/carts/AccountCartsTable.vue +284 -0
- package/app/components/account/dashboard/AccountDashboard.vue +351 -0
- package/app/components/account/directorder/AccountDirectOrder.vue +512 -0
- package/app/components/account/governance/AccountApprovalLimitsTable.vue +221 -0
- package/app/components/account/governance/AccountCostCenterDetail.vue +276 -0
- package/app/components/account/governance/AccountCostCentersTable.vue +252 -0
- package/app/components/account/governance/AccountRequisitionDetail.vue +295 -0
- package/app/components/account/governance/AccountRequisitionsTable.vue +255 -0
- package/app/components/account/governance/AccountWorkflowDetail.vue +215 -0
- package/app/components/account/governance/AccountWorkflowsTable.vue +168 -0
- package/app/components/account/governance/GovernanceApprovalLimitModal.vue +183 -0
- package/app/components/account/governance/GovernanceCostCenterModal.vue +188 -0
- package/app/components/account/governance/GovernanceWorkflowModal.vue +191 -0
- package/app/components/account/orderlists/AccountOrderListDetail.vue +349 -0
- package/app/components/account/orderlists/AccountOrderListsTable.vue +352 -0
- package/app/components/account/orders/AccountOrderDetail.vue +376 -0
- package/app/components/account/orders/AccountOrdersTable.vue +281 -0
- package/app/components/account/preferences/AccountPreferences.vue +50 -0
- package/app/components/auth/AuthForgotPasswordPanel.vue +88 -0
- package/app/components/auth/AuthLoginPanel.vue +103 -0
- package/app/components/auth/AuthLoginTeaser.vue +24 -0
- package/app/components/auth/AuthPageHeader.vue +21 -0
- package/app/components/auth/AuthRegisterPanel.vue +431 -0
- package/app/components/auth/AuthRegisterTeaser.vue +24 -0
- package/app/components/auth/AuthResetPasswordPanel.vue +115 -0
- package/app/components/cart/CartButton.vue +42 -0
- package/app/components/cart/actions/CartCostCenterModal.vue +110 -0
- package/app/components/cart/actions/CartExportModal.vue +82 -0
- package/app/components/cart/actions/CartPositionTextsModal.vue +92 -0
- package/app/components/cart/actions/CartSaveToListModal.vue +177 -0
- package/app/components/cart/actions/CartWorkflowPickerModal.vue +64 -0
- package/app/components/cart/drawer/CartDrawer.vue +49 -0
- package/app/components/cart/item/CartItem.vue +318 -0
- package/app/components/cart/manage/CartNameModal.vue +68 -0
- package/app/components/cart/position/CartPosition.vue +369 -0
- package/app/components/cart/quickadd/CartQuickAdd.vue +145 -0
- package/app/components/cart/recommend/CartCrossSell.vue +102 -0
- package/app/components/cart/recommend/CartRecommendCard.vue +59 -0
- package/app/components/cart/recommend/CartReorderStrip.vue +108 -0
- package/app/components/cart/requisition/CartRequisitionGroup.vue +74 -0
- package/app/components/cart/skeleton/CartSkeleton.vue +18 -0
- package/app/components/cart/summary/CartSummary.vue +25 -0
- package/app/components/cart/summary/CartSummaryBreakdown.vue +35 -0
- package/app/components/cart/switcher/CartSwitcher.vue +147 -0
- package/app/components/cart/target/CartTargetModal.vue +129 -0
- package/app/components/cart/view/CartApprovalsPanel.vue +89 -0
- package/app/components/cart/view/CartListHeader.vue +86 -0
- package/app/components/cart/view/CartPositionList.vue +94 -0
- package/app/components/cart/view/CartSummaryPanel.vue +254 -0
- package/app/components/cart/view/CartView.vue +310 -0
- package/app/components/category/info/CategoryPrice.vue +47 -0
- package/app/components/category/info/CategorySku.vue +15 -0
- package/app/components/category/info/CategoryStock.vue +25 -0
- package/app/components/category/list/CategoryItemCount.vue +27 -0
- package/app/components/category/list/CategoryListPagination.vue +81 -0
- package/app/components/category/skeleton/CategoryDetailSkeleton.vue +12 -0
- package/app/components/category/skeleton/CategoryListSkeleton.vue +65 -0
- package/app/components/category/view/CategoryViewToggle.vue +33 -0
- package/app/components/category/view/GridView.vue +78 -0
- package/app/components/category/view/ListView.vue +80 -0
- package/app/components/checkout/confirmation/CheckoutConfirmationView.vue +289 -0
- package/app/components/checkout/form/CheckoutSchemaForm.vue +72 -0
- package/app/components/checkout/onepage/CheckoutAddressPickerModal.vue +260 -0
- package/app/components/checkout/onepage/CheckoutAddressSection.vue +186 -0
- package/app/components/checkout/onepage/CheckoutDeliverySection.vue +158 -0
- package/app/components/checkout/onepage/CheckoutGate.vue +67 -0
- package/app/components/checkout/onepage/CheckoutGuestDetailsSection.vue +154 -0
- package/app/components/checkout/onepage/CheckoutNotesSection.vue +62 -0
- package/app/components/checkout/onepage/CheckoutOnePageView.vue +77 -0
- package/app/components/checkout/onepage/CheckoutPaymentSection.vue +181 -0
- package/app/components/checkout/onepage/CheckoutSectionTitle.vue +18 -0
- package/app/components/checkout/onepage/CheckoutSummarySection.vue +211 -0
- package/app/components/checkout/onepage/CheckoutWorkflowPanel.vue +38 -0
- package/app/components/layout/AppLogo.vue +21 -0
- package/app/components/layout/footer/Footer.vue +148 -0
- package/app/components/layout/header/AppBar.vue +75 -0
- package/app/components/layout/header/CategoryNav.vue +93 -0
- package/app/components/layout/header/HeaderActionItem.vue +81 -0
- package/app/components/layout/header/LocaleSwitcher.vue +123 -0
- package/app/components/layout/header/MainNav.vue +61 -0
- package/app/components/layout/header/MobileMenu.vue +81 -0
- package/app/components/layout/header/TopBar.vue +63 -0
- package/app/components/listing/ListingView.vue +227 -0
- package/app/components/product/detail/ProductDetailAddToCart.vue +188 -0
- package/app/components/product/detail/ProductDetailDescription.vue +20 -0
- package/app/components/product/detail/ProductDetailImageGallery.vue +58 -0
- package/app/components/product/detail/ProductDetailPricing.vue +108 -0
- package/app/components/product/detail/ProductDetailSaveToList.vue +291 -0
- package/app/components/product/detail/ProductDetailSpecifications.vue +33 -0
- package/app/components/product/detail/ProductDetailStock.vue +36 -0
- package/app/components/search/filter/SearchFacets.vue +256 -0
- package/app/components/search/filter/SearchFacetsDrawer.vue +58 -0
- package/app/components/ui/AppShell.vue +7 -0
- package/app/components/ui/debug/PiniaStateCard.vue +106 -0
- package/app/components/ui/feedback/EmptyState.vue +30 -0
- package/app/components/ui/feedback/ErrorBoundary.vue +44 -0
- package/app/components/ui/feedback/NotFound.vue +34 -0
- package/app/components/ui/forms/CountrySelection.vue +14 -0
- package/app/components/ui/forms/FormKitDatePicker.vue +124 -0
- package/app/components/ui/forms/PasswordInput.vue +136 -0
- package/app/components/ui/forms/SearchInput.vue +213 -0
- package/app/components/ui/table/TableSortButton.vue +51 -0
- package/app/components/ui/table/TableToolbar.vue +66 -0
- package/app/composables/useAccount.ts +27 -0
- package/app/composables/useAccountAddresses.ts +116 -0
- package/app/composables/useAccountOrders.ts +18 -0
- package/app/composables/useAppUrl.ts +38 -0
- package/app/composables/useAuthStore.ts +202 -0
- package/app/composables/useB2BContext.ts +23 -0
- package/app/composables/useCartActions.ts +25 -0
- package/app/composables/useCartCalculation.ts +90 -0
- package/app/composables/useCartSelection.ts +46 -0
- package/app/composables/useCartStore.ts +837 -0
- package/app/composables/useCartSummaryFormatting.ts +28 -0
- package/app/composables/useCategories.ts +29 -0
- package/app/composables/useCheckoutOnePage.ts +438 -0
- package/app/composables/useCheckoutProfileSource.ts +8 -0
- package/app/composables/useCheckoutSchema.ts +28 -0
- package/app/composables/useDataTable.ts +14 -0
- package/app/composables/useFormValidation.ts +29 -0
- package/app/composables/useIcons.ts +17 -0
- package/app/composables/useLocalePreferences.ts +45 -0
- package/app/composables/useMarkets.ts +15 -0
- package/app/composables/useProduct.ts +89 -0
- package/app/composables/useProductCard.ts +8 -0
- package/app/composables/useProductCardActions.ts +106 -0
- package/app/composables/useProductImage.ts +12 -0
- package/app/composables/useProductListing.ts +210 -0
- package/app/composables/useProductUrl.ts +17 -0
- package/app/composables/useProducts.ts +130 -0
- package/app/composables/useSearch.ts +12 -0
- package/app/composables/useThemeStore.ts +81 -0
- package/app/composables/useViewMode.ts +18 -0
- package/app/config/countries.ts +74 -0
- package/app/config/icons.ts +283 -0
- package/app/config/navigation.ts +191 -0
- package/app/config/palette.ts +13 -0
- package/app/config/themes.ts +20 -0
- package/app/formkit.config.ts +50 -0
- package/app/interfaces/account/address-list.ts +34 -0
- package/app/interfaces/account/order-list.ts +47 -0
- package/app/interfaces/account/order-lists.ts +35 -0
- package/app/interfaces/account/profile.ts +17 -0
- package/app/interfaces/account.ts +3 -0
- package/app/interfaces/address.ts +9 -0
- package/app/interfaces/auth.ts +104 -0
- package/app/interfaces/b2b.ts +234 -0
- package/app/interfaces/cart-calculation.ts +131 -0
- package/app/interfaces/cart-item.ts +45 -0
- package/app/interfaces/checkout-draft.ts +4 -0
- package/app/interfaces/checkout.ts +43 -0
- package/app/interfaces/delivery.ts +13 -0
- package/app/interfaces/market.ts +24 -0
- package/app/interfaces/payment.ts +19 -0
- package/app/interfaces/persisted-cart.ts +10 -0
- package/app/interfaces/product-detail.ts +54 -0
- package/app/interfaces/product-list.ts +33 -0
- package/app/interfaces/search-facets.ts +14 -0
- package/app/interfaces/validation.ts +14 -0
- package/app/layouts/default.vue +78 -0
- package/app/layouts/focus.vue +80 -0
- package/app/plugins/formkit-locale.client.ts +23 -0
- package/app/shared/constants.ts +1 -0
- package/app/validations/companyName.ts +18 -0
- package/app/validations/emailFormat.ts +10 -0
- package/app/validations/formValidationConfig.ts +50 -0
- package/app/validations/maxLength.ts +12 -0
- package/app/validations/minLength.ts +9 -0
- package/app/validations/optionalCompanyName.ts +23 -0
- package/app/validations/passwordsMatch.ts +5 -0
- package/app/validations/phoneNumber.ts +19 -0
- package/app/validations/required.ts +11 -0
- package/app/validations/termsRequired.ts +4 -0
- package/app/validations/types.ts +10 -0
- package/app/validations/zipCode.ts +15 -0
- package/i18n/locales/de/account.json +458 -0
- package/i18n/locales/de/auth.json +155 -0
- package/i18n/locales/de/cart.json +263 -0
- package/i18n/locales/de/checkout.json +217 -0
- package/i18n/locales/de/common.json +80 -0
- package/i18n/locales/de/cover.json +33 -0
- package/i18n/locales/de/order.json +1 -0
- package/i18n/locales/de/product.json +71 -0
- package/i18n/locales/de/search.json +54 -0
- package/i18n/locales/de/validation.json +12 -0
- package/i18n/locales/en/account.json +458 -0
- package/i18n/locales/en/auth.json +155 -0
- package/i18n/locales/en/cart.json +263 -0
- package/i18n/locales/en/checkout.json +217 -0
- package/i18n/locales/en/common.json +80 -0
- package/i18n/locales/en/cover.json +33 -0
- package/i18n/locales/en/order.json +1 -0
- package/i18n/locales/en/product.json +71 -0
- package/i18n/locales/en/search.json +54 -0
- package/i18n/locales/en/validation.json +12 -0
- package/nuxt.config.ts +109 -0
- package/package.json +65 -0
- package/public/img/product-placeholder.svg +8 -0
- package/public/templates/direct-order-template.csv +3 -0
- package/public/templates/direct-order-template.xlsx +0 -0
- package/server/api/account/address/[id].delete.ts +51 -0
- package/server/api/account/address/[id].put.ts +83 -0
- package/server/api/account/address/index.post.ts +60 -0
- package/server/api/account/addresses.get.ts +25 -0
- package/server/api/account/context.get.ts +16 -0
- package/server/api/account/governance/[domain]/[id].put.ts +57 -0
- package/server/api/account/governance/[domain].post.ts +111 -0
- package/server/api/account/order-lists/[id].delete.ts +22 -0
- package/server/api/account/order-lists/[id].get.ts +17 -0
- package/server/api/account/order-lists/[id].put.ts +46 -0
- package/server/api/account/order-lists/index.get.ts +14 -0
- package/server/api/account/order-lists/index.post.ts +38 -0
- package/server/api/account/orders/[id].get.ts +35 -0
- package/server/api/account/orders.get.ts +35 -0
- package/server/api/account/profile.get.ts +56 -0
- package/server/api/account/profile.put.ts +128 -0
- package/server/api/account/requisitions/[id].get.ts +15 -0
- package/server/api/account/requisitions.get.ts +23 -0
- package/server/api/auth/login.post.ts +37 -0
- package/server/api/auth/logout.post.ts +4 -0
- package/server/api/auth/me.get.ts +3 -0
- package/server/api/auth/personas.get.ts +7 -0
- package/server/api/auth/recovery.post.ts +32 -0
- package/server/api/auth/recovery.put.ts +37 -0
- package/server/api/auth/register.post.ts +126 -0
- package/server/api/cart/calculate.post.ts +25 -0
- package/server/api/cart/export.post.ts +81 -0
- package/server/api/cart/index.delete.ts +10 -0
- package/server/api/cart/index.get.ts +10 -0
- package/server/api/cart/sync.post.ts +14 -0
- package/server/api/carts/[id]/activate.post.ts +18 -0
- package/server/api/carts/[id]/index.delete.ts +18 -0
- package/server/api/carts/[id]/index.put.ts +19 -0
- package/server/api/carts/[id]/items.post.ts +21 -0
- package/server/api/carts/index.get.ts +14 -0
- package/server/api/carts/index.post.ts +14 -0
- package/server/api/categories/[slug].get.ts +22 -0
- package/server/api/categories/index.get.ts +11 -0
- package/server/api/checkout/profile.get.ts +21 -0
- package/server/api/checkout/schema/[key].get.ts +19 -0
- package/server/api/checkout/session.post.ts +8 -0
- package/server/api/images/detail/[filename].get.ts +18 -0
- package/server/api/images/list/[filename].get.ts +17 -0
- package/server/api/markets.get.ts +9 -0
- package/server/api/orders/index.post.ts +376 -0
- package/server/api/payment/methods.post.ts +65 -0
- package/server/api/product/[id].get.ts +29 -0
- package/server/api/products/[id].get.ts +30 -0
- package/server/api/products/index.get.ts +21 -0
- package/server/api/requisitions/index.post.ts +67 -0
- package/server/api/shipping/rates.post.ts +70 -0
- package/server/api/themes/index.get.ts +9 -0
- package/server/api/typesense/drop.get.ts +22 -0
- package/server/api/typesense/health.get.ts +9 -0
- package/server/api/typesense/search.post.ts +199 -0
- package/server/api/typesense/seed.get.ts +112 -0
- package/server/api/typesense/suggest.post.ts +69 -0
- package/server/config/account/organization.json +146 -0
- package/server/config/account/personas.json +169 -0
- package/server/config/account/user.json +8 -0
- package/server/config/account/workflows.json +19 -0
- package/server/data/account/address-list.json +103 -0
- package/server/data/account/order-list.json +491 -0
- package/server/data/account/order-lists.json +149 -0
- package/server/data/account/profile.json +9 -0
- package/server/data/account/registration-requests.json +3 -0
- package/server/data/account/requisitions.json +686 -0
- package/server/data/categories.json +186 -0
- package/server/data/forms/checkout/add-address.json +24 -0
- package/server/data/list/5137-1.png +0 -0
- package/server/data/list/5498-1.png +0 -0
- package/server/data/list/5498-2.png +0 -0
- package/server/data/list/5498-3.png +0 -0
- package/server/data/list/5498-4.png +0 -0
- package/server/data/list/5498-5.png +0 -0
- package/server/data/list/5498-6.png +0 -0
- package/server/data/list/5519-1.png +0 -0
- package/server/data/list/5713-1.png +0 -0
- package/server/data/list/5789-1.png +0 -0
- package/server/data/list/5930-1.png +0 -0
- package/server/data/list/6127-1.png +0 -0
- package/server/data/list/6234-1.png +0 -0
- package/server/data/list/6238-1.png +0 -0
- package/server/data/list/6246-1.png +0 -0
- package/server/data/list/6270-1.png +0 -0
- package/server/data/list/6330-1.png +0 -0
- package/server/data/list/6336-1.png +0 -0
- package/server/data/list/6360-1.png +0 -0
- package/server/data/list/6363-1.png +0 -0
- package/server/data/list/6375-1.png +0 -0
- package/server/data/list/6385-1.png +0 -0
- package/server/data/list/6413-1.png +0 -0
- package/server/data/list/6418-1.png +0 -0
- package/server/data/list/6465-1.png +0 -0
- package/server/data/list/6477-1.png +0 -0
- package/server/data/list/6509-1.png +0 -0
- package/server/data/list/6545-1.png +0 -0
- package/server/data/list/6548-1.png +0 -0
- package/server/data/list/6566-1.png +0 -0
- package/server/data/list/6581-1.png +0 -0
- package/server/data/list/6609-1.png +0 -0
- package/server/data/list/6611-1.png +0 -0
- package/server/data/list/6641-1.png +0 -0
- package/server/data/list/6659-1.png +0 -0
- package/server/data/list/6662-1.png +0 -0
- package/server/data/list/6689-1.png +0 -0
- package/server/data/list/6698-1.png +0 -0
- package/server/data/list/6701-1.png +0 -0
- package/server/data/list/6752-1.png +0 -0
- package/server/data/list/6755-1.png +0 -0
- package/server/data/list/6837-1.png +0 -0
- package/server/data/list/6841-1.png +0 -0
- package/server/data/list/6844-1.png +0 -0
- package/server/data/list/6846-1.png +0 -0
- package/server/data/list/6886-1.png +0 -0
- package/server/data/list/6895-1.png +0 -0
- package/server/data/list/6897-1.png +0 -0
- package/server/data/list/6919-1.png +0 -0
- package/server/data/list/6977-1.png +0 -0
- package/server/data/list/6983-1.png +0 -0
- package/server/data/list/6984-1.png +0 -0
- package/server/data/list/6985-1.png +0 -0
- package/server/data/list/6986-1.png +0 -0
- package/server/data/list/6989-1.png +0 -0
- package/server/data/list/6995-1.png +0 -0
- package/server/data/list/6998-1.png +0 -0
- package/server/data/markets.json +24 -0
- package/server/data/product-detail.json +2450 -0
- package/server/data/product-list.json +2450 -0
- package/server/data/themes.json +8 -0
- package/server/interfaces/account.ts +20 -0
- package/server/interfaces/auth.ts +32 -0
- package/server/interfaces/b2bContext.ts +23 -0
- package/server/interfaces/cart.ts +46 -0
- package/server/interfaces/cartCalculation.ts +17 -0
- package/server/interfaces/category.ts +12 -0
- package/server/interfaces/checkoutProfile.ts +5 -0
- package/server/interfaces/log.ts +3 -0
- package/server/interfaces/market.ts +10 -0
- package/server/interfaces/product.ts +21 -0
- package/server/interfaces/schema.ts +20 -0
- package/server/interfaces/theme.ts +10 -0
- package/server/services/ApiAuthService.ts +138 -0
- package/server/services/ApiCartService.ts +254 -0
- package/server/services/ApiCategoryService.ts +25 -0
- package/server/services/ApiMarketService.ts +71 -0
- package/server/services/ApiProductService.ts +53 -0
- package/server/services/LocalFileCategoryService.ts +23 -0
- package/server/services/LocalFileCheckoutProfileService.ts +117 -0
- package/server/services/LocalFileProductService.ts +128 -0
- package/server/services/LocalFileSchemaService.ts +70 -0
- package/server/services/LocalFileThemeService.ts +18 -0
- package/server/services/LogService.ts +28 -0
- package/server/services/MockAccountService.ts +58 -0
- package/server/services/MockAuthService.ts +105 -0
- package/server/services/MockB2BContextService.ts +149 -0
- package/server/services/MockCartCalculationService.ts +395 -0
- package/server/services/MockMarketService.ts +18 -0
- package/server/services/SdkAccountService.ts +56 -0
- package/server/services/SdkAuthService.ts +83 -0
- package/server/services/SessionCartService.ts +31 -0
- package/server/utils/accountService.ts +30 -0
- package/server/utils/authCookie.ts +13 -0
- package/server/utils/authService.ts +43 -0
- package/server/utils/b2bService.ts +49 -0
- package/server/utils/cartService.ts +59 -0
- package/server/utils/categoryService.ts +19 -0
- package/server/utils/checkoutProfileService.ts +9 -0
- package/server/utils/checkoutSession.ts +38 -0
- package/server/utils/coverData.ts +84 -0
- package/server/utils/governanceStore.ts +38 -0
- package/server/utils/i18n.ts +76 -0
- package/server/utils/inventoryService.ts +14 -0
- package/server/utils/liveCatalog.ts +234 -0
- package/server/utils/liveInventories.ts +76 -0
- package/server/utils/liveOrders.ts +139 -0
- package/server/utils/livePrices.ts +93 -0
- package/server/utils/locale.ts +39 -0
- package/server/utils/logService.ts +19 -0
- package/server/utils/marketService.ts +24 -0
- package/server/utils/orderService.ts +14 -0
- package/server/utils/paymentService.ts +14 -0
- package/server/utils/priceService.ts +14 -0
- package/server/utils/productService.ts +28 -0
- package/server/utils/productsSchema.ts +30 -0
- package/server/utils/revenexxApi.ts +136 -0
- package/server/utils/schemaService.ts +25 -0
- package/server/utils/serviceMode.ts +70 -0
- package/server/utils/shippingService.ts +14 -0
- package/server/utils/shopSdk.ts +88 -0
- package/server/utils/themeService.ts +16 -0
- package/server/utils/typesense.ts +27 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { slugify } from "../../../composables/useProducts";
|
|
3
|
+
import type { CalculatedCartLine } from "../../../interfaces/cart-calculation";
|
|
4
|
+
import type { CartItem } from "../../../interfaces/cart-item";
|
|
5
|
+
import { CART_MAX_QUANTITY } from "../../../interfaces/cart-item";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Full cart position (Cart 2.0): selector, drag handle, article identity,
|
|
9
|
+
* cost center, position texts, quantity, availability, calculated pricing
|
|
10
|
+
* and the position function bar. The compact variant for the mini-cart
|
|
11
|
+
* drawer remains in cart/item/CartItem.vue.
|
|
12
|
+
*/
|
|
13
|
+
const props = defineProps<{
|
|
14
|
+
item: CartItem;
|
|
15
|
+
line: CalculatedCartLine | null;
|
|
16
|
+
/** Hide selector/drag/functions (read-only display, e.g. checkout). */
|
|
17
|
+
readonly?: boolean;
|
|
18
|
+
}>();
|
|
19
|
+
|
|
20
|
+
const { icon } = useIcons();
|
|
21
|
+
const { t } = useI18n();
|
|
22
|
+
const { getImage } = useProductImage();
|
|
23
|
+
const localePath = useLocalePath();
|
|
24
|
+
const cart = useCartStore();
|
|
25
|
+
const selection = useCartSelection();
|
|
26
|
+
const actions = useCartActions();
|
|
27
|
+
const { settings, costCenterById, role } = useB2BContext();
|
|
28
|
+
const { formatCurrency } = useCartSummaryFormatting();
|
|
29
|
+
|
|
30
|
+
const lineKey = computed(() => cart.keyOf(props.item));
|
|
31
|
+
|
|
32
|
+
const detailUrl = computed(() => {
|
|
33
|
+
if (!props.item.categorySlug || !props.item.subcategorySlug) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return localePath(
|
|
37
|
+
`/category/${props.item.categorySlug}/${props.item.subcategorySlug}/product/${slugify(props.item)}`,
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const showCostCenter = computed(() =>
|
|
42
|
+
Boolean(role.value) && settings.value?.costCenters.enabled,
|
|
43
|
+
);
|
|
44
|
+
const costCenterLabel = computed(() => {
|
|
45
|
+
const cc = props.item.costCenterId
|
|
46
|
+
? costCenterById.value.get(props.item.costCenterId)
|
|
47
|
+
: undefined;
|
|
48
|
+
return cc ? `${cc.code} · ${cc.label}` : "–";
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const availability = computed(() => props.line?.availability ?? null);
|
|
52
|
+
const availabilityColor = computed(() => {
|
|
53
|
+
switch (availability.value?.state) {
|
|
54
|
+
case "in-stock": return "bg-success";
|
|
55
|
+
case "partial": return "bg-warning";
|
|
56
|
+
default: return "bg-error";
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
/* ---- quantity ---------------------------------------------------- */
|
|
61
|
+
const inputValue = ref(String(props.item.quantity));
|
|
62
|
+
watch(() => props.item.quantity, (val) => {
|
|
63
|
+
inputValue.value = String(val);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
function applyQuantity(next: number): void {
|
|
67
|
+
const clamped = Math.min(Math.max(next, 1), props.item.maxOrderQuantity ?? CART_MAX_QUANTITY);
|
|
68
|
+
cart.updateQuantityByKey(lineKey.value, clamped);
|
|
69
|
+
inputValue.value = String(clamped);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function onQuantityInput(event: Event): void {
|
|
73
|
+
const input = event.target as HTMLInputElement;
|
|
74
|
+
inputValue.value = input.value.replace(/[^0-9]/g, "").slice(0, 6);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function commitInput(): void {
|
|
78
|
+
const parsed = parseInt(inputValue.value, 10);
|
|
79
|
+
if (!parsed || parsed < 1) {
|
|
80
|
+
inputValue.value = String(props.item.quantity);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
applyQuantity(parsed);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const hintColor = (type: string) =>
|
|
87
|
+
type === "missing-cost-center" ? "warning" as const : "info" as const;
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
<template>
|
|
91
|
+
<div
|
|
92
|
+
class="py-4"
|
|
93
|
+
:class="selection.isSelected(lineKey) && !readonly ? 'bg-primary/5 -mx-3 px-3 rounded-lg' : ''"
|
|
94
|
+
>
|
|
95
|
+
<!-- Position hints -->
|
|
96
|
+
<div
|
|
97
|
+
v-if="line?.hints.length"
|
|
98
|
+
class="mb-3 space-y-1.5"
|
|
99
|
+
>
|
|
100
|
+
<UAlert
|
|
101
|
+
v-for="hint in line.hints"
|
|
102
|
+
:key="hint.type"
|
|
103
|
+
:color="hintColor(hint.type)"
|
|
104
|
+
variant="soft"
|
|
105
|
+
:icon="icon(hint.type === 'missing-cost-center' ? 'warning' : 'info')"
|
|
106
|
+
:title="t(hint.messageKey, hint.params ?? {})"
|
|
107
|
+
:ui="{ root: 'py-2', title: 'text-xs' }"
|
|
108
|
+
/>
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
<div class="flex items-start gap-3">
|
|
112
|
+
<!-- Selector + drag handle -->
|
|
113
|
+
<div
|
|
114
|
+
v-if="!readonly"
|
|
115
|
+
class="flex flex-col items-center gap-2 pt-1"
|
|
116
|
+
>
|
|
117
|
+
<UCheckbox
|
|
118
|
+
:model-value="selection.isSelected(lineKey)"
|
|
119
|
+
:aria-label="t('cart.selection.selectPosition', { name: item.name })"
|
|
120
|
+
tabindex="0"
|
|
121
|
+
@update:model-value="selection.toggle(lineKey)"
|
|
122
|
+
/>
|
|
123
|
+
<span
|
|
124
|
+
class="drag-handle cursor-grab text-dimmed hover:text-muted touch-none"
|
|
125
|
+
:title="t('cart.position.reorder')"
|
|
126
|
+
>
|
|
127
|
+
<UIcon
|
|
128
|
+
:name="icon('drag')"
|
|
129
|
+
class="size-4"
|
|
130
|
+
/>
|
|
131
|
+
</span>
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
<!-- Image -->
|
|
135
|
+
<NuxtLink
|
|
136
|
+
:to="detailUrl ?? undefined"
|
|
137
|
+
class="w-20 h-20 shrink-0 flex items-center justify-center rounded-lg
|
|
138
|
+
bg-elevated/60 ring-1 ring-(--ui-border) p-1.5"
|
|
139
|
+
:aria-label="item.name"
|
|
140
|
+
:tabindex="detailUrl ? 0 : -1"
|
|
141
|
+
>
|
|
142
|
+
<img
|
|
143
|
+
:src="getImage(item.image)"
|
|
144
|
+
:alt="item.name"
|
|
145
|
+
class="max-h-full max-w-full object-contain"
|
|
146
|
+
>
|
|
147
|
+
</NuxtLink>
|
|
148
|
+
|
|
149
|
+
<!-- Identity -->
|
|
150
|
+
<div class="flex flex-col gap-0.5 flex-1 min-w-0">
|
|
151
|
+
<div class="flex flex-wrap items-center gap-x-2 text-xs text-muted">
|
|
152
|
+
<span>{{ item.sku }}</span>
|
|
153
|
+
<span
|
|
154
|
+
v-if="role && item.customSku"
|
|
155
|
+
class="text-dimmed"
|
|
156
|
+
>{{ t('cart.position.customSku') }}: {{ item.customSku }}</span>
|
|
157
|
+
</div>
|
|
158
|
+
<NuxtLink
|
|
159
|
+
v-if="detailUrl"
|
|
160
|
+
:to="detailUrl"
|
|
161
|
+
class="text-sm font-medium text-highlighted leading-snug hover:underline w-fit"
|
|
162
|
+
>
|
|
163
|
+
{{ item.name }}
|
|
164
|
+
</NuxtLink>
|
|
165
|
+
<span
|
|
166
|
+
v-else
|
|
167
|
+
class="text-sm font-medium text-highlighted leading-snug"
|
|
168
|
+
>{{ item.name }}</span>
|
|
169
|
+
<span
|
|
170
|
+
v-if="item.name2"
|
|
171
|
+
class="text-xs text-muted"
|
|
172
|
+
>{{ item.name2 }}</span>
|
|
173
|
+
|
|
174
|
+
<!-- Cost center: shown and edited right at the position -->
|
|
175
|
+
<button
|
|
176
|
+
v-if="showCostCenter && !readonly"
|
|
177
|
+
type="button"
|
|
178
|
+
tabindex="0"
|
|
179
|
+
class="group/cc mt-1.5 w-fit text-xs text-muted hover:text-highlighted cursor-pointer
|
|
180
|
+
inline-flex items-center gap-1.5 rounded-md border border-(--ui-border)
|
|
181
|
+
hover:border-(--ui-border-accented) px-2 py-1 transition-colors"
|
|
182
|
+
:aria-label="t('cart.position.editCostCenter')"
|
|
183
|
+
@click="actions.open('cost-center', [lineKey])"
|
|
184
|
+
>
|
|
185
|
+
<UIcon
|
|
186
|
+
:name="icon('hash')"
|
|
187
|
+
class="size-3.5 text-primary"
|
|
188
|
+
/>
|
|
189
|
+
{{ t('cart.position.costCenter') }}: {{ costCenterLabel }}
|
|
190
|
+
<UIcon
|
|
191
|
+
:name="icon('edit')"
|
|
192
|
+
class="size-3 text-dimmed group-hover/cc:text-muted"
|
|
193
|
+
/>
|
|
194
|
+
</button>
|
|
195
|
+
<span
|
|
196
|
+
v-else-if="showCostCenter"
|
|
197
|
+
class="mt-1 text-xs text-muted inline-flex items-center gap-1"
|
|
198
|
+
>
|
|
199
|
+
<UIcon
|
|
200
|
+
:name="icon('hash')"
|
|
201
|
+
class="size-3.5"
|
|
202
|
+
/>
|
|
203
|
+
{{ t('cart.position.costCenter') }}: {{ costCenterLabel }}
|
|
204
|
+
</span>
|
|
205
|
+
|
|
206
|
+
<!-- Position texts: shown and edited right at the position -->
|
|
207
|
+
<button
|
|
208
|
+
v-if="!readonly && item.positionTexts?.length"
|
|
209
|
+
type="button"
|
|
210
|
+
tabindex="0"
|
|
211
|
+
class="group/texts mt-1 w-fit text-left cursor-pointer"
|
|
212
|
+
:aria-label="t('cart.position.editTexts')"
|
|
213
|
+
@click="actions.open('texts', [lineKey])"
|
|
214
|
+
>
|
|
215
|
+
<span
|
|
216
|
+
v-for="(text, index) in item.positionTexts"
|
|
217
|
+
:key="index"
|
|
218
|
+
class="block text-xs text-muted italic group-hover/texts:text-highlighted"
|
|
219
|
+
>
|
|
220
|
+
{{ text }}
|
|
221
|
+
<UIcon
|
|
222
|
+
v-if="index === (item.positionTexts?.length ?? 0) - 1"
|
|
223
|
+
:name="icon('edit')"
|
|
224
|
+
class="size-3 inline-block ms-1 text-dimmed group-hover/texts:text-muted"
|
|
225
|
+
/>
|
|
226
|
+
</span>
|
|
227
|
+
</button>
|
|
228
|
+
<ul
|
|
229
|
+
v-else-if="item.positionTexts?.length"
|
|
230
|
+
class="mt-1 space-y-0.5"
|
|
231
|
+
>
|
|
232
|
+
<li
|
|
233
|
+
v-for="(text, index) in item.positionTexts"
|
|
234
|
+
:key="index"
|
|
235
|
+
class="text-xs text-muted italic"
|
|
236
|
+
>
|
|
237
|
+
{{ text }}
|
|
238
|
+
</li>
|
|
239
|
+
</ul>
|
|
240
|
+
<button
|
|
241
|
+
v-else-if="!readonly"
|
|
242
|
+
type="button"
|
|
243
|
+
tabindex="0"
|
|
244
|
+
class="mt-1 w-fit text-xs text-dimmed hover:text-muted cursor-pointer
|
|
245
|
+
inline-flex items-center gap-1 transition-colors"
|
|
246
|
+
@click="actions.open('texts', [lineKey])"
|
|
247
|
+
>
|
|
248
|
+
<UIcon
|
|
249
|
+
:name="icon('plus')"
|
|
250
|
+
class="size-3"
|
|
251
|
+
/>
|
|
252
|
+
{{ t('cart.position.addTexts') }}
|
|
253
|
+
</button>
|
|
254
|
+
</div>
|
|
255
|
+
|
|
256
|
+
<!-- Quantity + availability -->
|
|
257
|
+
<div class="flex flex-col items-end gap-1.5 shrink-0">
|
|
258
|
+
<div
|
|
259
|
+
v-if="!readonly"
|
|
260
|
+
class="flex items-center gap-1"
|
|
261
|
+
>
|
|
262
|
+
<UButton
|
|
263
|
+
:icon="icon('minus')"
|
|
264
|
+
color="primary"
|
|
265
|
+
variant="soft"
|
|
266
|
+
size="xs"
|
|
267
|
+
tabindex="0"
|
|
268
|
+
:disabled="item.quantity <= 1"
|
|
269
|
+
:aria-label="t('cart.item.ariaDecreaseQuantity', { name: item.name })"
|
|
270
|
+
@click="applyQuantity(item.quantity - 1)"
|
|
271
|
+
/>
|
|
272
|
+
<input
|
|
273
|
+
v-model="inputValue"
|
|
274
|
+
type="text"
|
|
275
|
+
inputmode="numeric"
|
|
276
|
+
:aria-label="t('cart.item.ariaInputQuantity', { name: item.name })"
|
|
277
|
+
class="w-14 text-center text-sm border border-(--ui-border) rounded px-1 py-0.5
|
|
278
|
+
bg-transparent focus:outline-none focus:ring-1 focus:ring-(--ui-primary)"
|
|
279
|
+
@input="onQuantityInput"
|
|
280
|
+
@keydown.enter.prevent="commitInput"
|
|
281
|
+
@blur="commitInput"
|
|
282
|
+
>
|
|
283
|
+
<UButton
|
|
284
|
+
:icon="icon('plus')"
|
|
285
|
+
color="primary"
|
|
286
|
+
variant="soft"
|
|
287
|
+
size="xs"
|
|
288
|
+
tabindex="0"
|
|
289
|
+
:aria-label="t('cart.item.ariaIncreaseQuantity', { name: item.name })"
|
|
290
|
+
@click="applyQuantity(item.quantity + 1)"
|
|
291
|
+
/>
|
|
292
|
+
</div>
|
|
293
|
+
<span
|
|
294
|
+
v-else
|
|
295
|
+
class="text-sm text-highlighted"
|
|
296
|
+
>{{ line?.adjustedQuantity ?? item.quantity }}</span>
|
|
297
|
+
<span class="text-xs text-muted">{{ item.unit ?? t('cart.position.defaultUnit') }}</span>
|
|
298
|
+
<span
|
|
299
|
+
v-if="availability"
|
|
300
|
+
class="inline-flex items-center gap-1.5 text-xs text-muted"
|
|
301
|
+
>
|
|
302
|
+
<span
|
|
303
|
+
class="size-2 rounded-full"
|
|
304
|
+
:class="availabilityColor"
|
|
305
|
+
/>
|
|
306
|
+
{{ t(`cart.availability.${availability.state}`, { count: availability.availableQuantity, days: availability.deliveryDays ?? 0 }) }}
|
|
307
|
+
</span>
|
|
308
|
+
</div>
|
|
309
|
+
|
|
310
|
+
<!-- Price block -->
|
|
311
|
+
<div class="flex flex-col items-end gap-0.5 w-32 shrink-0">
|
|
312
|
+
<template v-if="line?.priceLabel">
|
|
313
|
+
<UBadge
|
|
314
|
+
color="neutral"
|
|
315
|
+
variant="subtle"
|
|
316
|
+
:label="line.priceLabel.label"
|
|
317
|
+
/>
|
|
318
|
+
</template>
|
|
319
|
+
<template v-else>
|
|
320
|
+
<span class="text-sm font-semibold text-highlighted">
|
|
321
|
+
{{ formatCurrency(line?.lineTotal ?? item.price * item.quantity) }}
|
|
322
|
+
</span>
|
|
323
|
+
<span class="text-xs text-muted">
|
|
324
|
+
{{ t('cart.position.perUnit', { price: formatCurrency(line?.unitPrice ?? item.price) }) }}
|
|
325
|
+
</span>
|
|
326
|
+
<span
|
|
327
|
+
v-for="surcharge in line?.surcharges ?? []"
|
|
328
|
+
:key="surcharge.name"
|
|
329
|
+
class="text-xs text-dimmed"
|
|
330
|
+
>
|
|
331
|
+
+ {{ surcharge.name }} {{ formatCurrency(surcharge.amountPerUnit) }}
|
|
332
|
+
</span>
|
|
333
|
+
</template>
|
|
334
|
+
</div>
|
|
335
|
+
|
|
336
|
+
<!-- Function bar -->
|
|
337
|
+
<div
|
|
338
|
+
v-if="!readonly"
|
|
339
|
+
class="flex flex-col gap-0.5 shrink-0"
|
|
340
|
+
>
|
|
341
|
+
<UTooltip
|
|
342
|
+
v-if="role"
|
|
343
|
+
:text="t('cart.bulk.saveToList')"
|
|
344
|
+
>
|
|
345
|
+
<UButton
|
|
346
|
+
:icon="icon('bookmark')"
|
|
347
|
+
color="neutral"
|
|
348
|
+
variant="ghost"
|
|
349
|
+
size="xs"
|
|
350
|
+
tabindex="0"
|
|
351
|
+
:aria-label="t('cart.bulk.saveToList')"
|
|
352
|
+
@click="actions.open('save', [lineKey])"
|
|
353
|
+
/>
|
|
354
|
+
</UTooltip>
|
|
355
|
+
<UTooltip :text="t('cart.item.remove')">
|
|
356
|
+
<UButton
|
|
357
|
+
:icon="icon('delete')"
|
|
358
|
+
color="neutral"
|
|
359
|
+
variant="ghost"
|
|
360
|
+
size="xs"
|
|
361
|
+
tabindex="0"
|
|
362
|
+
:aria-label="t('cart.item.ariaRemoveFromCart', { name: item.name })"
|
|
363
|
+
@click="cart.removeByKeys([lineKey])"
|
|
364
|
+
/>
|
|
365
|
+
</UTooltip>
|
|
366
|
+
</div>
|
|
367
|
+
</div>
|
|
368
|
+
</div>
|
|
369
|
+
</template>
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { productsApi } from "../../../api/products";
|
|
3
|
+
import { getBaseUnitPrice, getPriceTiers, type Product } from "../../../composables/useProducts";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Cart quick entry (spec: Warenkorb-Schnellerfassung): add positions by
|
|
7
|
+
* article number with quantity, embedded on the empty cart and available
|
|
8
|
+
* as a modal on the filled cart.
|
|
9
|
+
*/
|
|
10
|
+
const { icon } = useIcons();
|
|
11
|
+
const { t } = useI18n();
|
|
12
|
+
const toast = useToast();
|
|
13
|
+
const cart = useCartStore();
|
|
14
|
+
const { locale } = useI18n();
|
|
15
|
+
|
|
16
|
+
const sku = ref("");
|
|
17
|
+
const quantity = ref("1");
|
|
18
|
+
const adding = ref(false);
|
|
19
|
+
|
|
20
|
+
const { data: products } = useFetch<Product[]>(productsApi.list(), {
|
|
21
|
+
key: "quick-add-products",
|
|
22
|
+
headers: computed(() => ({ "x-locale": locale.value })),
|
|
23
|
+
server: false,
|
|
24
|
+
lazy: true,
|
|
25
|
+
default: () => [],
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const matches = computed(() => {
|
|
29
|
+
const q = sku.value.trim().toLowerCase();
|
|
30
|
+
if (q.length < 2) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
return (products.value ?? [])
|
|
34
|
+
.filter(p => p.sku.toLowerCase().includes(q) || p.name.toLowerCase().includes(q))
|
|
35
|
+
.slice(0, 5);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
function buildTiers(prices: { [key: string]: number }[]) {
|
|
39
|
+
return getPriceTiers(prices).map(tier => ({
|
|
40
|
+
minQuantity: tier.quantity,
|
|
41
|
+
unitPrice: tier.unitCents / 100,
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function addProduct(product: Product): void {
|
|
46
|
+
const qty = Math.max(1, parseInt(quantity.value, 10) || 1);
|
|
47
|
+
const price = getBaseUnitPrice(product.prices);
|
|
48
|
+
if (price === null) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
adding.value = true;
|
|
52
|
+
const added = cart.addItem({
|
|
53
|
+
id: product.id,
|
|
54
|
+
name: product.name,
|
|
55
|
+
image: product.image,
|
|
56
|
+
sku: product.sku,
|
|
57
|
+
price,
|
|
58
|
+
taxRate: product.tax.rate,
|
|
59
|
+
priceTiers: buildTiers(product.prices),
|
|
60
|
+
categorySlug: product.categorySlug,
|
|
61
|
+
subcategorySlug: product.subcategorySlug,
|
|
62
|
+
...(typeof product.maxOrderQuantity === "number"
|
|
63
|
+
? { maxOrderQuantity: product.maxOrderQuantity }
|
|
64
|
+
: {}),
|
|
65
|
+
}, { chooseTarget: true });
|
|
66
|
+
if (added && qty > 1) {
|
|
67
|
+
const item = cart.items.find(i => i.id === product.id && !i.requisitionId);
|
|
68
|
+
if (item) {
|
|
69
|
+
cart.updateQuantityByKey(cart.keyOf(item), item.quantity + qty - 1);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
toast.add({
|
|
73
|
+
title: t("cart.quickAdd.added", { quantity: qty, name: product.name }),
|
|
74
|
+
color: "success",
|
|
75
|
+
icon: icon("success"),
|
|
76
|
+
duration: 1500,
|
|
77
|
+
});
|
|
78
|
+
sku.value = "";
|
|
79
|
+
quantity.value = "1";
|
|
80
|
+
adding.value = false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function onSubmit(): void {
|
|
84
|
+
const exact = matches.value.find(p => p.sku.toLowerCase() === sku.value.trim().toLowerCase());
|
|
85
|
+
const target = exact ?? matches.value[0];
|
|
86
|
+
if (target) {
|
|
87
|
+
addProduct(target);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
<template>
|
|
93
|
+
<div class="space-y-2">
|
|
94
|
+
<div class="flex items-end gap-2">
|
|
95
|
+
<UFormField
|
|
96
|
+
:label="t('cart.quickAdd.skuLabel')"
|
|
97
|
+
class="flex-1"
|
|
98
|
+
>
|
|
99
|
+
<UInput
|
|
100
|
+
v-model="sku"
|
|
101
|
+
class="w-full"
|
|
102
|
+
:placeholder="t('cart.quickAdd.skuPlaceholder')"
|
|
103
|
+
@keydown.enter.prevent="onSubmit"
|
|
104
|
+
/>
|
|
105
|
+
</UFormField>
|
|
106
|
+
<UFormField :label="t('cart.quickAdd.quantityLabel')">
|
|
107
|
+
<UInput
|
|
108
|
+
v-model="quantity"
|
|
109
|
+
type="text"
|
|
110
|
+
inputmode="numeric"
|
|
111
|
+
class="w-20"
|
|
112
|
+
@keydown.enter.prevent="onSubmit"
|
|
113
|
+
/>
|
|
114
|
+
</UFormField>
|
|
115
|
+
<UButton
|
|
116
|
+
color="primary"
|
|
117
|
+
tabindex="0"
|
|
118
|
+
:loading="adding"
|
|
119
|
+
:disabled="matches.length === 0"
|
|
120
|
+
:label="t('cart.quickAdd.add')"
|
|
121
|
+
@click="onSubmit"
|
|
122
|
+
/>
|
|
123
|
+
</div>
|
|
124
|
+
<ul
|
|
125
|
+
v-if="matches.length"
|
|
126
|
+
class="border border-(--ui-border) rounded-lg divide-y divide-(--ui-border) overflow-hidden"
|
|
127
|
+
>
|
|
128
|
+
<li
|
|
129
|
+
v-for="product in matches"
|
|
130
|
+
:key="product.id"
|
|
131
|
+
>
|
|
132
|
+
<button
|
|
133
|
+
type="button"
|
|
134
|
+
tabindex="0"
|
|
135
|
+
class="w-full flex items-center justify-between gap-3 px-3 py-2 text-left
|
|
136
|
+
hover:bg-elevated transition-colors cursor-pointer"
|
|
137
|
+
@click="addProduct(product)"
|
|
138
|
+
>
|
|
139
|
+
<span class="text-sm text-highlighted truncate">{{ product.name }}</span>
|
|
140
|
+
<span class="text-xs text-muted shrink-0">{{ product.sku }}</span>
|
|
141
|
+
</button>
|
|
142
|
+
</li>
|
|
143
|
+
</ul>
|
|
144
|
+
</div>
|
|
145
|
+
</template>
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import CartRecommendCard from "./CartRecommendCard.vue";
|
|
3
|
+
import { searchApi } from "../../../api/search";
|
|
4
|
+
import { getBaseUnitPrice, getPriceTiers } from "../../../composables/useProducts";
|
|
5
|
+
|
|
6
|
+
import type { ProductList } from "../../../interfaces/product-list";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Cross-sell strip on the cart page: products from the same category as
|
|
10
|
+
* the cart content (or catalog-wide when `popular` — the empty-cart
|
|
11
|
+
* variant), excluding what's already in the cart.
|
|
12
|
+
*/
|
|
13
|
+
const props = defineProps<{
|
|
14
|
+
/** Catalog-wide suggestions instead of cart-category matches. */
|
|
15
|
+
popular?: boolean;
|
|
16
|
+
}>();
|
|
17
|
+
|
|
18
|
+
const { icon } = useIcons();
|
|
19
|
+
const { t } = useI18n();
|
|
20
|
+
const toast = useToast();
|
|
21
|
+
const cart = useCartStore();
|
|
22
|
+
|
|
23
|
+
const categorySlug = computed(() =>
|
|
24
|
+
props.popular ? null : cart.items.find(item => item.categorySlug)?.categorySlug ?? null);
|
|
25
|
+
|
|
26
|
+
const requestBody = computed(() => ({
|
|
27
|
+
q: "*",
|
|
28
|
+
...(categorySlug.value ? { filters: { categorySlug: [categorySlug.value] } } : {}),
|
|
29
|
+
perPage: 12,
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
const { data } = useFetch<{ products: ProductList[] }>(searchApi.search(), {
|
|
33
|
+
key: `cart-cross-sell:${props.popular ? "popular" : "category"}`,
|
|
34
|
+
method: "POST",
|
|
35
|
+
body: requestBody,
|
|
36
|
+
server: false,
|
|
37
|
+
lazy: true,
|
|
38
|
+
default: () => ({ products: [] }),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const suggestions = computed(() => {
|
|
42
|
+
const inCart = new Set(cart.items.map(item => item.id));
|
|
43
|
+
return (data.value.products ?? [])
|
|
44
|
+
.filter(product => !inCart.has(product.id) && !product.isOutOfStock)
|
|
45
|
+
.slice(0, 8);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
function add(product: ProductList): void {
|
|
49
|
+
const price = getBaseUnitPrice(product.prices);
|
|
50
|
+
if (price === null) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const ok = cart.addItem({
|
|
54
|
+
id: product.id,
|
|
55
|
+
name: product.name,
|
|
56
|
+
image: product.image,
|
|
57
|
+
sku: product.sku,
|
|
58
|
+
price,
|
|
59
|
+
taxRate: product.tax.rate,
|
|
60
|
+
priceTiers: getPriceTiers(product.prices).map(tier => ({
|
|
61
|
+
minQuantity: tier.quantity,
|
|
62
|
+
unitPrice: tier.unitCents / 100,
|
|
63
|
+
})),
|
|
64
|
+
categorySlug: product.categorySlug,
|
|
65
|
+
subcategorySlug: product.subcategorySlug,
|
|
66
|
+
}, { chooseTarget: true });
|
|
67
|
+
if (ok) {
|
|
68
|
+
toast.add({
|
|
69
|
+
title: t("product.actions.addedToCart", { quantity: 1, name: product.name }),
|
|
70
|
+
color: "primary",
|
|
71
|
+
icon: icon("check"),
|
|
72
|
+
duration: 1000,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<template>
|
|
79
|
+
<section
|
|
80
|
+
v-if="suggestions.length"
|
|
81
|
+
class="print:hidden"
|
|
82
|
+
>
|
|
83
|
+
<h2 class="flex items-center gap-2 text-sm font-semibold text-highlighted mb-3">
|
|
84
|
+
<UIcon
|
|
85
|
+
:name="icon(popular ? 'star' : 'plus')"
|
|
86
|
+
class="size-4 text-primary"
|
|
87
|
+
/>
|
|
88
|
+
{{ popular ? t('cart.boost.popularTitle') : t('cart.boost.crossSellTitle') }}
|
|
89
|
+
</h2>
|
|
90
|
+
<div class="flex gap-3 overflow-x-auto pb-2 -mx-1 px-1">
|
|
91
|
+
<CartRecommendCard
|
|
92
|
+
v-for="product in suggestions"
|
|
93
|
+
:key="product.id"
|
|
94
|
+
:name="product.name"
|
|
95
|
+
:image="product.image"
|
|
96
|
+
:sku="product.sku"
|
|
97
|
+
:price="getBaseUnitPrice(product.prices)"
|
|
98
|
+
@add="add(product)"
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
</section>
|
|
102
|
+
</template>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/** Compact product card for the cart recommendation strips. */
|
|
3
|
+
defineProps<{
|
|
4
|
+
name: string;
|
|
5
|
+
image?: string;
|
|
6
|
+
sku: string;
|
|
7
|
+
price: number | null;
|
|
8
|
+
}>();
|
|
9
|
+
|
|
10
|
+
const emit = defineEmits<{
|
|
11
|
+
(e: "add"): void;
|
|
12
|
+
}>();
|
|
13
|
+
|
|
14
|
+
const { icon } = useIcons();
|
|
15
|
+
const { t } = useI18n();
|
|
16
|
+
const { getImage } = useProductImage();
|
|
17
|
+
const { formatCurrency } = useCartSummaryFormatting();
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<div
|
|
22
|
+
class="flex flex-col w-44 shrink-0 rounded-xl border border-(--ui-border) p-3
|
|
23
|
+
hover:border-(--ui-border-accented) transition-colors"
|
|
24
|
+
>
|
|
25
|
+
<span
|
|
26
|
+
class="h-24 flex items-center justify-center rounded-lg bg-elevated/60 p-2 mb-2"
|
|
27
|
+
>
|
|
28
|
+
<img
|
|
29
|
+
v-if="image"
|
|
30
|
+
:src="getImage(image)"
|
|
31
|
+
:alt="name"
|
|
32
|
+
class="max-h-full max-w-full object-contain"
|
|
33
|
+
loading="lazy"
|
|
34
|
+
>
|
|
35
|
+
</span>
|
|
36
|
+
<p class="text-xs font-medium text-highlighted line-clamp-2 min-h-8">
|
|
37
|
+
{{ name }}
|
|
38
|
+
</p>
|
|
39
|
+
<p class="text-xs text-muted truncate mt-0.5">
|
|
40
|
+
{{ sku }}
|
|
41
|
+
</p>
|
|
42
|
+
<div class="flex items-center justify-between gap-2 mt-2">
|
|
43
|
+
<span class="text-sm font-semibold text-highlighted tabular-nums">
|
|
44
|
+
{{ price !== null ? formatCurrency(price) : '' }}
|
|
45
|
+
</span>
|
|
46
|
+
<UTooltip :text="t('cart.boost.add')">
|
|
47
|
+
<UButton
|
|
48
|
+
color="primary"
|
|
49
|
+
variant="soft"
|
|
50
|
+
size="xs"
|
|
51
|
+
tabindex="0"
|
|
52
|
+
:icon="icon('plus')"
|
|
53
|
+
:aria-label="t('cart.boost.add')"
|
|
54
|
+
@click="emit('add')"
|
|
55
|
+
/>
|
|
56
|
+
</UTooltip>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|