kupos-ui-components-lib 10.4.71 → 10.4.72

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.
@@ -113,7 +113,7 @@ function toDiscountLabel(discount, currencySign) {
113
113
  }
114
114
  return `${Math.round(discount.amount)}% de dcto`;
115
115
  }
116
- // Groups services into one card per discount category. Remate/wow-deal is always the first card.
116
+ // Groups services into one card per discount category, ordered from highest to lowest discount.
117
117
  export function deriveDiscountCards(services = [], wowDealData, currencySign = "$") {
118
118
  var _a, _b, _c, _d, _e;
119
119
  const cards = new Map();
@@ -217,5 +217,12 @@ export function deriveDiscountCards(services = [], wowDealData, currencySign = "
217
217
  return a.name.localeCompare(b.name, "es", { sensitivity: "base" });
218
218
  });
219
219
  }
220
- return Array.from(cards.values());
220
+ // Highest discount first. Percentages and fixed amounts can't be compared, so percentages
221
+ // lead. The sort is stable, so on a tie Remate stays ahead and the rest keep service order.
222
+ return Array.from(cards.values()).sort((a, b) => {
223
+ if (a.discountType !== b.discountType) {
224
+ return a.discountType === "percentage" ? -1 : 1;
225
+ }
226
+ return b.amount - a.amount;
227
+ });
221
228
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kupos-ui-components-lib",
3
- "version": "10.4.71",
3
+ "version": "10.4.72",
4
4
  "description": "A reusable UI components package",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -158,7 +158,7 @@ function toDiscountLabel(
158
158
  return `${Math.round(discount.amount)}% de dcto`;
159
159
  }
160
160
 
161
- // Groups services into one card per discount category. Remate/wow-deal is always the first card.
161
+ // Groups services into one card per discount category, ordered from highest to lowest discount.
162
162
  export function deriveDiscountCards(
163
163
  services: DiscountBannerServiceItem[] = [],
164
164
  wowDealData?: WowDealData,
@@ -276,5 +276,12 @@ export function deriveDiscountCards(
276
276
  });
277
277
  }
278
278
 
279
- return Array.from(cards.values());
279
+ // Highest discount first. Percentages and fixed amounts can't be compared, so percentages
280
+ // lead. The sort is stable, so on a tie Remate stays ahead and the rest keep service order.
281
+ return Array.from(cards.values()).sort((a, b) => {
282
+ if (a.discountType !== b.discountType) {
283
+ return a.discountType === "percentage" ? -1 : 1;
284
+ }
285
+ return b.amount - a.amount;
286
+ });
280
287
  }