@tapcart/mobile-components 0.8.25 → 0.8.27

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-block-conditional-rendering.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-block-conditional-rendering.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EAGb,MAAM,kBAAkB,CAAA;AAczB,eAAO,MAAM,4BAA4B,WAC/B;IACN,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,eAAe,EAAE,GAAG,CAAA;IACpB,iBAAiB,EAAE,GAAG,CAAA;CACvB,UACO,YAAY;;;CA+KrB,CAAA"}
1
+ {"version":3,"file":"use-block-conditional-rendering.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-block-conditional-rendering.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EAGb,MAAM,kBAAkB,CAAA;AAczB,eAAO,MAAM,4BAA4B,WAC/B;IACN,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,eAAe,EAAE,GAAG,CAAA;IACpB,iBAAiB,EAAE,GAAG,CAAA;CACvB,UACO,YAAY;;;CAiNrB,CAAA"}
@@ -35,13 +35,28 @@ export const useBlockConditionalRendering = (_props, _block) => {
35
35
  let blockProductMetafields = useMemo(() => blockState && blockState.productMetafield
36
36
  ? blockState.productMetafield
37
37
  : [], [blockState]);
38
- const productMetafieldsQuery = useMemo(() => blockProductMetafields.map((item) => {
39
- // these are the fields used in the query.
40
- return {
41
- namespace: item.namespace,
42
- key: item.key,
43
- };
44
- }), [blockProductMetafields]);
38
+ const productMetafieldsQuery = useMemo(() => {
39
+ var _a;
40
+ if (conditionalsV1IsEnabled && (blockState === null || blockState === void 0 ? void 0 : blockState.productMetafield)) {
41
+ return blockState.productMetafield;
42
+ }
43
+ if (conditionalsV2IsEnabled && ((_a = _block === null || _block === void 0 ? void 0 : _block.visibilityConditions) === null || _a === void 0 ? void 0 : _a.conditions)) {
44
+ const extractProductMetafields = (conditions) => {
45
+ return conditions.reduce((acc, condition) => {
46
+ if (condition.type === 'productMetafield' && condition.value) {
47
+ acc.push(condition.value);
48
+ }
49
+ if (condition.conditions) {
50
+ acc.push(...extractProductMetafields(condition.conditions));
51
+ }
52
+ return acc;
53
+ }, []);
54
+ };
55
+ //@ts-expect-error: conditions typing mismatch
56
+ return extractProductMetafields(blockState.conditions || []);
57
+ }
58
+ return [];
59
+ }, [blockState, conditionalsV1IsEnabled, conditionalsV2IsEnabled, _block === null || _block === void 0 ? void 0 : _block.visibilityConditions]);
45
60
  // Fetch product if productId is present
46
61
  const { products, error: useProductsError, isLoading: isProductsLoading, } = useProducts({
47
62
  productIds: productId !== undefined ? [gidFromId(productId)] : [],
@@ -53,9 +68,28 @@ export const useBlockConditionalRendering = (_props, _block) => {
53
68
  country,
54
69
  },
55
70
  });
56
- const blockCollectionMetafields = useMemo(() => blockState && blockState.collectionMetafield
57
- ? blockState.collectionMetafield
58
- : [], [blockState]);
71
+ const blockCollectionMetafields = useMemo(() => {
72
+ var _a;
73
+ if (conditionalsV1IsEnabled && (blockState === null || blockState === void 0 ? void 0 : blockState.collectionMetafield)) {
74
+ return blockState.collectionMetafield;
75
+ }
76
+ if (conditionalsV2IsEnabled && ((_a = _block === null || _block === void 0 ? void 0 : _block.visibilityConditions) === null || _a === void 0 ? void 0 : _a.conditions)) {
77
+ const extractCollectionMetafields = (conditions) => {
78
+ return conditions.reduce((acc, condition) => {
79
+ if (condition.type === 'collectionMetafield' && condition.value) {
80
+ acc.push(condition.value);
81
+ }
82
+ if (condition.conditions) {
83
+ acc.push(...extractCollectionMetafields(condition.conditions));
84
+ }
85
+ return acc;
86
+ }, []);
87
+ };
88
+ //@ts-expect-error: conditions typing mismatch
89
+ return extractCollectionMetafields(blockState.conditions || []);
90
+ }
91
+ return [];
92
+ }, [blockState, conditionalsV1IsEnabled, conditionalsV2IsEnabled, _block === null || _block === void 0 ? void 0 : _block.visibilityConditions]);
59
93
  const collectionMetafieldsQuery = useMemo(() => blockCollectionMetafields.map((item) => {
60
94
  // these are the fields used in the query.
61
95
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"YotpoLoyalty.d.ts","sourceRoot":"","sources":["../../../../components/libs/loyalty/YotpoLoyalty.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,EAAE,EACrB,eAAe,EACf,aAAa,EACb,aAAa,EACb,eAAe,EACf,WAAW,EACX,eAAe,EAChB,MAAM,kBAAkB,CAAA;AAEzB,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,cAAc;IACtD,OAAO,EAAE,MAAM,CAAU;;IAOnB,cAAc,IAAI,OAAO,CAAC,eAAe,CAAC;IAa1C,WAAW,IAAI,OAAO,CAAC,eAAe,CAAC;IAQvC,cAAc,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAajD,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAoBjD,SAAS,IAAI,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAa1C,UAAU,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAiEtC,YAAY,IAAI,OAAO,CAAC,aAAa,EAAE,GAAG,IAAI,CAAC;IAsE/C,sBAAsB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAkFpD,cAAc,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAyBnD,kBAAkB,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAkBvD,eAAe,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IA2B9C,QAAQ,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAsDlC,cAAc,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAiCnD,YAAY,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;CAqBxD"}
1
+ {"version":3,"file":"YotpoLoyalty.d.ts","sourceRoot":"","sources":["../../../../components/libs/loyalty/YotpoLoyalty.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,EAAE,EACrB,eAAe,EACf,aAAa,EACb,aAAa,EACb,eAAe,EACf,WAAW,EACX,eAAe,EAChB,MAAM,kBAAkB,CAAA;AAEzB,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,cAAc;IACtD,OAAO,EAAE,MAAM,CAAU;;IAOnB,cAAc,IAAI,OAAO,CAAC,eAAe,CAAC;IAa1C,WAAW,IAAI,OAAO,CAAC,eAAe,CAAC;IAQvC,cAAc,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAajD,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAoBjD,SAAS,IAAI,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAa1C,UAAU,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAiEtC,YAAY,IAAI,OAAO,CAAC,aAAa,EAAE,GAAG,IAAI,CAAC;IAsE/C,sBAAsB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAkFpD,cAAc,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAyBnD,kBAAkB,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAqCvD,eAAe,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IA2B9C,QAAQ,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAsDlC,cAAc,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAiCnD,YAAY,IAAI,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;CAqBxD"}
@@ -340,7 +340,7 @@ export default class YotpoLoyalty extends LoyaltyAdapter {
340
340
  });
341
341
  }
342
342
  getActivityHistory() {
343
- var _a;
343
+ var _a, _b, _c;
344
344
  return __awaiter(this, void 0, void 0, function* () {
345
345
  if (!this.customer) {
346
346
  console.error("No customer found");
@@ -350,12 +350,31 @@ export default class YotpoLoyalty extends LoyaltyAdapter {
350
350
  return [
351
351
  {
352
352
  id: "activity-3",
353
+ title: "Made a purchase",
353
354
  type: "purchase",
354
355
  points: 100,
355
356
  customerId: (_a = this.customer) === null || _a === void 0 ? void 0 : _a.id,
356
357
  status: "completed",
357
358
  createdAt: new Date(),
358
359
  },
360
+ {
361
+ id: "activity-1",
362
+ title: "Free shipping",
363
+ type: "redeem",
364
+ points: -1500,
365
+ customerId: (_b = this.customer) === null || _b === void 0 ? void 0 : _b.id,
366
+ status: "completed",
367
+ createdAt: new Date(),
368
+ },
369
+ {
370
+ id: "activity-2",
371
+ title: "Free product",
372
+ type: "redeem",
373
+ points: -1500,
374
+ customerId: (_c = this.customer) === null || _c === void 0 ? void 0 : _c.id,
375
+ status: "pending",
376
+ createdAt: new Date(),
377
+ },
359
378
  ];
360
379
  }
361
380
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.8.25",
3
+ "version": "0.8.27",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",