@shopware/composables 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -8
- package/dist/index.d.mts +29 -3
- package/dist/index.d.ts +29 -3
- package/dist/index.mjs +138 -79
- package/package.json +16 -16
- package/src/cms/useCmsElementConfig.test.ts +1 -0
- package/src/cms/useCmsElementConfig.ts +1 -0
- package/src/cms/useCmsElementImage.test.ts +1 -0
- package/src/cms/useCmsElementImage.ts +2 -0
- package/src/cms/useCmsElementProductBox.test.ts +1 -0
- package/src/cms/useCmsElementProductBox.ts +2 -0
- package/src/createShopwareContext.test.ts +1 -0
- package/src/createShopwareContext.ts +8 -0
- package/src/devtools/plugin.ts +13 -13
- package/src/helpers/ContextError.spec.ts +1 -0
- package/src/index.test.ts +2 -0
- package/src/index.ts +1 -0
- package/src/types/cmsElementTypes.ts +1 -0
- package/src/useAddToCart/useAddToCart.test.ts +1 -0
- package/src/useAddToCart/useAddToCart.ts +1 -0
- package/src/useAddress/useAddress.test.ts +2 -0
- package/src/useAddress/useAddress.ts +1 -0
- package/src/useB2bQuoteManagement/useB2bQuoteManagement.test.ts +1 -0
- package/src/useBreadcrumbs/useBreadcrumbs.test.ts +2 -0
- package/src/useBreadcrumbs/useBreadcrumbs.ts +1 -0
- package/src/useCart/useCart.test.ts +2 -0
- package/src/useCart/useCart.ts +1 -0
- package/src/useCartErrorParamsResolver/useCartErrorParamsResolver.test.ts +1 -0
- package/src/useCartItem/useCartItem.test.ts +2 -0
- package/src/useCartItem/useCartItem.ts +1 -0
- package/src/useCartNotification/useCartNotification.test.ts +2 -0
- package/src/useCategory/useCategory.test.ts +2 -0
- package/src/useCategory/useCategory.ts +2 -0
- package/src/useCategorySearch/useCategorySearch.test.ts +29 -0
- package/src/useCategorySearch/useCategorySearch.ts +15 -7
- package/src/useCheckout/useCheckout.test.ts +1 -0
- package/src/useCheckout/useCheckout.ts +1 -0
- package/src/useCmsBlock/useCmsBlock.test.ts +2 -0
- package/src/useCmsMeta/useCmsMeta.test.ts +2 -0
- package/src/useCmsMeta/useCmsMeta.ts +1 -0
- package/src/useCmsSection/useCmsSection.test.ts +2 -0
- package/src/useCmsTranslations/useCmsTranslations.test.ts +2 -0
- package/src/useCountries/useCountries.test.ts +19 -0
- package/src/useCountries/useCountries.ts +14 -7
- package/src/useCustomerOrders/useCustomerOrders.test.ts +1 -0
- package/src/useCustomerOrders/useCustomerOrders.ts +1 -0
- package/src/useCustomerPassword/useCustomerPassword.test.ts +1 -0
- package/src/useDefaultOrderAssociations/useDefaultOrderAssociations.test.ts +1 -0
- package/src/useInternationalization/useInternationalization.test.ts +14 -1
- package/src/useInternationalization/useInternationalization.ts +5 -3
- package/src/useLandingSearch/useLandingSearch.test.ts +1 -0
- package/src/useLandingSearch/useLandingSearch.ts +1 -0
- package/src/useListing/useListing.test.ts +2 -0
- package/src/useListing/useListing.ts +3 -2
- package/src/useLocalWishlist/useLocalWishlist.test.ts +1 -0
- package/src/useNavigation/useNavigation.test.ts +24 -1
- package/src/useNavigation/useNavigation.ts +36 -14
- package/src/useNavigationContext/useNavigationContext.test.ts +1 -0
- package/src/useNavigationContext/useNavigationContext.ts +1 -0
- package/src/useNavigationSearch/useNavigationSearch.test.ts +125 -2
- package/src/useNavigationSearch/useNavigationSearch.ts +38 -21
- package/src/useNewsletter/useNewsletter.test.ts +5 -1
- package/src/useNewsletter/useNewsletter.ts +5 -1
- package/src/useNotifications/useNotifications.test.ts +1 -0
- package/src/useOrderDetails/useOrderDetails.test.ts +1 -0
- package/src/useOrderDetails/useOrderDetails.ts +1 -0
- package/src/useOrderPayment/useOrderPayment.test.ts +2 -0
- package/src/useOrderPayment/useOrderPayment.ts +1 -0
- package/src/usePrice/usePrice.test.ts +2 -0
- package/src/usePrice/usePrice.ts +1 -0
- package/src/useProduct/useProduct.test.ts +2 -0
- package/src/useProduct/useProduct.ts +2 -0
- package/src/useProductAssociations/useProductAssociations.spec.ts +48 -0
- package/src/useProductAssociations/useProductAssociations.ts +7 -3
- package/src/useProductConfigurator/useProductConfigurator.spec.ts +24 -0
- package/src/useProductConfigurator/useProductConfigurator.ts +20 -13
- package/src/useProductPrice/useProductPrice.test.ts +2 -0
- package/src/useProductPrice/useProductPrice.ts +1 -0
- package/src/useProductReviews/useProductReviews.test.ts +1 -0
- package/src/useProductReviews/useProductReviews.ts +1 -0
- package/src/useProductSearch/useProductSearch.test.ts +24 -1
- package/src/useProductSearch/useProductSearch.ts +24 -11
- package/src/useProductSearchSuggest/useProductSearchSuggest.test.ts +1 -0
- package/src/useProductSearchSuggest/useProductSearchSuggest.ts +1 -0
- package/src/useProductWishlist/useProductWishlist.test.ts +2 -0
- package/src/useProductWishlist/useProductWishlist.ts +1 -0
- package/src/useSalutations/useSalutations.spec.ts +15 -0
- package/src/useSalutations/useSalutations.ts +5 -2
- package/src/useSessionContext/useSessionContext.test.ts +18 -0
- package/src/useSessionContext/useSessionContext.ts +10 -0
- package/src/useShopwareContext/useShopwareContext.test.ts +1 -0
- package/src/useShopwareContext/useShopwareContext.ts +13 -0
- package/src/useSyncWishlist/useSyncWishlist.test.ts +1 -0
- package/src/useSyncWishlist/useSyncWishlist.ts +1 -0
- package/src/useUrlResolver/useUrlResolver.test.ts +1 -0
- package/src/useUser/useUser.test.ts +35 -2
- package/src/useUser/useUser.ts +34 -25
- package/src/useWishlist/useWishlist.test.ts +2 -0
- package/src/useWishlist/useWishlist.ts +1 -0
package/README.md
CHANGED
|
@@ -123,6 +123,7 @@ Let's get back to the step where the `api-client` was initialized:
|
|
|
123
123
|
```ts [apiClient.ts]
|
|
124
124
|
import { createAPIClient } from "@shopware/api-client";
|
|
125
125
|
import Cookies from "js-cookie";
|
|
126
|
+
|
|
126
127
|
import type { operations } from "#shopware";
|
|
127
128
|
|
|
128
129
|
const shopwareEndpoint = "https://demo-frontends.shopware.store/store-api";
|
|
@@ -165,18 +166,20 @@ All composable functions are fully typed with TypeScript and they are registed g
|
|
|
165
166
|
|
|
166
167
|
Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/composables/CHANGELOG.md)
|
|
167
168
|
|
|
168
|
-
### Latest changes: 1.
|
|
169
|
+
### Latest changes: 1.12.0
|
|
169
170
|
|
|
170
171
|
### Minor Changes
|
|
171
172
|
|
|
172
|
-
- [#
|
|
173
|
+
- [#2486](https://github.com/shopware/frontends/pull/2486) [`5678fb0`](https://github.com/shopware/frontends/commit/5678fb008cbd86eaddd061e004de89e6f45bb7ec) Thanks [@mkucmus](https://github.com/mkucmus)! - `useSessionContext`: expose `currentLocaleCode` — the active language's locale code (e.g. `"en-GB"`), read directly from the context's `languageInfo`. The current locale can now be derived from the session context alone, without loading the full language list via `useInternationalization().getAvailableLanguages()` just to map the current `languageId` to a locale.
|
|
173
174
|
|
|
174
|
-
|
|
175
|
+
- [#2473](https://github.com/shopware/frontends/pull/2473) [`22611e5`](https://github.com/shopware/frontends/commit/22611e542b8f42a4f34dce5186f628f9a17f457b) Thanks [@mkucmus](https://github.com/mkucmus)! - Add an opt-in `cacheableReads` flag that routes anonymous Store API reads through their cacheable GET variants instead of POST. Criteria is compressed into the `_criteria` query param via `encodeForQuery` from `@shopware/api-client/helpers`, which lets CDNs / reverse proxies / the browser cache the responses.
|
|
176
|
+
|
|
177
|
+
Disabled by default — fully backwards compatible. Enable it in `nuxt.config` (`shopware: { cacheableReads: true }`) or via `createShopwareContext(app, { cacheableReads: true })` for non-Nuxt setups. It is surfaced on the Shopware context and read by the affected composables; public composable signatures are unchanged.
|
|
175
178
|
|
|
176
|
-
|
|
179
|
+
Affected composables: `useNavigation`, `useNavigationSearch`, `useCountries`, `useUser` (country + salutation lookups), `useSalutations`, `useInternationalization`, `useProductConfigurator`, `useProductSearch`, and `useCategorySearch.advancedSearch`.
|
|
177
180
|
|
|
178
|
-
|
|
181
|
+
`useListing` (product-listing), single-category `useCategorySearch.search`, and `useLandingSearch` remain POST for now: the generated Store API schema does not type `_criteria` on those GET routes (a Shopware OpenAPI gap). The backend does honor `_criteria` on product-listing GET at runtime, so that one can be migrated later once the types are augmented.
|
|
182
|
+
|
|
183
|
+
### Patch Changes
|
|
179
184
|
|
|
180
|
-
-
|
|
181
|
-
- @shopware/api-client@1.5.0
|
|
182
|
-
- @shopware/helpers@1.7.0
|
|
185
|
+
- [#2462](https://github.com/shopware/frontends/pull/2462) [`8be060d`](https://github.com/shopware/frontends/commit/8be060de825ca799f98a8f045a5e7fea61f5d1a2) Thanks [@mkucmus](https://github.com/mkucmus)! - `useProductAssociations`: add optional `includeSeoUrls` option. When `true`, the cross-selling request sends `sw-include-seo-urls: true` so returned products include the `seoUrls` association. Defaults to `false` to avoid extra backend overhead.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { CSSProperties, ComputedRef, AnchorHTMLAttributes, ImgHTMLAttributes, App, EffectScope, Ref } from 'vue';
|
|
3
3
|
import { createAPIClient, ApiError } from '@shopware/api-client';
|
|
4
|
-
import { operations as operations$1
|
|
4
|
+
import { components, operations as operations$1 } from '@shopware/api-client/store-api-types';
|
|
5
5
|
import * as _shopware_api_client_api_types from '@shopware/api-client/api-types';
|
|
6
6
|
import { getListingFilters, TierPrice } from '@shopware/helpers';
|
|
7
7
|
|
|
@@ -421,6 +421,13 @@ declare function createShopwareContext(app: App, options: {
|
|
|
421
421
|
devStorefrontUrl?: string | null;
|
|
422
422
|
enableDevtools?: boolean;
|
|
423
423
|
browserLocale?: string;
|
|
424
|
+
/**
|
|
425
|
+
* Opt in to reading data via cacheable GET Store API routes instead of
|
|
426
|
+
* POST. Surfaced on the Shopware context as `cacheableReads`.
|
|
427
|
+
*
|
|
428
|
+
* @default false
|
|
429
|
+
*/
|
|
430
|
+
cacheableReads?: boolean;
|
|
424
431
|
}): vue.Raw<{
|
|
425
432
|
install(app: App): void;
|
|
426
433
|
_a: App<any>;
|
|
@@ -430,6 +437,7 @@ declare function createShopwareContext(app: App, options: {
|
|
|
430
437
|
interceptors: {};
|
|
431
438
|
} | undefined;
|
|
432
439
|
browserLocale: string;
|
|
440
|
+
cacheableReads: boolean;
|
|
433
441
|
}>;
|
|
434
442
|
|
|
435
443
|
type UseAddressReturn = {
|
|
@@ -1374,7 +1382,7 @@ type UseNewsletterReturn = {
|
|
|
1374
1382
|
* Subscribes the user to the newsletter
|
|
1375
1383
|
* @param params {@link operations['subscribeToNewsletter post /newsletter/subscribe']['body']}
|
|
1376
1384
|
*/
|
|
1377
|
-
newsletterSubscribe(params: Omit<operations["subscribeToNewsletter post /newsletter/subscribe"]["body"], "storefrontUrl">): Promise<
|
|
1385
|
+
newsletterSubscribe(params: Omit<operations["subscribeToNewsletter post /newsletter/subscribe"]["body"], "storefrontUrl">): Promise<operations["subscribeToNewsletter post /newsletter/subscribe"]["response"]>;
|
|
1378
1386
|
/**
|
|
1379
1387
|
* Removes the email from the newsletter
|
|
1380
1388
|
* @param email
|
|
@@ -1715,6 +1723,7 @@ type UseProductAssociationsReturn = {
|
|
|
1715
1723
|
*/
|
|
1716
1724
|
declare function useProductAssociations(product: ComputedRef<Schemas["Product"]>, options: {
|
|
1717
1725
|
associationContext: "cross-selling" | "reviews";
|
|
1726
|
+
includeSeoUrls?: boolean;
|
|
1718
1727
|
}): UseProductAssociationsReturn;
|
|
1719
1728
|
|
|
1720
1729
|
type UseProductConfiguratorReturn = {
|
|
@@ -2018,6 +2027,12 @@ type UseSessionContextReturn = {
|
|
|
2018
2027
|
* current language code
|
|
2019
2028
|
*/
|
|
2020
2029
|
currentLanguageId: ComputedRef<string | undefined>;
|
|
2030
|
+
/**
|
|
2031
|
+
* Locale code of the active language (e.g. `"en-GB"`), read from the
|
|
2032
|
+
* context's `languageInfo`. Available from the session context alone — no
|
|
2033
|
+
* separate language list request is required to detect the current locale.
|
|
2034
|
+
*/
|
|
2035
|
+
currentLocaleCode: ComputedRef<string | undefined>;
|
|
2021
2036
|
/**
|
|
2022
2037
|
* current context's customer object
|
|
2023
2038
|
*/
|
|
@@ -2042,6 +2057,16 @@ type ShopwareContext = {
|
|
|
2042
2057
|
* If not provided, it will be "en-US"
|
|
2043
2058
|
*/
|
|
2044
2059
|
browserLocale: string;
|
|
2060
|
+
/**
|
|
2061
|
+
* When `true`, composables read data through the cacheable GET variants of
|
|
2062
|
+
* the Store API (criteria compressed into the `_criteria` query param)
|
|
2063
|
+
* instead of POST, so the responses can be cached by HTTP infrastructure
|
|
2064
|
+
* (CDN, reverse proxy, browser). Requires a backend that supports the GET
|
|
2065
|
+
* read routes.
|
|
2066
|
+
*
|
|
2067
|
+
* @default false
|
|
2068
|
+
*/
|
|
2069
|
+
cacheableReads: boolean;
|
|
2045
2070
|
};
|
|
2046
2071
|
/**
|
|
2047
2072
|
* @public
|
|
@@ -2343,4 +2368,5 @@ declare function getDefaultApiParams(): {
|
|
|
2343
2368
|
[composableName: string]: unknown;
|
|
2344
2369
|
};
|
|
2345
2370
|
|
|
2346
|
-
export {
|
|
2371
|
+
export { createCategoryListingContext, createListingComposable, createShopwareContext, getDefaultApiParams, resolveCmsComponent, useAddToCart, useAddress, useB2bQuoteManagement, useBreadcrumbs, useCart, useCartErrorParamsResolver, useCartFunction, useCartItem, useCartNotification, useCategory, useCategoryListing, useCategorySearch, useCheckout, useCmsBlock, useCmsElementConfig, useCmsElementImage, useCmsMeta, useCmsSection, useCmsTranslations, useContext, useCountries, useCustomerOrders, useCustomerPassword, useDefaultOrderAssociations, useInternationalization, useLandingSearch, useListing, useLocalWishlist, useNavigation, useNavigationContext, useNavigationSearch, useNewsletter, useNotifications, useOrderDetails, useOrderPayment, usePrice, useProduct, useProductAssociations, useProductConfigurator, useProductPrice, useProductReviews, useProductSearch, useProductSearchListing, useProductSearchSuggest, useProductWishlist, useSalutations, useSessionContext, useShopwareContext, useSyncWishlist, useUrlResolver, useUser, useWishlist };
|
|
2372
|
+
export type { BoxLayout, Breadcrumb, ChangePaymentShippingMethodParams, CmsBlockCategoryNavigation, CmsBlockCenterText, CmsBlockCrossSelling, CmsBlockForm, CmsBlockGalleryBuybox, CmsBlockHtml, CmsBlockImage, CmsBlockImageBubbleRow, CmsBlockImageCover, CmsBlockImageFourColumn, CmsBlockImageGallery, CmsBlockImageGalleryBig, CmsBlockImageHighlightRow, CmsBlockImageSimpleGrid, CmsBlockImageSlider, CmsBlockImageText, CmsBlockImageTextBubble, CmsBlockImageTextCover, CmsBlockImageTextGallery, CmsBlockImageTextRow, CmsBlockImageThreeColumn, CmsBlockImageThreeCover, CmsBlockImageTwoColumn, CmsBlockProductDescriptionReviews, CmsBlockProductHeading, CmsBlockProductListing, CmsBlockProductSlider, CmsBlockProductThreeColumn, CmsBlockSidebarFilter, CmsBlockText, CmsBlockTextHero, CmsBlockTextOnImage, CmsBlockTextTeaser, CmsBlockTextTeaserSection, CmsBlockTextThreeColumn, CmsBlockTextTwoColumn, CmsBlockVimeoVideo, CmsBlockYoutubeVideo, CmsElementBuyBox, CmsElementCategoryNavigation, CmsElementCrossSelling, CmsElementForm, CmsElementHtml, CmsElementImage, CmsElementImageGallery, CmsElementImageSlider, CmsElementManufacturerLogo, CmsElementProductBox, CmsElementProductDescriptionReviews, CmsElementProductListing, CmsElementProductName, CmsElementProductSlider, CmsElementSidebarFilter, CmsElementText, CmsElementVimeoVideo, CmsElementYoutubeVideo, CmsSectionBlock, CmsSectionDefault, CmsSectionSidebar, DisplayMode, ElementConfig, ErrorObjectParam, ImageContainerAttrs, ListingType, Notification, NotificationOptions, Position, RouteObject, ShopwareContext, ShortcutFilterParam, SliderElementConfig, SourceType, UseAddToCartReturn, UseAddressReturn, UseBreadcrumbsReturn, UseCartErrorParamsResolver, UseCartItemReturn, UseCartReturn, UseCategoryReturn, UseCategorySearchReturn, UseCheckoutReturn, UseCmsBlockReturn, UseCmsElementImage, UseCmsMetaReturn, UseCountriesReturn, UseCustomerOrdersReturn, UseCustomerPasswordReturn, UseInternationalizationReturn, UseLandingSearchReturn, UseListingReturn, UseLocalWishlistReturn, UseNavigationContextReturn, UseNavigationReturn, UseNavigationSearchReturn, UseNewsletterReturn, UseNotificationsReturn, UseOrderDetailsReturn, UseOrderPaymentReturn, UsePriceReturn, UseProductAssociationsReturn, UseProductConfiguratorReturn, UseProductPriceReturn, UseProductReturn, UseProductReviewsReturn, UseProductSearchReturn, UseProductSearchSuggestReturn, UseProductWishlistReturn, UseSalutationsReturn, UseSessionContextReturn, UseSyncWishlistReturn, UseUserReturn, UseWishlistReturn, VerticalAlign, useCartNotificationReturn };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { CSSProperties, ComputedRef, AnchorHTMLAttributes, ImgHTMLAttributes, App, EffectScope, Ref } from 'vue';
|
|
3
3
|
import { createAPIClient, ApiError } from '@shopware/api-client';
|
|
4
|
-
import { operations as operations$1
|
|
4
|
+
import { components, operations as operations$1 } from '@shopware/api-client/store-api-types';
|
|
5
5
|
import * as _shopware_api_client_api_types from '@shopware/api-client/api-types';
|
|
6
6
|
import { getListingFilters, TierPrice } from '@shopware/helpers';
|
|
7
7
|
|
|
@@ -421,6 +421,13 @@ declare function createShopwareContext(app: App, options: {
|
|
|
421
421
|
devStorefrontUrl?: string | null;
|
|
422
422
|
enableDevtools?: boolean;
|
|
423
423
|
browserLocale?: string;
|
|
424
|
+
/**
|
|
425
|
+
* Opt in to reading data via cacheable GET Store API routes instead of
|
|
426
|
+
* POST. Surfaced on the Shopware context as `cacheableReads`.
|
|
427
|
+
*
|
|
428
|
+
* @default false
|
|
429
|
+
*/
|
|
430
|
+
cacheableReads?: boolean;
|
|
424
431
|
}): vue.Raw<{
|
|
425
432
|
install(app: App): void;
|
|
426
433
|
_a: App<any>;
|
|
@@ -430,6 +437,7 @@ declare function createShopwareContext(app: App, options: {
|
|
|
430
437
|
interceptors: {};
|
|
431
438
|
} | undefined;
|
|
432
439
|
browserLocale: string;
|
|
440
|
+
cacheableReads: boolean;
|
|
433
441
|
}>;
|
|
434
442
|
|
|
435
443
|
type UseAddressReturn = {
|
|
@@ -1374,7 +1382,7 @@ type UseNewsletterReturn = {
|
|
|
1374
1382
|
* Subscribes the user to the newsletter
|
|
1375
1383
|
* @param params {@link operations['subscribeToNewsletter post /newsletter/subscribe']['body']}
|
|
1376
1384
|
*/
|
|
1377
|
-
newsletterSubscribe(params: Omit<operations["subscribeToNewsletter post /newsletter/subscribe"]["body"], "storefrontUrl">): Promise<
|
|
1385
|
+
newsletterSubscribe(params: Omit<operations["subscribeToNewsletter post /newsletter/subscribe"]["body"], "storefrontUrl">): Promise<operations["subscribeToNewsletter post /newsletter/subscribe"]["response"]>;
|
|
1378
1386
|
/**
|
|
1379
1387
|
* Removes the email from the newsletter
|
|
1380
1388
|
* @param email
|
|
@@ -1715,6 +1723,7 @@ type UseProductAssociationsReturn = {
|
|
|
1715
1723
|
*/
|
|
1716
1724
|
declare function useProductAssociations(product: ComputedRef<Schemas["Product"]>, options: {
|
|
1717
1725
|
associationContext: "cross-selling" | "reviews";
|
|
1726
|
+
includeSeoUrls?: boolean;
|
|
1718
1727
|
}): UseProductAssociationsReturn;
|
|
1719
1728
|
|
|
1720
1729
|
type UseProductConfiguratorReturn = {
|
|
@@ -2018,6 +2027,12 @@ type UseSessionContextReturn = {
|
|
|
2018
2027
|
* current language code
|
|
2019
2028
|
*/
|
|
2020
2029
|
currentLanguageId: ComputedRef<string | undefined>;
|
|
2030
|
+
/**
|
|
2031
|
+
* Locale code of the active language (e.g. `"en-GB"`), read from the
|
|
2032
|
+
* context's `languageInfo`. Available from the session context alone — no
|
|
2033
|
+
* separate language list request is required to detect the current locale.
|
|
2034
|
+
*/
|
|
2035
|
+
currentLocaleCode: ComputedRef<string | undefined>;
|
|
2021
2036
|
/**
|
|
2022
2037
|
* current context's customer object
|
|
2023
2038
|
*/
|
|
@@ -2042,6 +2057,16 @@ type ShopwareContext = {
|
|
|
2042
2057
|
* If not provided, it will be "en-US"
|
|
2043
2058
|
*/
|
|
2044
2059
|
browserLocale: string;
|
|
2060
|
+
/**
|
|
2061
|
+
* When `true`, composables read data through the cacheable GET variants of
|
|
2062
|
+
* the Store API (criteria compressed into the `_criteria` query param)
|
|
2063
|
+
* instead of POST, so the responses can be cached by HTTP infrastructure
|
|
2064
|
+
* (CDN, reverse proxy, browser). Requires a backend that supports the GET
|
|
2065
|
+
* read routes.
|
|
2066
|
+
*
|
|
2067
|
+
* @default false
|
|
2068
|
+
*/
|
|
2069
|
+
cacheableReads: boolean;
|
|
2045
2070
|
};
|
|
2046
2071
|
/**
|
|
2047
2072
|
* @public
|
|
@@ -2343,4 +2368,5 @@ declare function getDefaultApiParams(): {
|
|
|
2343
2368
|
[composableName: string]: unknown;
|
|
2344
2369
|
};
|
|
2345
2370
|
|
|
2346
|
-
export {
|
|
2371
|
+
export { createCategoryListingContext, createListingComposable, createShopwareContext, getDefaultApiParams, resolveCmsComponent, useAddToCart, useAddress, useB2bQuoteManagement, useBreadcrumbs, useCart, useCartErrorParamsResolver, useCartFunction, useCartItem, useCartNotification, useCategory, useCategoryListing, useCategorySearch, useCheckout, useCmsBlock, useCmsElementConfig, useCmsElementImage, useCmsMeta, useCmsSection, useCmsTranslations, useContext, useCountries, useCustomerOrders, useCustomerPassword, useDefaultOrderAssociations, useInternationalization, useLandingSearch, useListing, useLocalWishlist, useNavigation, useNavigationContext, useNavigationSearch, useNewsletter, useNotifications, useOrderDetails, useOrderPayment, usePrice, useProduct, useProductAssociations, useProductConfigurator, useProductPrice, useProductReviews, useProductSearch, useProductSearchListing, useProductSearchSuggest, useProductWishlist, useSalutations, useSessionContext, useShopwareContext, useSyncWishlist, useUrlResolver, useUser, useWishlist };
|
|
2372
|
+
export type { BoxLayout, Breadcrumb, ChangePaymentShippingMethodParams, CmsBlockCategoryNavigation, CmsBlockCenterText, CmsBlockCrossSelling, CmsBlockForm, CmsBlockGalleryBuybox, CmsBlockHtml, CmsBlockImage, CmsBlockImageBubbleRow, CmsBlockImageCover, CmsBlockImageFourColumn, CmsBlockImageGallery, CmsBlockImageGalleryBig, CmsBlockImageHighlightRow, CmsBlockImageSimpleGrid, CmsBlockImageSlider, CmsBlockImageText, CmsBlockImageTextBubble, CmsBlockImageTextCover, CmsBlockImageTextGallery, CmsBlockImageTextRow, CmsBlockImageThreeColumn, CmsBlockImageThreeCover, CmsBlockImageTwoColumn, CmsBlockProductDescriptionReviews, CmsBlockProductHeading, CmsBlockProductListing, CmsBlockProductSlider, CmsBlockProductThreeColumn, CmsBlockSidebarFilter, CmsBlockText, CmsBlockTextHero, CmsBlockTextOnImage, CmsBlockTextTeaser, CmsBlockTextTeaserSection, CmsBlockTextThreeColumn, CmsBlockTextTwoColumn, CmsBlockVimeoVideo, CmsBlockYoutubeVideo, CmsElementBuyBox, CmsElementCategoryNavigation, CmsElementCrossSelling, CmsElementForm, CmsElementHtml, CmsElementImage, CmsElementImageGallery, CmsElementImageSlider, CmsElementManufacturerLogo, CmsElementProductBox, CmsElementProductDescriptionReviews, CmsElementProductListing, CmsElementProductName, CmsElementProductSlider, CmsElementSidebarFilter, CmsElementText, CmsElementVimeoVideo, CmsElementYoutubeVideo, CmsSectionBlock, CmsSectionDefault, CmsSectionSidebar, DisplayMode, ElementConfig, ErrorObjectParam, ImageContainerAttrs, ListingType, Notification, NotificationOptions, Position, RouteObject, ShopwareContext, ShortcutFilterParam, SliderElementConfig, SourceType, UseAddToCartReturn, UseAddressReturn, UseBreadcrumbsReturn, UseCartErrorParamsResolver, UseCartItemReturn, UseCartReturn, UseCategoryReturn, UseCategorySearchReturn, UseCheckoutReturn, UseCmsBlockReturn, UseCmsElementImage, UseCmsMetaReturn, UseCountriesReturn, UseCustomerOrdersReturn, UseCustomerPasswordReturn, UseInternationalizationReturn, UseLandingSearchReturn, UseListingReturn, UseLocalWishlistReturn, UseNavigationContextReturn, UseNavigationReturn, UseNavigationSearchReturn, UseNewsletterReturn, UseNotificationsReturn, UseOrderDetailsReturn, UseOrderPaymentReturn, UsePriceReturn, UseProductAssociationsReturn, UseProductConfiguratorReturn, UseProductPriceReturn, UseProductReturn, UseProductReviewsReturn, UseProductSearchReturn, UseProductSearchSuggestReturn, UseProductWishlistReturn, UseSalutationsReturn, UseSessionContextReturn, UseSyncWishlistReturn, UseUserReturn, UseWishlistReturn, VerticalAlign, useCartNotificationReturn };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { pascalCase } from 'scule';
|
|
2
2
|
import { computed, effectScope, reactive, markRaw, inject, ref, provide, unref, onMounted, watch, resolveComponent } from 'vue';
|
|
3
|
-
import { urlIsAbsolute, relativeUrlSlash, getSrcSetForMedia, getMainImageUrl, getTranslatedProperty, getListingFilters, getProductTierPrices, buildUrlPrefix } from '@shopware/helpers';
|
|
3
|
+
import { urlIsAbsolute, relativeUrlSlash, getSrcSetForMedia, getMainImageUrl, getTranslatedProperty, getListingFilters, isTechnicalPath, normalizePath, getRouteFromPathInfo, getProductTierPrices, buildUrlPrefix } from '@shopware/helpers';
|
|
4
4
|
import { ApiClientError } from '@shopware/api-client';
|
|
5
5
|
import { createSharedComposable, injectLocal, provideLocal, createInjectionState, syncRefs } from '@vueuse/core';
|
|
6
|
+
import { encodeForQuery } from '@shopware/api-client/helpers';
|
|
6
7
|
import { defu } from 'defu';
|
|
7
8
|
|
|
8
9
|
function useCmsElementImage(element) {
|
|
@@ -86,7 +87,8 @@ function createShopwareContext(app, options) {
|
|
|
86
87
|
_e: scope,
|
|
87
88
|
devStorefrontUrl: options.devStorefrontUrl,
|
|
88
89
|
state,
|
|
89
|
-
browserLocale: options.browserLocale || "en-US"
|
|
90
|
+
browserLocale: options.browserLocale || "en-US",
|
|
91
|
+
cacheableReads: options.cacheableReads ?? false
|
|
90
92
|
});
|
|
91
93
|
if (options?.enableDevtools && typeof window !== "undefined") ;
|
|
92
94
|
return shopwarePlugin;
|
|
@@ -522,7 +524,7 @@ const cmsAssociations = {
|
|
|
522
524
|
};
|
|
523
525
|
|
|
524
526
|
function useCategorySearch() {
|
|
525
|
-
const { apiClient } = useShopwareContext();
|
|
527
|
+
const { apiClient, cacheableReads } = useShopwareContext();
|
|
526
528
|
async function search(categoryId, options) {
|
|
527
529
|
const associations = options?.withCmsAssociations ? cmsAssociations : {};
|
|
528
530
|
const result = await apiClient.invoke(
|
|
@@ -544,11 +546,14 @@ function useCategorySearch() {
|
|
|
544
546
|
}
|
|
545
547
|
async function advancedSearch(options) {
|
|
546
548
|
const associations = options?.withCmsAssociations ? cmsAssociations.associations : {};
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
549
|
+
const criteria = {
|
|
550
|
+
associations,
|
|
551
|
+
...options?.query
|
|
552
|
+
};
|
|
553
|
+
const result = cacheableReads ? await apiClient.invoke("readCategoryListGet get /category", {
|
|
554
|
+
query: { _criteria: encodeForQuery(criteria) }
|
|
555
|
+
}) : await apiClient.invoke("readCategoryList post /category", {
|
|
556
|
+
body: criteria
|
|
552
557
|
});
|
|
553
558
|
return result.data.elements ?? [];
|
|
554
559
|
}
|
|
@@ -698,16 +703,19 @@ function useContext(injectionName, params) {
|
|
|
698
703
|
}
|
|
699
704
|
|
|
700
705
|
function useCountries() {
|
|
701
|
-
const { apiClient } = useShopwareContext();
|
|
706
|
+
const { apiClient, cacheableReads } = useShopwareContext();
|
|
702
707
|
const _sharedCountries = inject("swCountries", ref());
|
|
703
708
|
provide("swCountries", _sharedCountries);
|
|
704
709
|
async function fetchCountries() {
|
|
705
|
-
const
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
states: {}
|
|
709
|
-
}
|
|
710
|
+
const criteria = {
|
|
711
|
+
associations: {
|
|
712
|
+
states: {}
|
|
710
713
|
}
|
|
714
|
+
};
|
|
715
|
+
const result = cacheableReads ? await apiClient.invoke("readCountryGet get /country", {
|
|
716
|
+
query: { _criteria: encodeForQuery(criteria) }
|
|
717
|
+
}) : await apiClient.invoke("readCountry post /country", {
|
|
718
|
+
body: criteria
|
|
711
719
|
});
|
|
712
720
|
_sharedCountries.value = result.data.elements;
|
|
713
721
|
return result.data;
|
|
@@ -835,8 +843,7 @@ function useDefaultOrderAssociations() {
|
|
|
835
843
|
}
|
|
836
844
|
|
|
837
845
|
function useInternationalization(pathResolver) {
|
|
838
|
-
const { devStorefrontUrl } = useShopwareContext();
|
|
839
|
-
const { apiClient } = useShopwareContext();
|
|
846
|
+
const { devStorefrontUrl, apiClient, cacheableReads } = useShopwareContext();
|
|
840
847
|
const _storeLanguages = useContext("swLanguages");
|
|
841
848
|
const _storeCurrentLanguage = useContext(
|
|
842
849
|
"swLanguagesCurrentLanguage"
|
|
@@ -846,7 +853,7 @@ function useInternationalization(pathResolver) {
|
|
|
846
853
|
return devStorefrontUrl ?? window.location.origin ?? "";
|
|
847
854
|
}
|
|
848
855
|
async function getAvailableLanguages() {
|
|
849
|
-
const { data } = await apiClient.invoke("readLanguages post /language");
|
|
856
|
+
const { data } = cacheableReads ? await apiClient.invoke("readLanguagesGet get /language") : await apiClient.invoke("readLanguages post /language");
|
|
850
857
|
_storeLanguages.value = data.elements;
|
|
851
858
|
return data;
|
|
852
859
|
}
|
|
@@ -1262,7 +1269,7 @@ function useLocalWishlist() {
|
|
|
1262
1269
|
|
|
1263
1270
|
function useNavigation(params) {
|
|
1264
1271
|
const type = params?.type || "main-navigation";
|
|
1265
|
-
const { apiClient } = useShopwareContext();
|
|
1272
|
+
const { apiClient, cacheableReads } = useShopwareContext();
|
|
1266
1273
|
const sharedElements = inject(
|
|
1267
1274
|
`swNavigation-${type}`,
|
|
1268
1275
|
ref([])
|
|
@@ -1271,7 +1278,24 @@ function useNavigation(params) {
|
|
|
1271
1278
|
const navigationElements = computed(() => sharedElements.value);
|
|
1272
1279
|
async function loadNavigationElements(params2) {
|
|
1273
1280
|
try {
|
|
1274
|
-
const
|
|
1281
|
+
const { buildTree, depth, ...criteria } = params2;
|
|
1282
|
+
const navigationResponse = cacheableReads ? await apiClient.invoke(
|
|
1283
|
+
"readNavigationGet get /navigation/{activeId}/{rootId}",
|
|
1284
|
+
{
|
|
1285
|
+
headers: {
|
|
1286
|
+
"sw-include-seo-urls": true
|
|
1287
|
+
},
|
|
1288
|
+
pathParams: {
|
|
1289
|
+
activeId: type,
|
|
1290
|
+
rootId: type
|
|
1291
|
+
},
|
|
1292
|
+
query: {
|
|
1293
|
+
_criteria: encodeForQuery(criteria),
|
|
1294
|
+
buildTree,
|
|
1295
|
+
depth
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
) : await apiClient.invoke(
|
|
1275
1299
|
"readNavigation post /navigation/{activeId}/{rootId}",
|
|
1276
1300
|
{
|
|
1277
1301
|
headers: {
|
|
@@ -1310,7 +1334,7 @@ function useNavigationContext(context) {
|
|
|
1310
1334
|
}
|
|
1311
1335
|
|
|
1312
1336
|
function useNavigationSearch() {
|
|
1313
|
-
const { apiClient } = useShopwareContext();
|
|
1337
|
+
const { apiClient, cacheableReads } = useShopwareContext();
|
|
1314
1338
|
const { sessionContext } = useSessionContext();
|
|
1315
1339
|
async function resolvePath(path) {
|
|
1316
1340
|
if (path === "/") {
|
|
@@ -1320,20 +1344,31 @@ function useNavigationSearch() {
|
|
|
1320
1344
|
foreignKey: categoryId
|
|
1321
1345
|
};
|
|
1322
1346
|
}
|
|
1323
|
-
const isTechnicalUrl =
|
|
1324
|
-
const normalizedPath = isTechnicalUrl ?
|
|
1325
|
-
const
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1347
|
+
const isTechnicalUrl = isTechnicalPath(path);
|
|
1348
|
+
const normalizedPath = isTechnicalUrl ? normalizePath(path) : path.substring(1);
|
|
1349
|
+
const criteria = {
|
|
1350
|
+
filter: [
|
|
1351
|
+
{
|
|
1352
|
+
type: "equals",
|
|
1353
|
+
field: isTechnicalUrl ? "pathInfo" : "seoPathInfo",
|
|
1354
|
+
value: normalizedPath
|
|
1355
|
+
}
|
|
1356
|
+
]
|
|
1357
|
+
};
|
|
1358
|
+
const seoResult = cacheableReads ? await apiClient.invoke("readSeoUrlGet get /seo-url", {
|
|
1359
|
+
query: { _criteria: encodeForQuery(criteria) }
|
|
1360
|
+
}) : await apiClient.invoke("readSeoUrl post /seo-url", {
|
|
1361
|
+
body: criteria
|
|
1335
1362
|
});
|
|
1336
|
-
|
|
1363
|
+
const element = seoResult.data.elements?.[0];
|
|
1364
|
+
if (element) {
|
|
1365
|
+
return element;
|
|
1366
|
+
}
|
|
1367
|
+
const fallback = getRouteFromPathInfo(path);
|
|
1368
|
+
if (fallback) {
|
|
1369
|
+
return fallback;
|
|
1370
|
+
}
|
|
1371
|
+
return null;
|
|
1337
1372
|
}
|
|
1338
1373
|
return {
|
|
1339
1374
|
resolvePath
|
|
@@ -1356,6 +1391,7 @@ function useNewsletter() {
|
|
|
1356
1391
|
}
|
|
1357
1392
|
}
|
|
1358
1393
|
);
|
|
1394
|
+
newsletterStatus.value = result.data.status;
|
|
1359
1395
|
return result.data;
|
|
1360
1396
|
}
|
|
1361
1397
|
async function newsletterUnsubscribe(email) {
|
|
@@ -1404,7 +1440,7 @@ function useNotifications() {
|
|
|
1404
1440
|
_notifications.value = [];
|
|
1405
1441
|
}
|
|
1406
1442
|
function geterateId() {
|
|
1407
|
-
return +`${( new Date()).getTime()}${Math.random() * 1e3}`;
|
|
1443
|
+
return +`${(/* @__PURE__ */ new Date()).getTime()}${Math.random() * 1e3}`;
|
|
1408
1444
|
}
|
|
1409
1445
|
async function pushNotification(message, options) {
|
|
1410
1446
|
const timeout = options.timeout || 2500;
|
|
@@ -1730,7 +1766,6 @@ function useProduct(product, configurator) {
|
|
|
1730
1766
|
function useProductAssociations(product, options) {
|
|
1731
1767
|
if (!product.value)
|
|
1732
1768
|
throw new Error("[useProductAssociations]: Product is not provided.");
|
|
1733
|
-
options.associationContext;
|
|
1734
1769
|
const { apiClient } = useShopwareContext();
|
|
1735
1770
|
const isLoading = ref(false);
|
|
1736
1771
|
const associations = ref([]);
|
|
@@ -1740,6 +1775,11 @@ function useProductAssociations(product, options) {
|
|
|
1740
1775
|
const response = await apiClient.invoke(
|
|
1741
1776
|
"readProductCrossSellings post /product/{productId}/cross-selling",
|
|
1742
1777
|
{
|
|
1778
|
+
...options.includeSeoUrls && {
|
|
1779
|
+
headers: {
|
|
1780
|
+
"sw-include-seo-urls": true
|
|
1781
|
+
}
|
|
1782
|
+
},
|
|
1743
1783
|
pathParams: { productId: product.value.id }
|
|
1744
1784
|
}
|
|
1745
1785
|
);
|
|
@@ -1761,7 +1801,7 @@ function useProductAssociations(product, options) {
|
|
|
1761
1801
|
}
|
|
1762
1802
|
|
|
1763
1803
|
function useProductConfigurator() {
|
|
1764
|
-
const { apiClient } = useShopwareContext();
|
|
1804
|
+
const { apiClient, cacheableReads } = useShopwareContext();
|
|
1765
1805
|
const { configurator, product } = useProduct();
|
|
1766
1806
|
const selected = ref({});
|
|
1767
1807
|
const isLoadingOptions = ref(!!product.value.options?.length);
|
|
@@ -1800,18 +1840,21 @@ function useProductConfigurator() {
|
|
|
1800
1840
|
)
|
|
1801
1841
|
];
|
|
1802
1842
|
try {
|
|
1803
|
-
const
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
seoUrls: {}
|
|
1813
|
-
}
|
|
1843
|
+
const criteria = {
|
|
1844
|
+
filter,
|
|
1845
|
+
limit: 1,
|
|
1846
|
+
includes: {
|
|
1847
|
+
product: ["id", "translated", "productNumber", "seoUrls"],
|
|
1848
|
+
seo_url: ["seoPathInfo"]
|
|
1849
|
+
},
|
|
1850
|
+
associations: {
|
|
1851
|
+
seoUrls: {}
|
|
1814
1852
|
}
|
|
1853
|
+
};
|
|
1854
|
+
const response = cacheableReads ? await apiClient.invoke("readProductGet get /product", {
|
|
1855
|
+
query: { _criteria: encodeForQuery(criteria) }
|
|
1856
|
+
}) : await apiClient.invoke("readProduct post /product", {
|
|
1857
|
+
body: criteria
|
|
1815
1858
|
});
|
|
1816
1859
|
return response.data.elements?.[0];
|
|
1817
1860
|
} catch (e) {
|
|
@@ -1922,23 +1965,31 @@ function useProductReviews(product) {
|
|
|
1922
1965
|
}
|
|
1923
1966
|
|
|
1924
1967
|
function useProductSearch() {
|
|
1925
|
-
const { apiClient } = useShopwareContext();
|
|
1968
|
+
const { apiClient, cacheableReads } = useShopwareContext();
|
|
1926
1969
|
const search = async (productId, options) => {
|
|
1927
1970
|
const associations = defu(
|
|
1928
1971
|
options?.withCmsAssociations ? cmsAssociations : {},
|
|
1929
1972
|
options?.criteria,
|
|
1930
1973
|
{ associations: options?.associations ?? {} }
|
|
1931
1974
|
);
|
|
1932
|
-
const result = await apiClient.invoke(
|
|
1933
|
-
"
|
|
1975
|
+
const result = cacheableReads ? await apiClient.invoke(
|
|
1976
|
+
"readProductDetailGet get /product/{productId}",
|
|
1934
1977
|
{
|
|
1935
1978
|
headers: {
|
|
1936
1979
|
"sw-include-seo-urls": true
|
|
1937
1980
|
},
|
|
1938
1981
|
pathParams: { productId },
|
|
1939
|
-
|
|
1982
|
+
query: {
|
|
1983
|
+
_criteria: encodeForQuery(associations)
|
|
1984
|
+
}
|
|
1940
1985
|
}
|
|
1941
|
-
)
|
|
1986
|
+
) : await apiClient.invoke("readProductDetail post /product/{productId}", {
|
|
1987
|
+
headers: {
|
|
1988
|
+
"sw-include-seo-urls": true
|
|
1989
|
+
},
|
|
1990
|
+
pathParams: { productId },
|
|
1991
|
+
body: associations
|
|
1992
|
+
});
|
|
1942
1993
|
return result.data;
|
|
1943
1994
|
};
|
|
1944
1995
|
return {
|
|
@@ -2006,11 +2057,11 @@ function useProductWishlist(productId) {
|
|
|
2006
2057
|
}
|
|
2007
2058
|
|
|
2008
2059
|
function useSalutations() {
|
|
2009
|
-
const { apiClient } = useShopwareContext();
|
|
2060
|
+
const { apiClient, cacheableReads } = useShopwareContext();
|
|
2010
2061
|
const _salutations = inject("swSalutations", ref());
|
|
2011
2062
|
provide("swSalutations", _salutations);
|
|
2012
2063
|
const fetchSalutations = async () => {
|
|
2013
|
-
const result = await apiClient.invoke("readSalutation post /salutation");
|
|
2064
|
+
const result = cacheableReads ? await apiClient.invoke("readSalutationGet get /salutation") : await apiClient.invoke("readSalutation post /salutation");
|
|
2014
2065
|
_salutations.value = result.data.elements;
|
|
2015
2066
|
return result.data;
|
|
2016
2067
|
};
|
|
@@ -2153,6 +2204,9 @@ function useSessionContext(newContext) {
|
|
|
2153
2204
|
const languageIdChain = computed(
|
|
2154
2205
|
() => sessionContext.value?.context?.languageIdChain?.[0] || ""
|
|
2155
2206
|
);
|
|
2207
|
+
const currentLocaleCode = computed(
|
|
2208
|
+
() => sessionContext.value?.languageInfo?.localeCode
|
|
2209
|
+
);
|
|
2156
2210
|
const taxState = computed(() => sessionContext.value?.context?.taxState);
|
|
2157
2211
|
const userFromContext = computed(() => sessionContext.value?.customer);
|
|
2158
2212
|
return {
|
|
@@ -2177,6 +2231,7 @@ function useSessionContext(newContext) {
|
|
|
2177
2231
|
languageIdChain,
|
|
2178
2232
|
salesChannelLanguageId: languageId,
|
|
2179
2233
|
currentLanguageId: languageIdChain,
|
|
2234
|
+
currentLocaleCode,
|
|
2180
2235
|
setCountry,
|
|
2181
2236
|
setContext
|
|
2182
2237
|
};
|
|
@@ -2192,7 +2247,8 @@ function useShopwareContext() {
|
|
|
2192
2247
|
return {
|
|
2193
2248
|
apiClient,
|
|
2194
2249
|
devStorefrontUrl: shopwareContext.devStorefrontUrl,
|
|
2195
|
-
browserLocale: shopwareContext.browserLocale || "en-US"
|
|
2250
|
+
browserLocale: shopwareContext.browserLocale || "en-US",
|
|
2251
|
+
cacheableReads: shopwareContext.cacheableReads ?? false
|
|
2196
2252
|
};
|
|
2197
2253
|
}
|
|
2198
2254
|
|
|
@@ -2289,7 +2345,7 @@ function useUrlResolver() {
|
|
|
2289
2345
|
}
|
|
2290
2346
|
|
|
2291
2347
|
function useUser() {
|
|
2292
|
-
const { apiClient } = useShopwareContext();
|
|
2348
|
+
const { apiClient, cacheableReads } = useShopwareContext();
|
|
2293
2349
|
const { userFromContext, refreshSessionContext } = useSessionContext();
|
|
2294
2350
|
const _user = useContext("customer");
|
|
2295
2351
|
syncRefs(userFromContext, _user, {
|
|
@@ -2358,35 +2414,38 @@ function useUser() {
|
|
|
2358
2414
|
}
|
|
2359
2415
|
}
|
|
2360
2416
|
async function loadCountry(countryId) {
|
|
2361
|
-
const
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2417
|
+
const criteria = {
|
|
2418
|
+
filter: [
|
|
2419
|
+
{
|
|
2420
|
+
field: "id",
|
|
2421
|
+
type: "equals",
|
|
2422
|
+
value: countryId
|
|
2423
|
+
}
|
|
2424
|
+
]
|
|
2425
|
+
};
|
|
2426
|
+
const countries = cacheableReads ? await apiClient.invoke("readCountryGet get /country", {
|
|
2427
|
+
query: { _criteria: encodeForQuery(criteria) }
|
|
2428
|
+
}) : await apiClient.invoke("readCountry post /country", {
|
|
2429
|
+
body: criteria
|
|
2371
2430
|
});
|
|
2372
2431
|
country.value = countries.data.elements?.[0] ?? null;
|
|
2373
2432
|
return countries.data;
|
|
2374
2433
|
}
|
|
2375
2434
|
async function loadSalutation(salutationId) {
|
|
2376
|
-
const
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
field: "id",
|
|
2383
|
-
type: "equals",
|
|
2384
|
-
value: salutationId
|
|
2385
|
-
}
|
|
2386
|
-
]
|
|
2435
|
+
const criteria = {
|
|
2436
|
+
filter: [
|
|
2437
|
+
{
|
|
2438
|
+
field: "id",
|
|
2439
|
+
type: "equals",
|
|
2440
|
+
value: salutationId
|
|
2387
2441
|
}
|
|
2388
|
-
|
|
2389
|
-
|
|
2442
|
+
]
|
|
2443
|
+
};
|
|
2444
|
+
const salutations = cacheableReads ? await apiClient.invoke("readSalutationGet get /salutation", {
|
|
2445
|
+
query: { _criteria: encodeForQuery(criteria) }
|
|
2446
|
+
}) : await apiClient.invoke("readSalutation post /salutation", {
|
|
2447
|
+
body: criteria
|
|
2448
|
+
});
|
|
2390
2449
|
salutation.value = salutations.data.elements?.[0] ?? null;
|
|
2391
2450
|
return salutations.data;
|
|
2392
2451
|
}
|