@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,28 @@
|
|
|
1
|
+
export const useCartSummaryFormatting = () => {
|
|
2
|
+
const { t } = useI18n();
|
|
3
|
+
const { public: { locale, currency, taxIncludedPrices } } = useRuntimeConfig();
|
|
4
|
+
|
|
5
|
+
const taxLabelKey = computed(() => taxIncludedPrices ? "summary.tax.incl" : "summary.tax.excl");
|
|
6
|
+
|
|
7
|
+
function formatPercent(rate: number): string {
|
|
8
|
+
return `${Math.round(rate * 100)}%`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function taxRateLabel(rate: number): string {
|
|
12
|
+
return t("summary.tax.rateLabel", {
|
|
13
|
+
label: t(taxLabelKey.value),
|
|
14
|
+
percent: formatPercent(rate),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function formatCurrency(value: number): string {
|
|
19
|
+
return (value).toLocaleString(locale as string, { style: "currency", currency: currency as string });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
taxLabelKey,
|
|
24
|
+
formatPercent,
|
|
25
|
+
taxRateLabel,
|
|
26
|
+
formatCurrency,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { NavigationMenuItem } from "@nuxt/ui";
|
|
2
|
+
|
|
3
|
+
import { categoriesApi } from "../api/categories";
|
|
4
|
+
import type { ProductCategory } from "../config/navigation";
|
|
5
|
+
|
|
6
|
+
export const useCategories = () => {
|
|
7
|
+
const localePath = useLocalePath();
|
|
8
|
+
const { icon } = useIcons();
|
|
9
|
+
const { locale } = useI18n();
|
|
10
|
+
const { data: categories, status, error } = useFetch<ProductCategory[]>(categoriesApi.list(), {
|
|
11
|
+
headers: computed(() => ({ "x-locale": locale.value })),
|
|
12
|
+
default: () => [] as ProductCategory[],
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const categoryNavItems = computed<NavigationMenuItem[]>(() =>
|
|
16
|
+
(categories.value ?? []).map((cat: ProductCategory) => ({
|
|
17
|
+
label: cat.label,
|
|
18
|
+
icon: icon(cat.icon),
|
|
19
|
+
to: localePath(`/category/${cat.slug}`),
|
|
20
|
+
children: cat.subcategories.map((sub: ProductCategory["subcategories"][number]) => ({
|
|
21
|
+
label: sub.label,
|
|
22
|
+
icon: icon(sub.icon),
|
|
23
|
+
to: localePath(`/category/${cat.slug}/${sub.slug}`),
|
|
24
|
+
})),
|
|
25
|
+
})),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return { categories, categoryNavItems, status, error };
|
|
29
|
+
};
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
import { checkoutApi } from "../api/checkout";
|
|
2
|
+
import type { CheckoutOnePageForm, CheckoutProfile } from "../interfaces/checkout";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Who is checking out:
|
|
6
|
+
* - `account` — signed-in user with address book and B2B context
|
|
7
|
+
* - `guest-business` — guest business customer (company data required)
|
|
8
|
+
* - `guest-private` — guest private customer (no company data)
|
|
9
|
+
*/
|
|
10
|
+
export type CheckoutCustomerType = "account" | "guest-business" | "guest-private";
|
|
11
|
+
|
|
12
|
+
export interface CheckoutGuestAddress {
|
|
13
|
+
companyName: string;
|
|
14
|
+
firstName: string;
|
|
15
|
+
lastName: string;
|
|
16
|
+
street: string;
|
|
17
|
+
postalCode: string;
|
|
18
|
+
city: string;
|
|
19
|
+
country: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const EMPTY_GUEST_ADDRESS: CheckoutGuestAddress = {
|
|
23
|
+
companyName: "",
|
|
24
|
+
firstName: "",
|
|
25
|
+
lastName: "",
|
|
26
|
+
street: "",
|
|
27
|
+
postalCode: "",
|
|
28
|
+
city: "",
|
|
29
|
+
country: "DE",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const EMPTY_FORM: CheckoutOnePageForm = {
|
|
33
|
+
shippingAddressId: "",
|
|
34
|
+
billingSameAsShipping: true,
|
|
35
|
+
billingAddressId: "",
|
|
36
|
+
deliveryMethod: "standard",
|
|
37
|
+
requestedDate: "",
|
|
38
|
+
deliveryNote: "",
|
|
39
|
+
partialDelivery: false,
|
|
40
|
+
paymentMethod: "invoice",
|
|
41
|
+
poNumber: "",
|
|
42
|
+
costCenterId: "",
|
|
43
|
+
orderNumber: "",
|
|
44
|
+
quoteNumber: "",
|
|
45
|
+
noOrderConfirmation: false,
|
|
46
|
+
orderNote: "",
|
|
47
|
+
promoCode: "",
|
|
48
|
+
acceptedTerms: false,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** Latest acceptable requested date: 100 calendar days ahead. */
|
|
52
|
+
const REQUESTED_DATE_MAX_DAYS = 100;
|
|
53
|
+
|
|
54
|
+
export function useCheckoutOnePage() {
|
|
55
|
+
const { t } = useI18n();
|
|
56
|
+
const cart = useCartStore();
|
|
57
|
+
const { settings } = useB2BContext();
|
|
58
|
+
const { data: profile, refresh: refreshProfile } = useCheckoutProfileSource();
|
|
59
|
+
const profileLoading = computed(() => profile.value === null);
|
|
60
|
+
|
|
61
|
+
const customerType = useState<CheckoutCustomerType>("checkout-customer-type", () => "account");
|
|
62
|
+
const isGuest = computed(() => customerType.value !== "account");
|
|
63
|
+
|
|
64
|
+
const form = useState<CheckoutOnePageForm>("checkout-one-page-form", () => ({ ...EMPTY_FORM }));
|
|
65
|
+
const guestContact = useState("checkout-guest-contact", () => ({ email: "", phone: "" }));
|
|
66
|
+
const guestShipping = useState<CheckoutGuestAddress>("checkout-guest-shipping", () => ({ ...EMPTY_GUEST_ADDRESS }));
|
|
67
|
+
const guestBilling = useState<CheckoutGuestAddress>("checkout-guest-billing", () => ({ ...EMPTY_GUEST_ADDRESS }));
|
|
68
|
+
const fieldErrors = useState<Record<string, string | undefined>>("checkout-one-page-field-errors", () => ({}));
|
|
69
|
+
const submitError = useState<string | null>("checkout-one-page-submit-error", () => null);
|
|
70
|
+
const submitting = useState<boolean>("checkout-one-page-submitting", () => false);
|
|
71
|
+
const sessionToken = useState<string | null>("checkout-one-page-session-token", () => null);
|
|
72
|
+
|
|
73
|
+
const orderNumberRequired = computed(() =>
|
|
74
|
+
settings.value?.checkout.orderNumberRequired ?? false,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const guestAddressValid = (address: CheckoutGuestAddress): boolean => {
|
|
78
|
+
const base = Boolean(address.firstName && address.lastName && address.street
|
|
79
|
+
&& address.postalCode && address.city && address.country);
|
|
80
|
+
return customerType.value === "guest-business"
|
|
81
|
+
? base && Boolean(address.companyName)
|
|
82
|
+
: base;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const requestedDateError = (value: string): string | null => {
|
|
86
|
+
if (!value) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const date = new Date(value);
|
|
90
|
+
if (isNaN(date.getTime())) {
|
|
91
|
+
return t("onepage.errors.requestedDateInvalid");
|
|
92
|
+
}
|
|
93
|
+
const today = new Date();
|
|
94
|
+
today.setHours(0, 0, 0, 0);
|
|
95
|
+
if (date < today) {
|
|
96
|
+
return t("onepage.errors.requestedDatePast");
|
|
97
|
+
}
|
|
98
|
+
const max = new Date(today);
|
|
99
|
+
max.setDate(max.getDate() + REQUESTED_DATE_MAX_DAYS);
|
|
100
|
+
if (date > max) {
|
|
101
|
+
return t("onepage.errors.requestedDateTooFar", { days: REQUESTED_DATE_MAX_DAYS });
|
|
102
|
+
}
|
|
103
|
+
const weekday = date.getDay();
|
|
104
|
+
if (weekday === 0 || weekday === 6) {
|
|
105
|
+
return t("onepage.errors.requestedDateWeekend");
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const isValid = computed(() => {
|
|
111
|
+
const f = form.value;
|
|
112
|
+
if (isGuest.value) {
|
|
113
|
+
if (!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(guestContact.value.email)) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (!guestAddressValid(guestShipping.value)) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
if (!f.billingSameAsShipping && !guestAddressValid(guestBilling.value)) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
if (!f.shippingAddressId) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
if (!f.billingSameAsShipping && !f.billingAddressId) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (!f.paymentMethod) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
if (orderNumberRequired.value && !f.orderNumber.trim()) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
if (requestedDateError(f.requestedDate)) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const canSubmit = computed(() => isValid.value && form.value.acceptedTerms && !submitting.value);
|
|
144
|
+
|
|
145
|
+
function initFromProfile(p: CheckoutProfile) {
|
|
146
|
+
form.value = {
|
|
147
|
+
...EMPTY_FORM,
|
|
148
|
+
shippingAddressId: p.defaultShippingAddressId,
|
|
149
|
+
billingAddressId: p.defaultBillingAddressId,
|
|
150
|
+
deliveryMethod: p.defaultDeliveryMethod,
|
|
151
|
+
paymentMethod: p.defaultPaymentMethod,
|
|
152
|
+
};
|
|
153
|
+
fieldErrors.value = {};
|
|
154
|
+
submitError.value = null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async function fetchSessionToken() {
|
|
158
|
+
const session = await $fetch(checkoutApi.session(), { method: "POST" }) as { checkoutSessionToken: string };
|
|
159
|
+
sessionToken.value = session.checkoutSessionToken;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function validateField(name: keyof CheckoutOnePageForm | "guestEmail") {
|
|
163
|
+
const f = form.value;
|
|
164
|
+
const errors = { ...fieldErrors.value };
|
|
165
|
+
|
|
166
|
+
switch (name) {
|
|
167
|
+
case "shippingAddressId":
|
|
168
|
+
errors.shippingAddressId = !isGuest.value && !f.shippingAddressId
|
|
169
|
+
? t("onepage.errors.shippingAddressRequired")
|
|
170
|
+
: undefined;
|
|
171
|
+
break;
|
|
172
|
+
case "billingAddressId":
|
|
173
|
+
errors.billingAddressId = !isGuest.value && !f.billingSameAsShipping && !f.billingAddressId
|
|
174
|
+
? t("onepage.errors.billingAddressRequired")
|
|
175
|
+
: undefined;
|
|
176
|
+
break;
|
|
177
|
+
case "paymentMethod":
|
|
178
|
+
errors.paymentMethod = f.paymentMethod
|
|
179
|
+
? undefined
|
|
180
|
+
: t("onepage.errors.paymentMethodRequired");
|
|
181
|
+
break;
|
|
182
|
+
case "orderNumber":
|
|
183
|
+
errors.orderNumber = orderNumberRequired.value && !f.orderNumber.trim()
|
|
184
|
+
? t("onepage.errors.orderNumberRequired")
|
|
185
|
+
: undefined;
|
|
186
|
+
break;
|
|
187
|
+
case "requestedDate":
|
|
188
|
+
errors.requestedDate = requestedDateError(f.requestedDate) ?? undefined;
|
|
189
|
+
break;
|
|
190
|
+
case "guestEmail":
|
|
191
|
+
errors.guestEmail = /^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(guestContact.value.email)
|
|
192
|
+
? undefined
|
|
193
|
+
: t("onepage.errors.guestEmailInvalid");
|
|
194
|
+
break;
|
|
195
|
+
case "acceptedTerms":
|
|
196
|
+
errors.acceptedTerms = f.acceptedTerms
|
|
197
|
+
? undefined
|
|
198
|
+
: t("onepage.errors.termsRequired");
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
fieldErrors.value = errors;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function validateAll(): boolean {
|
|
206
|
+
const fields: Array<keyof CheckoutOnePageForm | "guestEmail"> = [
|
|
207
|
+
"shippingAddressId", "billingAddressId", "paymentMethod",
|
|
208
|
+
"orderNumber", "requestedDate", "acceptedTerms",
|
|
209
|
+
];
|
|
210
|
+
if (isGuest.value) {
|
|
211
|
+
fields.push("guestEmail");
|
|
212
|
+
}
|
|
213
|
+
fields.forEach(f => validateField(f));
|
|
214
|
+
return Object.values(fieldErrors.value).every(v => !v) && isValid.value;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function guestAddressPayload(address: CheckoutGuestAddress, includeCompany: boolean) {
|
|
218
|
+
return {
|
|
219
|
+
...(includeCompany && address.companyName ? { companyName: address.companyName } : {}),
|
|
220
|
+
contactName: `${address.firstName} ${address.lastName}`.trim(),
|
|
221
|
+
street: address.street,
|
|
222
|
+
postalCode: address.postalCode,
|
|
223
|
+
city: address.city,
|
|
224
|
+
country: address.country,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function buildShippingAddress(): Record<string, unknown> {
|
|
229
|
+
const f = form.value;
|
|
230
|
+
if (isGuest.value) {
|
|
231
|
+
const includeCompany = customerType.value === "guest-business";
|
|
232
|
+
return {
|
|
233
|
+
...guestAddressPayload(guestShipping.value, includeCompany),
|
|
234
|
+
billingAddressSameAsShipping: f.billingSameAsShipping,
|
|
235
|
+
...(f.billingSameAsShipping
|
|
236
|
+
? {}
|
|
237
|
+
: { billing: guestAddressPayload(guestBilling.value, includeCompany) }),
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const p = profile.value;
|
|
242
|
+
if (!p) {
|
|
243
|
+
throw new Error("Checkout profile not available");
|
|
244
|
+
}
|
|
245
|
+
const shippingAddr = p.addresses.find(a => a.id === f.shippingAddressId);
|
|
246
|
+
const billingAddr = f.billingSameAsShipping
|
|
247
|
+
? undefined
|
|
248
|
+
: p.addresses.find(a => a.id === f.billingAddressId);
|
|
249
|
+
return {
|
|
250
|
+
...shippingAddr,
|
|
251
|
+
billingAddressSameAsShipping: f.billingSameAsShipping,
|
|
252
|
+
...(billingAddr
|
|
253
|
+
? {
|
|
254
|
+
billing: {
|
|
255
|
+
street: billingAddr.street,
|
|
256
|
+
city: billingAddr.city,
|
|
257
|
+
postalCode: billingAddr.postalCode,
|
|
258
|
+
country: billingAddr.country,
|
|
259
|
+
},
|
|
260
|
+
}
|
|
261
|
+
: {}),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function buildOrderPayload() {
|
|
266
|
+
const f = form.value;
|
|
267
|
+
const costCenter = profile.value?.costCenters.find(c => c.id === f.costCenterId);
|
|
268
|
+
|
|
269
|
+
const payment: Record<string, unknown> = { method: f.paymentMethod };
|
|
270
|
+
if (f.paymentMethod === "po_number" && f.poNumber) {
|
|
271
|
+
payment.poNumber = f.poNumber;
|
|
272
|
+
}
|
|
273
|
+
if (f.paymentMethod === "cost_center" && costCenter) {
|
|
274
|
+
payment.costCenter = costCenter.code;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return {
|
|
278
|
+
checkoutSessionToken: sessionToken.value ?? "",
|
|
279
|
+
customerType: customerType.value === "guest-private" ? "private" : "business",
|
|
280
|
+
address: buildShippingAddress(),
|
|
281
|
+
payment,
|
|
282
|
+
// Full cart lines: the BFF re-runs the calculation at order time
|
|
283
|
+
// (approval limits, quantity rules) against the same data.
|
|
284
|
+
items: cart.items,
|
|
285
|
+
...(isGuest.value ? { contactEmail: guestContact.value.email } : {}),
|
|
286
|
+
...(f.deliveryMethod ? { deliveryMethod: f.deliveryMethod } : {}),
|
|
287
|
+
...(f.requestedDate ? { requestedDate: f.requestedDate } : {}),
|
|
288
|
+
...(f.deliveryNote ? { deliveryNote: f.deliveryNote } : {}),
|
|
289
|
+
...(f.partialDelivery ? { partialDelivery: true } : {}),
|
|
290
|
+
...(f.orderNumber ? { orderNumber: f.orderNumber } : {}),
|
|
291
|
+
...(f.quoteNumber ? { quoteNumber: f.quoteNumber } : {}),
|
|
292
|
+
...(f.noOrderConfirmation ? { noOrderConfirmation: true } : {}),
|
|
293
|
+
...(f.orderNote ? { orderNote: f.orderNote } : {}),
|
|
294
|
+
...(f.promoCode ? { promoCode: f.promoCode } : {}),
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
interface SubmitResult {
|
|
299
|
+
orderId: string;
|
|
300
|
+
approvalRequired: boolean;
|
|
301
|
+
approvers: string[];
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
async function submitOrder(): Promise<SubmitResult | null> {
|
|
305
|
+
if (submitting.value) {
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
if (!validateAll()) {
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
submitting.value = true;
|
|
313
|
+
submitError.value = null;
|
|
314
|
+
|
|
315
|
+
try {
|
|
316
|
+
await fetchSessionToken();
|
|
317
|
+
|
|
318
|
+
const order = await $fetch(checkoutApi.orders(), {
|
|
319
|
+
method: "POST",
|
|
320
|
+
body: buildOrderPayload(),
|
|
321
|
+
}) as { orderId: string; approvalRequired?: boolean; approvers?: string[] };
|
|
322
|
+
|
|
323
|
+
cart.clearCart();
|
|
324
|
+
return {
|
|
325
|
+
orderId: order.orderId,
|
|
326
|
+
approvalRequired: order.approvalRequired ?? false,
|
|
327
|
+
approvers: order.approvers ?? [],
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
catch (err) {
|
|
331
|
+
submitError.value = err instanceof Error
|
|
332
|
+
? err.message
|
|
333
|
+
: t("onepage.errors.submitError");
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
finally {
|
|
337
|
+
submitting.value = false;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Requester checkout outcome: a requisition entering its workflow
|
|
343
|
+
* instead of an order.
|
|
344
|
+
*/
|
|
345
|
+
async function submitRequisition(workflowId: string): Promise<string | null> {
|
|
346
|
+
if (submitting.value) {
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
submitting.value = true;
|
|
350
|
+
submitError.value = null;
|
|
351
|
+
|
|
352
|
+
try {
|
|
353
|
+
const shipping = profile.value?.addresses.find(a => a.id === form.value.shippingAddressId);
|
|
354
|
+
const result = await $fetch("/api/requisitions", {
|
|
355
|
+
method: "POST",
|
|
356
|
+
body: {
|
|
357
|
+
workflowId,
|
|
358
|
+
items: cart.items.map(i => ({
|
|
359
|
+
id: i.id,
|
|
360
|
+
sku: i.sku,
|
|
361
|
+
name: i.name,
|
|
362
|
+
...(i.name2 ? { name2: i.name2 } : {}),
|
|
363
|
+
...(i.image ? { image: i.image } : {}),
|
|
364
|
+
quantity: i.quantity,
|
|
365
|
+
...(i.unit ? { unit: i.unit } : {}),
|
|
366
|
+
price: i.price,
|
|
367
|
+
taxRate: i.taxRate ?? 19,
|
|
368
|
+
...(i.costCenterId ? { costCenterId: i.costCenterId } : {}),
|
|
369
|
+
...(i.positionTexts ? { positionTexts: i.positionTexts } : {}),
|
|
370
|
+
...(i.customSku ? { customSku: i.customSku } : {}),
|
|
371
|
+
})),
|
|
372
|
+
...(shipping
|
|
373
|
+
? {
|
|
374
|
+
deliveryAddress: {
|
|
375
|
+
company: shipping.companyName,
|
|
376
|
+
street: shipping.street,
|
|
377
|
+
postalCode: shipping.postalCode,
|
|
378
|
+
city: shipping.city,
|
|
379
|
+
country: shipping.country,
|
|
380
|
+
},
|
|
381
|
+
}
|
|
382
|
+
: {}),
|
|
383
|
+
...(form.value.orderNote ? { note: form.value.orderNote } : {}),
|
|
384
|
+
},
|
|
385
|
+
}) as { requisitionId: string };
|
|
386
|
+
|
|
387
|
+
cart.clearCart();
|
|
388
|
+
return result.requisitionId;
|
|
389
|
+
}
|
|
390
|
+
catch (err) {
|
|
391
|
+
submitError.value = err instanceof Error
|
|
392
|
+
? err.message
|
|
393
|
+
: t("onepage.errors.submitError");
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
finally {
|
|
397
|
+
submitting.value = false;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function reset() {
|
|
402
|
+
form.value = { ...EMPTY_FORM };
|
|
403
|
+
guestContact.value = { email: "", phone: "" };
|
|
404
|
+
guestShipping.value = { ...EMPTY_GUEST_ADDRESS };
|
|
405
|
+
guestBilling.value = { ...EMPTY_GUEST_ADDRESS };
|
|
406
|
+
customerType.value = "account";
|
|
407
|
+
fieldErrors.value = {};
|
|
408
|
+
submitError.value = null;
|
|
409
|
+
submitting.value = false;
|
|
410
|
+
sessionToken.value = null;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return {
|
|
414
|
+
form,
|
|
415
|
+
profile,
|
|
416
|
+
profileLoading,
|
|
417
|
+
refreshProfile,
|
|
418
|
+
customerType,
|
|
419
|
+
isGuest,
|
|
420
|
+
guestContact,
|
|
421
|
+
guestShipping,
|
|
422
|
+
guestBilling,
|
|
423
|
+
orderNumberRequired,
|
|
424
|
+
fieldErrors,
|
|
425
|
+
submitError,
|
|
426
|
+
submitting,
|
|
427
|
+
isValid,
|
|
428
|
+
canSubmit,
|
|
429
|
+
initFromProfile,
|
|
430
|
+
fetchSessionToken,
|
|
431
|
+
validateField,
|
|
432
|
+
validateAll,
|
|
433
|
+
buildOrderPayload,
|
|
434
|
+
submitOrder,
|
|
435
|
+
submitRequisition,
|
|
436
|
+
reset,
|
|
437
|
+
};
|
|
438
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { checkoutApi } from "../api/checkout";
|
|
2
|
+
|
|
3
|
+
type SchemaObject = Record<string, unknown>;
|
|
4
|
+
|
|
5
|
+
const schemaCache = new Map<string, SchemaObject>();
|
|
6
|
+
|
|
7
|
+
export const useCheckoutSchema = () => {
|
|
8
|
+
const { locale } = useI18n();
|
|
9
|
+
|
|
10
|
+
async function fetchSchemaByKey(key: string): Promise<SchemaObject> {
|
|
11
|
+
const cacheKey = `schema:${key}:${locale.value}`;
|
|
12
|
+
const cached = schemaCache.get(cacheKey);
|
|
13
|
+
if (cached) {
|
|
14
|
+
return cached;
|
|
15
|
+
}
|
|
16
|
+
const data = await $fetch<SchemaObject>(checkoutApi.schema(key), {
|
|
17
|
+
headers: { "x-locale": locale.value },
|
|
18
|
+
});
|
|
19
|
+
schemaCache.set(cacheKey, data);
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function clearCache() {
|
|
24
|
+
schemaCache.clear();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return { fetchSchemaByKey, clearCache };
|
|
28
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared visual baseline for data tables (datatable-ux skill): tinted,
|
|
3
|
+
* uppercase header row that never reads as a data row, light separators
|
|
4
|
+
* and roomy data rows. Spread into UTable's `:ui` prop.
|
|
5
|
+
*/
|
|
6
|
+
export function useDataTable() {
|
|
7
|
+
const tableUi = {
|
|
8
|
+
thead: "bg-elevated/60",
|
|
9
|
+
th: "py-3 text-xs font-semibold uppercase tracking-wide text-muted",
|
|
10
|
+
td: "py-3.5 text-sm",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
return { tableUi };
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FormError } from "@nuxt/ui";
|
|
2
|
+
|
|
3
|
+
import type { FormKey } from "../interfaces/validation";
|
|
4
|
+
import { formValidationConfig } from "../validations/formValidationConfig";
|
|
5
|
+
|
|
6
|
+
export function useFormValidation<TState extends object>(formKey: FormKey) {
|
|
7
|
+
const { t } = useI18n();
|
|
8
|
+
const config = formValidationConfig[formKey];
|
|
9
|
+
|
|
10
|
+
function validate(state: TState): FormError[] {
|
|
11
|
+
const errors: FormError[] = [];
|
|
12
|
+
const stateRecord = state as Record<string, unknown>;
|
|
13
|
+
for (const fieldConfig of config) {
|
|
14
|
+
const value = stateRecord[fieldConfig.field];
|
|
15
|
+
for (const rule of fieldConfig.rules) {
|
|
16
|
+
const key = rule.kind === "cross"
|
|
17
|
+
? rule.fn(value, stateRecord, rule.options)
|
|
18
|
+
: rule.fn(value, rule.options);
|
|
19
|
+
if (key !== null) {
|
|
20
|
+
errors.push({ name: fieldConfig.field, message: t(key, rule.options ?? {}) });
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return errors;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return { validate };
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { solarIcon } from "../config/icons";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Resolves cover icon tokens (or raw Solar basenames) to Iconify names in
|
|
5
|
+
* the active theme's icon weight. Reactive — switching the theme or the
|
|
6
|
+
* weight override re-renders every resolved icon.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const { icon } = useIcons();
|
|
10
|
+
* icon("cart"); // "i-solar-cart-3-linear"
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export function useIcons() {
|
|
14
|
+
const themeStore = useThemeStore();
|
|
15
|
+
const icon = (name: string) => solarIcon(name, themeStore.iconWeight);
|
|
16
|
+
return { icon, iconWeight: computed(() => themeStore.iconWeight) };
|
|
17
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
|
|
3
|
+
import type { ShopMarket } from "../interfaces/market";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Market-driven locale preferences: the shop's markets (markets app) carry
|
|
7
|
+
* region, currency and the offered locales — the selector picks a market,
|
|
8
|
+
* language stays an independent choice within the market's locales
|
|
9
|
+
* (Smashing Magazine, "Designing A Better Language Selector"). Persisted
|
|
10
|
+
* as a cookie so SSR renders the same selection.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const CURRENCY_SYMBOLS: Record<string, string> = {
|
|
14
|
+
EUR: "€",
|
|
15
|
+
CHF: "CHF",
|
|
16
|
+
USD: "$",
|
|
17
|
+
GBP: "£",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function useLocalePreferences(markets: Ref<ShopMarket[]>) {
|
|
21
|
+
const marketCode = useCookie<string>("cover-market", {
|
|
22
|
+
default: () => "",
|
|
23
|
+
watch: true,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const market = computed<ShopMarket | null>(() => {
|
|
27
|
+
if (!markets.value.length) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return markets.value.find(m => m.code === marketCode.value)
|
|
31
|
+
?? markets.value.find(m => m.isDefault)
|
|
32
|
+
?? markets.value[0]
|
|
33
|
+
?? null;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const setMarket = (code: string): void => {
|
|
37
|
+
marketCode.value = code;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const region = computed(() => market.value?.name ?? "");
|
|
41
|
+
const currency = computed(() => market.value?.currency ?? "EUR");
|
|
42
|
+
const currencySymbol = computed(() => CURRENCY_SYMBOLS[currency.value] ?? currency.value);
|
|
43
|
+
|
|
44
|
+
return { market, setMarket, region, currency, currencySymbol };
|
|
45
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { marketsApi } from "../api/markets";
|
|
2
|
+
import type { ShopMarket } from "../interfaces/market";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Markets from the BFF (markets app live, bundled JSON in mock mode).
|
|
6
|
+
* SSR-fetched once and shared — the locale selector and price/tax surfaces
|
|
7
|
+
* derive region, currency and offered languages from the selected market.
|
|
8
|
+
*/
|
|
9
|
+
export function useMarkets() {
|
|
10
|
+
const { data: markets, status, error, refresh } = useFetch<ShopMarket[]>(marketsApi.list(), {
|
|
11
|
+
key: "shop-markets",
|
|
12
|
+
default: () => [] as ShopMarket[],
|
|
13
|
+
});
|
|
14
|
+
return { markets, status, error, refresh };
|
|
15
|
+
}
|