@azzas/azzas-tracker-web 2.0.0-preview.4 → 2.0.0-preview.5

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.
@@ -1308,6 +1308,38 @@ var AzzasTracker = function() {
1308
1308
  });
1309
1309
  })();
1310
1310
  };
1311
+ var getBrandCode2 = function getBrandCode2(brand) {
1312
+ if (!brand) return null;
1313
+ var standardized = brand.toLowerCase().trim();
1314
+ return BRAND_CODES2[standardized] || null;
1315
+ };
1316
+ var normalizeBrand2 = function normalizeBrand2(input) {
1317
+ var brandStrings = [];
1318
+ if (Array.isArray(input) && input.every(function(item) {
1319
+ return typeof item === "string";
1320
+ })) {
1321
+ brandStrings = input;
1322
+ } else if (Array.isArray(input)) {
1323
+ brandStrings = input.map(function(item) {
1324
+ var _item_additionalInfo;
1325
+ return ((_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) || item.brand;
1326
+ });
1327
+ } else if ((typeof input === "undefined" ? "undefined" : _type_of(input)) === "object" && input !== null && "brand" in input) {
1328
+ var _input_additionalInfo;
1329
+ brandStrings = [
1330
+ ((_input_additionalInfo = input.additionalInfo) === null || _input_additionalInfo === void 0 ? void 0 : _input_additionalInfo.brandName) || input.brand
1331
+ ];
1332
+ } else if (typeof input === "string") {
1333
+ return getBrandCode2(input);
1334
+ } else {
1335
+ return null;
1336
+ }
1337
+ var brandCodes = brandStrings.map(getBrandCode2).filter(function(code) {
1338
+ return code !== null;
1339
+ });
1340
+ var uniqueSortedCodes = _to_consumable_array(new Set(brandCodes)).sort();
1341
+ return uniqueSortedCodes.length > 0 ? uniqueSortedCodes.join("_") : null;
1342
+ };
1311
1343
  var getItemShippingTier2 = function getItemShippingTier2(orderForm, item) {
1312
1344
  var _orderForm_shippingData_logisticsInfo, _orderForm_shippingData, _info_slas, _selectedSla_pickupStoreInfo;
1313
1345
  var info = orderForm === null || orderForm === void 0 ? void 0 : (_orderForm_shippingData = orderForm.shippingData) === null || _orderForm_shippingData === void 0 ? void 0 : (_orderForm_shippingData_logisticsInfo = _orderForm_shippingData.logisticsInfo) === null || _orderForm_shippingData_logisticsInfo === void 0 ? void 0 : _orderForm_shippingData_logisticsInfo.find(function(li) {
@@ -2402,9 +2434,9 @@ var AzzasTracker = function() {
2402
2434
  // src/params/adapters/meta/index.ts
2403
2435
  var metaAdapters = {
2404
2436
  user_info: getUserInfo,
2405
- brand: function(context) {
2406
- return context.meta.brand || null;
2407
- },
2437
+ // brand: (context: MetaBrandContext) => {
2438
+ // return context.meta.brand || null;
2439
+ // },
2408
2440
  content_type: function(context) {
2409
2441
  return context.meta.content_type || null;
2410
2442
  },
@@ -2486,6 +2518,11 @@ var AzzasTracker = function() {
2486
2518
  var deepest = (_validHierarchy_ = validHierarchy[validHierarchy.length - 1]) !== null && _validHierarchy_ !== void 0 ? _validHierarchy_ : "";
2487
2519
  return capitalize(deepest);
2488
2520
  };
2521
+ var BRAND_CODES2 = {
2522
+ farm: "farmrio",
2523
+ "farm etc": "farmetc",
2524
+ "farm rio": "farmrio"
2525
+ };
2489
2526
  // src/params/adapters/deco/index.ts
2490
2527
  var IN_STOCK_SCHEMA = "https://schema.org/InStock";
2491
2528
  var LIST_PRICE_SCHEMA = "https://schema.org/ListPrice";
@@ -2529,13 +2566,16 @@ var AzzasTracker = function() {
2529
2566
  }
2530
2567
  return null;
2531
2568
  },
2532
- // brand: (context: DecoBrandContext) => {
2533
- // if (context?.brand) return context.brand
2534
- // if (context?.products) {
2535
- // return context.products[0].brand?.name // tem que ajustar FARM por conta de FARM_ETC
2536
- // }
2537
- // return null
2538
- // },
2569
+ brand: function(context) {
2570
+ if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
2571
+ if (context === null || context === void 0 ? void 0 : context.products) {
2572
+ return normalizeBrand2(context.products.map(function(p) {
2573
+ var _p_brand;
2574
+ return p === null || p === void 0 ? void 0 : (_p_brand = p.brand) === null || _p_brand === void 0 ? void 0 : _p_brand.name;
2575
+ }));
2576
+ }
2577
+ return null;
2578
+ },
2539
2579
  line_items: function(context) {
2540
2580
  if (context === null || context === void 0 ? void 0 : context.line_items) return context.line_items;
2541
2581
  if (context === null || context === void 0 ? void 0 : context.products) {
@@ -2644,13 +2684,15 @@ var AzzasTracker = function() {
2644
2684
  }
2645
2685
  return null;
2646
2686
  },
2647
- // brand: (context: any) => {
2648
- // if (context?.brand) return context.brand
2649
- // if (context?.products) {
2650
- // return context.products[0].brand?.name // tem que ajustar FARM por conta de FARM_ETC
2651
- // }
2652
- // return null
2653
- // },
2687
+ brand: function(context) {
2688
+ var _context_orderForm;
2689
+ if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
2690
+ if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
2691
+ var brands = getOrderFormItems(context.orderForm).map(function(item) {
2692
+ return item.additionalInfo.brandName;
2693
+ });
2694
+ return normalizeBrand2(brands);
2695
+ },
2654
2696
  line_items: function(context) {
2655
2697
  var _context_orderForm;
2656
2698
  if (context === null || context === void 0 ? void 0 : context.line_items) return context.line_items;
@@ -3064,10 +3106,10 @@ var AzzasTracker = function() {
3064
3106
  shippings: function(context) {
3065
3107
  if (context.shippings) {
3066
3108
  return context.shippings.map(function(s) {
3067
- var _s_line_items, _s_price;
3109
+ var _s_line_items;
3068
3110
  return {
3069
3111
  line_items: (_s_line_items = s.line_items) !== null && _s_line_items !== void 0 ? _s_line_items : "",
3070
- shipping: (_s_price = s.price) !== null && _s_price !== void 0 ? _s_price : 0,
3112
+ shipping: s.price / 100,
3071
3113
  shipping_tier: getShippingTier(s),
3072
3114
  delivery_time: getDeliveryTime(s)
3073
3115
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azzas/azzas-tracker-web",
3
- "version": "2.0.0-preview.4",
3
+ "version": "2.0.0-preview.5",
4
4
  "type": "module",
5
5
  "main": "./dist/mod.cjs",
6
6
  "module": "./dist/mod.js",