@azzas/azzas-tracker-web 2.0.0-preview.0 → 2.0.0-preview.2
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/dist/mod.cjs +300 -171
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.d.cts +24 -0
- package/dist/mod.d.ts +24 -0
- package/dist/mod.global.js +300 -171
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +300 -171
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +339 -210
- package/package.json +1 -1
package/dist/mod.vtex.global.js
CHANGED
|
@@ -1311,10 +1311,6 @@ var AzzasTracker = function() {
|
|
|
1311
1311
|
var getItemShippingTier2 = function getItemShippingTier2() {
|
|
1312
1312
|
return null;
|
|
1313
1313
|
};
|
|
1314
|
-
var resizeVtexImage3 = function resizeVtexImage3(url) {
|
|
1315
|
-
var width = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 500, height = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 500;
|
|
1316
|
-
return url === null || url === void 0 ? void 0 : url.replace(/(\/arquivos\/ids\/\d+)-\d+-\d+\//, "$1-".concat(width, "-").concat(height, "/"));
|
|
1317
|
-
};
|
|
1318
1314
|
var getParameters = function getParameters(context, eventName) {
|
|
1319
1315
|
return _async_to_generator(function() {
|
|
1320
1316
|
var _adapters_currentAdapter, eventConfig, currentAdapter, getters, entries;
|
|
@@ -1326,7 +1322,7 @@ var AzzasTracker = function() {
|
|
|
1326
1322
|
2
|
|
1327
1323
|
];
|
|
1328
1324
|
currentAdapter = context.adapter;
|
|
1329
|
-
getters = (_adapters_currentAdapter = adapters[currentAdapter]) !== null && _adapters_currentAdapter !== void 0 ? _adapters_currentAdapter :
|
|
1325
|
+
getters = (_adapters_currentAdapter = adapters[currentAdapter]) !== null && _adapters_currentAdapter !== void 0 ? _adapters_currentAdapter : legacyGetters;
|
|
1330
1326
|
return [
|
|
1331
1327
|
4,
|
|
1332
1328
|
Promise.all(eventConfig.requiredParams.map(function(param) {
|
|
@@ -1897,6 +1893,33 @@ var AzzasTracker = function() {
|
|
|
1897
1893
|
"size",
|
|
1898
1894
|
"item_ref"
|
|
1899
1895
|
]
|
|
1896
|
+
},
|
|
1897
|
+
REFINE_RESULTS: {
|
|
1898
|
+
name: "refine_results",
|
|
1899
|
+
hasEcommerce: false,
|
|
1900
|
+
destinations: [
|
|
1901
|
+
"DataLayer"
|
|
1902
|
+
],
|
|
1903
|
+
requiredParams: [
|
|
1904
|
+
"brand",
|
|
1905
|
+
"region",
|
|
1906
|
+
"color",
|
|
1907
|
+
"price_range",
|
|
1908
|
+
"size",
|
|
1909
|
+
"category",
|
|
1910
|
+
"ordering"
|
|
1911
|
+
]
|
|
1912
|
+
},
|
|
1913
|
+
GRID_SIZE: {
|
|
1914
|
+
name: "grid_size",
|
|
1915
|
+
hasEcommerce: false,
|
|
1916
|
+
destinations: [
|
|
1917
|
+
"DataLayer"
|
|
1918
|
+
],
|
|
1919
|
+
requiredParams: [
|
|
1920
|
+
"brand",
|
|
1921
|
+
"slot_per_line"
|
|
1922
|
+
]
|
|
1900
1923
|
}
|
|
1901
1924
|
};
|
|
1902
1925
|
var BRAND_CODES = {
|
|
@@ -2079,6 +2102,10 @@ var AzzasTracker = function() {
|
|
|
2079
2102
|
var capitalize = function(str) {
|
|
2080
2103
|
return str ? str[0].toUpperCase() + str.slice(1).toLowerCase() : "";
|
|
2081
2104
|
};
|
|
2105
|
+
var resizeVtexImage2 = function(url) {
|
|
2106
|
+
var width = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 500, height = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 500;
|
|
2107
|
+
return url === null || url === void 0 ? void 0 : url.replace(/(\/arquivos\/ids\/\d+)-\d+-\d+\//, "$1-".concat(width, "-").concat(height, "/"));
|
|
2108
|
+
};
|
|
2082
2109
|
// src/params/userInfo.ts
|
|
2083
2110
|
var PROD_DOMAINS = {
|
|
2084
2111
|
"animale": {
|
|
@@ -2108,7 +2135,7 @@ var AzzasTracker = function() {
|
|
|
2108
2135
|
}
|
|
2109
2136
|
};
|
|
2110
2137
|
// src/params/legacy/index.ts
|
|
2111
|
-
var
|
|
2138
|
+
var legacyGetters = {
|
|
2112
2139
|
brand: getBrand,
|
|
2113
2140
|
items: getItems,
|
|
2114
2141
|
payment_type: getPaymentType,
|
|
@@ -2372,8 +2399,7 @@ var AzzasTracker = function() {
|
|
|
2372
2399
|
return context.meta.brand || null;
|
|
2373
2400
|
},
|
|
2374
2401
|
content_type: function(context) {
|
|
2375
|
-
|
|
2376
|
-
return "regiao".concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
|
|
2402
|
+
return context.meta.content_type || null;
|
|
2377
2403
|
},
|
|
2378
2404
|
region: function(context) {
|
|
2379
2405
|
return context.meta.region || null;
|
|
@@ -2385,14 +2411,18 @@ var AzzasTracker = function() {
|
|
|
2385
2411
|
if (context === null || context === void 0 ? void 0 : context.currency) return context.currency;
|
|
2386
2412
|
return "BRL";
|
|
2387
2413
|
},
|
|
2414
|
+
slot_per_line: function(context) {
|
|
2415
|
+
var _context_meta_slot_per_line;
|
|
2416
|
+
return (_context_meta_slot_per_line = context.meta.slot_per_line) !== null && _context_meta_slot_per_line !== void 0 ? _context_meta_slot_per_line : null;
|
|
2417
|
+
},
|
|
2388
2418
|
search_term: function(context) {
|
|
2389
|
-
return context.
|
|
2419
|
+
return context.meta.search_term || null;
|
|
2390
2420
|
},
|
|
2391
2421
|
search_found: function(context) {
|
|
2392
|
-
return
|
|
2422
|
+
return context.meta.search_found || null;
|
|
2393
2423
|
},
|
|
2394
2424
|
search_quantity: function(context) {
|
|
2395
|
-
return context.
|
|
2425
|
+
return context.meta.search_quantity || 0;
|
|
2396
2426
|
},
|
|
2397
2427
|
promotion_name: function(context) {
|
|
2398
2428
|
return context.meta.promotion_name || null;
|
|
@@ -2403,9 +2433,6 @@ var AzzasTracker = function() {
|
|
|
2403
2433
|
creative_slot: function(context) {
|
|
2404
2434
|
return context.meta.creative_slot || null;
|
|
2405
2435
|
},
|
|
2406
|
-
zipcode: function(context) {
|
|
2407
|
-
return context.zipCode || null;
|
|
2408
|
-
},
|
|
2409
2436
|
size: function(context) {
|
|
2410
2437
|
return context.size || null;
|
|
2411
2438
|
},
|
|
@@ -2417,187 +2444,21 @@ var AzzasTracker = function() {
|
|
|
2417
2444
|
},
|
|
2418
2445
|
type: function(context) {
|
|
2419
2446
|
return context.type || null;
|
|
2420
|
-
}
|
|
2421
|
-
};
|
|
2422
|
-
// src/params/adapters/orderForm/index.ts
|
|
2423
|
-
var orderFormAdapters = {
|
|
2424
|
-
// orderform
|
|
2425
|
-
payment_type: getPaymentType,
|
|
2426
|
-
total_discount: function(context) {
|
|
2427
|
-
var _context_orderForm, _context_orderForm1;
|
|
2428
|
-
if (context === null || context === void 0 ? void 0 : context.totalDiscount) return context.totalDiscount;
|
|
2429
|
-
var totalsList = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.totalizers) || ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totals) || [];
|
|
2430
|
-
var items = context.orderForm.items;
|
|
2431
|
-
var totalDiscount = items.reduce(function(acc, item) {
|
|
2432
|
-
var unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
|
|
2433
|
-
return acc + unitDiscount * item.quantity;
|
|
2434
|
-
}, 0);
|
|
2435
|
-
var discounts = totalsList.find(function(t) {
|
|
2436
|
-
return t.id === "Discounts";
|
|
2437
|
-
});
|
|
2438
|
-
return Math.abs(((discounts === null || discounts === void 0 ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
|
|
2439
|
-
},
|
|
2440
|
-
subtotal: function(context) {
|
|
2441
|
-
var _context_orderForm, _context_orderForm1;
|
|
2442
|
-
var totalsList = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.totalizers) || ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totals) || [];
|
|
2443
|
-
var subtotal = totalsList.filter(function(t) {
|
|
2444
|
-
return t.id === "Items";
|
|
2445
|
-
}).reduce(function(acc, t) {
|
|
2446
|
-
return acc + (t.value || 0);
|
|
2447
|
-
}, 0) / 100 || 0;
|
|
2448
|
-
return subtotal;
|
|
2449
|
-
},
|
|
2450
|
-
coupon_message: function(context) {
|
|
2451
|
-
var _context_orderForm;
|
|
2452
|
-
if (context.couponMessage) return context.couponMessage;
|
|
2453
|
-
var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
|
|
2454
|
-
if (messages.length === 0) return null;
|
|
2455
|
-
var couponMessages = messages.filter(function(msg) {
|
|
2456
|
-
return msg.text.toLowerCase().includes("cupom");
|
|
2457
|
-
});
|
|
2458
|
-
if (couponMessages.length === 0) return null;
|
|
2459
|
-
return couponMessages.map(function(msg) {
|
|
2460
|
-
return msg.text;
|
|
2461
|
-
}).join(" | ");
|
|
2462
|
-
},
|
|
2463
|
-
flag_pickup: function(context) {
|
|
2464
|
-
var _orderForm_shippingData;
|
|
2465
|
-
var orderForm = context.orderForm;
|
|
2466
|
-
if (!orderForm) return null;
|
|
2467
|
-
var logisticsInfo = ((_orderForm_shippingData = orderForm.shippingData) === null || _orderForm_shippingData === void 0 ? void 0 : _orderForm_shippingData.logisticsInfo) || [];
|
|
2468
|
-
var hasPickup = logisticsInfo.some(function(info) {
|
|
2469
|
-
var _info_slas;
|
|
2470
|
-
return (_info_slas = info.slas) === null || _info_slas === void 0 ? void 0 : _info_slas.some(function(sla) {
|
|
2471
|
-
return sla.deliveryChannel === "pickup-in-point";
|
|
2472
|
-
});
|
|
2473
|
-
});
|
|
2474
|
-
return hasPickup;
|
|
2475
|
-
},
|
|
2476
|
-
shippings: function(context) {
|
|
2477
|
-
var orderForm = context.orderForm;
|
|
2478
|
-
if (!orderForm) return null;
|
|
2479
|
-
var groupShipping = {};
|
|
2480
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2481
|
-
try {
|
|
2482
|
-
for(var _iterator = orderForm.shippingData.logisticsInfo[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2483
|
-
var info = _step.value;
|
|
2484
|
-
var item = orderForm.items[info.itemIndex];
|
|
2485
|
-
if (!item) continue;
|
|
2486
|
-
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
2487
|
-
try {
|
|
2488
|
-
for(var _iterator1 = info.slas[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
2489
|
-
var sla = _step1.value;
|
|
2490
|
-
var key = sla.name;
|
|
2491
|
-
if (!groupShipping[key]) {
|
|
2492
|
-
groupShipping[key] = {
|
|
2493
|
-
shipping_tier: sla.name,
|
|
2494
|
-
delivery_time: parseInt(sla.shippingEstimate),
|
|
2495
|
-
shipping: parseFloat((sla.price / 100).toFixed(1)),
|
|
2496
|
-
line_items: []
|
|
2497
|
-
};
|
|
2498
|
-
}
|
|
2499
|
-
groupShipping[key].line_items.push(item.id);
|
|
2500
|
-
}
|
|
2501
|
-
} catch (err) {
|
|
2502
|
-
_didIteratorError1 = true;
|
|
2503
|
-
_iteratorError1 = err;
|
|
2504
|
-
} finally{
|
|
2505
|
-
try {
|
|
2506
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
2507
|
-
_iterator1.return();
|
|
2508
|
-
}
|
|
2509
|
-
} finally{
|
|
2510
|
-
if (_didIteratorError1) {
|
|
2511
|
-
throw _iteratorError1;
|
|
2512
|
-
}
|
|
2513
|
-
}
|
|
2514
|
-
}
|
|
2515
|
-
}
|
|
2516
|
-
} catch (err) {
|
|
2517
|
-
_didIteratorError = true;
|
|
2518
|
-
_iteratorError = err;
|
|
2519
|
-
} finally{
|
|
2520
|
-
try {
|
|
2521
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2522
|
-
_iterator.return();
|
|
2523
|
-
}
|
|
2524
|
-
} finally{
|
|
2525
|
-
if (_didIteratorError) {
|
|
2526
|
-
throw _iteratorError;
|
|
2527
|
-
}
|
|
2528
|
-
}
|
|
2529
|
-
}
|
|
2530
|
-
var shippings = Object.values(groupShipping).map(function(s) {
|
|
2531
|
-
return {
|
|
2532
|
-
shipping: s.shipping,
|
|
2533
|
-
shipping_tier: s.shipping_tier,
|
|
2534
|
-
delivery_time: s.delivery_time,
|
|
2535
|
-
line_items: s.line_items.join(",")
|
|
2536
|
-
};
|
|
2537
|
-
});
|
|
2538
|
-
return shippings || null;
|
|
2539
|
-
},
|
|
2540
|
-
shipping: function(context) {
|
|
2541
|
-
var _ref;
|
|
2542
|
-
var _context_orderForm_shippingData, _context_orderForm;
|
|
2543
|
-
var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
|
|
2544
|
-
return logistics.reduce(function(total, item) {
|
|
2545
|
-
var _ref;
|
|
2546
|
-
var _item_slas;
|
|
2547
|
-
var selected = (_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
2548
|
-
return sla.id === item.selectedSla;
|
|
2549
|
-
});
|
|
2550
|
-
return total + ((_ref = selected === null || selected === void 0 ? void 0 : selected.price) !== null && _ref !== void 0 ? _ref : 0);
|
|
2551
|
-
}, 0);
|
|
2552
2447
|
},
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
var _context_orderForm_shippingData, _context_orderForm;
|
|
2556
|
-
var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
|
|
2557
|
-
var selectedSlas = logistics.map(function(item) {
|
|
2558
|
-
var _item_slas;
|
|
2559
|
-
if (!item.selectedSla) return null;
|
|
2560
|
-
return ((_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
2561
|
-
return sla.id === item.selectedSla;
|
|
2562
|
-
})) || null;
|
|
2563
|
-
}).filter(Boolean);
|
|
2564
|
-
if (selectedSlas.length === 0) return null;
|
|
2565
|
-
var uniqueTiers = Array.from(new Map(selectedSlas.map(function(sla) {
|
|
2566
|
-
var _sla_pickupStoreInfo;
|
|
2567
|
-
var key = sla.deliveryChannel === "pickup-in-point" ? "pickup:".concat(((_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : _sla_pickupStoreInfo.friendlyName) || sla.name || "") : "delivery:".concat(sla.name || "");
|
|
2568
|
-
return [
|
|
2569
|
-
key,
|
|
2570
|
-
sla
|
|
2571
|
-
];
|
|
2572
|
-
})).values());
|
|
2573
|
-
var sortedTiers = uniqueTiers.sort(function(a, b) {
|
|
2574
|
-
var _a_pickupStoreInfo, _b_pickupStoreInfo;
|
|
2575
|
-
var aOrder = a.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
2576
|
-
var bOrder = b.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
2577
|
-
if (aOrder !== bOrder) return aOrder - bOrder;
|
|
2578
|
-
var aLabel = a.deliveryChannel === "pickup-in-point" ? ((_a_pickupStoreInfo = a.pickupStoreInfo) === null || _a_pickupStoreInfo === void 0 ? void 0 : _a_pickupStoreInfo.friendlyName) || a.name || "" : a.name || "";
|
|
2579
|
-
var bLabel = b.deliveryChannel === "pickup-in-point" ? ((_b_pickupStoreInfo = b.pickupStoreInfo) === null || _b_pickupStoreInfo === void 0 ? void 0 : _b_pickupStoreInfo.friendlyName) || b.name || "" : b.name || "";
|
|
2580
|
-
return aLabel.localeCompare(bLabel, "pt-BR");
|
|
2581
|
-
});
|
|
2582
|
-
var shippingTier = sortedTiers.map(function(sla) {
|
|
2583
|
-
var _sla_pickupStoreInfo;
|
|
2584
|
-
return sla.deliveryChannel === "pickup-in-point" ? "retirada em loja".concat(((_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : _sla_pickupStoreInfo.friendlyName) ? ": ".concat(sla.pickupStoreInfo.friendlyName) : "") : sla.deliveryChannel === "delivery" ? "receba em casa".concat(sla.name ? ": ".concat(sla.name) : "") : null;
|
|
2585
|
-
}).filter(Boolean).join(", ");
|
|
2586
|
-
return shippingTier || null;
|
|
2448
|
+
color: function(context) {
|
|
2449
|
+
return context.meta.color || null;
|
|
2587
2450
|
},
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
return ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_orderGroup = _context_orderForm.orderGroup) === null || _context_orderForm_orderGroup === void 0 ? void 0 : _context_orderForm_orderGroup.toString()) || null;
|
|
2451
|
+
price_range: function(context) {
|
|
2452
|
+
return context.meta.price_range || null;
|
|
2591
2453
|
},
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
return context.appliedCoupon || (context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_marketingData = _context_orderForm.marketingData) === null || _context_orderForm_marketingData === void 0 ? void 0 : _context_orderForm_marketingData.coupon) || null;
|
|
2454
|
+
category: function(context) {
|
|
2455
|
+
return context.meta.category || null;
|
|
2595
2456
|
},
|
|
2596
|
-
|
|
2597
|
-
return context.
|
|
2457
|
+
ordering: function(context) {
|
|
2458
|
+
return context.meta.ordering || null;
|
|
2598
2459
|
}
|
|
2599
2460
|
};
|
|
2600
|
-
// src/params/adapters/deco/utils
|
|
2461
|
+
// src/params/adapters/deco/utils.ts
|
|
2601
2462
|
var getItemCategory3 = function(item) {
|
|
2602
2463
|
var _text_match;
|
|
2603
2464
|
var value = item === null || item === void 0 ? void 0 : item.category;
|
|
@@ -2618,21 +2479,17 @@ var AzzasTracker = function() {
|
|
|
2618
2479
|
var deepest = (_validHierarchy_ = validHierarchy[validHierarchy.length - 1]) !== null && _validHierarchy_ !== void 0 ? _validHierarchy_ : "";
|
|
2619
2480
|
return capitalize(deepest);
|
|
2620
2481
|
};
|
|
2621
|
-
var resizeVtexImage2 = function(url) {
|
|
2622
|
-
var width = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 500, height = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 500;
|
|
2623
|
-
return url === null || url === void 0 ? void 0 : url.replace(/(\/arquivos\/ids\/\d+)-\d+-\d+\//, "$1-".concat(width, "-").concat(height, "/"));
|
|
2624
|
-
};
|
|
2625
2482
|
// src/params/adapters/deco/index.ts
|
|
2626
2483
|
var IN_STOCK_SCHEMA = "https://schema.org/InStock";
|
|
2627
2484
|
var LIST_PRICE_SCHEMA = "https://schema.org/ListPrice";
|
|
2628
|
-
var decoAdapter = _object_spread_props(_object_spread({}, metaAdapters
|
|
2629
|
-
//
|
|
2485
|
+
var decoAdapter = _object_spread_props(_object_spread({}, metaAdapters), {
|
|
2486
|
+
// global adapters
|
|
2630
2487
|
items: function(context) {
|
|
2631
2488
|
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2632
2489
|
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2633
2490
|
return context.products.map(function(item) {
|
|
2634
2491
|
var _ref, _ref1, _item_alternateName, _ref2, _ref3, _ref4, _getItemCategory3, _getItemCategory22, _ref5, _item_sku, _item_url, _resizeVtexImage2, _ref6, _ref7;
|
|
2635
|
-
var _item_offers_offers__priceSpecification_find, _item_offers_offers, _item_offers, _item_brand_name, _item_brand, _item_offers1, _item_offers2, _item_name_split_, _item_name, _item_name1, _item_additionalProperty_find, _item_additionalProperty, _item_image, _item_offers_offers_, _item_offers_offers1, _item_offers3;
|
|
2492
|
+
var _item_offers_offers__priceSpecification_find, _item_offers_offers, _item_offers, _item_brand_name, _item_brand, _item_offers1, _item_offers2, _item_name_split_, _item_name, _item_name1, _item_additionalProperty_find_value, _item_additionalProperty_find, _item_additionalProperty, _item_image, _item_offers_offers_, _item_offers_offers1, _item_offers3;
|
|
2636
2493
|
var COLOR_REGEX = /^[^_]+_/;
|
|
2637
2494
|
var listPrice = item === null || item === void 0 ? void 0 : (_item_offers = item.offers) === null || _item_offers === void 0 ? void 0 : (_item_offers_offers = _item_offers.offers) === null || _item_offers_offers === void 0 ? void 0 : (_item_offers_offers__priceSpecification_find = _item_offers_offers[0].priceSpecification.find(function(s) {
|
|
2638
2495
|
return s.priceType === LIST_PRICE_SCHEMA;
|
|
@@ -2643,7 +2500,7 @@ var AzzasTracker = function() {
|
|
|
2643
2500
|
item_brand: (_ref1 = (_item_brand = item.brand) === null || _item_brand === void 0 ? void 0 : (_item_brand_name = _item_brand.name) === null || _item_brand_name === void 0 ? void 0 : _item_brand_name.toLowerCase()) !== null && _ref1 !== void 0 ? _ref1 : null,
|
|
2644
2501
|
item_name: (_item_alternateName = item.alternateName) !== null && _item_alternateName !== void 0 ? _item_alternateName : null,
|
|
2645
2502
|
price: (_ref2 = (_item_offers1 = item.offers) === null || _item_offers1 === void 0 ? void 0 : _item_offers1.lowPrice) !== null && _ref2 !== void 0 ? _ref2 : null,
|
|
2646
|
-
discount: Number(listPrice) - Number(item === null || item === void 0 ? void 0 : (_item_offers2 = item.offers) === null || _item_offers2 === void 0 ? void 0 : _item_offers2.lowPrice),
|
|
2503
|
+
discount: Math.round((Number(listPrice) - Number(item === null || item === void 0 ? void 0 : (_item_offers2 = item.offers) === null || _item_offers2 === void 0 ? void 0 : _item_offers2.lowPrice)) * 100) / 100,
|
|
2647
2504
|
item_variant: (item === null || item === void 0 ? void 0 : (_item_name = item.name) === null || _item_name === void 0 ? void 0 : (_item_name_split_ = _item_name.split(" - ")[0]) === null || _item_name_split_ === void 0 ? void 0 : _item_name_split_.replace(COLOR_REGEX, "").replace(/_/g, " ")) || null,
|
|
2648
2505
|
// cor
|
|
2649
2506
|
item_variant2: (_ref3 = item === null || item === void 0 ? void 0 : (_item_name1 = item.name) === null || _item_name1 === void 0 ? void 0 : _item_name1.split(" - ")[1]) !== null && _ref3 !== void 0 ? _ref3 : null,
|
|
@@ -2651,7 +2508,7 @@ var AzzasTracker = function() {
|
|
|
2651
2508
|
item_shipping_tier: getItemShippingTier2(),
|
|
2652
2509
|
item_ref: (_ref4 = (_item_additionalProperty = item.additionalProperty) === null || _item_additionalProperty === void 0 ? void 0 : (_item_additionalProperty_find = _item_additionalProperty.find(function(i) {
|
|
2653
2510
|
return i.name === "RefId";
|
|
2654
|
-
})) === null || _item_additionalProperty_find === void 0 ? void 0 : _item_additionalProperty_find.value) !== null && _ref4 !== void 0 ? _ref4 : null,
|
|
2511
|
+
})) === null || _item_additionalProperty_find === void 0 ? void 0 : (_item_additionalProperty_find_value = _item_additionalProperty_find.value) === null || _item_additionalProperty_find_value === void 0 ? void 0 : _item_additionalProperty_find_value.replace(/_\d+$/, "")) !== null && _ref4 !== void 0 ? _ref4 : null,
|
|
2655
2512
|
item_category: (_getItemCategory3 = getItemCategory3(item)) !== null && _getItemCategory3 !== void 0 ? _getItemCategory3 : null,
|
|
2656
2513
|
item_category2: (_getItemCategory22 = getItemCategory22(item)) !== null && _getItemCategory22 !== void 0 ? _getItemCategory22 : null,
|
|
2657
2514
|
item_id: (_ref5 = item === null || item === void 0 ? void 0 : item.inProductGroupWithID) !== null && _ref5 !== void 0 ? _ref5 : null,
|
|
@@ -2721,8 +2578,235 @@ var AzzasTracker = function() {
|
|
|
2721
2578
|
return null;
|
|
2722
2579
|
}
|
|
2723
2580
|
});
|
|
2724
|
-
// src/params/adapters/
|
|
2581
|
+
// src/params/adapters/orderForm/utils.ts
|
|
2725
2582
|
var getItemCategory5 = function(item) {
|
|
2583
|
+
var _text_match;
|
|
2584
|
+
var categories = item === null || item === void 0 ? void 0 : item.productCategories;
|
|
2585
|
+
if (!categories) return "Cole\xE7\xE3o";
|
|
2586
|
+
var text = Object.values(categories).join(" ");
|
|
2587
|
+
var match = (_text_match = text.match(/outlet|bazar|sale/i)) === null || _text_match === void 0 ? void 0 : _text_match[0].toLowerCase();
|
|
2588
|
+
return match !== null && match !== void 0 ? match : "Cole\xE7\xE3o";
|
|
2589
|
+
};
|
|
2590
|
+
var getItemCategory23 = function(item) {
|
|
2591
|
+
var _ref, _validHierarchy_;
|
|
2592
|
+
var AVOID_CATEGORIES = /outlet|bazar|sale/i;
|
|
2593
|
+
var categories = Object.values((_ref = item === null || item === void 0 ? void 0 : item.productCategories) !== null && _ref !== void 0 ? _ref : {});
|
|
2594
|
+
var validHierarchy = categories.map(function(c) {
|
|
2595
|
+
return c.trim();
|
|
2596
|
+
}).filter(function(c) {
|
|
2597
|
+
return c && !AVOID_CATEGORIES.test(c);
|
|
2598
|
+
});
|
|
2599
|
+
var deepest = (_validHierarchy_ = validHierarchy[validHierarchy.length - 1]) !== null && _validHierarchy_ !== void 0 ? _validHierarchy_ : "";
|
|
2600
|
+
return capitalize(deepest);
|
|
2601
|
+
};
|
|
2602
|
+
var getOrderFormItems = function(orderForm) {
|
|
2603
|
+
var idSelected = orderForm === null || orderForm === void 0 ? void 0 : orderForm.selected;
|
|
2604
|
+
return idSelected ? orderForm.items.filter(function(item) {
|
|
2605
|
+
return item.id === idSelected;
|
|
2606
|
+
}) : orderForm.items;
|
|
2607
|
+
};
|
|
2608
|
+
// src/params/adapters/orderForm/index.ts
|
|
2609
|
+
var orderFormAdapter = _object_spread_props(_object_spread({}, metaAdapters), {
|
|
2610
|
+
items: function(context) {
|
|
2611
|
+
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2612
|
+
if ((context === null || context === void 0 ? void 0 : context.orderForm) && (context === null || context === void 0 ? void 0 : context.orderForm.items)) {
|
|
2613
|
+
return getOrderFormItems(context.orderForm).map(function(item, index) {
|
|
2614
|
+
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _getItemCategory5, _getItemCategory23, _ref7, _ref8, _item_detailUrl, _resizeVtexImage2, _ref9, _ref10;
|
|
2615
|
+
var _context_orderForm, _item_additionalInfo, _item_skuName_split__split_pop, _item_skuName_split_, _item_skuName, _item_skuName_split_1, _item_skuName1, _context_orderForm1;
|
|
2616
|
+
return {
|
|
2617
|
+
quantity: (_ref = item === null || item === void 0 ? void 0 : item.quantity) !== null && _ref !== void 0 ? _ref : 1,
|
|
2618
|
+
index: (_ref1 = (_ref2 = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.index) !== null && _ref2 !== void 0 ? _ref2 : index) !== null && _ref1 !== void 0 ? _ref1 : null,
|
|
2619
|
+
item_brand: (_ref3 = (_item_additionalInfo = item.additionalInfo) === null || _item_additionalInfo === void 0 ? void 0 : _item_additionalInfo.brandName) !== null && _ref3 !== void 0 ? _ref3 : null,
|
|
2620
|
+
item_name: (_ref4 = item === null || item === void 0 ? void 0 : item.name.replace(item === null || item === void 0 ? void 0 : item.skuName, "").trim()) !== null && _ref4 !== void 0 ? _ref4 : null,
|
|
2621
|
+
price: (item === null || item === void 0 ? void 0 : item.price) / 100,
|
|
2622
|
+
discount: ((item === null || item === void 0 ? void 0 : item.listPrice) - (item === null || item === void 0 ? void 0 : item.sellingPrice)) / 100,
|
|
2623
|
+
item_variant: (_ref5 = item === null || item === void 0 ? void 0 : (_item_skuName = item.skuName) === null || _item_skuName === void 0 ? void 0 : (_item_skuName_split_ = _item_skuName.split(" - ")[0]) === null || _item_skuName_split_ === void 0 ? void 0 : (_item_skuName_split__split_pop = _item_skuName_split_.split("_").pop()) === null || _item_skuName_split__split_pop === void 0 ? void 0 : _item_skuName_split__split_pop.trim()) !== null && _ref5 !== void 0 ? _ref5 : null,
|
|
2624
|
+
item_variant2: (_ref6 = item === null || item === void 0 ? void 0 : (_item_skuName1 = item.skuName) === null || _item_skuName1 === void 0 ? void 0 : (_item_skuName_split_1 = _item_skuName1.split(" - ")[1]) === null || _item_skuName_split_1 === void 0 ? void 0 : _item_skuName_split_1.trim()) !== null && _ref6 !== void 0 ? _ref6 : null,
|
|
2625
|
+
item_shipping_tier: "",
|
|
2626
|
+
item_ref: (item === null || item === void 0 ? void 0 : item.productRefId) || (item === null || item === void 0 ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
|
|
2627
|
+
item_category: (_getItemCategory5 = getItemCategory5(item)) !== null && _getItemCategory5 !== void 0 ? _getItemCategory5 : null,
|
|
2628
|
+
item_category2: (_getItemCategory23 = getItemCategory23(item)) !== null && _getItemCategory23 !== void 0 ? _getItemCategory23 : null,
|
|
2629
|
+
item_id: (_ref7 = item === null || item === void 0 ? void 0 : item.productId) !== null && _ref7 !== void 0 ? _ref7 : null,
|
|
2630
|
+
item_sku: (_ref8 = item === null || item === void 0 ? void 0 : item.id) !== null && _ref8 !== void 0 ? _ref8 : null,
|
|
2631
|
+
item_url: (_item_detailUrl = item.detailUrl) !== null && _item_detailUrl !== void 0 ? _item_detailUrl : null,
|
|
2632
|
+
image_url: (_resizeVtexImage2 = resizeVtexImage2(item.imageUrl)) !== null && _resizeVtexImage2 !== void 0 ? _resizeVtexImage2 : null,
|
|
2633
|
+
seller_id: (_ref9 = item === null || item === void 0 ? void 0 : item.seller) !== null && _ref9 !== void 0 ? _ref9 : null,
|
|
2634
|
+
item_list_name: (_ref10 = context === null || context === void 0 ? void 0 : (_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.item_list_name) !== null && _ref10 !== void 0 ? _ref10 : null
|
|
2635
|
+
};
|
|
2636
|
+
});
|
|
2637
|
+
}
|
|
2638
|
+
return null;
|
|
2639
|
+
},
|
|
2640
|
+
// brand: (context: any) => {
|
|
2641
|
+
// if (context?.brand) return context.brand
|
|
2642
|
+
// if (context?.products) {
|
|
2643
|
+
// return context.products[0].brand?.name // tem que ajustar FARM por conta de FARM_ETC
|
|
2644
|
+
// }
|
|
2645
|
+
// return null
|
|
2646
|
+
// },
|
|
2647
|
+
line_items: function(context) {
|
|
2648
|
+
var _context_orderForm;
|
|
2649
|
+
if (context === null || context === void 0 ? void 0 : context.line_items) return context.line_items;
|
|
2650
|
+
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2651
|
+
return getOrderFormItems(context.orderForm).map(function(item) {
|
|
2652
|
+
return item === null || item === void 0 ? void 0 : item.productId;
|
|
2653
|
+
}).filter(function(id) {
|
|
2654
|
+
return Boolean(id);
|
|
2655
|
+
});
|
|
2656
|
+
},
|
|
2657
|
+
value: function(context) {
|
|
2658
|
+
var _context_orderForm;
|
|
2659
|
+
if (context === null || context === void 0 ? void 0 : context.value) return context.value;
|
|
2660
|
+
if (!(context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.items)) return null;
|
|
2661
|
+
return getOrderFormItems(context.orderForm).map(function(item) {
|
|
2662
|
+
return (item === null || item === void 0 ? void 0 : item.price) / 100 * item.quantity;
|
|
2663
|
+
}).filter(function(price) {
|
|
2664
|
+
return price !== void 0;
|
|
2665
|
+
}).reduce(function(sum, price) {
|
|
2666
|
+
return sum + price;
|
|
2667
|
+
}, 0);
|
|
2668
|
+
},
|
|
2669
|
+
payment_type: getPaymentType,
|
|
2670
|
+
total_discount: function(context) {
|
|
2671
|
+
var _context_orderForm, _context_orderForm1;
|
|
2672
|
+
if (context === null || context === void 0 ? void 0 : context.totalDiscount) return context.totalDiscount;
|
|
2673
|
+
var totalsList = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.totalizers) || ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totals) || [];
|
|
2674
|
+
var items = context.orderForm.items;
|
|
2675
|
+
var totalDiscount = items.reduce(function(acc, item) {
|
|
2676
|
+
var unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
|
|
2677
|
+
return acc + unitDiscount * item.quantity;
|
|
2678
|
+
}, 0);
|
|
2679
|
+
var discounts = totalsList.find(function(t) {
|
|
2680
|
+
return t.id === "Discounts";
|
|
2681
|
+
});
|
|
2682
|
+
return Math.abs(((discounts === null || discounts === void 0 ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
|
|
2683
|
+
},
|
|
2684
|
+
subtotal: function(context) {
|
|
2685
|
+
var _context_orderForm, _context_orderForm1;
|
|
2686
|
+
var totalsList = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.totalizers) || ((_context_orderForm1 = context.orderForm) === null || _context_orderForm1 === void 0 ? void 0 : _context_orderForm1.totals) || [];
|
|
2687
|
+
var subtotal = totalsList.filter(function(t) {
|
|
2688
|
+
return t.id === "Items";
|
|
2689
|
+
}).reduce(function(acc, t) {
|
|
2690
|
+
return acc + (t.value || 0);
|
|
2691
|
+
}, 0) / 100 || 0;
|
|
2692
|
+
return subtotal;
|
|
2693
|
+
},
|
|
2694
|
+
coupon_message: function(context) {
|
|
2695
|
+
var _context_orderForm;
|
|
2696
|
+
if (context.couponMessage) return context.couponMessage;
|
|
2697
|
+
var messages = ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : _context_orderForm.messages) || [];
|
|
2698
|
+
if (messages.length === 0) return null;
|
|
2699
|
+
var couponMessages = messages.filter(function(msg) {
|
|
2700
|
+
return msg.text.toLowerCase().includes("cupom");
|
|
2701
|
+
});
|
|
2702
|
+
if (couponMessages.length === 0) return null;
|
|
2703
|
+
return couponMessages.map(function(msg) {
|
|
2704
|
+
return msg.text;
|
|
2705
|
+
}).join(" | ");
|
|
2706
|
+
},
|
|
2707
|
+
zipcode: function(context) {
|
|
2708
|
+
var _context_zipcode;
|
|
2709
|
+
return (_context_zipcode = context.zipcode) !== null && _context_zipcode !== void 0 ? _context_zipcode : null;
|
|
2710
|
+
},
|
|
2711
|
+
flag_pickup: function(context) {
|
|
2712
|
+
var _orderForm_shippingData;
|
|
2713
|
+
var orderForm = context.orderForm;
|
|
2714
|
+
if (!orderForm) return null;
|
|
2715
|
+
var logisticsInfo = ((_orderForm_shippingData = orderForm.shippingData) === null || _orderForm_shippingData === void 0 ? void 0 : _orderForm_shippingData.logisticsInfo) || [];
|
|
2716
|
+
var hasPickup = logisticsInfo.some(function(info) {
|
|
2717
|
+
var _info_slas;
|
|
2718
|
+
return (_info_slas = info.slas) === null || _info_slas === void 0 ? void 0 : _info_slas.some(function(sla) {
|
|
2719
|
+
return sla.deliveryChannel === "pickup-in-point";
|
|
2720
|
+
});
|
|
2721
|
+
});
|
|
2722
|
+
return hasPickup;
|
|
2723
|
+
},
|
|
2724
|
+
shippings: function(context) {
|
|
2725
|
+
if (!context.orderForm) return null;
|
|
2726
|
+
var _context_orderForm = context.orderForm, items = _context_orderForm.items, shippingData = _context_orderForm.shippingData;
|
|
2727
|
+
var acc = {};
|
|
2728
|
+
shippingData.logisticsInfo.forEach(function(param) {
|
|
2729
|
+
var itemIndex = param.itemIndex, slas = param.slas;
|
|
2730
|
+
var item = items[itemIndex];
|
|
2731
|
+
if (!item) return;
|
|
2732
|
+
slas.forEach(function(sla) {
|
|
2733
|
+
if (!acc[sla.name]) acc[sla.name] = {
|
|
2734
|
+
shipping_tier: sla.name,
|
|
2735
|
+
delivery_time: parseInt(sla.shippingEstimate),
|
|
2736
|
+
shipping: parseFloat((sla.price / 100).toFixed(1)),
|
|
2737
|
+
line_items: []
|
|
2738
|
+
};
|
|
2739
|
+
acc[sla.name].line_items.push(item.id);
|
|
2740
|
+
});
|
|
2741
|
+
});
|
|
2742
|
+
return Object.values(acc).map(function(s) {
|
|
2743
|
+
return _object_spread_props(_object_spread({}, s), {
|
|
2744
|
+
line_items: s.line_items.join(",")
|
|
2745
|
+
});
|
|
2746
|
+
});
|
|
2747
|
+
},
|
|
2748
|
+
shipping: function(context) {
|
|
2749
|
+
var _ref;
|
|
2750
|
+
var _context_orderForm_shippingData, _context_orderForm;
|
|
2751
|
+
var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
|
|
2752
|
+
return logistics.reduce(function(total, item) {
|
|
2753
|
+
var _ref;
|
|
2754
|
+
var _item_slas;
|
|
2755
|
+
var selected = (_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
2756
|
+
return sla.id === item.selectedSla;
|
|
2757
|
+
});
|
|
2758
|
+
return total + ((_ref = selected === null || selected === void 0 ? void 0 : selected.price) !== null && _ref !== void 0 ? _ref : 0);
|
|
2759
|
+
}, 0);
|
|
2760
|
+
},
|
|
2761
|
+
shipping_tier: function(context) {
|
|
2762
|
+
var _ref;
|
|
2763
|
+
var _context_orderForm_shippingData, _context_orderForm;
|
|
2764
|
+
var logistics = (_ref = context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_shippingData = _context_orderForm.shippingData) === null || _context_orderForm_shippingData === void 0 ? void 0 : _context_orderForm_shippingData.logisticsInfo) !== null && _ref !== void 0 ? _ref : [];
|
|
2765
|
+
var selectedSlas = logistics.map(function(item) {
|
|
2766
|
+
var _item_slas;
|
|
2767
|
+
if (!item.selectedSla) return null;
|
|
2768
|
+
return ((_item_slas = item.slas) === null || _item_slas === void 0 ? void 0 : _item_slas.find(function(sla) {
|
|
2769
|
+
return sla.id === item.selectedSla;
|
|
2770
|
+
})) || null;
|
|
2771
|
+
}).filter(Boolean);
|
|
2772
|
+
if (selectedSlas.length === 0) return null;
|
|
2773
|
+
var uniqueTiers = Array.from(new Map(selectedSlas.map(function(sla) {
|
|
2774
|
+
var _sla_pickupStoreInfo;
|
|
2775
|
+
var key = sla.deliveryChannel === "pickup-in-point" ? "pickup:".concat(((_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : _sla_pickupStoreInfo.friendlyName) || sla.name || "") : "delivery:".concat(sla.name || "");
|
|
2776
|
+
return [
|
|
2777
|
+
key,
|
|
2778
|
+
sla
|
|
2779
|
+
];
|
|
2780
|
+
})).values());
|
|
2781
|
+
var sortedTiers = uniqueTiers.sort(function(a, b) {
|
|
2782
|
+
var _a_pickupStoreInfo, _b_pickupStoreInfo;
|
|
2783
|
+
var aOrder = a.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
2784
|
+
var bOrder = b.deliveryChannel === "pickup-in-point" ? 0 : 1;
|
|
2785
|
+
if (aOrder !== bOrder) return aOrder - bOrder;
|
|
2786
|
+
var aLabel = a.deliveryChannel === "pickup-in-point" ? ((_a_pickupStoreInfo = a.pickupStoreInfo) === null || _a_pickupStoreInfo === void 0 ? void 0 : _a_pickupStoreInfo.friendlyName) || a.name || "" : a.name || "";
|
|
2787
|
+
var bLabel = b.deliveryChannel === "pickup-in-point" ? ((_b_pickupStoreInfo = b.pickupStoreInfo) === null || _b_pickupStoreInfo === void 0 ? void 0 : _b_pickupStoreInfo.friendlyName) || b.name || "" : b.name || "";
|
|
2788
|
+
return aLabel.localeCompare(bLabel, "pt-BR");
|
|
2789
|
+
});
|
|
2790
|
+
var shippingTier = sortedTiers.map(function(sla) {
|
|
2791
|
+
var _sla_pickupStoreInfo;
|
|
2792
|
+
return sla.deliveryChannel === "pickup-in-point" ? "retirada em loja".concat(((_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : _sla_pickupStoreInfo.friendlyName) ? ": ".concat(sla.pickupStoreInfo.friendlyName) : "") : sla.deliveryChannel === "delivery" ? "receba em casa".concat(sla.name ? ": ".concat(sla.name) : "") : null;
|
|
2793
|
+
}).filter(Boolean).join(", ");
|
|
2794
|
+
return shippingTier || null;
|
|
2795
|
+
},
|
|
2796
|
+
transaction_id: function(context) {
|
|
2797
|
+
var _context_orderForm_orderGroup, _context_orderForm;
|
|
2798
|
+
return ((_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_orderGroup = _context_orderForm.orderGroup) === null || _context_orderForm_orderGroup === void 0 ? void 0 : _context_orderForm_orderGroup.toString()) || null;
|
|
2799
|
+
},
|
|
2800
|
+
coupon: function(context) {
|
|
2801
|
+
var _context_orderForm_marketingData, _context_orderForm;
|
|
2802
|
+
return context.appliedCoupon || (context === null || context === void 0 ? void 0 : (_context_orderForm = context.orderForm) === null || _context_orderForm === void 0 ? void 0 : (_context_orderForm_marketingData = _context_orderForm.marketingData) === null || _context_orderForm_marketingData === void 0 ? void 0 : _context_orderForm_marketingData.coupon) || null;
|
|
2803
|
+
},
|
|
2804
|
+
seller_cod_name: function(context) {
|
|
2805
|
+
return context.appliedSellerCodName || (context === null || context === void 0 ? void 0 : context.orderForm.marketingData.utmiCampaign) || null;
|
|
2806
|
+
}
|
|
2807
|
+
});
|
|
2808
|
+
// src/params/adapters/headless/utils.ts
|
|
2809
|
+
var getItemCategory6 = function(item) {
|
|
2726
2810
|
var keywords = [
|
|
2727
2811
|
"outlet",
|
|
2728
2812
|
"bazar",
|
|
@@ -2739,7 +2823,7 @@ var AzzasTracker = function() {
|
|
|
2739
2823
|
}
|
|
2740
2824
|
return "Cole\xE7\xE3o";
|
|
2741
2825
|
};
|
|
2742
|
-
var
|
|
2826
|
+
var getItemCategory24 = function(item) {
|
|
2743
2827
|
var _ref, _reverse_find;
|
|
2744
2828
|
var _item_categories;
|
|
2745
2829
|
var avoidList = /outlet|bazar|sale/i;
|
|
@@ -2756,7 +2840,7 @@ var AzzasTracker = function() {
|
|
|
2756
2840
|
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2757
2841
|
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2758
2842
|
return context.products.map(function(item) {
|
|
2759
|
-
var _ref, _item_brand, _item_productName, _ref1, _ref2, _item_productReference,
|
|
2843
|
+
var _ref, _item_brand, _item_productName, _ref1, _ref2, _item_productReference, _getItemCategory24, _ref3, _ref4, _item_link, _resizeVtexImage2, _ref5, _item_item_list_name;
|
|
2760
2844
|
var _item_items__sellers, _item_items__sellers1, _item_items__name, _item_items_, _item_items__name1, _item_items_1, _item_items, _item_items__images, _item_items1, _item_items__sellers2, _item_items_2, _item_items2;
|
|
2761
2845
|
var listPrice = item === null || item === void 0 ? void 0 : (_item_items__sellers = item.items[0].sellers) === null || _item_items__sellers === void 0 ? void 0 : _item_items__sellers[0].commertialOffer.ListPrice;
|
|
2762
2846
|
var price = item === null || item === void 0 ? void 0 : (_item_items__sellers1 = item.items[0].sellers) === null || _item_items__sellers1 === void 0 ? void 0 : _item_items__sellers1[0].commertialOffer.Price;
|
|
@@ -2766,18 +2850,19 @@ var AzzasTracker = function() {
|
|
|
2766
2850
|
item_brand: (_item_brand = item.brand) !== null && _item_brand !== void 0 ? _item_brand : null,
|
|
2767
2851
|
item_name: (_item_productName = item.productName) !== null && _item_productName !== void 0 ? _item_productName : null,
|
|
2768
2852
|
price: price !== null && price !== void 0 ? price : null,
|
|
2853
|
+
item_shipping_tier: null,
|
|
2769
2854
|
discount: Number(listPrice) - Number(price),
|
|
2770
2855
|
item_variant: (_ref1 = (_item_items_ = item.items[0]) === null || _item_items_ === void 0 ? void 0 : (_item_items__name = _item_items_.name) === null || _item_items__name === void 0 ? void 0 : _item_items__name.split(" - ")[0]) !== null && _ref1 !== void 0 ? _ref1 : null,
|
|
2771
2856
|
item_variant2: (_ref2 = (_item_items_1 = item.items[0]) === null || _item_items_1 === void 0 ? void 0 : (_item_items__name1 = _item_items_1.name) === null || _item_items__name1 === void 0 ? void 0 : _item_items__name1.split(" - ")[1]) !== null && _ref2 !== void 0 ? _ref2 : null,
|
|
2772
2857
|
item_ref: (_item_productReference = item.productReference) !== null && _item_productReference !== void 0 ? _item_productReference : null,
|
|
2773
2858
|
// sem ref no retorno do IS na multi-lib produtos PDC
|
|
2774
|
-
item_category:
|
|
2775
|
-
item_category2: (
|
|
2859
|
+
item_category: getItemCategory6(item),
|
|
2860
|
+
item_category2: (_getItemCategory24 = getItemCategory24(item)) !== null && _getItemCategory24 !== void 0 ? _getItemCategory24 : null,
|
|
2776
2861
|
item_id: (_ref3 = item === null || item === void 0 ? void 0 : item.productId) !== null && _ref3 !== void 0 ? _ref3 : null,
|
|
2777
2862
|
item_sku: (_ref4 = (_item_items = item.items) === null || _item_items === void 0 ? void 0 : _item_items[0].itemId) !== null && _ref4 !== void 0 ? _ref4 : null,
|
|
2778
2863
|
item_url: (_item_link = item.link) !== null && _item_link !== void 0 ? _item_link : null,
|
|
2779
2864
|
// sem link/url no retorno do IS na multi-lib produtos PDC
|
|
2780
|
-
image_url: (
|
|
2865
|
+
image_url: (_resizeVtexImage2 = resizeVtexImage2(item === null || item === void 0 ? void 0 : (_item_items1 = item.items) === null || _item_items1 === void 0 ? void 0 : (_item_items__images = _item_items1[0].images) === null || _item_items__images === void 0 ? void 0 : _item_items__images[0].imageUrl)) !== null && _resizeVtexImage2 !== void 0 ? _resizeVtexImage2 : null,
|
|
2781
2866
|
seller_id: (_ref5 = (_item_items2 = item.items) === null || _item_items2 === void 0 ? void 0 : (_item_items_2 = _item_items2[0]) === null || _item_items_2 === void 0 ? void 0 : (_item_items__sellers2 = _item_items_2.sellers) === null || _item_items__sellers2 === void 0 ? void 0 : _item_items__sellers2[0].sellerId) !== null && _ref5 !== void 0 ? _ref5 : null,
|
|
2782
2867
|
item_list_name: (_item_item_list_name = item.item_list_name) !== null && _item_item_list_name !== void 0 ? _item_item_list_name : null
|
|
2783
2868
|
};
|
|
@@ -2826,7 +2911,7 @@ var AzzasTracker = function() {
|
|
|
2826
2911
|
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2827
2912
|
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2828
2913
|
return context.products.map(function(item) {
|
|
2829
|
-
var _ref, _item_brand_name, _item_name, _ref1, _ref2, _item_additionalProperty,
|
|
2914
|
+
var _ref, _item_brand_name, _item_name, _ref1, _ref2, _item_additionalProperty, _getItemCategory24, _item_isVariantOf_productGroupID, _item_sku, _resizeVtexImage2, _ref3, _item_item_list_name;
|
|
2830
2915
|
var _item_isVariantOf_hasVariant, _item_isVariantOf, _find, _item_image, _item_offers_offers_find_seller, _item_offers_offers_find, _item_offers_offers, _item_offers;
|
|
2831
2916
|
var listPrice = item.offers.highPrice;
|
|
2832
2917
|
var price = item.offers.lowPrice;
|
|
@@ -2836,6 +2921,7 @@ var AzzasTracker = function() {
|
|
|
2836
2921
|
item_brand: (_item_brand_name = item.brand.name) !== null && _item_brand_name !== void 0 ? _item_brand_name : null,
|
|
2837
2922
|
item_name: (_item_name = item.name) !== null && _item_name !== void 0 ? _item_name : null,
|
|
2838
2923
|
price: price !== null && price !== void 0 ? price : null,
|
|
2924
|
+
item_shipping_tier: null,
|
|
2839
2925
|
discount: Number(listPrice) - Number(price),
|
|
2840
2926
|
item_variant: (_ref1 = (_item_isVariantOf = item.isVariantOf) === null || _item_isVariantOf === void 0 ? void 0 : (_item_isVariantOf_hasVariant = _item_isVariantOf.hasVariant) === null || _item_isVariantOf_hasVariant === void 0 ? void 0 : _item_isVariantOf_hasVariant[0].name.split(" - ")[0]) !== null && _ref1 !== void 0 ? _ref1 : null,
|
|
2841
2927
|
item_variant2: (_ref2 = (_find = ((_item_additionalProperty = item.additionalProperty) !== null && _item_additionalProperty !== void 0 ? _item_additionalProperty : []).find(function(p) {
|
|
@@ -2843,13 +2929,13 @@ var AzzasTracker = function() {
|
|
|
2843
2929
|
})) === null || _find === void 0 ? void 0 : _find.value) !== null && _ref2 !== void 0 ? _ref2 : null,
|
|
2844
2930
|
item_ref: null,
|
|
2845
2931
|
// sem ref no retorno do IS na multi-lib produtos PDC
|
|
2846
|
-
item_category:
|
|
2847
|
-
item_category2: (
|
|
2932
|
+
item_category: getItemCategory6(item),
|
|
2933
|
+
item_category2: (_getItemCategory24 = getItemCategory24(item)) !== null && _getItemCategory24 !== void 0 ? _getItemCategory24 : null,
|
|
2848
2934
|
item_id: (_item_isVariantOf_productGroupID = item.isVariantOf.productGroupID) !== null && _item_isVariantOf_productGroupID !== void 0 ? _item_isVariantOf_productGroupID : null,
|
|
2849
2935
|
item_sku: (_item_sku = item.sku) !== null && _item_sku !== void 0 ? _item_sku : null,
|
|
2850
2936
|
item_url: null,
|
|
2851
2937
|
// sem link/url no retorno do IS na multi-lib produtos PDC
|
|
2852
|
-
image_url: (
|
|
2938
|
+
image_url: (_resizeVtexImage2 = resizeVtexImage2(item === null || item === void 0 ? void 0 : (_item_image = item.image) === null || _item_image === void 0 ? void 0 : _item_image[0].url)) !== null && _resizeVtexImage2 !== void 0 ? _resizeVtexImage2 : null,
|
|
2853
2939
|
seller_id: (_ref3 = (_item_offers = item.offers) === null || _item_offers === void 0 ? void 0 : (_item_offers_offers = _item_offers.offers) === null || _item_offers_offers === void 0 ? void 0 : (_item_offers_offers_find = _item_offers_offers.find(function(o) {
|
|
2854
2940
|
return o.availability;
|
|
2855
2941
|
})) === null || _item_offers_offers_find === void 0 ? void 0 : (_item_offers_offers_find_seller = _item_offers_offers_find.seller) === null || _item_offers_offers_find_seller === void 0 ? void 0 : _item_offers_offers_find_seller.identifier) !== null && _ref3 !== void 0 ? _ref3 : null,
|
|
@@ -2894,7 +2980,7 @@ var AzzasTracker = function() {
|
|
|
2894
2980
|
}
|
|
2895
2981
|
};
|
|
2896
2982
|
// src/params/adapters/headless/index.ts
|
|
2897
|
-
var headlessAdapter = _object_spread_props(_object_spread({}, metaAdapters,
|
|
2983
|
+
var headlessAdapter = _object_spread_props(_object_spread({}, metaAdapters, orderFormAdapter), {
|
|
2898
2984
|
// orderForm adapters, confirmar se no storefront tem evento que usa essses params
|
|
2899
2985
|
brand: function(context) {
|
|
2900
2986
|
if (context.zone === "PDP") {
|
|
@@ -2946,10 +3032,53 @@ var AzzasTracker = function() {
|
|
|
2946
3032
|
return null;
|
|
2947
3033
|
}
|
|
2948
3034
|
});
|
|
3035
|
+
// src/params/adapters/pickup/utils.ts
|
|
3036
|
+
var getShippingTier = function(sla) {
|
|
3037
|
+
var isPickup = sla.deliveryChannel === "pickup-in-point" /* PickupInPoint */ ;
|
|
3038
|
+
if (isPickup) {
|
|
3039
|
+
var _sla_pickupStoreInfo_friendlyName, _sla_pickupStoreInfo;
|
|
3040
|
+
var storeName = (_sla_pickupStoreInfo = sla.pickupStoreInfo) === null || _sla_pickupStoreInfo === void 0 ? void 0 : (_sla_pickupStoreInfo_friendlyName = _sla_pickupStoreInfo.friendlyName) === null || _sla_pickupStoreInfo_friendlyName === void 0 ? void 0 : _sla_pickupStoreInfo_friendlyName.trim();
|
|
3041
|
+
return storeName ? "retirada em loja: ".concat(storeName) : "retirada em loja";
|
|
3042
|
+
}
|
|
3043
|
+
return sla.name ? "receba em casa: ".concat(sla.name.toLowerCase()) : "receba em casa";
|
|
3044
|
+
};
|
|
3045
|
+
var getDeliveryTime = function(sla) {
|
|
3046
|
+
var estimate = sla.shippingEstimate;
|
|
3047
|
+
if (!estimate) return 0;
|
|
3048
|
+
var days = parseInt(estimate, 10);
|
|
3049
|
+
return isNaN(days) ? 0 : days;
|
|
3050
|
+
};
|
|
3051
|
+
// src/params/adapters/pickup/index.ts
|
|
3052
|
+
var pickupAdapter = _object_spread_props(_object_spread({}, metaAdapters), {
|
|
3053
|
+
flag_pickup: function(context) {
|
|
3054
|
+
var _ref;
|
|
3055
|
+
return (_ref = context === null || context === void 0 ? void 0 : context.flag_pickup) !== null && _ref !== void 0 ? _ref : null;
|
|
3056
|
+
},
|
|
3057
|
+
shippings: function(context) {
|
|
3058
|
+
if (context.shippings) {
|
|
3059
|
+
return context.shippings.map(function(s) {
|
|
3060
|
+
var _s_line_items, _s_price;
|
|
3061
|
+
return {
|
|
3062
|
+
line_items: (_s_line_items = s.line_items) !== null && _s_line_items !== void 0 ? _s_line_items : "",
|
|
3063
|
+
shipping: (_s_price = s.price) !== null && _s_price !== void 0 ? _s_price : 0,
|
|
3064
|
+
shipping_tier: getShippingTier(s),
|
|
3065
|
+
delivery_time: getDeliveryTime(s)
|
|
3066
|
+
};
|
|
3067
|
+
});
|
|
3068
|
+
}
|
|
3069
|
+
return null;
|
|
3070
|
+
},
|
|
3071
|
+
zipcode: function(context) {
|
|
3072
|
+
var _context_zipcode;
|
|
3073
|
+
return (_context_zipcode = context.zipcode) !== null && _context_zipcode !== void 0 ? _context_zipcode : null;
|
|
3074
|
+
}
|
|
3075
|
+
});
|
|
2949
3076
|
// src/formatter.ts
|
|
2950
3077
|
var adapters = {
|
|
2951
3078
|
DECO: decoAdapter,
|
|
2952
|
-
HEADLESS: headlessAdapter
|
|
3079
|
+
HEADLESS: headlessAdapter,
|
|
3080
|
+
PICKUP: pickupAdapter,
|
|
3081
|
+
ORDERFORM: orderFormAdapter
|
|
2953
3082
|
};
|
|
2954
3083
|
var src_default = {
|
|
2955
3084
|
trackWebEvent: trackWebEvent,
|