@infrab4a/connect 5.5.6-beta.1 → 5.5.6-beta.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.
Files changed (3) hide show
  1. package/index.cjs.js +15 -12
  2. package/index.esm.js +15 -12
  3. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -2435,9 +2435,9 @@ class ShopSettings extends BaseModel {
2435
2435
  if (section.type === ShopPageSectionType.CAROUSEL && Array.isArray(section.banners)) {
2436
2436
  const filteredBanners = section.banners.filter((banner) => {
2437
2437
  // Filtra por displayRules
2438
- const rulesMatch = banner.displayRules
2439
- ? Object.keys(displayRules).some((key) => banner.displayRules && banner.displayRules[key] === displayRules[key])
2440
- : false;
2438
+ const rulesMatch = banner.displayRules.length
2439
+ ? banner.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2440
+ : true;
2441
2441
  // Filtra por publishDate e expirationDate
2442
2442
  const publishOk = !banner.publishDate || now >= new Date(banner.publishDate);
2443
2443
  const expireOk = !banner.expirationDate || now <= new Date(banner.expirationDate);
@@ -2449,27 +2449,30 @@ class ShopSettings extends BaseModel {
2449
2449
  if (section.type === ShopPageSectionType.HIGHLIGHTS && Array.isArray(section.highlights)) {
2450
2450
  const filteredHighlights = section.highlights.filter((highlight) => {
2451
2451
  // Filtra por displayRules
2452
- const rulesMatch = highlight.displayRules
2453
- ? Object.keys(displayRules).some((key) => highlight.displayRules && highlight.displayRules[key] === displayRules[key])
2454
- : false;
2452
+ const rulesMatch = highlight.displayRules.length
2453
+ ? highlight.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2454
+ : true;
2455
2455
  return rulesMatch;
2456
2456
  });
2457
2457
  return { ...section, highlights: filteredHighlights };
2458
2458
  }
2459
2459
  // Filtra collections
2460
2460
  if (section.type === ShopPageSectionType.COLLECTION) {
2461
- const rulesMatch = section.displayRules
2462
- ? Object.keys(displayRules).some((key) => section.displayRules && section.displayRules[key] === displayRules[key])
2463
- : false;
2461
+ console.warn('SECTION', section.title, section.slug, displayRules);
2462
+ const rulesMatch = section.displayRules.length
2463
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2464
+ : true;
2465
+ console.warn('RULES MATCH', rulesMatch);
2464
2466
  const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2465
2467
  const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2468
+ console.warn('PUBLISH OK', publishOk, 'EXPIRE OK', expireOk);
2466
2469
  return rulesMatch && publishOk && expireOk ? section : null;
2467
2470
  }
2468
2471
  // Filtra banners
2469
2472
  if (section.type === ShopPageSectionType.BANNER) {
2470
- const rulesMatch = section.displayRules
2471
- ? Object.keys(displayRules).some((key) => section.displayRules && section.displayRules[key] === displayRules[key])
2472
- : false;
2473
+ const rulesMatch = section.displayRules.length
2474
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2475
+ : true;
2473
2476
  const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2474
2477
  const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2475
2478
  return rulesMatch && publishOk && expireOk ? section : null;
package/index.esm.js CHANGED
@@ -2411,9 +2411,9 @@ class ShopSettings extends BaseModel {
2411
2411
  if (section.type === ShopPageSectionType.CAROUSEL && Array.isArray(section.banners)) {
2412
2412
  const filteredBanners = section.banners.filter((banner) => {
2413
2413
  // Filtra por displayRules
2414
- const rulesMatch = banner.displayRules
2415
- ? Object.keys(displayRules).some((key) => banner.displayRules && banner.displayRules[key] === displayRules[key])
2416
- : false;
2414
+ const rulesMatch = banner.displayRules.length
2415
+ ? banner.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2416
+ : true;
2417
2417
  // Filtra por publishDate e expirationDate
2418
2418
  const publishOk = !banner.publishDate || now >= new Date(banner.publishDate);
2419
2419
  const expireOk = !banner.expirationDate || now <= new Date(banner.expirationDate);
@@ -2425,27 +2425,30 @@ class ShopSettings extends BaseModel {
2425
2425
  if (section.type === ShopPageSectionType.HIGHLIGHTS && Array.isArray(section.highlights)) {
2426
2426
  const filteredHighlights = section.highlights.filter((highlight) => {
2427
2427
  // Filtra por displayRules
2428
- const rulesMatch = highlight.displayRules
2429
- ? Object.keys(displayRules).some((key) => highlight.displayRules && highlight.displayRules[key] === displayRules[key])
2430
- : false;
2428
+ const rulesMatch = highlight.displayRules.length
2429
+ ? highlight.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2430
+ : true;
2431
2431
  return rulesMatch;
2432
2432
  });
2433
2433
  return { ...section, highlights: filteredHighlights };
2434
2434
  }
2435
2435
  // Filtra collections
2436
2436
  if (section.type === ShopPageSectionType.COLLECTION) {
2437
- const rulesMatch = section.displayRules
2438
- ? Object.keys(displayRules).some((key) => section.displayRules && section.displayRules[key] === displayRules[key])
2439
- : false;
2437
+ console.warn('SECTION', section.title, section.slug, displayRules);
2438
+ const rulesMatch = section.displayRules.length
2439
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2440
+ : true;
2441
+ console.warn('RULES MATCH', rulesMatch);
2440
2442
  const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2441
2443
  const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2444
+ console.warn('PUBLISH OK', publishOk, 'EXPIRE OK', expireOk);
2442
2445
  return rulesMatch && publishOk && expireOk ? section : null;
2443
2446
  }
2444
2447
  // Filtra banners
2445
2448
  if (section.type === ShopPageSectionType.BANNER) {
2446
- const rulesMatch = section.displayRules
2447
- ? Object.keys(displayRules).some((key) => section.displayRules && section.displayRules[key] === displayRules[key])
2448
- : false;
2449
+ const rulesMatch = section.displayRules.length
2450
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2451
+ : true;
2449
2452
  const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2450
2453
  const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2451
2454
  return rulesMatch && publishOk && expireOk ? section : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.5.6-beta.1",
3
+ "version": "5.5.6-beta.2",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },