@tapcart/mobile-components 0.8.59 → 0.8.60

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.
@@ -1 +1 @@
1
- {"version":3,"file":"use-infinite-scroll.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-infinite-scroll.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAmB,MAAM,iBAAiB,CAAA;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE1C,UAAU,QAAQ;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,GAAG,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;CACxC;AAED,UAAU,sBAAsB;IAC9B,WAAW,EAAE,QAAQ,CAAA;IACrB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,SAAS,EAAE,UAAU,GAAG,YAAY,CAAA;IACpC,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAChD,YAAY,CAAC,EAAE,CACb,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,GAAG,GAAG,IAAI,EAC5B,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,GAAG,CAAA;CACT;AAED,UAAU,uBAAuB;IAC/B,IAAI,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAA;IAC5B,KAAK,EAAE,GAAG,CAAA;IACV,oBAAoB,EAAE,OAAO,CAAA;IAC7B,aAAa,EAAE,OAAO,GAAG,SAAS,CAAA;IAClC,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,OAAO,CAAA;IACtB,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAA;IAChD,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,OAAO,CAAA;CACtB;AAED,eAAO,MAAM,sCAAsC,iBACnC,uBAAuB,OAsBtC,CAAA;AAED,QAAA,MAAM,YAAY,WAAY,MAAM,WAGnC,CAAA;AAED,QAAA,MAAM,iBAAiB,oIASpB,sBAAsB,KAAG,uBA8H3B,CAAA;AAED,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,CAAA"}
1
+ {"version":3,"file":"use-infinite-scroll.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-infinite-scroll.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAmB,MAAM,iBAAiB,CAAA;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE1C,UAAU,QAAQ;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,GAAG,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;CACxC;AAED,UAAU,sBAAsB;IAC9B,WAAW,EAAE,QAAQ,CAAA;IACrB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,SAAS,EAAE,UAAU,GAAG,YAAY,CAAA;IACpC,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAChD,YAAY,CAAC,EAAE,CACb,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,GAAG,GAAG,IAAI,EAC5B,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,GAAG,CAAA;CACT;AAED,UAAU,uBAAuB;IAC/B,IAAI,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAA;IAC5B,KAAK,EAAE,GAAG,CAAA;IACV,oBAAoB,EAAE,OAAO,CAAA;IAC7B,aAAa,EAAE,OAAO,GAAG,SAAS,CAAA;IAClC,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,OAAO,CAAA;IACtB,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAA;IAChD,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,OAAO,CAAA;CACtB;AAED,eAAO,MAAM,sCAAsC,iBACnC,uBAAuB,OAsBtC,CAAA;AAED,QAAA,MAAM,YAAY,WAAY,MAAM,WAGnC,CAAA;AAED,QAAA,MAAM,iBAAiB,oIASpB,sBAAsB,KAAG,uBA0H3B,CAAA;AAED,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,CAAA"}
@@ -43,7 +43,7 @@ const constructURL = (apiURL) => {
43
43
  };
44
44
  const useInfiniteScroll = ({ initialData, queryVariables: queryVariableProps, direction = "vertical", productLimit = Infinity, threshold = 0.01, interval = 33, // ~2 frames
45
45
  customFetcher, customGetKey, }) => {
46
- var _a, _b, _c, _d, _e, _f;
46
+ var _a, _b, _c, _d, _e;
47
47
  const searchParams = useSearchParams();
48
48
  const productCount = useRef(0);
49
49
  const { ref, inView } = useInView({
@@ -52,7 +52,7 @@ customFetcher, customGetKey, }) => {
52
52
  });
53
53
  const queryVariables = useMemo(() => {
54
54
  const formattedParams = formatSearchParamsAsNextQueryVariables(searchParams);
55
- return Object.assign(Object.assign({}, queryVariableProps), { searchParams: formattedParams, productCount: productCount });
55
+ return Object.assign(Object.assign({}, queryVariableProps), { searchParams: formattedParams });
56
56
  }, [queryVariableProps, searchParams]);
57
57
  let getKey = (pageIndex, previousPageData, queryVariables) => {
58
58
  var _a;
@@ -67,11 +67,13 @@ customFetcher, customGetKey, }) => {
67
67
  getKey = customGetKey;
68
68
  }
69
69
  let fetcher = (body) => __awaiter(void 0, void 0, void 0, function* () {
70
+ var _f, _g;
70
71
  const res = yield fetch(constructURL(initialData.apiURL), {
71
72
  method: "POST",
72
73
  body: JSON.stringify(body),
73
74
  });
74
75
  const data = yield res.json();
76
+ productCount.current += (_g = (_f = data === null || data === void 0 ? void 0 : data.products) === null || _f === void 0 ? void 0 : _f.length) !== null && _g !== void 0 ? _g : 0;
75
77
  return data;
76
78
  });
77
79
  if (customFetcher) {
@@ -81,16 +83,12 @@ customFetcher, customGetKey, }) => {
81
83
  revalidateFirstPage: false,
82
84
  initialSize: 1,
83
85
  });
84
- productCount.current += (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data[size - 1]) === null || _a === void 0 ? void 0 : _a.products) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
85
- const hasMore = () => {
86
- var _a, _b;
87
- return (_b = (_a = data === null || data === void 0 ? void 0 : data[size - 1]) === null || _a === void 0 ? void 0 : _a.pageData) === null || _b === void 0 ? void 0 : _b.cursorBlob;
88
- };
89
86
  const isLoadingInitialData = !data && !error;
90
87
  const isLoadingMore = isLoadingInitialData ||
91
88
  (size > 0 && data && typeof data[size - 1] === "undefined");
92
- const isEmpty = ((_f = (_e = (_d = data === null || data === void 0 ? void 0 : data[0]) === null || _d === void 0 ? void 0 : _d.products) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0) === 0;
93
- const isEndPointer = data ? !hasMore() : true;
89
+ const isEmpty = ((_c = (_b = (_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.products) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) === 0;
90
+ const hasMore = (_e = (_d = data === null || data === void 0 ? void 0 : data[data.length - 1]) === null || _d === void 0 ? void 0 : _d.pageData) === null || _e === void 0 ? void 0 : _e.cursorBlob;
91
+ const isEndPointer = data ? !hasMore : true;
94
92
  const isReachingEnd = isEmpty || isEndPointer;
95
93
  const isRefreshing = isValidating && data && data.length === size;
96
94
  const loadMore = useCallback(() => {
@@ -1,4 +1,3 @@
1
- import { Money, Product, DiscountApplicationTargetType } from "app-studio-types";
2
1
  type UseMockCartParams = {
3
2
  apiUrl: string;
4
3
  appId: string;
@@ -16,118 +15,550 @@ export declare const useMockCart: ({ apiUrl, appId, enabled, limit, }: UseMockCa
16
15
  isLoading: boolean;
17
16
  cart: {
18
17
  calculatedData: import("../../lib/cart.util").CalculatedData;
19
- subtotal: number;
20
18
  items: {
21
- id: string;
22
- title: any;
23
- featuredImage: string;
24
- image: string;
19
+ attributes: {};
20
+ compareAtPrice: number | null;
21
+ cost: {
22
+ totalAmount: {
23
+ amount: number;
24
+ currencyCode: string;
25
+ };
26
+ };
27
+ currencyCode: string;
25
28
  discounts: {
26
- amount: number;
29
+ title: string;
27
30
  code: string;
28
- type: string;
31
+ amount: number;
29
32
  }[];
33
+ featuredImage: string;
34
+ id: string;
35
+ image: string;
36
+ merchandise: {
37
+ id: string;
38
+ title: string;
39
+ availableForSale: boolean;
40
+ compareAtPrice: number | null;
41
+ image: {
42
+ id: any;
43
+ url: string;
44
+ altText: string;
45
+ height: number;
46
+ width: number;
47
+ originalSrc: string;
48
+ src: string;
49
+ transformedSrc: string;
50
+ };
51
+ isAvailable: boolean;
52
+ price: number;
53
+ priceCurrencyCode: string;
54
+ product: {
55
+ id: string;
56
+ handle: any;
57
+ productType: string;
58
+ availableForSale: any;
59
+ title: any;
60
+ description: any;
61
+ descriptionHtml: any;
62
+ vendor: string;
63
+ requiresSellingPlan: boolean;
64
+ options: any;
65
+ compareAtPriceRange: {
66
+ maxVariantPrice: {
67
+ amount: string;
68
+ currencyCode: string;
69
+ };
70
+ minVariantPrice: {
71
+ amount: string;
72
+ currencyCode: string;
73
+ };
74
+ };
75
+ priceRange: {
76
+ maxVariantPrice: {
77
+ amount: string;
78
+ currencyCode: string;
79
+ };
80
+ minVariantPrice: {
81
+ amount: string;
82
+ currencyCode: string;
83
+ };
84
+ };
85
+ featuredImage: {
86
+ url: string;
87
+ altText: string;
88
+ width: number;
89
+ height: number;
90
+ };
91
+ flashSaleData: {};
92
+ seo: {
93
+ description: any;
94
+ title: any;
95
+ };
96
+ tags: any;
97
+ updatedAt: string;
98
+ sellingPlanGroups: {
99
+ edges: never[];
100
+ };
101
+ metafields: never[];
102
+ collections: never[];
103
+ images: {
104
+ url: string;
105
+ altText: string;
106
+ width: number;
107
+ height: number;
108
+ }[];
109
+ variants: {
110
+ id: string;
111
+ title: string;
112
+ availableForSale: boolean;
113
+ sku: any;
114
+ compareAtPrice: null;
115
+ selectedOptions: {
116
+ name: string;
117
+ value: string;
118
+ optionValue: import("app-studio-types").ProductOptionValue;
119
+ }[];
120
+ price: {
121
+ amount: string;
122
+ currencyCode: string;
123
+ };
124
+ image: {
125
+ altText: string;
126
+ height: number;
127
+ id: any;
128
+ originalSrc: string;
129
+ src: string;
130
+ transformedSrc: string;
131
+ url: string;
132
+ width: number;
133
+ };
134
+ }[];
135
+ media: {
136
+ mediaContentType: string;
137
+ image: {
138
+ url: string;
139
+ altText: string;
140
+ };
141
+ }[];
142
+ };
143
+ quantityAvailable: number;
144
+ quantityRule: {
145
+ increment: number;
146
+ minimum: number;
147
+ };
148
+ selectedOptions: {
149
+ name: string;
150
+ value: string;
151
+ optionValue: import("app-studio-types").ProductOptionValue;
152
+ }[];
153
+ };
154
+ price: number;
30
155
  productId: string;
156
+ productVendor: string;
31
157
  quantity: number;
158
+ quantityAvailable: number;
159
+ selectedOptions: {
160
+ name: string;
161
+ value: string;
162
+ optionValue: import("app-studio-types").ProductOptionValue;
163
+ }[];
164
+ title: any;
165
+ totalAmount: number;
32
166
  variantId: string;
33
- productDetails: Product;
34
- variantDetails: {
35
- compareAtPrice: {
36
- amount: string;
37
- currencyCode: string;
167
+ isGWPItem: boolean;
168
+ productDetails: {
169
+ id: string;
170
+ handle: any;
171
+ availableForSale: any;
172
+ title: any;
173
+ description: any;
174
+ descriptionHtml: any;
175
+ vendor: string;
176
+ requiresSellingPlan: boolean;
177
+ options: any;
178
+ compareAtPriceRange: {
179
+ maxVariantPrice: {
180
+ amount: string;
181
+ currencyCode: string;
182
+ };
183
+ minVariantPrice: {
184
+ amount: string;
185
+ currencyCode: string;
186
+ };
187
+ };
188
+ priceRange: {
189
+ maxVariantPrice: {
190
+ amount: string;
191
+ currencyCode: string;
192
+ };
193
+ minVariantPrice: {
194
+ amount: string;
195
+ currencyCode: string;
196
+ };
197
+ };
198
+ featuredImage: {
199
+ url: string;
200
+ altText: string;
201
+ width: number;
202
+ height: number;
38
203
  };
204
+ seo: {
205
+ description: any;
206
+ title: any;
207
+ };
208
+ tags: any;
209
+ updatedAt: string;
210
+ sellingPlanGroups: {
211
+ edges: never[];
212
+ };
213
+ metafields: never[];
214
+ images: {
215
+ url: string;
216
+ altText: string;
217
+ width: number;
218
+ height: number;
219
+ }[];
220
+ variants: {
221
+ id: string;
222
+ title: string;
223
+ availableForSale: boolean;
224
+ sku: any;
225
+ compareAtPrice: null;
226
+ selectedOptions: {
227
+ name: string;
228
+ value: string;
229
+ optionValue: import("app-studio-types").ProductOptionValue;
230
+ }[];
231
+ price: {
232
+ amount: string;
233
+ currencyCode: string;
234
+ };
235
+ image: {
236
+ altText: string;
237
+ height: number;
238
+ id: any;
239
+ originalSrc: string;
240
+ src: string;
241
+ transformedSrc: string;
242
+ url: string;
243
+ width: number;
244
+ };
245
+ }[];
246
+ media: {
247
+ mediaContentType: string;
248
+ image: {
249
+ url: string;
250
+ altText: string;
251
+ };
252
+ }[];
253
+ };
254
+ variantDetails: {
39
255
  id: string;
40
256
  title: string;
41
257
  availableForSale: boolean;
258
+ sku: any;
259
+ compareAtPrice: null;
42
260
  selectedOptions: {
43
261
  name: string;
44
262
  value: string;
45
263
  optionValue: import("app-studio-types").ProductOptionValue;
46
264
  }[];
47
- price: Money;
48
- available: boolean;
49
- image?: import("app-studio-types").Image | undefined;
50
- createdAt: string;
51
- displayName: string;
52
- inventoryPolicy: "continue" | "deny";
53
- quantityAvailable: number;
54
- legacyResourceId: string;
55
- metafield?: import("app-studio-types").Metafield | undefined;
56
- position: number;
57
- product: Product;
265
+ price: {
266
+ amount: string;
267
+ currencyCode: string;
268
+ };
269
+ image: {
270
+ altText: string;
271
+ height: number;
272
+ id: any;
273
+ originalSrc: string;
274
+ src: string;
275
+ transformedSrc: string;
276
+ url: string;
277
+ width: number;
278
+ };
58
279
  };
280
+ stringifiedDiscounts: string;
281
+ }[];
282
+ lines: {
283
+ attributes: {};
284
+ compareAtPrice: number | null;
59
285
  cost: {
60
286
  totalAmount: {
61
- amount: string;
287
+ amount: number;
62
288
  currencyCode: string;
63
289
  };
64
290
  };
65
- sellingPlanAllocation: {
66
- priceAdjustments: {
67
- perDeliveryPrice: {
291
+ currencyCode: string;
292
+ discounts: {
293
+ title: string;
294
+ code: string;
295
+ amount: number;
296
+ }[];
297
+ featuredImage: string;
298
+ id: string;
299
+ image: string;
300
+ merchandise: {
301
+ id: string;
302
+ title: string;
303
+ availableForSale: boolean;
304
+ compareAtPrice: number | null;
305
+ image: {
306
+ id: any;
307
+ url: string;
308
+ altText: string;
309
+ height: number;
310
+ width: number;
311
+ originalSrc: string;
312
+ src: string;
313
+ transformedSrc: string;
314
+ };
315
+ isAvailable: boolean;
316
+ price: number;
317
+ priceCurrencyCode: string;
318
+ product: {
319
+ id: string;
320
+ handle: any;
321
+ productType: string;
322
+ availableForSale: any;
323
+ title: any;
324
+ description: any;
325
+ descriptionHtml: any;
326
+ vendor: string;
327
+ requiresSellingPlan: boolean;
328
+ options: any;
329
+ compareAtPriceRange: {
330
+ maxVariantPrice: {
331
+ amount: string;
332
+ currencyCode: string;
333
+ };
334
+ minVariantPrice: {
335
+ amount: string;
336
+ currencyCode: string;
337
+ };
338
+ };
339
+ priceRange: {
340
+ maxVariantPrice: {
341
+ amount: string;
342
+ currencyCode: string;
343
+ };
344
+ minVariantPrice: {
345
+ amount: string;
346
+ currencyCode: string;
347
+ };
348
+ };
349
+ featuredImage: {
350
+ url: string;
351
+ altText: string;
352
+ width: number;
353
+ height: number;
354
+ };
355
+ flashSaleData: {};
356
+ seo: {
357
+ description: any;
358
+ title: any;
359
+ };
360
+ tags: any;
361
+ updatedAt: string;
362
+ sellingPlanGroups: {
363
+ edges: never[];
364
+ };
365
+ metafields: never[];
366
+ collections: never[];
367
+ images: {
368
+ url: string;
369
+ altText: string;
370
+ width: number;
371
+ height: number;
372
+ }[];
373
+ variants: {
374
+ id: string;
375
+ title: string;
376
+ availableForSale: boolean;
377
+ sku: any;
378
+ compareAtPrice: null;
379
+ selectedOptions: {
380
+ name: string;
381
+ value: string;
382
+ optionValue: import("app-studio-types").ProductOptionValue;
383
+ }[];
384
+ price: {
385
+ amount: string;
386
+ currencyCode: string;
387
+ };
388
+ image: {
389
+ altText: string;
390
+ height: number;
391
+ id: any;
392
+ originalSrc: string;
393
+ src: string;
394
+ transformedSrc: string;
395
+ url: string;
396
+ width: number;
397
+ };
398
+ }[];
399
+ media: {
400
+ mediaContentType: string;
401
+ image: {
402
+ url: string;
403
+ altText: string;
404
+ };
405
+ }[];
406
+ };
407
+ quantityAvailable: number;
408
+ quantityRule: {
409
+ increment: number;
410
+ minimum: number;
411
+ };
412
+ selectedOptions: {
413
+ name: string;
414
+ value: string;
415
+ optionValue: import("app-studio-types").ProductOptionValue;
416
+ }[];
417
+ };
418
+ price: number;
419
+ productId: string;
420
+ productVendor: string;
421
+ quantity: number;
422
+ quantityAvailable: number;
423
+ selectedOptions: {
424
+ name: string;
425
+ value: string;
426
+ optionValue: import("app-studio-types").ProductOptionValue;
427
+ }[];
428
+ title: any;
429
+ totalAmount: number;
430
+ variantId: string;
431
+ isGWPItem: boolean;
432
+ productDetails: {
433
+ id: string;
434
+ handle: any;
435
+ availableForSale: any;
436
+ title: any;
437
+ description: any;
438
+ descriptionHtml: any;
439
+ vendor: string;
440
+ requiresSellingPlan: boolean;
441
+ options: any;
442
+ compareAtPriceRange: {
443
+ maxVariantPrice: {
68
444
  amount: string;
69
445
  currencyCode: string;
70
446
  };
71
- price: {
447
+ minVariantPrice: {
72
448
  amount: string;
73
449
  currencyCode: string;
74
450
  };
75
- compareAtPrice: {
451
+ };
452
+ priceRange: {
453
+ maxVariantPrice: {
76
454
  amount: string;
77
455
  currencyCode: string;
78
456
  };
457
+ minVariantPrice: {
458
+ amount: string;
459
+ currencyCode: string;
460
+ };
461
+ };
462
+ featuredImage: {
463
+ url: string;
464
+ altText: string;
465
+ width: number;
466
+ height: number;
467
+ };
468
+ seo: {
469
+ description: any;
470
+ title: any;
471
+ };
472
+ tags: any;
473
+ updatedAt: string;
474
+ sellingPlanGroups: {
475
+ edges: never[];
476
+ };
477
+ metafields: never[];
478
+ images: {
479
+ url: string;
480
+ altText: string;
481
+ width: number;
482
+ height: number;
79
483
  }[];
80
- sellingPlan: {
484
+ variants: {
81
485
  id: string;
486
+ title: string;
487
+ availableForSale: boolean;
488
+ sku: any;
489
+ compareAtPrice: null;
490
+ selectedOptions: {
491
+ name: string;
492
+ value: string;
493
+ optionValue: import("app-studio-types").ProductOptionValue;
494
+ }[];
495
+ price: {
496
+ amount: string;
497
+ currencyCode: string;
498
+ };
499
+ image: {
500
+ altText: string;
501
+ height: number;
502
+ id: any;
503
+ originalSrc: string;
504
+ src: string;
505
+ transformedSrc: string;
506
+ url: string;
507
+ width: number;
508
+ };
509
+ }[];
510
+ media: {
511
+ mediaContentType: string;
512
+ image: {
513
+ url: string;
514
+ altText: string;
515
+ };
516
+ }[];
517
+ };
518
+ variantDetails: {
519
+ id: string;
520
+ title: string;
521
+ availableForSale: boolean;
522
+ sku: any;
523
+ compareAtPrice: null;
524
+ selectedOptions: {
82
525
  name: string;
83
- recurringDeliveries: boolean;
526
+ value: string;
527
+ optionValue: import("app-studio-types").ProductOptionValue;
528
+ }[];
529
+ price: {
530
+ amount: string;
531
+ currencyCode: string;
532
+ };
533
+ image: {
534
+ altText: string;
535
+ height: number;
536
+ id: any;
537
+ originalSrc: string;
538
+ src: string;
539
+ transformedSrc: string;
540
+ url: string;
541
+ width: number;
84
542
  };
85
- } | undefined;
543
+ };
544
+ stringifiedDiscounts: string;
86
545
  }[];
546
+ subtotal: number;
547
+ totalQuantity: number;
87
548
  discountAllocations: {
88
- targetType: DiscountApplicationTargetType;
549
+ code: string;
89
550
  discountedAmount: {
90
551
  amount: string;
91
552
  currencyCode: string;
92
553
  };
554
+ }[];
555
+ discountCodes: {
93
556
  code: string;
557
+ applicable: boolean;
94
558
  }[];
95
- delivery: {
96
- addresses: {
97
- selected: boolean;
98
- oneTimeUse: boolean;
99
- id: string;
100
- address: {
101
- address1: string;
102
- city: string;
103
- countryCode: string;
104
- };
105
- }[];
106
- };
107
- deliveryGroups: {
108
- id: string;
109
- deliveryOptions: {
110
- code: string;
111
- handle: string;
112
- title: string;
113
- deliveryMethodType: string;
114
- description: string;
115
- estimatedCost: {
116
- amount: string;
117
- currencyCode: string;
118
- };
119
- }[];
120
- selectedDeliveryOption: {
121
- code: string;
122
- handle: string;
123
- title: string;
124
- deliveryMethodType: string;
125
- description: string;
126
- estimatedCost: {
127
- amount: string;
128
- currencyCode: string;
129
- };
130
- };
559
+ discounts: {
560
+ code: string;
561
+ applicable: boolean;
131
562
  }[];
132
563
  cost: {
133
564
  subtotalAmount: {
@@ -138,36 +569,26 @@ export declare const useMockCart: ({ apiUrl, appId, enabled, limit, }: UseMockCa
138
569
  amount: string;
139
570
  currencyCode: string;
140
571
  };
141
- totalTaxAmount: {
142
- amount: string;
143
- currencyCode: string;
144
- };
572
+ totalTaxAmount: null;
573
+ totalDutyAmount: null;
145
574
  };
146
- attributes: {
147
- key: string;
148
- value: string;
149
- }[];
150
- currency: string;
151
- discounts: string[];
575
+ appliedGiftCards: never[];
576
+ attributes: never[];
577
+ buyerIdentity: {
578
+ countryCode: string;
579
+ email: null;
580
+ phone: null;
581
+ deliveryAddressPreferences: never[];
582
+ };
583
+ checkoutUrl: string;
584
+ delivery: {
585
+ addresses: never[];
586
+ };
587
+ deliveryGroups: never[];
152
588
  id: string;
153
589
  note: string;
154
- appliedGiftCards: {
155
- id: string;
156
- lastCharacters: string;
157
- amountUsed: {
158
- amount: string;
159
- currencyCode: string;
160
- };
161
- balance: {
162
- amount: string;
163
- currencyCode: string;
164
- };
165
- presentmentAmountUsed: {
166
- amount: string;
167
- currencyCode: string;
168
- };
169
- }[];
170
- checkoutUrl: string;
590
+ notes: string;
591
+ currency: string;
171
592
  };
172
593
  };
173
594
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"use-mock-cart.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-mock-cart.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAA;AAyLhF,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,WAAW,uCAKrB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CnB,CAAA"}
1
+ {"version":3,"file":"use-mock-cart.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-mock-cart.ts"],"names":[],"mappings":"AAyYA,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,WAAW,uCAKrB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CnB,CAAA"}
@@ -4,160 +4,360 @@ import { useState, useEffect } from "react";
4
4
  import { getCalculatedCartData } from "../../lib/cart.util";
5
5
  import { getIdFromGid } from "../../lib/utils";
6
6
  import { useProducts } from "./use-products";
7
- import { DiscountApplicationTargetType } from "app-studio-types";
8
7
  const cartMock = {
9
- attributes: [{ key: "tapcart_id", value: "123" }],
10
- currency: "USD",
11
- discounts: ["10_OFF_ORDER", "10_OFF_PRODUCT"],
12
- id: "456?key=789",
8
+ appliedGiftCards: [],
9
+ attributes: [],
10
+ buyerIdentity: {
11
+ countryCode: "US",
12
+ email: null,
13
+ phone: null,
14
+ deliveryAddressPreferences: [],
15
+ },
16
+ checkoutUrl: "",
17
+ delivery: {
18
+ addresses: [],
19
+ },
20
+ deliveryGroups: [],
21
+ discountAllocations: [],
22
+ discountCodes: [],
23
+ discounts: [],
24
+ id: "gid://shopify/Cart/mock-cart-id?key=mock-key",
13
25
  items: [],
14
- note: "this is a mock cart",
26
+ lines: [],
27
+ note: "",
28
+ notes: "",
15
29
  subtotal: 0,
16
- discountAllocations: [
17
- {
18
- targetType: DiscountApplicationTargetType.ShippingLine,
19
- discountedAmount: { amount: "10.00", currencyCode: "USD" },
20
- code: "FREE_SHIPPING",
30
+ totalQuantity: 0,
31
+ currency: "USD",
32
+ cost: {
33
+ subtotalAmount: {
34
+ amount: "0",
35
+ currencyCode: "USD",
21
36
  },
22
- ],
23
- appliedGiftCards: [
24
- {
25
- id: "gid://shopify/GiftCard/1",
26
- lastCharacters: "1234",
27
- amountUsed: { amount: "10.00", currencyCode: "USD" },
28
- balance: { amount: "40.00", currencyCode: "USD" },
29
- presentmentAmountUsed: { amount: "10.00", currencyCode: "USD" },
37
+ totalAmount: {
38
+ amount: "0",
39
+ currencyCode: "USD",
30
40
  },
31
- ],
32
- checkoutUrl: "",
41
+ totalTaxAmount: null,
42
+ totalDutyAmount: null,
43
+ },
33
44
  };
34
45
  const transformCart = ({ products, cartOrigin = cartMock, }) => {
35
- let subtotal = cartOrigin.subtotal;
46
+ let subtotal = 0;
47
+ let totalQuantity = 0;
36
48
  const items = products.map((product, i) => {
37
- var _a, _b;
38
- const variant = Object.assign(Object.assign({}, product.variants[0]), { compareAtPrice: {
39
- amount: (parseInt(product.variants[0].price.amount) * 1.2).toString(),
40
- currencyCode: "USD",
41
- } });
42
- const price = parseInt(variant.price.amount);
43
- const productId = getIdFromGid(product.id);
44
- const variantId = getIdFromGid(variant.id);
45
- const discounts = i === 0
46
- ? [
47
- {
48
- amount: price / 10,
49
- code: "10_OFF_PRODUCT",
50
- type: "code",
51
- },
52
- ]
53
- : [];
54
- const cost = {
55
- totalAmount: {
56
- amount: price.toString(),
57
- currencyCode: "USD",
49
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
50
+ const variant = product.variants[0];
51
+ const price = parseFloat(variant.price.amount);
52
+ const compareAtPrice = variant.compareAtPrice
53
+ ? parseFloat(variant.compareAtPrice.amount)
54
+ : null;
55
+ const quantity = 1;
56
+ const productDiscount = i === 0 ? price * 0.13 : 0; // 13% discount on first item
57
+ const totalAmount = price * quantity - productDiscount;
58
+ subtotal += price * quantity;
59
+ totalQuantity += quantity;
60
+ const merchandise = {
61
+ id: getIdFromGid(variant.id),
62
+ title: variant.title || "Default Title",
63
+ availableForSale: variant.availableForSale,
64
+ compareAtPrice,
65
+ image: {
66
+ id: ((_a = variant.image) === null || _a === void 0 ? void 0 : _a.id) || "",
67
+ url: ((_b = variant.image) === null || _b === void 0 ? void 0 : _b.url) || ((_c = product.images[0]) === null || _c === void 0 ? void 0 : _c.url) || "",
68
+ altText: ((_d = variant.image) === null || _d === void 0 ? void 0 : _d.altText) || ((_e = product.images[0]) === null || _e === void 0 ? void 0 : _e.altText) || "",
69
+ height: 1600,
70
+ width: 1600,
71
+ originalSrc: ((_f = variant.image) === null || _f === void 0 ? void 0 : _f.url) || ((_g = product.images[0]) === null || _g === void 0 ? void 0 : _g.url) || "",
72
+ src: ((_h = variant.image) === null || _h === void 0 ? void 0 : _h.url) || ((_j = product.images[0]) === null || _j === void 0 ? void 0 : _j.url) || "",
73
+ transformedSrc: ((_k = variant.image) === null || _k === void 0 ? void 0 : _k.url) || ((_l = product.images[0]) === null || _l === void 0 ? void 0 : _l.url) || "",
58
74
  },
59
- };
60
- subtotal += price;
61
- if (discounts.length) {
62
- subtotal -= discounts[0].amount;
63
- }
64
- const sellingPlanAllocation = i === 0
65
- ? {
66
- priceAdjustments: [
67
- {
68
- perDeliveryPrice: {
69
- amount: price.toString(),
70
- currencyCode: "USD",
71
- },
75
+ isAvailable: variant.availableForSale,
76
+ price,
77
+ priceCurrencyCode: "USD",
78
+ product: {
79
+ id: `gid://shopify/Product/${getIdFromGid(product.id)}`,
80
+ handle: product.handle || "",
81
+ productType: product.productType || "",
82
+ availableForSale: product.availableForSale,
83
+ title: product.title,
84
+ description: product.description || "This is a mock product description",
85
+ descriptionHtml: product.descriptionHtml ||
86
+ "<p>This is a mock product description</p>",
87
+ vendor: product.vendor || "Mock Vendor",
88
+ requiresSellingPlan: false,
89
+ options: ((_m = product.options) === null || _m === void 0 ? void 0 : _m.map((opt) => ({
90
+ id: `gid://shopify/ProductOption/${Math.random()
91
+ .toString(36)
92
+ .substr(2, 9)}`,
93
+ name: opt.name,
94
+ values: opt.values,
95
+ }))) || [],
96
+ compareAtPriceRange: {
97
+ maxVariantPrice: { amount: "0.0", currencyCode: "USD" },
98
+ minVariantPrice: { amount: "0.0", currencyCode: "USD" },
99
+ },
100
+ priceRange: {
101
+ maxVariantPrice: { amount: price.toString(), currencyCode: "USD" },
102
+ minVariantPrice: { amount: price.toString(), currencyCode: "USD" },
103
+ },
104
+ featuredImage: {
105
+ url: ((_o = product.images[0]) === null || _o === void 0 ? void 0 : _o.url) || "",
106
+ altText: ((_p = product.images[0]) === null || _p === void 0 ? void 0 : _p.altText) || "",
107
+ width: 1600,
108
+ height: 1600,
109
+ },
110
+ flashSaleData: {},
111
+ seo: {
112
+ description: ((_q = product.seo) === null || _q === void 0 ? void 0 : _q.description) ||
113
+ `${product.title.toLowerCase()} product description`,
114
+ title: ((_r = product.seo) === null || _r === void 0 ? void 0 : _r.title) || product.title,
115
+ },
116
+ tags: product.tags || [],
117
+ updatedAt: new Date().toISOString(),
118
+ sellingPlanGroups: { edges: [] },
119
+ metafields: [],
120
+ collections: [],
121
+ images: (product.images || []).map((img) => ({
122
+ url: img.url,
123
+ altText: img.altText || "",
124
+ width: 1600,
125
+ height: 1600,
126
+ })),
127
+ variants: product.variants.map((v) => {
128
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
129
+ return ({
130
+ id: `gid://shopify/ProductVariant/${getIdFromGid(v.id)}`,
131
+ title: v.title,
132
+ availableForSale: v.availableForSale,
133
+ sku: v.sku || null,
134
+ compareAtPrice: null,
135
+ selectedOptions: v.selectedOptions,
72
136
  price: {
73
- amount: price.toString(),
137
+ amount: v.price.amount,
74
138
  currencyCode: "USD",
75
139
  },
76
- compareAtPrice: {
77
- amount: (price * 1.2).toString(),
78
- currencyCode: "USD",
140
+ image: {
141
+ altText: ((_a = v.image) === null || _a === void 0 ? void 0 : _a.altText) || ((_b = product.images[0]) === null || _b === void 0 ? void 0 : _b.altText) || "",
142
+ height: 1600,
143
+ id: ((_c = v.image) === null || _c === void 0 ? void 0 : _c.id) ||
144
+ `gid://shopify/ProductImage/${Math.random()
145
+ .toString(36)
146
+ .substr(2, 9)}`,
147
+ originalSrc: ((_d = v.image) === null || _d === void 0 ? void 0 : _d.url) || ((_e = product.images[0]) === null || _e === void 0 ? void 0 : _e.url) || "",
148
+ src: ((_f = v.image) === null || _f === void 0 ? void 0 : _f.url) || ((_g = product.images[0]) === null || _g === void 0 ? void 0 : _g.url) || "",
149
+ transformedSrc: ((_h = v.image) === null || _h === void 0 ? void 0 : _h.url) || ((_j = product.images[0]) === null || _j === void 0 ? void 0 : _j.url) || "",
150
+ url: ((_k = v.image) === null || _k === void 0 ? void 0 : _k.url) || ((_l = product.images[0]) === null || _l === void 0 ? void 0 : _l.url) || "",
151
+ width: 1600,
79
152
  },
153
+ });
154
+ }),
155
+ media: (product.images || []).map((img) => ({
156
+ mediaContentType: "IMAGE",
157
+ image: {
158
+ url: img.url,
159
+ altText: img.altText || "",
80
160
  },
81
- ],
82
- sellingPlan: {
83
- id: "gid://shopify/SellingPlan/123",
84
- name: "Delivery every 30 Days",
85
- recurringDeliveries: true,
161
+ })),
162
+ },
163
+ quantityAvailable: variant.quantityAvailable || 7,
164
+ quantityRule: {
165
+ increment: 1,
166
+ minimum: 1,
167
+ },
168
+ selectedOptions: variant.selectedOptions || [
169
+ {
170
+ name: "Title",
171
+ value: "Default Title",
86
172
  },
87
- }
88
- : undefined;
89
- return {
90
- id: `item-${i}`,
91
- title: product.title,
92
- featuredImage: (_a = product.images[0]) === null || _a === void 0 ? void 0 : _a.url,
93
- image: (_b = product.images[0]) === null || _b === void 0 ? void 0 : _b.url,
94
- discounts,
95
- productId,
96
- quantity: 1,
97
- variantId,
98
- productDetails: product,
99
- variantDetails: variant,
100
- cost,
101
- sellingPlanAllocation,
173
+ ],
102
174
  };
103
- });
104
- const orderLevelDiscount = {
105
- targetType: DiscountApplicationTargetType.LineItem,
106
- discountedAmount: {
107
- amount: (subtotal / 10).toString(),
108
- currencyCode: "USD",
109
- },
110
- code: "10_OFF_ORDER",
111
- };
112
- const delivery = {
113
- addresses: [
114
- {
115
- selected: true,
116
- oneTimeUse: false,
117
- id: "mock-delivery-address-id",
118
- address: {
119
- address1: "123 Mock St",
120
- city: "Mock City",
121
- countryCode: "US",
175
+ const lineItem = {
176
+ attributes: {},
177
+ compareAtPrice,
178
+ cost: {
179
+ totalAmount: {
180
+ amount: totalAmount,
181
+ currencyCode: "USD",
122
182
  },
123
183
  },
124
- ],
125
- };
126
- const deliveryGroups = [
127
- {
128
- id: "mock-delivery-group-id",
129
- deliveryOptions: [
184
+ currencyCode: "USD",
185
+ discounts: productDiscount > 0
186
+ ? [
187
+ {
188
+ title: "10product",
189
+ code: "10product",
190
+ amount: productDiscount,
191
+ },
192
+ ]
193
+ : [],
194
+ featuredImage: (_s = product.images[0]) === null || _s === void 0 ? void 0 : _s.url,
195
+ id: `gid://shopify/CartLine/${i}?cart=${cartOrigin.id}`,
196
+ image: (_t = product.images[0]) === null || _t === void 0 ? void 0 : _t.url,
197
+ merchandise,
198
+ price,
199
+ productId: getIdFromGid(product.id),
200
+ productVendor: product.vendor || "Mock Vendor",
201
+ quantity,
202
+ quantityAvailable: variant.quantityAvailable || 7,
203
+ selectedOptions: variant.selectedOptions || [
130
204
  {
131
- code: "mock-code",
132
- handle: "mock-handle",
133
- title: "Mock Delivery Option",
134
- deliveryMethodType: "standard",
135
- description: "Mock delivery description",
136
- estimatedCost: { amount: "5.00", currencyCode: "USD" },
205
+ name: "Title",
206
+ value: "Default Title",
137
207
  },
138
208
  ],
139
- selectedDeliveryOption: {
140
- code: "mock-code",
141
- handle: "mock-handle",
142
- title: "Mock Delivery Option",
143
- deliveryMethodType: "standard",
144
- description: "Mock delivery description",
145
- estimatedCost: { amount: "5.00", currencyCode: "USD" },
209
+ title: product.title,
210
+ totalAmount,
211
+ variantId: getIdFromGid(variant.id),
212
+ isGWPItem: false,
213
+ productDetails: {
214
+ id: `gid://shopify/Product/${getIdFromGid(product.id)}`,
215
+ handle: product.handle || "",
216
+ availableForSale: product.availableForSale,
217
+ title: product.title,
218
+ description: product.description || "This is a mock product description",
219
+ descriptionHtml: product.descriptionHtml ||
220
+ "<p>This is a mock product description</p>",
221
+ vendor: product.vendor || "Mock Vendor",
222
+ requiresSellingPlan: false,
223
+ options: ((_u = product.options) === null || _u === void 0 ? void 0 : _u.map((opt) => ({
224
+ id: `gid://shopify/ProductOption/${Math.random()
225
+ .toString(36)
226
+ .substr(2, 9)}`,
227
+ name: opt.name,
228
+ values: opt.values,
229
+ }))) || [],
230
+ compareAtPriceRange: {
231
+ maxVariantPrice: { amount: "0.0", currencyCode: "USD" },
232
+ minVariantPrice: { amount: "0.0", currencyCode: "USD" },
233
+ },
234
+ priceRange: {
235
+ maxVariantPrice: { amount: price.toString(), currencyCode: "USD" },
236
+ minVariantPrice: { amount: price.toString(), currencyCode: "USD" },
237
+ },
238
+ featuredImage: {
239
+ url: ((_v = product.images[0]) === null || _v === void 0 ? void 0 : _v.url) || "",
240
+ altText: ((_w = product.images[0]) === null || _w === void 0 ? void 0 : _w.altText) || "",
241
+ width: 1600,
242
+ height: 1600,
243
+ },
244
+ seo: {
245
+ description: ((_x = product.seo) === null || _x === void 0 ? void 0 : _x.description) ||
246
+ `${product.title.toLowerCase()} product description`,
247
+ title: ((_y = product.seo) === null || _y === void 0 ? void 0 : _y.title) || product.title,
248
+ },
249
+ tags: product.tags || [],
250
+ updatedAt: new Date().toISOString(),
251
+ sellingPlanGroups: { edges: [] },
252
+ metafields: [],
253
+ images: (product.images || []).map((img) => ({
254
+ url: img.url,
255
+ altText: img.altText || "",
256
+ width: 1600,
257
+ height: 1600,
258
+ })),
259
+ variants: product.variants.map((v) => {
260
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
261
+ return ({
262
+ id: `gid://shopify/ProductVariant/${getIdFromGid(v.id)}`,
263
+ title: v.title,
264
+ availableForSale: v.availableForSale,
265
+ sku: v.sku || null,
266
+ compareAtPrice: null,
267
+ selectedOptions: v.selectedOptions,
268
+ price: {
269
+ amount: v.price.amount,
270
+ currencyCode: "USD",
271
+ },
272
+ image: {
273
+ altText: ((_a = v.image) === null || _a === void 0 ? void 0 : _a.altText) || ((_b = product.images[0]) === null || _b === void 0 ? void 0 : _b.altText) || "",
274
+ height: 1600,
275
+ id: ((_c = v.image) === null || _c === void 0 ? void 0 : _c.id) ||
276
+ `gid://shopify/ProductImage/${Math.random()
277
+ .toString(36)
278
+ .substr(2, 9)}`,
279
+ originalSrc: ((_d = v.image) === null || _d === void 0 ? void 0 : _d.url) || ((_e = product.images[0]) === null || _e === void 0 ? void 0 : _e.url) || "",
280
+ src: ((_f = v.image) === null || _f === void 0 ? void 0 : _f.url) || ((_g = product.images[0]) === null || _g === void 0 ? void 0 : _g.url) || "",
281
+ transformedSrc: ((_h = v.image) === null || _h === void 0 ? void 0 : _h.url) || ((_j = product.images[0]) === null || _j === void 0 ? void 0 : _j.url) || "",
282
+ url: ((_k = v.image) === null || _k === void 0 ? void 0 : _k.url) || ((_l = product.images[0]) === null || _l === void 0 ? void 0 : _l.url) || "",
283
+ width: 1600,
284
+ },
285
+ });
286
+ }),
287
+ media: (product.images || []).map((img) => ({
288
+ mediaContentType: "IMAGE",
289
+ image: {
290
+ url: img.url,
291
+ altText: img.altText || "",
292
+ },
293
+ })),
294
+ },
295
+ variantDetails: {
296
+ id: `gid://shopify/ProductVariant/${getIdFromGid(variant.id)}`,
297
+ title: variant.title,
298
+ availableForSale: variant.availableForSale,
299
+ sku: variant.sku || null,
300
+ compareAtPrice: null,
301
+ selectedOptions: variant.selectedOptions,
302
+ price: {
303
+ amount: variant.price.amount,
304
+ currencyCode: "USD",
305
+ },
306
+ image: {
307
+ altText: ((_z = variant.image) === null || _z === void 0 ? void 0 : _z.altText) || ((_0 = product.images[0]) === null || _0 === void 0 ? void 0 : _0.altText) || "",
308
+ height: 1600,
309
+ id: ((_1 = variant.image) === null || _1 === void 0 ? void 0 : _1.id) ||
310
+ `gid://shopify/ProductImage/${Math.random()
311
+ .toString(36)
312
+ .substr(2, 9)}`,
313
+ originalSrc: ((_2 = variant.image) === null || _2 === void 0 ? void 0 : _2.url) || ((_3 = product.images[0]) === null || _3 === void 0 ? void 0 : _3.url) || "",
314
+ src: ((_4 = variant.image) === null || _4 === void 0 ? void 0 : _4.url) || ((_5 = product.images[0]) === null || _5 === void 0 ? void 0 : _5.url) || "",
315
+ transformedSrc: ((_6 = variant.image) === null || _6 === void 0 ? void 0 : _6.url) || ((_7 = product.images[0]) === null || _7 === void 0 ? void 0 : _7.url) || "",
316
+ url: ((_8 = variant.image) === null || _8 === void 0 ? void 0 : _8.url) || ((_9 = product.images[0]) === null || _9 === void 0 ? void 0 : _9.url) || "",
317
+ width: 1600,
318
+ },
319
+ },
320
+ stringifiedDiscounts: "[]",
321
+ };
322
+ return lineItem;
323
+ });
324
+ // Calculate order-level discount (10% off total)
325
+ const orderDiscount = subtotal * 0.1;
326
+ const finalTotal = subtotal - orderDiscount;
327
+ const discountAllocations = [
328
+ {
329
+ code: "10order",
330
+ discountedAmount: {
331
+ amount: orderDiscount.toString(),
332
+ currencyCode: "USD",
146
333
  },
147
334
  },
148
335
  ];
149
- const cost = {
150
- subtotalAmount: { amount: subtotal.toString(), currencyCode: "USD" },
151
- totalAmount: { amount: (subtotal + 5).toString(), currencyCode: "USD" },
152
- totalTaxAmount: { amount: "0.00", currencyCode: "USD" },
153
- };
154
- return Object.assign(Object.assign({}, cartOrigin), { subtotal,
155
- items, discountAllocations: [
156
- ...cartOrigin.discountAllocations,
157
- orderLevelDiscount,
158
- ], delivery,
159
- deliveryGroups,
160
- cost });
336
+ const discountCodes = [
337
+ {
338
+ code: "10order",
339
+ applicable: true,
340
+ },
341
+ {
342
+ code: "10product",
343
+ applicable: true,
344
+ },
345
+ ];
346
+ return Object.assign(Object.assign({}, cartOrigin), { items, lines: items, subtotal,
347
+ totalQuantity,
348
+ discountAllocations,
349
+ discountCodes, discounts: discountCodes, cost: {
350
+ subtotalAmount: {
351
+ amount: subtotal.toString(),
352
+ currencyCode: "USD",
353
+ },
354
+ totalAmount: {
355
+ amount: finalTotal.toString(),
356
+ currencyCode: "USD",
357
+ },
358
+ totalTaxAmount: null,
359
+ totalDutyAmount: null,
360
+ } });
161
361
  };
162
362
  export const useMockCart = ({ apiUrl, appId, enabled = true, limit = 3, }) => {
163
363
  const [isLoading, setIsLoading] = useState(true);
package/dist/lib/utils.js CHANGED
@@ -575,9 +575,9 @@ const evaluateSingleCondition = (condition, context) => {
575
575
  // For regular values (like collection names, customer auth, etc)
576
576
  switch (operator) {
577
577
  case "equals":
578
- return contextValues.some((contextValue) => { var _a; return ((_a = contextValue === null || contextValue === void 0 ? void 0 : contextValue.value) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === (value === null || value === void 0 ? void 0 : value.toLowerCase()); });
578
+ return contextValues.some((contextValue) => (contextValue === null || contextValue === void 0 ? void 0 : contextValue.value) === value);
579
579
  case "does not equal":
580
- return !contextValues.some((contextValue) => { var _a; return ((_a = contextValue === null || contextValue === void 0 ? void 0 : contextValue.value) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === (value === null || value === void 0 ? void 0 : value.toLowerCase()); });
580
+ return !contextValues.some((contextValue) => (contextValue === null || contextValue === void 0 ? void 0 : contextValue.value) === value);
581
581
  case "contains":
582
582
  return contextValues.some((contextValue) => { var _a; return (_a = contextValue === null || contextValue === void 0 ? void 0 : contextValue.value) === null || _a === void 0 ? void 0 : _a.includes(value); });
583
583
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.8.59",
3
+ "version": "0.8.60",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",