@shopware/composables 1.12.1 → 1.13.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 +49 -13
- package/dist/index.d.mts +38 -12
- package/dist/index.d.ts +38 -12
- package/dist/index.mjs +58 -16
- package/package.json +6 -6
- package/src/cms/useCmsElementConfig.ts +3 -7
- package/src/cms/useCmsElementImage.test.ts +139 -0
- package/src/cms/useCmsElementImage.ts +19 -1
- package/src/types/cmsElementTypes.ts +6 -2
- package/src/useB2bQuoteManagement/useB2bQuoteManagement.test.ts +61 -1
- package/src/useB2bQuoteManagement/useB2bQuoteManagement.ts +121 -14
- package/src/useListing/useListing.ts +3 -1
- package/src/useProductSearch/useProductSearch.ts +1 -1
package/README.md
CHANGED
|
@@ -166,24 +166,60 @@ All composable functions are fully typed with TypeScript and they are registed g
|
|
|
166
166
|
|
|
167
167
|
Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/composables/CHANGELOG.md)
|
|
168
168
|
|
|
169
|
-
### Latest changes: 1.
|
|
169
|
+
### Latest changes: 1.13.0
|
|
170
170
|
|
|
171
|
-
###
|
|
171
|
+
### Minor Changes
|
|
172
|
+
|
|
173
|
+
- [#2663](https://github.com/shopware/frontends/pull/2663) [`7020545`](https://github.com/shopware/frontends/commit/70205458cb9357a068029d0aaef41898ab94b354) Thanks [@mkucmus](https://github.com/mkucmus)! - `useCmsElementImage` now honours the `ariaLabel` and `isDecorative` fields of a CMS image element, which were ignored before, and returns both. `imageAttrs.alt` is empty for a decorative image. `ariaLabel` names the link the image sits in, as it does in the Storefront, so it is not copied into `alt`.
|
|
174
|
+
|
|
175
|
+
Both fields are optional on the image element config, because a Shopware instance that has never had them set does not return them. `useCmsElementConfig` accepts optional config members now, so `getConfigValue` keeps the declared value type for them instead of widening to `{}`.
|
|
176
|
+
|
|
177
|
+
`SliderElementConfig` gained the `"none"` value for `navigationDots` and `navigationArrows`. The Administration offers it, the type did not list it.
|
|
172
178
|
|
|
173
|
-
- [#
|
|
179
|
+
- [#2642](https://github.com/shopware/frontends/pull/2642) [`183c183`](https://github.com/shopware/frontends/commit/183c183f905486c27fa770fd0f4cd9993e86c20e) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - Add `createDraftQuoteVersion` and `deleteDraftQuoteVersion` to `useB2bQuoteManagement`.
|
|
174
180
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
181
|
+
Quote write operations such as `declineQuoteWithComment` expect the identifier of a temporary storefront draft version, not the `versionId` property of the quote entity. `createDraftQuoteVersion` wraps `POST /quote/{id}/draft-version` and returns that identifier, throwing when the API responds without one; `deleteDraftQuoteVersion` discards the draft again.
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
const { createDraftQuoteVersion, declineQuoteWithComment } =
|
|
185
|
+
useB2bQuoteManagement();
|
|
186
|
+
|
|
187
|
+
const versionId = await createDraftQuoteVersion(quoteId);
|
|
188
|
+
|
|
189
|
+
await declineQuoteWithComment(quoteId, {
|
|
190
|
+
comment: "Too expensive",
|
|
191
|
+
lineItemId,
|
|
192
|
+
versionId,
|
|
193
|
+
});
|
|
194
|
+
```
|
|
178
195
|
|
|
179
|
-
- [#
|
|
196
|
+
- [#2642](https://github.com/shopware/frontends/pull/2642) [`183c183`](https://github.com/shopware/frontends/commit/183c183f905486c27fa770fd0f4cd9993e86c20e) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - Add `declineQuoteWithComment` to `useB2bQuoteManagement`, following the Store API `POST /quote/{id}/decline` schema, which as of `6.7.12` also carries `lineItemId` and `versionId` next to `comment`.
|
|
197
|
+
|
|
198
|
+
`declineQuote` keeps its `(quoteId, comment)` signature and is deprecated. It will be removed in the next major.
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
const { declineQuoteWithComment, createDraftQuoteVersion } =
|
|
202
|
+
useB2bQuoteManagement();
|
|
203
|
+
|
|
204
|
+
const versionId = await createDraftQuoteVersion(quoteId);
|
|
205
|
+
|
|
206
|
+
await declineQuoteWithComment(quoteId, {
|
|
207
|
+
comment: "Too expensive",
|
|
208
|
+
lineItemId,
|
|
209
|
+
versionId,
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Patch Changes
|
|
180
214
|
|
|
181
|
-
- [#
|
|
215
|
+
- [#2676](https://github.com/shopware/frontends/pull/2676) [`458494e`](https://github.com/shopware/frontends/commit/458494e8bd2be88d4fbf161636a109c8f4efc443) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - Realign the composables with the `6.7.13.0` Store API schema:
|
|
182
216
|
|
|
183
|
-
-
|
|
217
|
+
- `useB2bQuoteManagement`: `getQuote()` now invokes `readQuote post /quote/{id}` (was `readQuote post /quote/detail/{id}`) and `createOrderFromQuote()` now invokes `createOrderFromQuote post /quote/{id}/order` (was `createOrderFromQuote post /quote/order/{id}`), matching the renamed endpoints.
|
|
218
|
+
- `useListing`: `getSortingOrders` is typed as `Schemas["ProductListingResult"]["availableSortings"]` instead of the removed `Schemas["ProductSorting"][]`.
|
|
219
|
+
- `useProductSearch`: the `associations` option is typed as `Partial<Schemas["Associations"]>` instead of the removed `Schemas["Association"]`.
|
|
184
220
|
|
|
185
|
-
- [#
|
|
221
|
+
- [#2660](https://github.com/shopware/frontends/pull/2660) [`8913956`](https://github.com/shopware/frontends/commit/89139563924163e57cafdd9770fe603f2dbd8cba) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - `useCmsElementImage` now returns the translated media `alt` in `imageAttrs`. It read `element.data.media.alt` from the entity root, which the Store API fills with the system language value, so the `alt` attribute ignored the language of the current request. The value is now resolved with `getTranslatedProperty()` and falls back to the root property when `translated` is missing.
|
|
186
222
|
|
|
187
|
-
- Updated dependencies [[`
|
|
188
|
-
- @shopware/
|
|
189
|
-
- @shopware/
|
|
223
|
+
- Updated dependencies [[`2ddf156`](https://github.com/shopware/frontends/commit/2ddf156805b2941fe2069e78453fb3c4eb6d44ac), [`204c8f4`](https://github.com/shopware/frontends/commit/204c8f45f737e724db6d00b80c5faef8ddb77cb4), [`183c183`](https://github.com/shopware/frontends/commit/183c183f905486c27fa770fd0f4cd9993e86c20e), [`458494e`](https://github.com/shopware/frontends/commit/458494e8bd2be88d4fbf161636a109c8f4efc443)]:
|
|
224
|
+
- @shopware/helpers@1.8.0
|
|
225
|
+
- @shopware/api-client@1.6.0
|
package/dist/index.d.mts
CHANGED
|
@@ -99,9 +99,11 @@ type ImageElementConfig = {
|
|
|
99
99
|
media: ElementConfig<string>;
|
|
100
100
|
newTab: ElementConfig<boolean>;
|
|
101
101
|
product: ElementConfig<string>;
|
|
102
|
+
ariaLabel?: ElementConfig<string | null>;
|
|
102
103
|
boxLayout: ElementConfig<BoxLayout>;
|
|
103
104
|
displayMode: ElementConfig<DisplayMode>;
|
|
104
105
|
minHeight: ElementConfig<string | number>;
|
|
106
|
+
isDecorative?: ElementConfig<boolean>;
|
|
105
107
|
verticalAlign: ElementConfig<VerticalAlign>;
|
|
106
108
|
horizontalAlign: ElementConfig<VerticalAlign>;
|
|
107
109
|
};
|
|
@@ -112,6 +114,7 @@ type CmsElementImage = Omit<Schemas["CmsSlot"], "config"> & {
|
|
|
112
114
|
mediaId: string;
|
|
113
115
|
url: string;
|
|
114
116
|
newTab: boolean;
|
|
117
|
+
ariaLabel?: string | null;
|
|
115
118
|
apiAlias: "cms_image";
|
|
116
119
|
media: Schemas["Media"];
|
|
117
120
|
};
|
|
@@ -121,8 +124,8 @@ type SliderElementConfig = {
|
|
|
121
124
|
minHeight: ElementConfig<string | number>;
|
|
122
125
|
verticalAlign?: ElementConfig<VerticalAlign>;
|
|
123
126
|
displayMode?: ElementConfig<"standard" | "cover" | "contain">;
|
|
124
|
-
navigationDots?: ElementConfig<"outside" | "inside" | "">;
|
|
125
|
-
navigationArrows?: ElementConfig<"outside" | "inside" | "">;
|
|
127
|
+
navigationDots?: ElementConfig<"outside" | "inside" | "none" | "">;
|
|
128
|
+
navigationArrows?: ElementConfig<"outside" | "inside" | "none" | "">;
|
|
126
129
|
};
|
|
127
130
|
type ImageSliderElementConfig = ImageElementConfig & SliderElementConfig & {
|
|
128
131
|
sliderItems: ElementConfig<Array<{
|
|
@@ -363,6 +366,7 @@ type CmsElementManufacturerLogo = Omit<Schemas["CmsSlot"], "config"> & {
|
|
|
363
366
|
mediaId: string;
|
|
364
367
|
url: string;
|
|
365
368
|
newTab: boolean;
|
|
369
|
+
ariaLabel?: string | null;
|
|
366
370
|
apiAlias: "cms_manufacturer_logo";
|
|
367
371
|
media: Schemas["Media"];
|
|
368
372
|
};
|
|
@@ -391,6 +395,8 @@ type UseCmsElementImage = {
|
|
|
391
395
|
newTab: boolean;
|
|
392
396
|
url: string;
|
|
393
397
|
}>;
|
|
398
|
+
ariaLabel: ComputedRef<string>;
|
|
399
|
+
isDecorative: ComputedRef<boolean>;
|
|
394
400
|
displayMode: ComputedRef<DisplayMode>;
|
|
395
401
|
isVideoElement: ComputedRef<boolean>;
|
|
396
402
|
mimeType: ComputedRef<string | undefined>;
|
|
@@ -408,13 +414,9 @@ declare function useCmsElementImage(element: CmsElementImage | CmsElementManufac
|
|
|
408
414
|
* @category CMS (Shopping Experiences)
|
|
409
415
|
*/
|
|
410
416
|
declare function useCmsElementConfig<T extends Omit<Schemas["CmsSlot"], "config"> & {
|
|
411
|
-
config:
|
|
412
|
-
[key in infer X extends keyof T["config"]]: ElementConfig<unknown>;
|
|
413
|
-
} ? {
|
|
414
|
-
[key in X]: ElementConfig<T["config"][key]["value"]>;
|
|
415
|
-
} : never;
|
|
417
|
+
config: Record<string, ElementConfig<unknown> | undefined>;
|
|
416
418
|
}>(element: T): {
|
|
417
|
-
getConfigValue: <ELEMENT_CONFIG extends keyof T["config"]>(key: ELEMENT_CONFIG) =>
|
|
419
|
+
getConfigValue: <ELEMENT_CONFIG extends keyof T["config"]>(key: ELEMENT_CONFIG) => NonNullable<T["config"][ELEMENT_CONFIG]>["value"];
|
|
418
420
|
};
|
|
419
421
|
|
|
420
422
|
declare function createShopwareContext(app: App, options: {
|
|
@@ -1138,7 +1140,7 @@ type UseListingReturn = {
|
|
|
1138
1140
|
/**
|
|
1139
1141
|
* Available sorting orders
|
|
1140
1142
|
*/
|
|
1141
|
-
getSortingOrders: ComputedRef<Schemas["
|
|
1143
|
+
getSortingOrders: ComputedRef<Schemas["ProductListingResult"]["availableSortings"] | {
|
|
1142
1144
|
key: string;
|
|
1143
1145
|
label: string;
|
|
1144
1146
|
}[] | undefined>;
|
|
@@ -1841,7 +1843,7 @@ declare function useProductReviews(product: Ref<Schemas["Product"]>): UseProduct
|
|
|
1841
1843
|
type UseProductSearchReturnOptions = {
|
|
1842
1844
|
withCmsAssociations?: boolean;
|
|
1843
1845
|
criteria?: Partial<Schemas["Criteria"]>;
|
|
1844
|
-
associations?: Partial<Schemas["
|
|
1846
|
+
associations?: Partial<Schemas["Associations"]>;
|
|
1845
1847
|
};
|
|
1846
1848
|
type UseProductSearchReturn = {
|
|
1847
1849
|
/**
|
|
@@ -2290,13 +2292,36 @@ declare function useWishlist(): UseWishlistReturn;
|
|
|
2290
2292
|
type UseB2bQuoteManagement = {
|
|
2291
2293
|
getQuoteList: () => Promise<Schemas["Quote"][]>;
|
|
2292
2294
|
getQuote: (quoteId: string) => Promise<Schemas["Quote"]>;
|
|
2295
|
+
/**
|
|
2296
|
+
* @deprecated use `declineQuoteWithComment` instead — it sends the
|
|
2297
|
+
* `lineItemId` and `versionId` that `POST /quote/{id}/decline` expects.
|
|
2298
|
+
* A `comment`-only body is still accepted at runtime on 6.7.12+: the API
|
|
2299
|
+
* schema marks `lineItemId` and `versionId` as required, but the endpoint
|
|
2300
|
+
* does not validate the request body, so existing callers keep working.
|
|
2301
|
+
* Removed in v2.
|
|
2302
|
+
*/
|
|
2293
2303
|
declineQuote: (quoteId: string, comment: string) => Promise<void>;
|
|
2304
|
+
declineQuoteWithComment: (quoteId: string, params: DeclineQuoteParams) => Promise<void>;
|
|
2305
|
+
createDraftQuoteVersion: (quoteId: string) => Promise<string>;
|
|
2306
|
+
deleteDraftQuoteVersion: (quoteId: string, versionId: string) => Promise<void>;
|
|
2294
2307
|
requestChangeQuote: (quoteId: string, comment: string) => Promise<void>;
|
|
2295
2308
|
requestQuote: (comment: string) => Promise<Schemas["Quote"]>;
|
|
2296
2309
|
createOrderFromQuote: (quoteId: string, comment: string) => Promise<Schemas["Order"]>;
|
|
2297
2310
|
changeShippingMethod: (quoteId: string, shippingMethodId: string) => Promise<void>;
|
|
2298
2311
|
changePaymentMethod: (quoteId: string, paymentMethodId: string) => Promise<void>;
|
|
2299
2312
|
};
|
|
2313
|
+
type DeclineQuoteParams = {
|
|
2314
|
+
/** Message content */
|
|
2315
|
+
comment: string;
|
|
2316
|
+
/** Identifier of the quote line item that owns the new comment */
|
|
2317
|
+
lineItemId: string;
|
|
2318
|
+
/**
|
|
2319
|
+
* Draft version identifier of the quote currently shown in storefront,
|
|
2320
|
+
* as returned by `createDraftQuoteVersion`. This is not the `versionId`
|
|
2321
|
+
* property of the quote entity.
|
|
2322
|
+
*/
|
|
2323
|
+
versionId: string;
|
|
2324
|
+
};
|
|
2300
2325
|
type ChangePaymentShippingMethodParams = {
|
|
2301
2326
|
quoteId: string;
|
|
2302
2327
|
paymentMethodId?: string;
|
|
@@ -2308,7 +2333,8 @@ type ChangePaymentShippingMethodParams = {
|
|
|
2308
2333
|
* With this composable you can:
|
|
2309
2334
|
* - Get list of quotes
|
|
2310
2335
|
* - Get quote details
|
|
2311
|
-
* -
|
|
2336
|
+
* - Create and delete a storefront draft version of the quote
|
|
2337
|
+
* - Decline quote, with or without a line item comment
|
|
2312
2338
|
* - Request change of the quote
|
|
2313
2339
|
* - Change shipping method
|
|
2314
2340
|
* - Change payment method
|
|
@@ -2374,4 +2400,4 @@ declare function getDefaultApiParams(): {
|
|
|
2374
2400
|
};
|
|
2375
2401
|
|
|
2376
2402
|
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 };
|
|
2377
|
-
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 };
|
|
2403
|
+
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, DeclineQuoteParams, 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
|
@@ -99,9 +99,11 @@ type ImageElementConfig = {
|
|
|
99
99
|
media: ElementConfig<string>;
|
|
100
100
|
newTab: ElementConfig<boolean>;
|
|
101
101
|
product: ElementConfig<string>;
|
|
102
|
+
ariaLabel?: ElementConfig<string | null>;
|
|
102
103
|
boxLayout: ElementConfig<BoxLayout>;
|
|
103
104
|
displayMode: ElementConfig<DisplayMode>;
|
|
104
105
|
minHeight: ElementConfig<string | number>;
|
|
106
|
+
isDecorative?: ElementConfig<boolean>;
|
|
105
107
|
verticalAlign: ElementConfig<VerticalAlign>;
|
|
106
108
|
horizontalAlign: ElementConfig<VerticalAlign>;
|
|
107
109
|
};
|
|
@@ -112,6 +114,7 @@ type CmsElementImage = Omit<Schemas["CmsSlot"], "config"> & {
|
|
|
112
114
|
mediaId: string;
|
|
113
115
|
url: string;
|
|
114
116
|
newTab: boolean;
|
|
117
|
+
ariaLabel?: string | null;
|
|
115
118
|
apiAlias: "cms_image";
|
|
116
119
|
media: Schemas["Media"];
|
|
117
120
|
};
|
|
@@ -121,8 +124,8 @@ type SliderElementConfig = {
|
|
|
121
124
|
minHeight: ElementConfig<string | number>;
|
|
122
125
|
verticalAlign?: ElementConfig<VerticalAlign>;
|
|
123
126
|
displayMode?: ElementConfig<"standard" | "cover" | "contain">;
|
|
124
|
-
navigationDots?: ElementConfig<"outside" | "inside" | "">;
|
|
125
|
-
navigationArrows?: ElementConfig<"outside" | "inside" | "">;
|
|
127
|
+
navigationDots?: ElementConfig<"outside" | "inside" | "none" | "">;
|
|
128
|
+
navigationArrows?: ElementConfig<"outside" | "inside" | "none" | "">;
|
|
126
129
|
};
|
|
127
130
|
type ImageSliderElementConfig = ImageElementConfig & SliderElementConfig & {
|
|
128
131
|
sliderItems: ElementConfig<Array<{
|
|
@@ -363,6 +366,7 @@ type CmsElementManufacturerLogo = Omit<Schemas["CmsSlot"], "config"> & {
|
|
|
363
366
|
mediaId: string;
|
|
364
367
|
url: string;
|
|
365
368
|
newTab: boolean;
|
|
369
|
+
ariaLabel?: string | null;
|
|
366
370
|
apiAlias: "cms_manufacturer_logo";
|
|
367
371
|
media: Schemas["Media"];
|
|
368
372
|
};
|
|
@@ -391,6 +395,8 @@ type UseCmsElementImage = {
|
|
|
391
395
|
newTab: boolean;
|
|
392
396
|
url: string;
|
|
393
397
|
}>;
|
|
398
|
+
ariaLabel: ComputedRef<string>;
|
|
399
|
+
isDecorative: ComputedRef<boolean>;
|
|
394
400
|
displayMode: ComputedRef<DisplayMode>;
|
|
395
401
|
isVideoElement: ComputedRef<boolean>;
|
|
396
402
|
mimeType: ComputedRef<string | undefined>;
|
|
@@ -408,13 +414,9 @@ declare function useCmsElementImage(element: CmsElementImage | CmsElementManufac
|
|
|
408
414
|
* @category CMS (Shopping Experiences)
|
|
409
415
|
*/
|
|
410
416
|
declare function useCmsElementConfig<T extends Omit<Schemas["CmsSlot"], "config"> & {
|
|
411
|
-
config:
|
|
412
|
-
[key in infer X extends keyof T["config"]]: ElementConfig<unknown>;
|
|
413
|
-
} ? {
|
|
414
|
-
[key in X]: ElementConfig<T["config"][key]["value"]>;
|
|
415
|
-
} : never;
|
|
417
|
+
config: Record<string, ElementConfig<unknown> | undefined>;
|
|
416
418
|
}>(element: T): {
|
|
417
|
-
getConfigValue: <ELEMENT_CONFIG extends keyof T["config"]>(key: ELEMENT_CONFIG) =>
|
|
419
|
+
getConfigValue: <ELEMENT_CONFIG extends keyof T["config"]>(key: ELEMENT_CONFIG) => NonNullable<T["config"][ELEMENT_CONFIG]>["value"];
|
|
418
420
|
};
|
|
419
421
|
|
|
420
422
|
declare function createShopwareContext(app: App, options: {
|
|
@@ -1138,7 +1140,7 @@ type UseListingReturn = {
|
|
|
1138
1140
|
/**
|
|
1139
1141
|
* Available sorting orders
|
|
1140
1142
|
*/
|
|
1141
|
-
getSortingOrders: ComputedRef<Schemas["
|
|
1143
|
+
getSortingOrders: ComputedRef<Schemas["ProductListingResult"]["availableSortings"] | {
|
|
1142
1144
|
key: string;
|
|
1143
1145
|
label: string;
|
|
1144
1146
|
}[] | undefined>;
|
|
@@ -1841,7 +1843,7 @@ declare function useProductReviews(product: Ref<Schemas["Product"]>): UseProduct
|
|
|
1841
1843
|
type UseProductSearchReturnOptions = {
|
|
1842
1844
|
withCmsAssociations?: boolean;
|
|
1843
1845
|
criteria?: Partial<Schemas["Criteria"]>;
|
|
1844
|
-
associations?: Partial<Schemas["
|
|
1846
|
+
associations?: Partial<Schemas["Associations"]>;
|
|
1845
1847
|
};
|
|
1846
1848
|
type UseProductSearchReturn = {
|
|
1847
1849
|
/**
|
|
@@ -2290,13 +2292,36 @@ declare function useWishlist(): UseWishlistReturn;
|
|
|
2290
2292
|
type UseB2bQuoteManagement = {
|
|
2291
2293
|
getQuoteList: () => Promise<Schemas["Quote"][]>;
|
|
2292
2294
|
getQuote: (quoteId: string) => Promise<Schemas["Quote"]>;
|
|
2295
|
+
/**
|
|
2296
|
+
* @deprecated use `declineQuoteWithComment` instead — it sends the
|
|
2297
|
+
* `lineItemId` and `versionId` that `POST /quote/{id}/decline` expects.
|
|
2298
|
+
* A `comment`-only body is still accepted at runtime on 6.7.12+: the API
|
|
2299
|
+
* schema marks `lineItemId` and `versionId` as required, but the endpoint
|
|
2300
|
+
* does not validate the request body, so existing callers keep working.
|
|
2301
|
+
* Removed in v2.
|
|
2302
|
+
*/
|
|
2293
2303
|
declineQuote: (quoteId: string, comment: string) => Promise<void>;
|
|
2304
|
+
declineQuoteWithComment: (quoteId: string, params: DeclineQuoteParams) => Promise<void>;
|
|
2305
|
+
createDraftQuoteVersion: (quoteId: string) => Promise<string>;
|
|
2306
|
+
deleteDraftQuoteVersion: (quoteId: string, versionId: string) => Promise<void>;
|
|
2294
2307
|
requestChangeQuote: (quoteId: string, comment: string) => Promise<void>;
|
|
2295
2308
|
requestQuote: (comment: string) => Promise<Schemas["Quote"]>;
|
|
2296
2309
|
createOrderFromQuote: (quoteId: string, comment: string) => Promise<Schemas["Order"]>;
|
|
2297
2310
|
changeShippingMethod: (quoteId: string, shippingMethodId: string) => Promise<void>;
|
|
2298
2311
|
changePaymentMethod: (quoteId: string, paymentMethodId: string) => Promise<void>;
|
|
2299
2312
|
};
|
|
2313
|
+
type DeclineQuoteParams = {
|
|
2314
|
+
/** Message content */
|
|
2315
|
+
comment: string;
|
|
2316
|
+
/** Identifier of the quote line item that owns the new comment */
|
|
2317
|
+
lineItemId: string;
|
|
2318
|
+
/**
|
|
2319
|
+
* Draft version identifier of the quote currently shown in storefront,
|
|
2320
|
+
* as returned by `createDraftQuoteVersion`. This is not the `versionId`
|
|
2321
|
+
* property of the quote entity.
|
|
2322
|
+
*/
|
|
2323
|
+
versionId: string;
|
|
2324
|
+
};
|
|
2300
2325
|
type ChangePaymentShippingMethodParams = {
|
|
2301
2326
|
quoteId: string;
|
|
2302
2327
|
paymentMethodId?: string;
|
|
@@ -2308,7 +2333,8 @@ type ChangePaymentShippingMethodParams = {
|
|
|
2308
2333
|
* With this composable you can:
|
|
2309
2334
|
* - Get list of quotes
|
|
2310
2335
|
* - Get quote details
|
|
2311
|
-
* -
|
|
2336
|
+
* - Create and delete a storefront draft version of the quote
|
|
2337
|
+
* - Decline quote, with or without a line item comment
|
|
2312
2338
|
* - Request change of the quote
|
|
2313
2339
|
* - Change shipping method
|
|
2314
2340
|
* - Change payment method
|
|
@@ -2374,4 +2400,4 @@ declare function getDefaultApiParams(): {
|
|
|
2374
2400
|
};
|
|
2375
2401
|
|
|
2376
2402
|
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 };
|
|
2377
|
-
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 };
|
|
2403
|
+
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, DeclineQuoteParams, 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,6 +1,6 @@
|
|
|
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,
|
|
3
|
+
import { urlIsAbsolute, relativeUrlSlash, getSrcSetForMedia, getTranslatedProperty, getMainImageUrl, 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
6
|
import { encodeForQuery } from '@shopware/api-client/helpers';
|
|
@@ -30,9 +30,13 @@ function useCmsElementImage(element) {
|
|
|
30
30
|
}
|
|
31
31
|
return attr;
|
|
32
32
|
});
|
|
33
|
+
const ariaLabel = computed(
|
|
34
|
+
() => element.data?.ariaLabel || getConfigValue("ariaLabel") || ""
|
|
35
|
+
);
|
|
36
|
+
const isDecorative = computed(() => !!getConfigValue("isDecorative"));
|
|
33
37
|
const imageAttrs = computed(() => ({
|
|
34
38
|
src: element.data?.media?.url,
|
|
35
|
-
alt: element.data?.media
|
|
39
|
+
alt: isDecorative.value ? "" : getTranslatedProperty(element.data?.media, "alt"),
|
|
36
40
|
srcset: getSrcSetForMedia(element.data?.media)
|
|
37
41
|
}));
|
|
38
42
|
const displayMode = computed(
|
|
@@ -50,6 +54,8 @@ function useCmsElementImage(element) {
|
|
|
50
54
|
imageAttrs,
|
|
51
55
|
imageContainerAttrs,
|
|
52
56
|
imageLink,
|
|
57
|
+
ariaLabel,
|
|
58
|
+
isDecorative,
|
|
53
59
|
displayMode,
|
|
54
60
|
isVideoElement,
|
|
55
61
|
mimeType
|
|
@@ -2605,31 +2611,64 @@ function useB2bQuoteManagement() {
|
|
|
2605
2611
|
return response.data.elements ?? [];
|
|
2606
2612
|
};
|
|
2607
2613
|
const getQuote = async (quoteId) => {
|
|
2614
|
+
const response = await apiClient.invoke("readQuote post /quote/{id}", {
|
|
2615
|
+
pathParams: {
|
|
2616
|
+
id: quoteId
|
|
2617
|
+
},
|
|
2618
|
+
body: {
|
|
2619
|
+
associations: {
|
|
2620
|
+
lineItems: {},
|
|
2621
|
+
comments: {},
|
|
2622
|
+
stateMachineState: {}
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
});
|
|
2626
|
+
return response.data;
|
|
2627
|
+
};
|
|
2628
|
+
async function createDraftQuoteVersion(quoteId) {
|
|
2608
2629
|
const response = await apiClient.invoke(
|
|
2609
|
-
"
|
|
2630
|
+
"createDraftQuoteVersion post /quote/{id}/draft-version",
|
|
2610
2631
|
{
|
|
2611
2632
|
pathParams: {
|
|
2612
2633
|
id: quoteId
|
|
2613
|
-
},
|
|
2614
|
-
body: {
|
|
2615
|
-
associations: {
|
|
2616
|
-
lineItems: {},
|
|
2617
|
-
comments: {},
|
|
2618
|
-
stateMachineState: {}
|
|
2619
|
-
}
|
|
2620
2634
|
}
|
|
2621
2635
|
}
|
|
2622
2636
|
);
|
|
2623
|
-
|
|
2624
|
-
|
|
2637
|
+
if (!response.data.versionId) {
|
|
2638
|
+
throw new Error(
|
|
2639
|
+
`Could not create a draft version for quote "${quoteId}": the API returned no versionId.`
|
|
2640
|
+
);
|
|
2641
|
+
}
|
|
2642
|
+
return response.data.versionId;
|
|
2643
|
+
}
|
|
2644
|
+
async function deleteDraftQuoteVersion(quoteId, versionId) {
|
|
2645
|
+
await apiClient.invoke(
|
|
2646
|
+
"deleteDraftQuoteVersion delete /quote/{id}/draft-version",
|
|
2647
|
+
{
|
|
2648
|
+
pathParams: {
|
|
2649
|
+
id: quoteId
|
|
2650
|
+
},
|
|
2651
|
+
body: { versionId }
|
|
2652
|
+
}
|
|
2653
|
+
);
|
|
2654
|
+
}
|
|
2625
2655
|
async function declineQuote(quoteId, comment) {
|
|
2626
2656
|
await apiClient.invoke("declineQuote post /quote/{id}/decline", {
|
|
2627
2657
|
pathParams: {
|
|
2628
2658
|
id: quoteId
|
|
2629
2659
|
},
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2660
|
+
// The 6.7.12 schema marks `lineItemId` and `versionId` as required, so a
|
|
2661
|
+
// comment-only body no longer matches the generated type. Sent as-is to
|
|
2662
|
+
// keep the pre-6.7.12 behaviour of this deprecated method unchanged.
|
|
2663
|
+
body: { comment }
|
|
2664
|
+
});
|
|
2665
|
+
}
|
|
2666
|
+
async function declineQuoteWithComment(quoteId, params) {
|
|
2667
|
+
await apiClient.invoke("declineQuote post /quote/{id}/decline", {
|
|
2668
|
+
pathParams: {
|
|
2669
|
+
id: quoteId
|
|
2670
|
+
},
|
|
2671
|
+
body: params
|
|
2633
2672
|
});
|
|
2634
2673
|
}
|
|
2635
2674
|
async function requestChangeQuote(quoteId, comment) {
|
|
@@ -2671,7 +2710,7 @@ function useB2bQuoteManagement() {
|
|
|
2671
2710
|
}
|
|
2672
2711
|
const createOrderFromQuote = async (quoteId, comment) => {
|
|
2673
2712
|
const response = await apiClient.invoke(
|
|
2674
|
-
"createOrderFromQuote post /quote/
|
|
2713
|
+
"createOrderFromQuote post /quote/{id}/order",
|
|
2675
2714
|
{
|
|
2676
2715
|
pathParams: { id: quoteId },
|
|
2677
2716
|
body: { customerComment: comment }
|
|
@@ -2683,6 +2722,9 @@ function useB2bQuoteManagement() {
|
|
|
2683
2722
|
getQuoteList,
|
|
2684
2723
|
getQuote,
|
|
2685
2724
|
declineQuote,
|
|
2725
|
+
declineQuoteWithComment,
|
|
2726
|
+
createDraftQuoteVersion,
|
|
2727
|
+
deleteDraftQuoteVersion,
|
|
2686
2728
|
requestChangeQuote,
|
|
2687
2729
|
changeShippingMethod,
|
|
2688
2730
|
changePaymentMethod,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopware/composables",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "Shopware Frontends composables for Vue",
|
|
5
5
|
"author": "Shopware",
|
|
6
6
|
"repository": {
|
|
@@ -55,19 +55,19 @@
|
|
|
55
55
|
"@vueuse/core": "14.4.0",
|
|
56
56
|
"defu": "6.1.7",
|
|
57
57
|
"scule": "1.3.0",
|
|
58
|
-
"@shopware/helpers": "1.
|
|
59
|
-
"@shopware/api-client": "1.
|
|
58
|
+
"@shopware/helpers": "1.8.0",
|
|
59
|
+
"@shopware/api-client": "1.6.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@nuxt/kit": "4.
|
|
62
|
+
"@nuxt/kit": "4.5.2",
|
|
63
63
|
"@typescript/native-preview": "7.0.0-dev.20260205.1",
|
|
64
64
|
"@vitest/coverage-v8": "4.1.10",
|
|
65
65
|
"@vue/test-utils": "2.4.11",
|
|
66
|
-
"happy-dom": "20.
|
|
66
|
+
"happy-dom": "20.11.1",
|
|
67
67
|
"typescript": "5.9.3",
|
|
68
68
|
"unbuild": "3.6.1",
|
|
69
69
|
"vitest": "4.1.10",
|
|
70
|
-
"vue": "3.5.
|
|
70
|
+
"vue": "3.5.42",
|
|
71
71
|
"tsconfig": "0.0.0"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
@@ -9,18 +9,14 @@ import type { ElementConfig } from "../types";
|
|
|
9
9
|
*/
|
|
10
10
|
export function useCmsElementConfig<
|
|
11
11
|
T extends Omit<Schemas["CmsSlot"], "config"> & {
|
|
12
|
-
config:
|
|
13
|
-
[key in infer X extends keyof T["config"]]: ElementConfig<unknown>;
|
|
14
|
-
}
|
|
15
|
-
? { [key in X]: ElementConfig<T["config"][key]["value"]> }
|
|
16
|
-
: never;
|
|
12
|
+
config: Record<string, ElementConfig<unknown> | undefined>;
|
|
17
13
|
},
|
|
18
14
|
>(element: T) {
|
|
19
15
|
const getConfigValue = <ELEMENT_CONFIG extends keyof T["config"]>(
|
|
20
16
|
key: ELEMENT_CONFIG,
|
|
21
|
-
):
|
|
17
|
+
): NonNullable<T["config"][ELEMENT_CONFIG]>["value"] => {
|
|
22
18
|
if (!element?.config) {
|
|
23
|
-
return undefined as
|
|
19
|
+
return undefined as NonNullable<T["config"][ELEMENT_CONFIG]>["value"];
|
|
24
20
|
}
|
|
25
21
|
return (
|
|
26
22
|
element.config[key]?.source !== "mapped" && element.config[key]?.value
|
|
@@ -155,6 +155,145 @@ describe("useCmsElementImage", () => {
|
|
|
155
155
|
});
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
+
it("should prefer the translated media alt over the root alt", () => {
|
|
159
|
+
const { imageAttrs } = useCmsElementImage({
|
|
160
|
+
data: {
|
|
161
|
+
media: {
|
|
162
|
+
url: "https://shopware.com/logo.png",
|
|
163
|
+
alt: "Company logo",
|
|
164
|
+
translated: {
|
|
165
|
+
alt: "Firmenlogo",
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
} as unknown as CmsElementManufacturerLogo);
|
|
170
|
+
|
|
171
|
+
expect(imageAttrs.value.alt).toBe("Firmenlogo");
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("should fall back to the root media alt when translated is missing", () => {
|
|
175
|
+
const { imageAttrs } = useCmsElementImage({
|
|
176
|
+
data: {
|
|
177
|
+
media: {
|
|
178
|
+
url: "https://shopware.com/logo.png",
|
|
179
|
+
alt: "Company logo",
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
} as unknown as CmsElementManufacturerLogo);
|
|
183
|
+
|
|
184
|
+
expect(imageAttrs.value.alt).toBe("Company logo");
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("should fall back to the root media alt when the translated alt is empty", () => {
|
|
188
|
+
const { imageAttrs } = useCmsElementImage({
|
|
189
|
+
data: {
|
|
190
|
+
media: {
|
|
191
|
+
url: "https://shopware.com/logo.png",
|
|
192
|
+
alt: "Company logo",
|
|
193
|
+
translated: {
|
|
194
|
+
alt: "",
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
} as unknown as CmsElementManufacturerLogo);
|
|
199
|
+
|
|
200
|
+
expect(imageAttrs.value.alt).toBe("Company logo");
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("should return an empty alt when the media has no alt at all", () => {
|
|
204
|
+
const { imageAttrs } = useCmsElementImage({
|
|
205
|
+
data: {
|
|
206
|
+
media: {
|
|
207
|
+
url: "https://shopware.com/logo.png",
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
} as unknown as CmsElementManufacturerLogo);
|
|
211
|
+
|
|
212
|
+
expect(imageAttrs.value.alt).toBe("");
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("should keep the alt empty when media has none, the aria label names the link", () => {
|
|
216
|
+
const { imageAttrs, ariaLabel } = useCmsElementImage({
|
|
217
|
+
data: {
|
|
218
|
+
ariaLabel: "Go to the summer collection",
|
|
219
|
+
media: {
|
|
220
|
+
url: "https://shopware.com/banner.png",
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
} as unknown as CmsElementImage);
|
|
224
|
+
|
|
225
|
+
expect(ariaLabel.value).toBe("Go to the summer collection");
|
|
226
|
+
expect(imageAttrs.value.alt).toBe("");
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("should read the aria label from config when data has none", () => {
|
|
230
|
+
const { ariaLabel } = useCmsElementImage({
|
|
231
|
+
config: {
|
|
232
|
+
ariaLabel: {
|
|
233
|
+
value: "Go to the sale",
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
} as unknown as CmsElementImage);
|
|
237
|
+
|
|
238
|
+
expect(ariaLabel.value).toBe("Go to the sale");
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it("should return an empty aria label when neither data nor config has one", () => {
|
|
242
|
+
const { ariaLabel } = useCmsElementImage({
|
|
243
|
+
data: {},
|
|
244
|
+
config: {},
|
|
245
|
+
} as unknown as CmsElementImage);
|
|
246
|
+
|
|
247
|
+
expect(ariaLabel.value).toBe("");
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it("should drop alternative text when the image is decorative but keep the aria label", () => {
|
|
251
|
+
const { imageAttrs, isDecorative, ariaLabel } = useCmsElementImage({
|
|
252
|
+
data: {
|
|
253
|
+
ariaLabel: "Go to the sale",
|
|
254
|
+
media: {
|
|
255
|
+
url: "https://shopware.com/pattern.png",
|
|
256
|
+
alt: "ignored",
|
|
257
|
+
translated: {
|
|
258
|
+
alt: "ignoriert",
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
config: {
|
|
263
|
+
isDecorative: {
|
|
264
|
+
value: true,
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
} as unknown as CmsElementImage);
|
|
268
|
+
|
|
269
|
+
expect(isDecorative.value).toBe(true);
|
|
270
|
+
expect(imageAttrs.value.alt).toBe("");
|
|
271
|
+
// a decorative image inside a link still needs the link named
|
|
272
|
+
expect(ariaLabel.value).toBe("Go to the sale");
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it("should keep the media alt when an aria label is also set", () => {
|
|
276
|
+
const { imageAttrs } = useCmsElementImage({
|
|
277
|
+
data: {
|
|
278
|
+
ariaLabel: "Go to the sale",
|
|
279
|
+
media: {
|
|
280
|
+
url: "https://shopware.com/banner.png",
|
|
281
|
+
alt: "Two mugs on a table",
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
} as unknown as CmsElementImage);
|
|
285
|
+
|
|
286
|
+
expect(imageAttrs.value.alt).toBe("Two mugs on a table");
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it("should not be decorative by default", () => {
|
|
290
|
+
const { isDecorative } = useCmsElementImage({
|
|
291
|
+
config: {},
|
|
292
|
+
} as unknown as CmsElementImage);
|
|
293
|
+
|
|
294
|
+
expect(isDecorative.value).toBe(false);
|
|
295
|
+
});
|
|
296
|
+
|
|
158
297
|
it("should return displayMode", () => {
|
|
159
298
|
const { displayMode } = useCmsElementImage({
|
|
160
299
|
config: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getSrcSetForMedia,
|
|
3
|
+
getTranslatedProperty,
|
|
3
4
|
relativeUrlSlash,
|
|
4
5
|
urlIsAbsolute,
|
|
5
6
|
} from "@shopware/helpers";
|
|
@@ -31,6 +32,8 @@ export type UseCmsElementImage = {
|
|
|
31
32
|
imageAttrs: ComputedRef<ImgHTMLAttributes>;
|
|
32
33
|
imageContainerAttrs: ComputedRef<ImageContainerAttrs>;
|
|
33
34
|
imageLink: ComputedRef<{ newTab: boolean; url: string }>;
|
|
35
|
+
ariaLabel: ComputedRef<string>;
|
|
36
|
+
isDecorative: ComputedRef<boolean>;
|
|
34
37
|
displayMode: ComputedRef<DisplayMode>;
|
|
35
38
|
isVideoElement: ComputedRef<boolean>;
|
|
36
39
|
mimeType: ComputedRef<string | undefined>;
|
|
@@ -74,9 +77,22 @@ export function useCmsElementImage(
|
|
|
74
77
|
return attr;
|
|
75
78
|
});
|
|
76
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Names the link the image sits in, not the image itself. Shopware exposes
|
|
82
|
+
* it on both `data` and `config`.
|
|
83
|
+
*/
|
|
84
|
+
const ariaLabel = computed(
|
|
85
|
+
() => element.data?.ariaLabel || getConfigValue("ariaLabel") || "",
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// Config only, the element data carries no such field.
|
|
89
|
+
const isDecorative = computed(() => !!getConfigValue("isDecorative"));
|
|
90
|
+
|
|
77
91
|
const imageAttrs: ComputedRef<ImgHTMLAttributes> = computed(() => ({
|
|
78
92
|
src: element.data?.media?.url,
|
|
79
|
-
alt:
|
|
93
|
+
alt: isDecorative.value
|
|
94
|
+
? ""
|
|
95
|
+
: getTranslatedProperty(element.data?.media, "alt"),
|
|
80
96
|
srcset: getSrcSetForMedia(element.data?.media),
|
|
81
97
|
}));
|
|
82
98
|
|
|
@@ -98,6 +114,8 @@ export function useCmsElementImage(
|
|
|
98
114
|
imageAttrs,
|
|
99
115
|
imageContainerAttrs,
|
|
100
116
|
imageLink,
|
|
117
|
+
ariaLabel,
|
|
118
|
+
isDecorative,
|
|
101
119
|
displayMode,
|
|
102
120
|
isVideoElement,
|
|
103
121
|
mimeType,
|
|
@@ -62,9 +62,11 @@ type ImageElementConfig = {
|
|
|
62
62
|
media: ElementConfig<string>;
|
|
63
63
|
newTab: ElementConfig<boolean>;
|
|
64
64
|
product: ElementConfig<string>;
|
|
65
|
+
ariaLabel?: ElementConfig<string | null>;
|
|
65
66
|
boxLayout: ElementConfig<BoxLayout>;
|
|
66
67
|
displayMode: ElementConfig<DisplayMode>;
|
|
67
68
|
minHeight: ElementConfig<string | number>;
|
|
69
|
+
isDecorative?: ElementConfig<boolean>;
|
|
68
70
|
verticalAlign: ElementConfig<VerticalAlign>;
|
|
69
71
|
horizontalAlign: ElementConfig<VerticalAlign>;
|
|
70
72
|
};
|
|
@@ -76,6 +78,7 @@ export type CmsElementImage = Omit<Schemas["CmsSlot"], "config"> & {
|
|
|
76
78
|
mediaId: string;
|
|
77
79
|
url: string;
|
|
78
80
|
newTab: boolean;
|
|
81
|
+
ariaLabel?: string | null;
|
|
79
82
|
apiAlias: "cms_image";
|
|
80
83
|
media: Schemas["Media"];
|
|
81
84
|
};
|
|
@@ -87,8 +90,8 @@ export type SliderElementConfig = {
|
|
|
87
90
|
minHeight: ElementConfig<string | number>;
|
|
88
91
|
verticalAlign?: ElementConfig<VerticalAlign>;
|
|
89
92
|
displayMode?: ElementConfig<"standard" | "cover" | "contain">;
|
|
90
|
-
navigationDots?: ElementConfig<"outside" | "inside" | "">;
|
|
91
|
-
navigationArrows?: ElementConfig<"outside" | "inside" | "">;
|
|
93
|
+
navigationDots?: ElementConfig<"outside" | "inside" | "none" | "">;
|
|
94
|
+
navigationArrows?: ElementConfig<"outside" | "inside" | "none" | "">;
|
|
92
95
|
};
|
|
93
96
|
|
|
94
97
|
type ImageSliderElementConfig = ImageElementConfig &
|
|
@@ -391,6 +394,7 @@ export type CmsElementManufacturerLogo = Omit<Schemas["CmsSlot"], "config"> & {
|
|
|
391
394
|
mediaId: string;
|
|
392
395
|
url: string;
|
|
393
396
|
newTab: boolean;
|
|
397
|
+
ariaLabel?: string | null;
|
|
394
398
|
apiAlias: "cms_manufacturer_logo";
|
|
395
399
|
media: Schemas["Media"];
|
|
396
400
|
};
|
|
@@ -49,7 +49,45 @@ describe("useB2bQuoteManagement", () => {
|
|
|
49
49
|
);
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
it("
|
|
52
|
+
it("createDraftQuoteVersion", async () => {
|
|
53
|
+
const { vm, injections } = useSetup(() => useB2bQuoteManagement());
|
|
54
|
+
injections.apiClient.invoke.mockResolvedValue({
|
|
55
|
+
data: { versionId: "test-version-id" },
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
expect(await vm.createDraftQuoteVersion("test-12")).toBe("test-version-id");
|
|
59
|
+
expect(injections.apiClient.invoke).toHaveBeenCalledWith(
|
|
60
|
+
expect.stringContaining("createDraftQuoteVersion"),
|
|
61
|
+
expect.objectContaining({
|
|
62
|
+
pathParams: { id: "test-12" },
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("createDraftQuoteVersion - no versionId in response", async () => {
|
|
68
|
+
const { vm, injections } = useSetup(() => useB2bQuoteManagement());
|
|
69
|
+
injections.apiClient.invoke.mockResolvedValue({ data: {} });
|
|
70
|
+
|
|
71
|
+
await expect(vm.createDraftQuoteVersion("test-12")).rejects.toThrow(
|
|
72
|
+
/no versionId/,
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("deleteDraftQuoteVersion", async () => {
|
|
77
|
+
const { vm, injections } = useSetup(() => useB2bQuoteManagement());
|
|
78
|
+
injections.apiClient.invoke.mockResolvedValue({ data: null });
|
|
79
|
+
await vm.deleteDraftQuoteVersion("test-12", "test-version-id");
|
|
80
|
+
|
|
81
|
+
expect(injections.apiClient.invoke).toHaveBeenCalledWith(
|
|
82
|
+
expect.stringContaining("deleteDraftQuoteVersion"),
|
|
83
|
+
expect.objectContaining({
|
|
84
|
+
pathParams: { id: "test-12" },
|
|
85
|
+
body: { versionId: "test-version-id" },
|
|
86
|
+
}),
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("declineQuote - deprecated, comment only", async () => {
|
|
53
91
|
const { vm, injections } = useSetup(() => useB2bQuoteManagement());
|
|
54
92
|
injections.apiClient.invoke.mockResolvedValue({ data: null });
|
|
55
93
|
await vm.declineQuote("test-12", "test-comment");
|
|
@@ -63,6 +101,28 @@ describe("useB2bQuoteManagement", () => {
|
|
|
63
101
|
);
|
|
64
102
|
});
|
|
65
103
|
|
|
104
|
+
it("declineQuoteWithComment", async () => {
|
|
105
|
+
const { vm, injections } = useSetup(() => useB2bQuoteManagement());
|
|
106
|
+
injections.apiClient.invoke.mockResolvedValue({ data: null });
|
|
107
|
+
await vm.declineQuoteWithComment("test-12", {
|
|
108
|
+
comment: "test-comment",
|
|
109
|
+
lineItemId: "test-line-item-id",
|
|
110
|
+
versionId: "test-version-id",
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
expect(injections.apiClient.invoke).toHaveBeenCalledWith(
|
|
114
|
+
expect.stringContaining("declineQuote"),
|
|
115
|
+
expect.objectContaining({
|
|
116
|
+
pathParams: { id: "test-12" },
|
|
117
|
+
body: {
|
|
118
|
+
comment: "test-comment",
|
|
119
|
+
lineItemId: "test-line-item-id",
|
|
120
|
+
versionId: "test-version-id",
|
|
121
|
+
},
|
|
122
|
+
}),
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
|
|
66
126
|
it("requestChangeQuote", async () => {
|
|
67
127
|
const { vm, injections } = useSetup(() => useB2bQuoteManagement());
|
|
68
128
|
injections.apiClient.invoke.mockResolvedValue({ data: null });
|
|
@@ -7,7 +7,24 @@ import type { Schemas } from "#shopware";
|
|
|
7
7
|
type UseB2bQuoteManagement = {
|
|
8
8
|
getQuoteList: () => Promise<Schemas["Quote"][]>;
|
|
9
9
|
getQuote: (quoteId: string) => Promise<Schemas["Quote"]>;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated use `declineQuoteWithComment` instead — it sends the
|
|
12
|
+
* `lineItemId` and `versionId` that `POST /quote/{id}/decline` expects.
|
|
13
|
+
* A `comment`-only body is still accepted at runtime on 6.7.12+: the API
|
|
14
|
+
* schema marks `lineItemId` and `versionId` as required, but the endpoint
|
|
15
|
+
* does not validate the request body, so existing callers keep working.
|
|
16
|
+
* Removed in v2.
|
|
17
|
+
*/
|
|
10
18
|
declineQuote: (quoteId: string, comment: string) => Promise<void>;
|
|
19
|
+
declineQuoteWithComment: (
|
|
20
|
+
quoteId: string,
|
|
21
|
+
params: DeclineQuoteParams,
|
|
22
|
+
) => Promise<void>;
|
|
23
|
+
createDraftQuoteVersion: (quoteId: string) => Promise<string>;
|
|
24
|
+
deleteDraftQuoteVersion: (
|
|
25
|
+
quoteId: string,
|
|
26
|
+
versionId: string,
|
|
27
|
+
) => Promise<void>;
|
|
11
28
|
requestChangeQuote: (quoteId: string, comment: string) => Promise<void>;
|
|
12
29
|
requestQuote: (comment: string) => Promise<Schemas["Quote"]>;
|
|
13
30
|
createOrderFromQuote: (
|
|
@@ -24,6 +41,19 @@ type UseB2bQuoteManagement = {
|
|
|
24
41
|
) => Promise<void>;
|
|
25
42
|
};
|
|
26
43
|
|
|
44
|
+
export type DeclineQuoteParams = {
|
|
45
|
+
/** Message content */
|
|
46
|
+
comment: string;
|
|
47
|
+
/** Identifier of the quote line item that owns the new comment */
|
|
48
|
+
lineItemId: string;
|
|
49
|
+
/**
|
|
50
|
+
* Draft version identifier of the quote currently shown in storefront,
|
|
51
|
+
* as returned by `createDraftQuoteVersion`. This is not the `versionId`
|
|
52
|
+
* property of the quote entity.
|
|
53
|
+
*/
|
|
54
|
+
versionId: string;
|
|
55
|
+
};
|
|
56
|
+
|
|
27
57
|
export type ChangePaymentShippingMethodParams = {
|
|
28
58
|
quoteId: string;
|
|
29
59
|
paymentMethodId?: string;
|
|
@@ -36,7 +66,8 @@ export type ChangePaymentShippingMethodParams = {
|
|
|
36
66
|
* With this composable you can:
|
|
37
67
|
* - Get list of quotes
|
|
38
68
|
* - Get quote details
|
|
39
|
-
* -
|
|
69
|
+
* - Create and delete a storefront draft version of the quote
|
|
70
|
+
* - Decline quote, with or without a line item comment
|
|
40
71
|
* - Request change of the quote
|
|
41
72
|
* - Change shipping method
|
|
42
73
|
* - Change payment method
|
|
@@ -66,26 +97,78 @@ export function useB2bQuoteManagement(): UseB2bQuoteManagement {
|
|
|
66
97
|
* @returns {Promise<Schemas["Quote"]>}
|
|
67
98
|
*/
|
|
68
99
|
const getQuote = async (quoteId: string) => {
|
|
100
|
+
const response = await apiClient.invoke("readQuote post /quote/{id}", {
|
|
101
|
+
pathParams: {
|
|
102
|
+
id: quoteId,
|
|
103
|
+
},
|
|
104
|
+
body: {
|
|
105
|
+
associations: {
|
|
106
|
+
lineItems: {},
|
|
107
|
+
comments: {},
|
|
108
|
+
stateMachineState: {},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
return response.data;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Create a temporary draft version of the quote for storefront editing.
|
|
117
|
+
*
|
|
118
|
+
* The returned identifier is the `versionId` that quote write operations
|
|
119
|
+
* expect, for example {@link declineQuoteWithComment}. It is not the
|
|
120
|
+
* `versionId` property of the quote entity.
|
|
121
|
+
*
|
|
122
|
+
* @param {string} quoteId
|
|
123
|
+
* @returns {Promise<string>} draft version identifier
|
|
124
|
+
*/
|
|
125
|
+
async function createDraftQuoteVersion(quoteId: string) {
|
|
69
126
|
const response = await apiClient.invoke(
|
|
70
|
-
"
|
|
127
|
+
"createDraftQuoteVersion post /quote/{id}/draft-version",
|
|
71
128
|
{
|
|
72
129
|
pathParams: {
|
|
73
130
|
id: quoteId,
|
|
74
131
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
132
|
+
},
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
if (!response.data.versionId) {
|
|
136
|
+
throw new Error(
|
|
137
|
+
`Could not create a draft version for quote "${quoteId}": the API returned no versionId.`,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return response.data.versionId;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Delete the temporary draft version of the quote.
|
|
146
|
+
*
|
|
147
|
+
* @param {string} quoteId
|
|
148
|
+
* @param {string} versionId draft version identifier returned by {@link createDraftQuoteVersion}
|
|
149
|
+
* @returns {Promise<void>}
|
|
150
|
+
*/
|
|
151
|
+
async function deleteDraftQuoteVersion(quoteId: string, versionId: string) {
|
|
152
|
+
await apiClient.invoke(
|
|
153
|
+
"deleteDraftQuoteVersion delete /quote/{id}/draft-version",
|
|
154
|
+
{
|
|
155
|
+
pathParams: {
|
|
156
|
+
id: quoteId,
|
|
81
157
|
},
|
|
158
|
+
body: { versionId },
|
|
82
159
|
},
|
|
83
160
|
);
|
|
84
|
-
|
|
85
|
-
};
|
|
161
|
+
}
|
|
86
162
|
|
|
87
163
|
/**
|
|
88
|
-
*
|
|
164
|
+
* Decline quote with a comment only.
|
|
165
|
+
*
|
|
166
|
+
* @deprecated use {@link declineQuoteWithComment} instead — it sends the
|
|
167
|
+
* `lineItemId` and `versionId` that `POST /quote/{id}/decline` expects.
|
|
168
|
+
* A `comment`-only body is still accepted at runtime on 6.7.12+: the API
|
|
169
|
+
* schema marks `lineItemId` and `versionId` as required, but the endpoint
|
|
170
|
+
* does not validate the request body, so existing callers keep working.
|
|
171
|
+
* Removed in v2.
|
|
89
172
|
*
|
|
90
173
|
* @param {string} quoteId
|
|
91
174
|
* @param {string} comment
|
|
@@ -96,9 +179,30 @@ export function useB2bQuoteManagement(): UseB2bQuoteManagement {
|
|
|
96
179
|
pathParams: {
|
|
97
180
|
id: quoteId,
|
|
98
181
|
},
|
|
99
|
-
|
|
100
|
-
|
|
182
|
+
// The 6.7.12 schema marks `lineItemId` and `versionId` as required, so a
|
|
183
|
+
// comment-only body no longer matches the generated type. Sent as-is to
|
|
184
|
+
// keep the pre-6.7.12 behaviour of this deprecated method unchanged.
|
|
185
|
+
body: { comment } as DeclineQuoteParams,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Decline quote, attaching the comment to a quote line item in the current
|
|
191
|
+
* draft version.
|
|
192
|
+
*
|
|
193
|
+
* @param {string} quoteId
|
|
194
|
+
* @param {DeclineQuoteParams} params
|
|
195
|
+
* @returns {Promise<void>}
|
|
196
|
+
*/
|
|
197
|
+
async function declineQuoteWithComment(
|
|
198
|
+
quoteId: string,
|
|
199
|
+
params: DeclineQuoteParams,
|
|
200
|
+
) {
|
|
201
|
+
await apiClient.invoke("declineQuote post /quote/{id}/decline", {
|
|
202
|
+
pathParams: {
|
|
203
|
+
id: quoteId,
|
|
101
204
|
},
|
|
205
|
+
body: params,
|
|
102
206
|
});
|
|
103
207
|
}
|
|
104
208
|
|
|
@@ -202,7 +306,7 @@ export function useB2bQuoteManagement(): UseB2bQuoteManagement {
|
|
|
202
306
|
*/
|
|
203
307
|
const createOrderFromQuote = async (quoteId: string, comment: string) => {
|
|
204
308
|
const response = await apiClient.invoke(
|
|
205
|
-
"createOrderFromQuote post /quote/
|
|
309
|
+
"createOrderFromQuote post /quote/{id}/order",
|
|
206
310
|
{
|
|
207
311
|
pathParams: { id: quoteId },
|
|
208
312
|
body: { customerComment: comment },
|
|
@@ -216,6 +320,9 @@ export function useB2bQuoteManagement(): UseB2bQuoteManagement {
|
|
|
216
320
|
getQuoteList,
|
|
217
321
|
getQuote,
|
|
218
322
|
declineQuote,
|
|
323
|
+
declineQuoteWithComment,
|
|
324
|
+
createDraftQuoteVersion,
|
|
325
|
+
deleteDraftQuoteVersion,
|
|
219
326
|
requestChangeQuote,
|
|
220
327
|
changeShippingMethod,
|
|
221
328
|
changePaymentMethod,
|
|
@@ -96,7 +96,9 @@ export type UseListingReturn = {
|
|
|
96
96
|
* Available sorting orders
|
|
97
97
|
*/
|
|
98
98
|
getSortingOrders: ComputedRef<
|
|
99
|
-
Schemas["
|
|
99
|
+
| Schemas["ProductListingResult"]["availableSortings"]
|
|
100
|
+
| { key: string; label: string }[]
|
|
101
|
+
| undefined
|
|
100
102
|
>;
|
|
101
103
|
/**
|
|
102
104
|
* Current sorting order
|
|
@@ -9,7 +9,7 @@ import { cmsAssociations } from "../cms/cmsAssociations";
|
|
|
9
9
|
type UseProductSearchReturnOptions = {
|
|
10
10
|
withCmsAssociations?: boolean;
|
|
11
11
|
criteria?: Partial<Schemas["Criteria"]>;
|
|
12
|
-
associations?: Partial<Schemas["
|
|
12
|
+
associations?: Partial<Schemas["Associations"]>;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export type UseProductSearchReturn = {
|