@zenky/storefront-vue 0.10.8 → 0.10.10
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/CHANGELOG.md +23 -0
- package/README.md +4 -18
- package/dist/cart/index.d.ts +167 -160
- package/dist/cart/index.js +7 -7
- package/dist/catalog/index.d.ts +23 -24
- package/dist/catalog/index.js +2 -2
- package/dist/catalogEntity-DgrPsJpf.d.ts +44 -0
- package/dist/{chunk-RO25KNM5.js → chunk-2Y6QTHXI.js} +2 -2
- package/dist/chunk-2Y6QTHXI.js.map +1 -0
- package/dist/{chunk-3FDM6T7F.js → chunk-32SLDGE5.js} +8 -6
- package/dist/chunk-32SLDGE5.js.map +1 -0
- package/dist/{chunk-5YD4AIY2.js → chunk-46FNHMWC.js} +4 -4
- package/dist/chunk-46FNHMWC.js.map +1 -0
- package/dist/{chunk-2SMSLZ6G.js → chunk-4UMDIBW5.js} +15 -11
- package/dist/chunk-4UMDIBW5.js.map +1 -0
- package/dist/{chunk-4IFPVEO7.js → chunk-BUNI6MGH.js} +3 -3
- package/dist/chunk-BUNI6MGH.js.map +1 -0
- package/dist/{chunk-E3G7NGCH.js → chunk-FS2UNPTY.js} +2 -2
- package/dist/chunk-FS2UNPTY.js.map +1 -0
- package/dist/{chunk-PTMSPB34.js → chunk-FXKG5TFQ.js} +3 -3
- package/dist/chunk-FXKG5TFQ.js.map +1 -0
- package/dist/{chunk-MOG6UMFM.js → chunk-GILJFP55.js} +2 -2
- package/dist/chunk-GILJFP55.js.map +1 -0
- package/dist/{chunk-2CI4RW7V.js → chunk-GLQXTMVW.js} +2 -2
- package/dist/{chunk-2CI4RW7V.js.map → chunk-GLQXTMVW.js.map} +1 -1
- package/dist/{chunk-MZ66ARDL.js → chunk-GXDTRTUT.js} +2 -2
- package/dist/chunk-GXDTRTUT.js.map +1 -0
- package/dist/{chunk-Z3IW4ODZ.js → chunk-NSOIL7PW.js} +2 -2
- package/dist/chunk-NSOIL7PW.js.map +1 -0
- package/dist/{chunk-NG7RUIWW.js → chunk-OBNMXLJO.js} +19 -3
- package/dist/chunk-OBNMXLJO.js.map +1 -0
- package/dist/{chunk-VFMVQR6Y.js → chunk-QZ3S3NN3.js} +5 -3
- package/dist/chunk-QZ3S3NN3.js.map +1 -0
- package/dist/{chunk-Z247QRDJ.js → chunk-XULHV6SS.js} +3 -3
- package/dist/chunk-XULHV6SS.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +14 -14
- package/dist/money/index.d.ts +8 -8
- package/dist/money/index.js +1 -1
- package/dist/order/index.d.ts +3 -3
- package/dist/order/index.js.map +1 -1
- package/dist/pagination/index.d.ts +29 -37
- package/dist/pagination/index.js.map +1 -1
- package/dist/ports/index.d.ts +23 -22
- package/dist/ports/index.js +1 -1
- package/dist/products/index.d.ts +10 -10
- package/dist/products/index.js +3 -3
- package/dist/promotions/index.d.ts +5 -5
- package/dist/promotions/index.js +3 -3
- package/dist/seo/index.d.ts +17 -17
- package/dist/seo/index.js +15 -9
- package/dist/seo/index.js.map +1 -1
- package/dist/snippets/index.js +1 -1
- package/dist/stores/index.d.ts +8 -8
- package/dist/stores/index.js +4 -4
- package/dist/theme/index.d.ts +3 -3
- package/dist/theme/index.js +1 -1
- package/dist/utils/index.d.ts +16 -16
- package/dist/utils/index.js +1 -1
- package/docs/architecture.md +85 -0
- package/docs/consumer-setup.md +13 -54
- package/docs/ports.md +12 -13
- package/package.json +1 -1
- package/dist/chunk-2SMSLZ6G.js.map +0 -1
- package/dist/chunk-3FDM6T7F.js.map +0 -1
- package/dist/chunk-4IFPVEO7.js.map +0 -1
- package/dist/chunk-5YD4AIY2.js.map +0 -1
- package/dist/chunk-E3G7NGCH.js.map +0 -1
- package/dist/chunk-MOG6UMFM.js.map +0 -1
- package/dist/chunk-MZ66ARDL.js.map +0 -1
- package/dist/chunk-NG7RUIWW.js.map +0 -1
- package/dist/chunk-PTMSPB34.js.map +0 -1
- package/dist/chunk-RO25KNM5.js.map +0 -1
- package/dist/chunk-VFMVQR6Y.js.map +0 -1
- package/dist/chunk-Z247QRDJ.js.map +0 -1
- package/dist/chunk-Z3IW4ODZ.js.map +0 -1
package/dist/cart/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { CASH_DENOMINATIONS_MAJOR, DEFAULT_ROUND_STEPS_MAJOR, ORDER_EVENTS, ORDER_WITH, buildCartLineKey, buildCashChangePresets, buildMainPaymentRequest, getCartErrorCode, getCartErrorHttpCode, getCartErrorMessage, getCashDenominationsMinor, getDefaultRoundStepsMinor, getValidationErrors, logCartError, normalizeAddress, useBonusesReconciliation, useCartAddressSync, useCartCustomerAttachment, useCartDeliveryAttachment, useCartInitialization, useCartMutation, useCartOperations, useCartQuantities, useCartRecalculation, useCartStockWatcher, useCheckoutFlow, useCheckoutSubmit, useCustomerAttach, useOnlinePaymentRetry, useOrderBonuses, useOrderChannel, useOrderDelivery, useOrderPromocode, useOrderSettings, useOrderTotal, usePaymentSelection, useRestrictedAddToCart, useRestrictionGate, useStorefrontCart, useVisibleCartVariants, variantLineKey } from '../chunk-
|
|
2
|
-
export { useCartCredentials } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
1
|
+
export { CASH_DENOMINATIONS_MAJOR, DEFAULT_ROUND_STEPS_MAJOR, ORDER_EVENTS, ORDER_WITH, buildCartLineKey, buildCashChangePresets, buildMainPaymentRequest, getCartErrorCode, getCartErrorHttpCode, getCartErrorMessage, getCashDenominationsMinor, getDefaultRoundStepsMinor, getValidationErrors, logCartError, normalizeAddress, useBonusesReconciliation, useCartAddressSync, useCartCustomerAttachment, useCartDeliveryAttachment, useCartInitialization, useCartMutation, useCartOperations, useCartQuantities, useCartRecalculation, useCartStockWatcher, useCheckoutFlow, useCheckoutSubmit, useCustomerAttach, useOnlinePaymentRetry, useOrderBonuses, useOrderChannel, useOrderDelivery, useOrderPromocode, useOrderSettings, useOrderTotal, usePaymentSelection, useRestrictedAddToCart, useRestrictionGate, useStorefrontCart, useVisibleCartVariants, variantLineKey } from '../chunk-4UMDIBW5.js';
|
|
2
|
+
export { useCartCredentials } from '../chunk-46FNHMWC.js';
|
|
3
|
+
import '../chunk-XULHV6SS.js';
|
|
4
|
+
import '../chunk-FS2UNPTY.js';
|
|
5
|
+
import '../chunk-2Y6QTHXI.js';
|
|
6
6
|
import '../chunk-5QCUH3FF.js';
|
|
7
|
-
import '../chunk-
|
|
8
|
-
import '../chunk-
|
|
7
|
+
import '../chunk-NSOIL7PW.js';
|
|
8
|
+
import '../chunk-QZ3S3NN3.js';
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
package/dist/catalog/index.d.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { NestedCategory, Product, Store, City, Stock,
|
|
1
|
+
import { NestedCategory, Product, Store, City, Stock, ZenkyStorefront, CollectionsListRequest, ProductsCollection } from '@zenky/storefront-api';
|
|
2
|
+
import { a as StaticRemoteCatalog } from '../catalogEntity-DgrPsJpf.js';
|
|
3
|
+
export { C as CatalogEntity, S as StaticCatalogItem, c as catalogItemEntity, i as isRenderableCatalogItem } from '../catalogEntity-DgrPsJpf.js';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
6
|
+
* Recursively searches the category tree by `short_id`.
|
|
5
7
|
*
|
|
6
|
-
* `NestedCategory[]`
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* нужно рекурсивно обойти все ветки.
|
|
8
|
+
* `NestedCategory[]` is a tree: root categories at the top level, nested ones
|
|
9
|
+
* inside `children[]`. A plain `tree.find()` only reaches root categories, so
|
|
10
|
+
* nested ones (e.g. "Jackets" inside "Men" inside "Clothing") need a recursive walk.
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
+
* Returns the first match (DFS pre-order).
|
|
12
13
|
*/
|
|
13
14
|
declare function findCategoryByShortId(tree: NestedCategory[], shortId: string): NestedCategory | null;
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* Finds a category's root ancestor by `parent_id`.
|
|
16
17
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
18
|
+
* For nested "Jackets" (parent: "Men"), returns "Clothing" (the root of the branch).
|
|
19
|
+
* For root "Clothing", returns itself.
|
|
19
20
|
*
|
|
20
|
-
*
|
|
21
|
-
* находится на вложенной категории.
|
|
21
|
+
* Used in `CategoryTabs` to highlight the root tab when the user is on a nested category.
|
|
22
22
|
*/
|
|
23
23
|
declare function findRootAncestor(tree: NestedCategory[], category: NestedCategory): NestedCategory | null;
|
|
24
|
-
/**
|
|
24
|
+
/** Recursive search by `id` (not `short_id`). Used by findRootAncestor. */
|
|
25
25
|
declare function findCategoryById(tree: NestedCategory[], id: string): NestedCategory | null;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Returns the path from the root category down to the target (inclusive).
|
|
28
28
|
*
|
|
29
|
-
*
|
|
30
|
-
* → [
|
|
29
|
+
* Example for "Jackets" in the branch "Clothing → Men → Jackets":
|
|
30
|
+
* → [Clothing, Men, Jackets]
|
|
31
31
|
*
|
|
32
|
-
*
|
|
32
|
+
* Used to build breadcrumbs.
|
|
33
33
|
*/
|
|
34
34
|
declare function getCategoryPath(tree: NestedCategory[], target: NestedCategory): NestedCategory[];
|
|
35
35
|
|
|
@@ -46,18 +46,17 @@ declare function groupProductsBySubcategory(rootCategory: NestedCategory, produc
|
|
|
46
46
|
|
|
47
47
|
declare function getCity(store: Store, cityId?: string | null): City | null;
|
|
48
48
|
declare function getStock(city: City, stockId?: string | null): Stock | null;
|
|
49
|
-
declare function getRemoteCatalog(store: Store, city: City, stock: Stock | null):
|
|
49
|
+
declare function getRemoteCatalog(store: Store, city: City, stock: Stock | null): StaticRemoteCatalog | null;
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
53
|
-
* Pure composable — SDK передаётся параметром (DI), Nuxt не нужен.
|
|
52
|
+
* Pure composable — the SDK is passed in as a parameter (DI), no Nuxt needed.
|
|
54
53
|
*
|
|
55
|
-
* NOTE:
|
|
56
|
-
*
|
|
57
|
-
*
|
|
54
|
+
* NOTE: the storefront API has no single `getCollection(id)`; use
|
|
55
|
+
* `GET /products?collection_id=...` to get a collection's products.
|
|
56
|
+
* To get a collection's metadata, look it up in the list via `loadCollections`.
|
|
58
57
|
*/
|
|
59
58
|
declare function useCollections(sdk: ZenkyStorefront): {
|
|
60
59
|
loadCollections: (storeId: string, request?: CollectionsListRequest) => Promise<ProductsCollection[]>;
|
|
61
60
|
};
|
|
62
61
|
|
|
63
|
-
export { type GroupedProducts, type SubcategoryGroup, collectDescendantIds, findCategoryById, findCategoryByShortId, findRootAncestor, getCategoryPath, getCity, getRemoteCatalog, getStock, groupProductsBySubcategory, useCollections };
|
|
62
|
+
export { type GroupedProducts, StaticRemoteCatalog, type SubcategoryGroup, collectDescendantIds, findCategoryById, findCategoryByShortId, findRootAncestor, getCategoryPath, getCity, getRemoteCatalog, getStock, groupProductsBySubcategory, useCollections };
|
package/dist/catalog/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { collectDescendantIds, findCategoryById, findCategoryByShortId, findRootAncestor, getCategoryPath, groupProductsBySubcategory, useCollections } from '../chunk-
|
|
2
|
-
export { getCity, getRemoteCatalog, getStock } from '../chunk-
|
|
1
|
+
export { catalogItemEntity, collectDescendantIds, findCategoryById, findCategoryByShortId, findRootAncestor, getCategoryPath, groupProductsBySubcategory, isRenderableCatalogItem, useCollections } from '../chunk-OBNMXLJO.js';
|
|
2
|
+
export { getCity, getRemoteCatalog, getStock } from '../chunk-FS2UNPTY.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Category, ProductsCollection, CatalogItem, RemoteCatalog } from '@zenky/storefront-api';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Static catalog item. `@zenky/storefront-api@1.0.2` predates manual catalogs: it
|
|
5
|
+
* spells the collection `collection` and types `type` as `'category' | 'collection'`,
|
|
6
|
+
* while the payload uses `products_collection`. Both spellings are declared here, and
|
|
7
|
+
* the fields are re-declared rather than inherited so a later SDK release that adds
|
|
8
|
+
* them cannot conflict with this narrowing.
|
|
9
|
+
*/
|
|
10
|
+
interface StaticCatalogItem extends Omit<CatalogItem, 'type' | 'collection' | 'products_collection'> {
|
|
11
|
+
type: 'category' | 'collection' | 'products_collection';
|
|
12
|
+
collection?: ProductsCollection | null;
|
|
13
|
+
products_collection?: ProductsCollection | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Store profile catalog entry. `catalog_id` is filled for manual catalogs only, and
|
|
17
|
+
* is optional because the SDK type omits it — test it with `!= null`, since `undefined`
|
|
18
|
+
* means "SDK-typed value", not "automatic catalog".
|
|
19
|
+
*/
|
|
20
|
+
interface StaticRemoteCatalog extends Omit<RemoteCatalog, 'catalog_id'> {
|
|
21
|
+
catalog_id?: string | null;
|
|
22
|
+
}
|
|
23
|
+
/** What a catalog section represents; `id` and `name` are lifted so callers needn't branch. */
|
|
24
|
+
type CatalogEntity = {
|
|
25
|
+
kind: 'category';
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
category: Category;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'collection';
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
collection: ProductsCollection;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Resolve what a catalog section is about, or null for a malformed item. Keyed off
|
|
37
|
+
* which entity object is present, not off `type`: the payload and the SDK type
|
|
38
|
+
* disagree on the discriminator's value, but presence holds under both.
|
|
39
|
+
*/
|
|
40
|
+
declare function catalogItemEntity(item: StaticCatalogItem): CatalogEntity | null;
|
|
41
|
+
/** Sections worth rendering: a known entity and at least one product. */
|
|
42
|
+
declare function isRenderableCatalogItem(item: StaticCatalogItem): boolean;
|
|
43
|
+
|
|
44
|
+
export { type CatalogEntity as C, type StaticCatalogItem as S, type StaticRemoteCatalog as a, catalogItemEntity as c, isRenderableCatalogItem as i };
|
|
@@ -32,5 +32,5 @@ function minorToMajorString(value, currency = "RUB") {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export { asMajor, asMinor, formatPrice, majorToMinor, minorToMajor, minorToMajorString };
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
36
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-2Y6QTHXI.js.map
|
|
36
|
+
//# sourceMappingURL=chunk-2Y6QTHXI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/money/money.ts"],"names":[],"mappings":";AAmBO,IAAM,OAAA,GAAU,CAAC,KAAA,KAAyB;AAC1C,IAAM,OAAA,GAAU,CAAC,KAAA,KAAyB;AAQjD,SAAS,eAAe,QAAA,EAA0B;AAC9C,EAAA,MAAM,cAAA,GACF,IAAI,IAAA,CAAK,YAAA,CAAa,IAAA,EAAM;AAAA,IACxB,KAAA,EAAO,UAAA;AAAA,IACP;AAAA,GACH,CAAA,CAAE,eAAA,EAAgB,CAAE,qBAAA,IAAyB,CAAA;AAClD,EAAA,OAAO,EAAA,IAAM,cAAA;AACjB;AAMA,IAAM,cAAA,GAAiB,OAAA;AAKhB,SAAS,WAAA,CACZ,KAAA,EACA,QAAA,GAAW,KAAA,EACX,SAAiB,cAAA,EACX;AACN,EAAA,IAAI,CAAC,KAAA,IAAS,KAAA,KAAU,CAAA,EAAG;AACvB,IAAA,OAAO,EAAA;AAAA,EACX;AAEA,EAAA,OAAO,IAAI,IAAA,CAAK,YAAA,CAAa,MAAA,EAAQ;AAAA,IACjC,KAAA,EAAO,UAAA;AAAA,IACP,QAAA;AAAA,IACA,qBAAA,EAAuB;AAAA,GAC1B,CAAA,CAAE,MAAA,CAAO,KAAA,GAAQ,cAAA,CAAe,QAAQ,CAAC,CAAA;AAC9C;AAGO,SAAS,YAAA,CAAa,KAAA,EAAe,QAAA,GAAW,KAAA,EAAe;AAClE,EAAA,OAAO,KAAA,GAAQ,eAAe,QAAQ,CAAA;AAC1C;AAGO,SAAS,YAAA,CAAa,KAAA,EAAe,QAAA,GAAW,KAAA,EAAe;AAClE,EAAA,OAAO,IAAA,CAAK,KAAA,CAAM,KAAA,GAAQ,cAAA,CAAe,QAAQ,CAAC,CAAA;AACtD;AAMO,SAAS,kBAAA,CAAmB,KAAA,EAAe,QAAA,GAAW,KAAA,EAAe;AACxE,EAAA,MAAM,MAAA,GAAS,eAAe,QAAQ,CAAA;AACtC,EAAA,MAAM,QAAQ,KAAA,GAAQ,MAAA;AACtB,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,IAAA,CAAK,KAAA,CAAM,MAAM,CAAC,CAAA;AAC3C","file":"chunk-2Y6QTHXI.js","sourcesContent":["// Money units. Zenky's golden rule:\n// • store and compute in MINOR units (kopecks/tyins/…) — that's what the API returns;\n// • send MAJOR units (rubles) to some API endpoints, as a number or a string.\n//\n// The compat functions below share their signatures with app/storefront/utils/price.ts —\n// a drop-in replacement that doesn't break call sites during the move.\n\n// ── Branded types (opt-in, for new code) ────────────────────────────────────\n// Minor and Major are distinct types — the compiler rejects mixing them up:\n// sendToServer(bill: Minor) ← passing Major is a compile error.\ndeclare const MINOR: unique symbol\ndeclare const MAJOR: unique symbol\n\n/** An amount in minor units (kopecks) — how the API stores and returns it. */\nexport type Minor = number & { readonly [MINOR]: true }\n/** An amount in major units (rubles) — the shape some API endpoints expect. */\nexport type Major = number & { readonly [MAJOR]: true }\n\n/** Marks a raw number from the API as Minor — a zero-cost assertion, not a conversion. */\nexport const asMinor = (value: number): Minor => value as Minor\nexport const asMajor = (value: number): Major => value as Major\n\n// ── Currency helpers ────────────────────────────────────────────────────────\n\n/**\n * Minor-to-major multiplier for a currency's ISO code, via Intl (no hardcoded table):\n * RUB/KZT/THB/EUR/USD = ×100, JPY/KRW = ×1, KWD/BHD/OMR = ×1000.\n */\nfunction getMinorFactor(currency: string): number {\n const fractionDigits =\n new Intl.NumberFormat('en', {\n style: 'currency',\n currency,\n }).resolvedOptions().maximumFractionDigits ?? 2\n return 10 ** fractionDigits\n}\n\n/**\n * Default formatting locale. Affects the separator (1 290 ₽ vs 1,290 ₽).\n * `ru-RU` fits RU/KZ/BY/UA. Pass `locale` explicitly for TH/JP/EN.\n */\nconst DEFAULT_LOCALE = 'ru-RU' as const\n\n// ── Compat API (previous number-based signatures — drop-in) ─────────────────\n\n/** Formats a price from minor units into a readable string (`1 290 ₽`). */\nexport function formatPrice(\n value?: number | null,\n currency = 'RUB',\n locale: string = DEFAULT_LOCALE\n): string {\n if (!value && value !== 0) {\n return ''\n }\n\n return new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n minimumFractionDigits: 0,\n }).format(value / getMinorFactor(currency))\n}\n\n/** Raw minor-to-major conversion (kopecks → rubles), no formatting. */\nexport function minorToMajor(value: number, currency = 'RUB'): number {\n return value / getMinorFactor(currency)\n}\n\n/** Raw major-to-minor conversion (rubles → kopecks), rounded to a whole number. */\nexport function majorToMinor(value: number, currency = 'RUB'): number {\n return Math.round(value * getMinorFactor(currency))\n}\n\n/**\n * Minor to major, as a string. The payments/bonuses API expects the amount\n * as a ruble string, e.g. `\"103.50\"`.\n */\nexport function minorToMajorString(value: number, currency = 'RUB'): string {\n const factor = getMinorFactor(currency)\n const major = value / factor\n return major.toFixed(Math.log10(factor))\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createDebounce } from './chunk-XUGXLJZB.js';
|
|
2
2
|
import { createRuntimeState } from './chunk-5QCUH3FF.js';
|
|
3
|
-
import { useCatalogStore } from './chunk-
|
|
4
|
-
import { useRuntime, useStoreProfileStore, useAuthStore } from './chunk-
|
|
3
|
+
import { useCatalogStore } from './chunk-NSOIL7PW.js';
|
|
4
|
+
import { useRuntime, useStoreProfileStore, useAuthStore } from './chunk-QZ3S3NN3.js';
|
|
5
5
|
import { UnitType } from '@zenky/storefront-api';
|
|
6
6
|
import { computed, ref, watch } from 'vue';
|
|
7
7
|
|
|
@@ -359,7 +359,7 @@ function usePriceRecalculation({
|
|
|
359
359
|
selectedVariant.value.id,
|
|
360
360
|
{
|
|
361
361
|
modifiers: modifiersModel.value,
|
|
362
|
-
// exactOptionalPropertyTypes: stock_id
|
|
362
|
+
// exactOptionalPropertyTypes: only include stock_id when it's set
|
|
363
363
|
...currentStockId.value ? { stock_id: currentStockId.value } : {}
|
|
364
364
|
}
|
|
365
365
|
);
|
|
@@ -574,7 +574,9 @@ function useProductDetail() {
|
|
|
574
574
|
const storeId = profileStore.store?.id;
|
|
575
575
|
if (!storeId) return null;
|
|
576
576
|
try {
|
|
577
|
-
return await sdk.products.getProduct(storeId, shortId, {
|
|
577
|
+
return await sdk.products.getProduct(storeId, shortId, {
|
|
578
|
+
with: PRODUCT_DETAIL_INCLUDES
|
|
579
|
+
});
|
|
578
580
|
} catch (e) {
|
|
579
581
|
console.error("[product-detail] getProduct failed", e);
|
|
580
582
|
return null;
|
|
@@ -622,5 +624,5 @@ function useProductList() {
|
|
|
622
624
|
}
|
|
623
625
|
|
|
624
626
|
export { canAddDirectly, findProductInCatalog, formatWeight, getProductWeight, getVariantWeight, resolveVariantPrice, toGrams, usePriceRecalculation, useProductDetail, useProductList, useProductPricing, useProductVariant, useProductVariantModifiers, useProductVariantSelector, useProductsByCategory, useRelatedProducts };
|
|
625
|
-
//# sourceMappingURL=chunk-
|
|
626
|
-
//# sourceMappingURL=chunk-
|
|
627
|
+
//# sourceMappingURL=chunk-32SLDGE5.js.map
|
|
628
|
+
//# sourceMappingURL=chunk-32SLDGE5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/products/formatWeight.ts","../src/products/useProductsByCategory.ts","../src/products/useProductVariantModifiers.ts","../src/products/useProductPricing.ts","../src/products/useProductVariant.ts","../src/products/usePriceRecalculation.ts","../src/products/useProductVariantSelector.ts","../src/products/useRelatedProducts.ts","../src/products/findProductInCatalog.ts","../src/products/useProductDetail.ts","../src/products/useProductList.ts"],"names":["computed","ref","watch"],"mappings":";;;;;;;AAIA,IAAM,WAAA,GAAwC;AAAA,EAC1C,CAAC,QAAA,CAAS,IAAI,GAAG,QAAA;AAAA,EACjB,CAAC,QAAA,CAAS,QAAQ,GAAG,cAAA;AAAA,EACrB,CAAC,QAAA,CAAS,KAAK,GAAG,QAAA;AAAA,EAClB,CAAC,QAAA,CAAS,KAAK,GAAG;AACtB,CAAA;AAEA,SAAS,wBAAwB,QAAA,EAAuD;AACpF,EAAA,IAAI,CAAC,QAAA,EAAU,MAAA,EAAQ,OAAO,IAAA;AAE9B,EAAA,MAAM,SAAA,GAAY,QAAA,CAAS,CAAC,CAAA,EAAG,UAAA,EAAY,KAAK,CAAC,CAAA,KAAM,CAAA,CAAE,SAAA,KAAc,QAAQ,CAAA;AAE/E,EAAA,OAAO,WAAW,KAAA,IAAS,IAAA;AAC/B;AAEO,SAAS,iBAAiB,OAAA,EAA2D;AACxF,EAAA,IAAI,CAAC,SAAS,OAAO,IAAA;AAErB,EAAA,OAAO,OAAA,CAAQ,YAAY,IAAA,CAAK,CAAC,MAAM,CAAA,CAAE,SAAA,KAAc,QAAQ,CAAA,EAAG,KAAA,IAAS,IAAA;AAC/E;AAEO,SAAS,iBAAiB,OAAA,EAAiC;AAC9D,EAAA,OAAO,OAAA,CAAQ,MAAA,IAAU,uBAAA,CAAwB,OAAA,CAAQ,QAAQ,CAAA,IAAK,IAAA;AAC1E;AAEO,SAAS,OAAA,CAAQ,QAAuB,QAAA,EAAmC;AAC9E,EAAA,IAAI,CAAC,MAAA,EAAQ;AACT,IAAA,OAAO,IAAA;AAAA,EACX;AAEA,EAAA,IAAI,QAAA,KAAa,SAAS,QAAA,EAAU;AAChC,IAAA,OAAO,MAAA,GAAS,GAAA;AAAA,EACpB;AAEA,E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AO,OAAA;AAAA,MACjB,MAAM,MAAA,CAAO,IAAA;AAAA,MACb,OAAO,MAAA,CAAO;AAAA,KACjB,CAAA;AAAA,EACL;AAEA,EAAA,OAAO,EAAE,aAAA,EAAc;AAC3B","file":"chunk-32SLDGE5.js","sourcesContent":["import { UnitType } from '@zenky/storefront-api'\n\nimport type { Product, ProductVariant } from '@zenky/storefront-api'\n\nconst UNIT_LABELS: Record<UnitType, string> = {\n [UnitType.Gram]: 'г',\n [UnitType.Kilogram]: 'кг',\n [UnitType.Meter]: 'м',\n [UnitType.Piece]: 'г',\n} as const\n\nfunction getWeightFromDimensions(variants: ProductVariant[] | undefined): number | null {\n if (!variants?.length) return null\n\n const dimension = variants[0]?.dimensions?.find((d) => d.dimension === 'weight')\n\n return dimension?.value ?? null\n}\n\nexport function getVariantWeight(variant: ProductVariant | null | undefined): number | null {\n if (!variant) return null\n\n return variant.dimensions?.find((d) => d.dimension === 'weight')?.value ?? null\n}\n\nexport function getProductWeight(product: Product): number | null {\n return product.weight ?? getWeightFromDimensions(product.variants) ?? null\n}\n\nexport function toGrams(weight: number | null, unitType: UnitType): number | null {\n if (!weight) {\n return null\n }\n\n if (unitType === UnitType.Kilogram) {\n return weight * 1000\n }\n\n if (unitType === UnitType.Meter) {\n return null\n }\n\n return weight\n}\n\nexport function formatWeight(weight: number | null, unitType: UnitType): string | null {\n if (!weight) {\n return null\n }\n\n const label = UNIT_LABELS[unitType]\n\n return `${weight} ${label}`\n}\n","import { computed, type ComputedRef } from 'vue'\n\nimport type { NestedCategory, Product } from '@zenky/storefront-api'\n\nexport interface CategoryWithProducts {\n id: string\n shortId: string\n slug: string | null\n name: string | null\n products: Product[]\n}\n\nexport function useProductsByCategory(\n products: ComputedRef<Product[]>,\n categories: ComputedRef<NestedCategory[]>\n): {\n grouped: ComputedRef<CategoryWithProducts[]>\n} {\n const grouped = computed<CategoryWithProducts[]>(() => {\n if (!categories.value.length || !products.value.length) {\n return []\n }\n\n const productsByCategory = new Map<string, Product[]>()\n\n for (const product of products.value) {\n for (const category of product.categories) {\n const existing = productsByCategory.get(category.id) ?? []\n existing.push(product)\n productsByCategory.set(category.id, existing)\n }\n }\n\n return flattenCategories(categories.value)\n .filter((category) => productsByCategory.has(category.id))\n .map((category) => ({\n id: category.id,\n shortId: category.short_id,\n slug: category.slug,\n name: category.name,\n products: productsByCategory.get(category.id) ?? [],\n }))\n })\n\n return { grouped }\n}\n\nfunction flattenCategories(categories: NestedCategory[]): NestedCategory[] {\n const result: NestedCategory[] = []\n\n for (const category of categories) {\n result.push(category)\n\n if (category.children?.length) {\n result.push(...flattenCategories(category.children))\n }\n }\n\n return result\n}\n","import { computed, ref, watch, type ComputedRef, type Ref } from 'vue'\n\nimport type { ProductModifiersRequest, ProductVariant } from '@zenky/storefront-api'\n\nfunction getInitialModifiersModel(variant: ProductVariant | null): ProductModifiersRequest[] {\n if (!variant?.default_modifiers?.modifiers.length) {\n return []\n }\n\n return variant.default_modifiers.modifiers.map((modifier) => ({\n modifier_id: modifier.modifier_id,\n modifiers_group_id: modifier.modifiers_group_id,\n quantity: modifier.quantity,\n }))\n}\n\nexport function useProductVariantModifiers(variant: ComputedRef<ProductVariant | null>): {\n modifiersModel: Ref<ProductModifiersRequest[]>\n selectedModifiersHash: Ref<string | null>\n hasAnyModifier: ComputedRef<boolean>\n} {\n const modifiersModel: Ref<ProductModifiersRequest[]> = ref([\n ...getInitialModifiersModel(variant.value),\n ])\n const selectedModifiersHash: Ref<string | null> = ref(null)\n const hasAnyModifier = computed<boolean>(() => modifiersModel.value.length > 0)\n\n watch(variant, () => {\n const newDefaults = getInitialModifiersModel(variant.value)\n\n // Keep standalone modifiers (no group) — they belong to the product, not the variant.\n // Group modifiers reset to the new variant's defaults.\n const userStandalone = modifiersModel.value.filter((m) => !m.modifiers_group_id)\n const defaultStandaloneIds = new Set(\n newDefaults.filter((d) => !d.modifiers_group_id).map((d) => d.modifier_id)\n )\n const preservedStandalone = userStandalone.filter(\n (m) => !defaultStandaloneIds.has(m.modifier_id)\n )\n\n modifiersModel.value = [...preservedStandalone, ...newDefaults]\n })\n\n return { modifiersModel, selectedModifiersHash, hasAnyModifier }\n}\n","import { computed, type ComputedRef } from 'vue'\n\nimport type { Discount, Product, ProductVariant } from '@zenky/storefront-api'\n\nexport interface ResolvedPrice {\n price: number\n originalPrice: number | null\n discount: Discount | null\n}\n\n/**\n * Resolves a variant's price, accounting for stock.\n * Priority: prices[stockId] → prices[null] → top-level price.\n */\nexport function resolveVariantPrice(\n variant: ProductVariant,\n stockId?: string | null\n): ResolvedPrice {\n if (variant.prices?.length) {\n // 1. Exact match by stock\n if (stockId) {\n const stockEntry = variant.prices.find((p) => p.stock_id === stockId)\n\n if (stockEntry) {\n return {\n price: stockEntry.price,\n originalPrice: stockEntry.original_price,\n discount: stockEntry.discount,\n }\n }\n }\n\n // 2. Global price (stock_id = null)\n const globalEntry = variant.prices.find((p) => p.stock_id === null)\n\n if (globalEntry) {\n return {\n price: globalEntry.price,\n originalPrice: globalEntry.original_price,\n discount: globalEntry.discount,\n }\n }\n }\n\n // 3. Fallback — the variant's top-level fields\n return {\n price: variant.price,\n originalPrice: variant.original_price ?? null,\n discount: variant.discount ?? null,\n }\n}\n\nexport function useProductPricing(\n product: ComputedRef<Product>,\n stockId?: ComputedRef<string | null | undefined>\n): {\n displayPrice: ComputedRef<number>\n originalDisplayPrice: ComputedRef<number | null>\n hasDifferentPrices: ComputedRef<boolean>\n needsSelection: ComputedRef<boolean>\n} {\n const variants = computed(() => product.value.variants ?? [])\n const currentStockId = computed(() => stockId?.value ?? null)\n\n const resolvedPrices = computed(() =>\n variants.value.map((v) => resolveVariantPrice(v, currentStockId.value))\n )\n\n // Minimum required modifier cost that's always added to the price:\n // 1. modEntry.is_required — the modifier is always sent to the API (can't be removed)\n // 2. groupEntry.is_required — the user must pick at least one from the group →\n // add the cheapest price in the group (if no is_required modifier already covers it)\n const minRequiredModifiersCost = computed<number>(() => {\n let total = 0\n\n for (const groupEntry of product.value.modifiers_groups ?? []) {\n const group = groupEntry.group\n\n for (const modEntry of group.modifiers) {\n if (modEntry.is_required && modEntry.modifier.price) {\n total += modEntry.modifier.price * Math.max(modEntry.min_quantity ?? 0, 1)\n }\n }\n\n if (\n groupEntry.is_required &&\n group.modifiers.length &&\n !group.modifiers.some((m) => m.is_required)\n ) {\n const cheapest = group.modifiers.reduce((min, m) =>\n (m.modifier.price ?? 0) < (min.modifier.price ?? 0) ? m : min\n )\n total += (cheapest.modifier.price ?? 0) * Math.max(cheapest.min_quantity ?? 0, 1)\n }\n }\n\n return total\n })\n\n const displayPrice = computed<number>(() => {\n if (!resolvedPrices.value.length) {\n return 0\n }\n\n return (\n Math.min(...resolvedPrices.value.map((r) => r.price)) + minRequiredModifiersCost.value\n )\n })\n\n // Price without the discount: original_price of the cheapest variant + required modifiers.\n // null if there is no discount.\n // original_price can be null even when a discount exists — then compute it via discount.difference.\n const originalDisplayPrice = computed<number | null>(() => {\n if (!resolvedPrices.value.length) return null\n\n // Find the variant with the minimum price (the same one that determines displayPrice)\n const cheapest = resolvedPrices.value.reduce((min, r) => (r.price < min.price ? r : min))\n\n // Priority: original_price, then compute via discount\n let originalVariantPrice: number | null = null\n\n if (cheapest.originalPrice && cheapest.originalPrice > cheapest.price) {\n originalVariantPrice = cheapest.originalPrice\n } else if (cheapest.discount && cheapest.discount.difference > 0) {\n originalVariantPrice = cheapest.price + cheapest.discount.difference\n }\n\n if (!originalVariantPrice) return null\n\n return originalVariantPrice + minRequiredModifiersCost.value\n })\n\n const hasDifferentPrices = computed<boolean>(() => {\n if (resolvedPrices.value.length <= 1) {\n return false\n }\n\n const prices = new Set(resolvedPrices.value.map((r) => r.price))\n\n return prices.size > 1\n })\n\n const needsSelection = computed<boolean>(() => {\n if (variants.value.length > 1) {\n return true\n }\n\n const mods = product.value.modifiers\n const groups = product.value.modifiers_groups\n\n return (\n (Array.isArray(mods) && mods.length > 0) || (Array.isArray(groups) && groups.length > 0)\n )\n })\n\n return { displayPrice, originalDisplayPrice, hasDifferentPrices, needsSelection }\n}\n","import { computed, ref, watch, type ComputedRef, type Ref } from 'vue'\n\nimport type {\n Product,\n ProductVariant,\n ProductVariantOption,\n ProductVariantOptionValue,\n} from '@zenky/storefront-api'\n\nexport interface ProductVariantOptionListItem {\n id: string\n name: string | null\n values: ProductVariantOptionValue[]\n}\n\nfunction getDefaultOptionsModel(product: Product): Record<string, string> {\n const model: Record<string, string> = {}\n\n if (!product.variants?.length) {\n return model\n }\n\n const firstVariantOptions = product.variants.find(\n (variant: ProductVariant) => variant.options?.length\n )?.options\n\n if (!firstVariantOptions) {\n return model\n }\n\n firstVariantOptions.forEach((option: ProductVariantOption) => {\n model[option.id] = option.value.id\n })\n\n return model\n}\n\nfunction getProductVariantOptionsList(product: Product): ProductVariantOptionListItem[] {\n const list: ProductVariantOptionListItem[] = []\n\n if (!product.variants?.length) {\n return list\n }\n\n product.variants.forEach((variant: ProductVariant) => {\n if (!variant.options?.length) {\n return\n }\n\n variant.options.forEach((option: ProductVariantOption) => {\n let index = list.findIndex(\n (item: ProductVariantOptionListItem) => item.id === option.id\n )\n\n if (index === -1) {\n index = list.push({\n id: option.id,\n name: option.name,\n values: [],\n })\n\n index--\n }\n\n const valueIndex = list[index]!.values.findIndex(\n (value: ProductVariantOptionValue) => value.id === option.value.id\n )\n\n if (valueIndex === -1) {\n list[index]!.values.push(option.value)\n }\n })\n })\n\n return list\n}\n\nfunction computeDisabledValues(\n variants: ProductVariant[],\n optionsList: ProductVariantOptionListItem[],\n optionsModel: Record<string, string>\n): Record<string, Set<string>> {\n if (!variants.length) return {}\n\n const result: Record<string, Set<string>> = {}\n\n for (const option of optionsList) {\n const disabled = new Set<string>()\n\n for (const value of option.values) {\n const hasMatch = variants.some((variant) => {\n if (!variant.options?.length) return false\n\n const variantMap: Record<string, string> = {}\n for (const opt of variant.options) {\n variantMap[opt.id] = opt.value.id\n }\n\n // Variant must have this specific value for this option\n if (variantMap[option.id] !== value.id) return false\n\n // Variant must match all OTHER currently-selected values\n for (const [otherId, selectedId] of Object.entries(optionsModel)) {\n if (otherId === option.id) continue\n if (variantMap[otherId] !== selectedId) return false\n }\n\n return true\n })\n\n if (!hasMatch) {\n disabled.add(value.id)\n }\n }\n\n result[option.id] = disabled\n }\n\n return result\n}\n\nexport function useProductVariant(product: ComputedRef<Product>): {\n optionsModel: Ref<Record<string, string>>\n optionsList: Ref<ProductVariantOptionListItem[]>\n selectedVariant: ComputedRef<ProductVariant | null>\n disabledValues: ComputedRef<Record<string, Set<string>>>\n} {\n const optionsModel = ref({ ...getDefaultOptionsModel(product.value) })\n const optionsList = ref([...getProductVariantOptionsList(product.value)])\n\n const selectedVariant = computed<ProductVariant | null>(() => {\n if (!product.value.variants?.length) {\n return null\n } else if (product.value.variants.length === 1 || !Object.keys(optionsModel.value).length) {\n return product.value.variants[0] ?? null\n }\n\n return (\n product.value.variants.find((variant: ProductVariant) => {\n if (!variant.options?.length) {\n return false\n }\n\n return variant.options.every(\n (option: ProductVariantOption) =>\n optionsModel.value[option.id] === option.value.id\n )\n }) ?? null\n )\n })\n\n const disabledValues = computed<Record<string, Set<string>>>(() =>\n computeDisabledValues(product.value.variants ?? [], optionsList.value, optionsModel.value)\n )\n\n watch(product, () => {\n optionsModel.value = { ...getDefaultOptionsModel(product.value) }\n optionsList.value = [...getProductVariantOptionsList(product.value)]\n })\n\n return { optionsModel, optionsList, selectedVariant, disabledValues }\n}\n","import { computed, ref, watch, type ComputedRef, type Ref } from 'vue'\n\nimport type { Product, ProductModifiersRequest, ProductVariant } from '@zenky/storefront-api'\n\nimport { useRuntime } from '../ports/runtime'\nimport { useStoreProfileStore } from '../stores/store-profile'\nimport { createDebounce } from '../utils/debounce'\nimport { resolveVariantPrice } from './useProductPricing'\n\ninterface PriceRecalculationOptions {\n product: ComputedRef<Product>\n selectedVariant: ComputedRef<ProductVariant | null>\n modifiersModel: Ref<ProductModifiersRequest[]>\n requiredModifiersGroupIsMissing: ComputedRef<boolean>\n selectedModifiersHash: Ref<string | null>\n}\n\nexport function usePriceRecalculation({\n product,\n selectedVariant,\n modifiersModel,\n requiredModifiersGroupIsMissing,\n selectedModifiersHash,\n}: PriceRecalculationOptions): {\n price: ComputedRef<number>\n originalPrice: ComputedRef<number | null>\n priceWasModified: ComputedRef<boolean>\n priceIsRecalculating: Ref<boolean>\n} {\n // Get the SDK from the runtime (DI port), not from the Nuxt-specific useStorefrontApi().\n const sdk = useRuntime().sdk\n const profileStore = useStoreProfileStore()\n\n // -------------------------------------------------------------------------\n // Computed: stock-aware variant pricing\n // -------------------------------------------------------------------------\n\n const currentStockId = computed(() => profileStore.stock?.id ?? null)\n\n const resolvedVariant = computed(() => {\n if (!selectedVariant.value) return null\n\n return resolveVariantPrice(selectedVariant.value, currentStockId.value)\n })\n\n // -------------------------------------------------------------------------\n // Computed: modifier price helpers\n // -------------------------------------------------------------------------\n\n const modifierPriceMap = computed<Map<string, number>>(() => {\n const map = new Map<string, number>()\n\n for (const item of product.value.modifiers ?? []) {\n if (item.modifier.price) {\n map.set(item.modifier.id, item.modifier.price)\n }\n }\n\n for (const group of product.value.modifiers_groups ?? []) {\n for (const item of group.group.modifiers ?? []) {\n if (item.modifier.price) {\n map.set(item.modifier.id, item.modifier.price)\n }\n }\n }\n\n return map\n })\n\n // Sum of selected modifier prices (includes defaults — they're already in modifiersModel)\n const selectedModifierTotal = computed<number>(() =>\n modifiersModel.value.reduce(\n (sum, req) => sum + (modifierPriceMap.value.get(req.modifier_id) ?? 0) * req.quantity,\n 0\n )\n )\n\n // -------------------------------------------------------------------------\n // Computed: optimistic price (instant, without hitting the API)\n // -------------------------------------------------------------------------\n\n // variant.price is the variant's base price (stock-specific or fallback);\n // it does NOT include modifiers. selectedModifierTotal adds all selected\n // modifiers (default + required + custom).\n const optimisticPrice = computed<number>(() => {\n if (!resolvedVariant.value) return 0\n\n return resolvedVariant.value.price + selectedModifierTotal.value\n })\n\n const optimisticOriginalPrice = computed<number | null>(() => {\n if (!resolvedVariant.value) return null\n\n const r = resolvedVariant.value\n\n if (r.originalPrice && r.originalPrice > r.price) return r.originalPrice\n if (r.discount && r.discount.difference > 0) return r.price + r.discount.difference\n\n return null\n })\n\n // -------------------------------------------------------------------------\n // API-confirmed price (overrides the optimistic price once the response arrives)\n // -------------------------------------------------------------------------\n\n const apiPrice = ref<number | null>(null)\n const apiOriginalPrice = ref<number | null>(null)\n const priceIsRecalculating = ref(false)\n let requestId = 0\n\n // -------------------------------------------------------------------------\n // Final displayed price: API > optimistic\n // -------------------------------------------------------------------------\n\n const price = computed<number>(() => apiPrice.value ?? optimisticPrice.value)\n const originalPrice = computed<number | null>(\n () => apiOriginalPrice.value ?? optimisticOriginalPrice.value\n )\n const priceWasModified = computed<boolean>(() => apiPrice.value !== null)\n\n // -------------------------------------------------------------------------\n // API recalculation (confirms / corrects the optimistic price)\n // -------------------------------------------------------------------------\n\n async function recalculatePrice(): Promise<void> {\n if (requiredModifiersGroupIsMissing.value) return\n if (!modifiersModel.value.length || !selectedVariant.value) return\n\n const currentRequestId = ++requestId\n priceIsRecalculating.value = true\n\n try {\n const response = await sdk.products.getProductVariantPrice(\n profileStore.store!.id,\n product.value.id,\n selectedVariant.value.id,\n {\n modifiers: modifiersModel.value,\n // exactOptionalPropertyTypes: only include stock_id when it's set\n ...(currentStockId.value ? { stock_id: currentStockId.value } : {}),\n }\n )\n\n if (currentRequestId !== requestId) return\n\n apiPrice.value = response.price\n apiOriginalPrice.value = response.original_price\n selectedModifiersHash.value = response.modifiers_hash\n } catch (e) {\n console.error('[usePriceRecalculation] price recalculation failed', e)\n } finally {\n if (currentRequestId === requestId) {\n priceIsRecalculating.value = false\n }\n }\n }\n\n const debouncedRecalculate = createDebounce(() => recalculatePrice(), 300)\n\n // -------------------------------------------------------------------------\n // Watcher: reset the API price + recalculate when the variant/modifiers change\n // -------------------------------------------------------------------------\n\n watch(selectedVariant, () => {\n apiPrice.value = null\n apiOriginalPrice.value = null\n requestId++\n selectedModifiersHash.value = selectedVariant.value?.default_modifiers?.hash ?? null\n })\n\n watch(\n modifiersModel,\n () => {\n apiPrice.value = null\n apiOriginalPrice.value = null\n requestId++\n\n if (modifiersModel.value.length && selectedVariant.value) {\n debouncedRecalculate()\n } else {\n selectedModifiersHash.value = selectedVariant.value?.default_modifiers?.hash ?? null\n }\n },\n { deep: true }\n )\n\n return { price, originalPrice, priceWasModified, priceIsRecalculating }\n}\n","import { computed, watch, type ComputedRef, type Ref } from 'vue'\n\nimport type { Product, ProductModifiersRequest, ProductVariant } from '@zenky/storefront-api'\n\nimport { usePriceRecalculation } from './usePriceRecalculation'\nimport { useProductVariant, type ProductVariantOptionListItem } from './useProductVariant'\nimport { useProductVariantModifiers } from './useProductVariantModifiers'\n\n// The SDK's min_quantity field is optional (number | null); normalize it to a positive quantity.\nfunction resolveQuantity(minQuantity: number | null): number {\n return minQuantity && minQuantity > 0 ? minQuantity : 1\n}\n\nexport function useProductVariantSelector(product: ComputedRef<Product>): {\n optionsModel: Ref<Record<string, string>>\n optionsList: Ref<ProductVariantOptionListItem[]>\n disabledValues: ComputedRef<Record<string, Set<string>>>\n modifiersModel: Ref<ProductModifiersRequest[]>\n selectedVariant: ComputedRef<ProductVariant | null>\n price: ComputedRef<number>\n originalPrice: ComputedRef<number | null>\n priceWasModified: ComputedRef<boolean>\n priceIsRecalculating: Ref<boolean>\n selectedModifiersHash: Ref<string | null>\n requiredModifiersGroupIsMissing: ComputedRef<boolean>\n} {\n const { optionsModel, optionsList, selectedVariant, disabledValues } =\n useProductVariant(product)\n const { modifiersModel, selectedModifiersHash } = useProductVariantModifiers(selectedVariant)\n\n // Required modifiers must always be present in the model.\n // 1) modEntry.is_required — an individually required modifier\n // 2) groupEntry.is_required — a required group: if it has no is_required modifiers,\n // auto-select the cheapest one (mirrors minRequiredModifiersCost in useProductPricing)\n const requiredModifierEntries = computed<ProductModifiersRequest[]>(() => {\n const result: ProductModifiersRequest[] = []\n\n for (const groupEntry of product.value.modifiers_groups ?? []) {\n const group = groupEntry.group\n const hasIndividualRequired = group.modifiers.some((m) => m.is_required)\n\n // 1. Individually required modifiers\n for (const modEntry of group.modifiers) {\n if (modEntry.is_required) {\n result.push({\n modifier_id: modEntry.modifier.id,\n modifiers_group_id: group.id,\n quantity: resolveQuantity(modEntry.min_quantity),\n })\n }\n }\n\n // 2. A required group with no is_required modifiers →\n // the user must pick at least one; take the cheapest\n if (groupEntry.is_required && !hasIndividualRequired) {\n const sorted = [...group.modifiers].sort(\n (a, b) => (a.modifier.price ?? 0) - (b.modifier.price ?? 0)\n )\n const cheapest = sorted[0]\n\n if (cheapest) {\n result.push({\n modifier_id: cheapest.modifier.id,\n modifiers_group_id: group.id,\n quantity: resolveQuantity(cheapest.min_quantity),\n })\n }\n }\n }\n\n return result\n })\n\n // Adds required modifiers to the model (for both UI and API).\n // Single mutation — avoids extra reactive recalculations.\n function seedRequiredModifiers(): void {\n const missing = requiredModifierEntries.value.filter(\n (req) => !modifiersModel.value.some((m) => m.modifier_id === req.modifier_id)\n )\n\n if (missing.length) {\n modifiersModel.value = [...modifiersModel.value, ...missing]\n }\n }\n\n // Synchronous initialization — runs before any watchers are registered in\n // usePriceRecalculation, so the first render already sees the correct price.\n seedRequiredModifiers()\n\n // On variant change: the useProductVariantModifiers watcher resets the model to defaults,\n // then we add the required ones back. Both watchers use flush: 'pre' — they run in\n // registration order, before the render.\n watch(selectedVariant, seedRequiredModifiers)\n\n const requiredModifiersGroupIsMissing = computed<boolean>(() => {\n const requiredGroups = (product.value.modifiers_groups ?? [])\n .filter((group) => group.is_required)\n .map((group) => group.group.id)\n\n if (!requiredGroups.length) return false\n\n return requiredGroups.some(\n (groupId) =>\n !modifiersModel.value.find(\n (m) => m.modifiers_group_id === groupId && m.quantity > 0\n )\n )\n })\n\n const { price, originalPrice, priceWasModified, priceIsRecalculating } = usePriceRecalculation({\n product,\n selectedVariant,\n modifiersModel,\n requiredModifiersGroupIsMissing,\n selectedModifiersHash,\n })\n\n return {\n optionsModel,\n optionsList,\n disabledValues,\n modifiersModel,\n selectedVariant,\n price,\n originalPrice,\n priceWasModified,\n priceIsRecalculating,\n selectedModifiersHash,\n requiredModifiersGroupIsMissing,\n }\n}\n","// Requests for recommended products. The SDK has no typed related.products.list\n// method, so this goes through the public sdk.client.request instead.\nimport type { Product } from '@zenky/storefront-api'\n\nimport { useRuntime } from '../ports/runtime'\nimport { createRuntimeState } from '../ports/runtimeState'\nimport { useAuthStore } from '../stores/auth'\nimport { useStoreProfileStore } from '../stores/store-profile'\n\nexport interface OrderCredentials {\n id: string\n token: string\n}\n\ninterface UseRelatedProductsApi {\n fetchForProduct: (\n productId: string,\n orderCredentials: OrderCredentials | null,\n signal?: AbortSignal\n ) => Promise<Product[]>\n fetchForOrder: (orderId: string, orderToken: string, signal?: AbortSignal) => Promise<Product[]>\n}\n\n/**\n * A single variant and no modifiers — such a product can be added to the cart\n * directly with one click from a recommendation, without opening the product card.\n */\nexport function canAddDirectly(product: Product): boolean {\n const variantsCount = product.variants?.length ?? 0\n const hasModifiers = (product.modifiers?.length ?? 0) > 0\n const hasModifierGroups = (product.modifiers_groups?.length ?? 0) > 0\n return variantsCount === 1 && !hasModifiers && !hasModifierGroups\n}\n\n// Without `variants.prices` prices come back as 0 (prices live on variants). Without\n// modifiers/groups, canAddDirectly breaks — it treats the product as \"direct add\"\n// even though it has modifiers.\nconst RELATED_PRODUCT_INCLUDES = 'variants.prices,modifiers,modifiers_groups'\n\ninterface RelatedProductsState {\n productInFlight: Map<string, Promise<Product[]>>\n}\n\nconst getRelatedProductsState = createRuntimeState<RelatedProductsState>(() => ({\n productInFlight: new Map<string, Promise<Product[]>>(),\n}))\n\nexport function useRelatedProducts(): UseRelatedProductsApi {\n const runtime = useRuntime()\n const { sdk } = runtime\n const { productInFlight } = getRelatedProductsState(runtime)\n const profileStore = useStoreProfileStore()\n const authStore = useAuthStore()\n\n function getStoreId(): string {\n const id = profileStore.store?.id\n if (!id) throw new Error('Store is not initialized')\n return id\n }\n\n async function fetchForProduct(\n productId: string,\n orderCredentials: OrderCredentials | null,\n signal?: AbortSignal\n ): Promise<Product[]> {\n if (signal?.aborted) return []\n\n const key = orderCredentials ? `${productId}:${orderCredentials.id}` : productId\n\n let promise = productInFlight.get(key)\n if (!promise) {\n promise = (async (): Promise<Product[]> => {\n try {\n const storeId = getStoreId()\n const query: Record<string, string> = { with: RELATED_PRODUCT_INCLUDES }\n if (orderCredentials) {\n query.order_id = orderCredentials.id\n query.order_token = orderCredentials.token\n }\n const url = sdk.client.getStoreUrl(\n storeId,\n `/products/${productId}/related/products`,\n query\n )\n const response = await sdk.client.request(\n 'GET',\n url,\n undefined,\n authStore.token\n )\n return (response?.data as Product[] | undefined) ?? []\n } catch (e: unknown) {\n // Per spec: on error or empty response, show nothing to the customer —\n // the block just doesn't appear. The log is for developers.\n console.warn('[recommendations:product] fetch failed', e)\n return []\n }\n })().finally(() => productInFlight.delete(key))\n productInFlight.set(key, promise)\n }\n\n const result = await promise\n return signal?.aborted ? [] : result\n }\n\n async function fetchForOrder(\n orderId: string,\n orderToken: string,\n signal?: AbortSignal\n ): Promise<Product[]> {\n if (signal?.aborted) return []\n\n try {\n const storeId = getStoreId()\n const url = sdk.client.getStoreUrl(storeId, `/orders/${orderId}/related/products`, {\n token: orderToken,\n with: RELATED_PRODUCT_INCLUDES,\n })\n const response = await sdk.client.request('GET', url, undefined, authStore.token)\n if (signal?.aborted) return []\n return (response?.data as Product[] | undefined) ?? []\n } catch (e: unknown) {\n console.warn('[recommendations:order] fetch failed', e)\n return []\n }\n }\n\n return { fetchForProduct, fetchForOrder }\n}\n","import type { Product } from '@zenky/storefront-api'\n\nimport type { StaticCatalogItem } from '../catalog/catalogEntity'\n\nexport interface CatalogProductMatch {\n product: Product\n catalogItem: StaticCatalogItem\n}\n\nexport function findProductInCatalog(\n catalog: StaticCatalogItem[],\n shortId: string\n): CatalogProductMatch | null {\n for (const item of catalog) {\n if (!item.products.length) continue\n\n const found = item.products.find((p) => p.short_id === shortId)\n if (found) return { product: found, catalogItem: item }\n }\n\n return null\n}\n","import { useRuntime } from '../ports/runtime'\nimport { useCatalogStore } from '../stores/catalog'\nimport { useStoreProfileStore } from '../stores/store-profile'\nimport { findProductInCatalog, type CatalogProductMatch } from './findProductInCatalog'\n\nimport type { Product } from '@zenky/storefront-api'\n\n// images — cover and OG image; variants.options — without it the variant selector\n// collapses to the first variant; variants.prices — the variant's own price, not 0;\n// custom_fields — extra product attributes.\nconst PRODUCT_DETAIL_INCLUDES =\n 'images,variants.prices,variants.options,categories,modifiers,modifiers.cover,modifiers_groups,modifiers_groups.cover,custom_fields'\n\nexport interface UseProductDetailApi {\n /** Synchronous search against the already-loaded static catalog. */\n findInCatalog: (shortId: string) => CatalogProductMatch | null\n /** API fallback for when the product isn't in the catalog. */\n fetchProduct: (shortId: string) => Promise<Product | null>\n}\n\nexport function useProductDetail(): UseProductDetailApi {\n const { sdk } = useRuntime()\n const catalogStore = useCatalogStore()\n const profileStore = useStoreProfileStore()\n\n function findInCatalog(shortId: string): CatalogProductMatch | null {\n return findProductInCatalog(catalogStore.catalog, shortId)\n }\n\n async function fetchProduct(shortId: string): Promise<Product | null> {\n const storeId = profileStore.store?.id\n if (!storeId) return null\n\n try {\n return await sdk.products.getProduct(storeId, shortId, {\n with: PRODUCT_DETAIL_INCLUDES,\n })\n } catch (e) {\n console.error('[product-detail] getProduct failed', e)\n return null\n }\n }\n\n return { findInCatalog, fetchProduct }\n}\n","import { useRuntime } from '../ports/runtime'\nimport { useStoreProfileStore } from '../stores/store-profile'\n\nimport type { PaginatedResponse, Product } from '@zenky/storefront-api'\n\n// images — cover image; variants.prices — price per stock (see resolveVariantPrice);\n// modifiers/modifiers_groups — the card shows \"from X ₽\" when these are present.\nconst PRODUCT_LIST_INCLUDES =\n 'images,variants.prices,variants.options,modifiers,modifiers.cover,modifiers_groups,modifiers_groups.cover'\n\nexport interface ProductListParams {\n categoryId?: string\n collectionId?: string\n orderBy?: string\n page?: number\n count?: number\n}\n\nexport interface UseProductListApi {\n fetchProducts: (params: ProductListParams) => Promise<PaginatedResponse<Product>>\n}\n\nfunction emptyPage(page: number, count: number): PaginatedResponse<Product> {\n return {\n items: [],\n pagination: {\n total: 0,\n count: 0,\n per_page: count,\n current_page: page,\n total_pages: 0,\n links: {},\n has_previous_page: false,\n has_next_page: false,\n elements: [],\n },\n }\n}\n\nexport function useProductList(): UseProductListApi {\n const { sdk } = useRuntime()\n const profileStore = useStoreProfileStore()\n\n async function fetchProducts(params: ProductListParams): Promise<PaginatedResponse<Product>> {\n const storeId = profileStore.store?.id\n\n if (!storeId) {\n return emptyPage(params.page ?? 1, params.count ?? 0)\n }\n\n return sdk.products.getProducts(storeId, {\n category_id: params.categoryId,\n collection_id: params.collectionId,\n with: PRODUCT_LIST_INCLUDES,\n order_by: params.orderBy,\n page: params.page,\n count: params.count,\n })\n }\n\n return { fetchProducts }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useCartStore, usePromotionsStore } from './chunk-
|
|
2
|
-
import { useRuntime, useAuthStore, useStoreProfileStore } from './chunk-
|
|
1
|
+
import { useCartStore, usePromotionsStore } from './chunk-XULHV6SS.js';
|
|
2
|
+
import { useRuntime, useAuthStore, useStoreProfileStore } from './chunk-QZ3S3NN3.js';
|
|
3
3
|
import { ref } from 'vue';
|
|
4
4
|
|
|
5
5
|
var KEY_ORDER_ID = "zenky_order_id";
|
|
@@ -105,5 +105,5 @@ function usePromotionsChecker() {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
export { useCartCredentials, usePromotionsChecker };
|
|
108
|
-
//# sourceMappingURL=chunk-
|
|
109
|
-
//# sourceMappingURL=chunk-
|
|
108
|
+
//# sourceMappingURL=chunk-46FNHMWC.js.map
|
|
109
|
+
//# sourceMappingURL=chunk-46FNHMWC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cart/useCartCredentials.ts","../src/promotions/usePromotionsChecker.ts"],"names":[],"mappings":";;;;A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ref, type Ref } from 'vue'\n\nimport type { Order, OrderCredentials } from '@zenky/storefront-api'\n\nimport { useRuntime } from '../ports/runtime'\nimport { useAuthStore } from '../stores/auth'\nimport { useCartStore } from '../stores/cart'\nimport { useStoreProfileStore } from '../stores/store-profile'\n\nconst KEY_ORDER_ID = 'zenky_order_id'\nconst KEY_ORDER_TOKEN = 'zenky_order_token'\nconst WEEK_SECONDS = 60 * 60 * 24 * 7\n\n// App-level enum: OrderStatusKind.Pending = 'pending'.\nconst ORDER_STATUS_PENDING = 'pending'\n\nexport interface CartCredentials {\n orderIdCookie: Ref<string | null>\n orderTokenCookie: Ref<string | null>\n getStoreId: () => string\n getCityId: () => string\n getApiToken: () => string | undefined\n buildCredentials: (orderId: string, orderToken: string) => OrderCredentials\n getCredentials: () => OrderCredentials\n persistCredentials: (savedOrder: Order) => void\n clearPersistedCredentials: () => void\n isOrderActive: (order: Order) => boolean\n}\n\n/**\n * Manages order credentials. Order id/token persistence goes through the `storage`\n * port (the core doesn't know about useCookie). The refs are initialized from\n * storage; persisting writes to both.\n */\nexport function useCartCredentials(): CartCredentials {\n const { storage } = useRuntime()\n const cartStore = useCartStore()\n const authStore = useAuthStore()\n const profileStore = useStoreProfileStore()\n\n const orderIdRef = ref<string | null>(storage.get(KEY_ORDER_ID))\n const orderTokenRef = ref<string | null>(storage.get(KEY_ORDER_TOKEN))\n\n function getStoreId(): string {\n if (!profileStore.store) {\n throw new Error('Store is not initialized.')\n }\n\n return profileStore.store.id\n }\n\n function getCityId(): string {\n if (!profileStore.city) {\n throw new Error('City is not initialized.')\n }\n\n return profileStore.city.id\n }\n\n function getApiToken(): string | undefined {\n return authStore.apiToken\n }\n\n function buildCredentials(orderId: string, orderToken: string): OrderCredentials {\n const credentials: OrderCredentials = {\n id: orderId,\n token: orderToken,\n }\n\n const apiToken = getApiToken()\n\n if (apiToken) {\n credentials.api_token = apiToken\n }\n\n return credentials\n }\n\n function getCredentials(): OrderCredentials {\n if (!cartStore.credentials) {\n throw new Error('Cart has no credentials.')\n }\n\n return buildCredentials(cartStore.credentials.id, cartStore.credentials.token)\n }\n\n function persistCredentials(savedOrder: Order): void {\n orderIdRef.value = savedOrder.id\n orderTokenRef.value = savedOrder.token\n storage.set(KEY_ORDER_ID, savedOrder.id, { maxAge: WEEK_SECONDS })\n storage.set(KEY_ORDER_TOKEN, savedOrder.token, { maxAge: WEEK_SECONDS })\n }\n\n function clearPersistedCredentials(): void {\n orderIdRef.value = null\n orderTokenRef.value = null\n storage.remove(KEY_ORDER_ID)\n storage.remove(KEY_ORDER_TOKEN)\n }\n\n function isOrderActive(existingOrder: Order): boolean {\n if (!existingOrder.status) return true\n\n return String(existingOrder.status.kind) === ORDER_STATUS_PENDING\n }\n\n return {\n orderIdCookie: orderIdRef,\n orderTokenCookie: orderTokenRef,\n getStoreId,\n getCityId,\n getApiToken,\n buildCredentials,\n getCredentials,\n persistCredentials,\n clearPersistedCredentials,\n isOrderActive,\n }\n}\n","import { useRuntime } from '../ports/runtime'\nimport { useCartCredentials } from '../cart/useCartCredentials'\nimport { useCartStore } from '../stores/cart'\nimport { usePromotionsStore } from '../stores/promotions'\nimport { useStoreProfileStore } from '../stores/store-profile'\n\nexport interface PromotionsChecker {\n dispatchCheck: () => Promise<void>\n}\n\n/** Timeout — if the WS never responds, reset the checking flag. */\nconst WS_RESPONSE_TIMEOUT_MS = 5000\n\n/**\n * Checks promotions. Calls dispatchPromotionsChecker after the cart changes.\n * The result arrives over WebSocket (handled in useOrderChannel).\n *\n * Resolve this synchronously in setup, and call only `dispatchCheck` after an\n * await — like any core composable, see \"Call composables and stores\n * synchronously in setup\" in the README.\n *\n * ```ts\n * const { dispatchCheck } = usePromotionsChecker()\n *\n * async function addGift() {\n * await addVariantToOrder()\n * dispatchCheck()\n * }\n * ```\n */\nexport function usePromotionsChecker(): PromotionsChecker {\n const { sdk, events } = useRuntime()\n const cartStore = useCartStore()\n const profileStore = useStoreProfileStore()\n const promotionsStore = usePromotionsStore()\n const credentials = useCartCredentials()\n\n async function dispatchCheck(): Promise<void> {\n if (!cartStore.hasOrder || promotionsStore.checking) return\n\n const storeId = profileStore.store?.id\n if (!storeId) return\n\n promotionsStore.setChecking(true)\n promotionsStore.clearRewards() // Clear old ones — WS will refill with current ones\n events?.get()?.promotionsCheckerStarted({ order: cartStore.order })\n\n try {\n const creds = credentials.getCredentials()\n await sdk.orders.dispatchPromotionsChecker(storeId, creds)\n\n setTimeout(() => {\n if (promotionsStore.checking) promotionsStore.setChecking(false)\n }, WS_RESPONSE_TIMEOUT_MS)\n } catch (e: unknown) {\n console.error('[promotions] check failed', e)\n promotionsStore.setChecking(false)\n }\n }\n\n return { dispatchCheck }\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useCartCredentials, usePromotionsChecker } from './chunk-
|
|
2
|
-
import { useCartStore, useOrderSettingsStore, usePromotionsStore } from './chunk-
|
|
3
|
-
import { getRemoteCatalog } from './chunk-
|
|
4
|
-
import { minorToMajor, majorToMinor } from './chunk-
|
|
1
|
+
import { useCartCredentials, usePromotionsChecker } from './chunk-46FNHMWC.js';
|
|
2
|
+
import { useCartStore, useOrderSettingsStore, usePromotionsStore } from './chunk-XULHV6SS.js';
|
|
3
|
+
import { getRemoteCatalog } from './chunk-FS2UNPTY.js';
|
|
4
|
+
import { minorToMajor, majorToMinor } from './chunk-2Y6QTHXI.js';
|
|
5
5
|
import { createRuntimeState } from './chunk-5QCUH3FF.js';
|
|
6
|
-
import { useCatalogStore } from './chunk-
|
|
7
|
-
import { useRuntime, useStoreProfileStore, useAuthStore } from './chunk-
|
|
6
|
+
import { useCatalogStore } from './chunk-NSOIL7PW.js';
|
|
7
|
+
import { useRuntime, useStoreProfileStore, useAuthStore } from './chunk-QZ3S3NN3.js';
|
|
8
8
|
import { PaymentMethod, OrderAuthenticationMethod, DeliveryMethod, OrderCartCheckerResultAction, RecaptchaAction } from '@zenky/storefront-api';
|
|
9
9
|
import { ref, computed, watch, watchEffect, getCurrentScope, onScopeDispose, toValue } from 'vue';
|
|
10
10
|
import { storeToRefs } from 'pinia';
|
|
@@ -441,7 +441,7 @@ var ORDER_INCLUDES = [
|
|
|
441
441
|
"variants.product.categories",
|
|
442
442
|
"variants.modifiers.modifier",
|
|
443
443
|
"variants.modifiers.modifiers_group",
|
|
444
|
-
//
|
|
444
|
+
// Line restrictions: is_blocking is used for cart messages and to block checkout.
|
|
445
445
|
"variants.restrictions"
|
|
446
446
|
].join(",");
|
|
447
447
|
var ORDER_WITH = { with: ORDER_INCLUDES };
|
|
@@ -1447,7 +1447,8 @@ function useCartOperations(credentials, initialization, sdk, deps) {
|
|
|
1447
1447
|
{
|
|
1448
1448
|
product_variant_id: variantId,
|
|
1449
1449
|
quantity: qty,
|
|
1450
|
-
modifiers: batch.modifiers
|
|
1450
|
+
modifiers: batch.modifiers,
|
|
1451
|
+
...batch.recommendationsBlock ? { recommendations_block: batch.recommendationsBlock } : {}
|
|
1451
1452
|
}
|
|
1452
1453
|
);
|
|
1453
1454
|
rum?.measure(RUM_METRIC_CART_ADD, RUM_MARK_CART_ADD);
|
|
@@ -1516,7 +1517,8 @@ function useCartOperations(credentials, initialization, sdk, deps) {
|
|
|
1516
1517
|
productVariantId: variantId,
|
|
1517
1518
|
quantity: qty,
|
|
1518
1519
|
unitPrice: orderVariant ? minorToMajor(orderVariant.unit_price, currency) : void 0,
|
|
1519
|
-
totalPrice: cartTotal != null ? minorToMajor(cartTotal, currency) : void 0
|
|
1520
|
+
totalPrice: cartTotal != null ? minorToMajor(cartTotal, currency) : void 0,
|
|
1521
|
+
recommendationsBlock: batch.recommendationsBlock
|
|
1520
1522
|
});
|
|
1521
1523
|
} else {
|
|
1522
1524
|
commerceEvents.trackRemovedFromCart(commerceOrderId, {
|
|
@@ -1590,6 +1592,7 @@ function useCartOperations(credentials, initialization, sdk, deps) {
|
|
|
1590
1592
|
if (existing) {
|
|
1591
1593
|
clearTimeout(existing.timer);
|
|
1592
1594
|
existing.delta += delta;
|
|
1595
|
+
existing.recommendationsBlock ??= request.recommendationsBlock;
|
|
1593
1596
|
existing.timer = setTimeout(() => flushBatch(lineKey), BATCH_DELAY);
|
|
1594
1597
|
return;
|
|
1595
1598
|
}
|
|
@@ -1605,6 +1608,7 @@ function useCartOperations(credentials, initialization, sdk, deps) {
|
|
|
1605
1608
|
promotionRewardId: request.promotionRewardId,
|
|
1606
1609
|
productName: request.productName,
|
|
1607
1610
|
variantLabel: request.variantLabel,
|
|
1611
|
+
recommendationsBlock: request.recommendationsBlock,
|
|
1608
1612
|
timer
|
|
1609
1613
|
});
|
|
1610
1614
|
}
|
|
@@ -2007,5 +2011,5 @@ function useVisibleCartVariants() {
|
|
|
2007
2011
|
}
|
|
2008
2012
|
|
|
2009
2013
|
export { CASH_DENOMINATIONS_MAJOR, DEFAULT_ROUND_STEPS_MAJOR, ORDER_EVENTS, ORDER_WITH, buildCartLineKey, buildCashChangePresets, buildMainPaymentRequest, getCartErrorCode, getCartErrorHttpCode, getCartErrorMessage, getCashDenominationsMinor, getDefaultRoundStepsMinor, getValidationErrors, logCartError, normalizeAddress, useBonusesReconciliation, useCartAddressSync, useCartCustomerAttachment, useCartDeliveryAttachment, useCartInitialization, useCartMutation, useCartOperations, useCartQuantities, useCartRecalculation, useCartStockWatcher, useCheckoutFlow, useCheckoutSubmit, useCustomerAttach, useOnlinePaymentRetry, useOrderBonuses, useOrderChannel, useOrderDelivery, useOrderPromocode, useOrderSettings, useOrderTotal, usePaymentSelection, useRestrictedAddToCart, useRestrictionGate, useStorefrontCart, useVisibleCartVariants, variantLineKey };
|
|
2010
|
-
//# sourceMappingURL=chunk-
|
|
2011
|
-
//# sourceMappingURL=chunk-
|
|
2014
|
+
//# sourceMappingURL=chunk-4UMDIBW5.js.map
|
|
2015
|
+
//# sourceMappingURL=chunk-4UMDIBW5.js.map
|