@citygross/components 0.7.178 → 0.7.180

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.
@@ -24,26 +24,36 @@ var calculateSummaryLine = function (items) {
24
24
  return sumOfItems;
25
25
  };
26
26
  function CartSummary(_a) {
27
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
28
- var _m = _a.saveLabel, saveLabel = _m === void 0 ? 'Rabatter' : _m, _o = _a.shippingLabel, shippingLabel = _o === void 0 ? 'frakt' : _o, _p = _a.totalLabel, totalLabel = _p === void 0 ? 'totalt' : _p, _q = _a.taxLabel, taxLabel = _q === void 0 ? 'varav moms' : _q, cartSummary = __rest(_a, ["saveLabel", "shippingLabel", "totalLabel", "taxLabel"]);
27
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
28
+ var _p = _a.saveLabel, saveLabel = _p === void 0 ? 'Rabatter' : _p, _q = _a.shippingLabel, shippingLabel = _q === void 0 ? 'frakt' : _q, _r = _a.totalLabel, totalLabel = _r === void 0 ? 'totalt' : _r, _s = _a.taxLabel, taxLabel = _s === void 0 ? 'varav moms' : _s, cartSummary = __rest(_a, ["saveLabel", "shippingLabel", "totalLabel", "taxLabel"]);
29
29
  var charges = (_b = cartSummary.charges) !== null && _b !== void 0 ? _b : [];
30
30
  var bags = (_c = cartSummary.bags) !== null && _c !== void 0 ? _c : [];
31
31
  var groceries = (_d = cartSummary.groceries) !== null && _d !== void 0 ? _d : [];
32
+ var cateredMeals = (_e = cartSummary === null || cartSummary === void 0 ? void 0 : cartSummary.cateredMeals) !== null && _e !== void 0 ? _e : [];
32
33
  var sumOfBags = calculateSummaryLine(bags);
33
34
  var sumOfGroceries = calculateSummaryLine(groceries);
35
+ var sumOfCateredMeals = calculateSummaryLine(cateredMeals);
34
36
  return (React.createElement(CartSummaryContainer, null,
35
37
  React.createElement(CartPaymentContainer, null,
36
38
  cartSummary.title && (React.createElement(CartSummaryTitle, null,
37
39
  React.createElement(H3, null, cartSummary.title),
38
40
  React.createElement(BodyText, null, cartSummary.subTitle))),
39
41
  React.createElement(CartSummaryHeader, { title: cartSummary.title },
42
+ (cateredMeals === null || cateredMeals === void 0 ? void 0 : cateredMeals.length) > 0 && (React.createElement(CartLine, null,
43
+ React.createElement(BodyText, null,
44
+ "catering ",
45
+ sumOfCateredMeals.quantity,
46
+ " st"),
47
+ React.createElement(AmountWrapper, null,
48
+ sumOfCateredMeals.cancelledAmount > 0 && (React.createElement(BodyText, { lineThrough: true, color: (_f = theme_1 === null || theme_1 === void 0 ? void 0 : theme_1.palette) === null || _f === void 0 ? void 0 : _f.dark }, formatPrice(sumOfCateredMeals.cancelledAmount))),
49
+ React.createElement(H3, { fontWeight: 'semiBold' }, formatPrice(sumOfCateredMeals.amount))))),
40
50
  bags.length > 0 && (React.createElement(CartLine, null,
41
51
  React.createElement(BodyText, null,
42
52
  "matkassar ",
43
53
  sumOfBags.quantity,
44
54
  " st"),
45
55
  React.createElement(AmountWrapper, null,
46
- sumOfBags.cancelledAmount > 0 && (React.createElement(BodyText, { lineThrough: true, color: (_e = theme_1 === null || theme_1 === void 0 ? void 0 : theme_1.palette) === null || _e === void 0 ? void 0 : _e.dark }, formatPrice(sumOfBags.cancelledAmount))),
56
+ sumOfBags.cancelledAmount > 0 && (React.createElement(BodyText, { lineThrough: true, color: (_g = theme_1 === null || theme_1 === void 0 ? void 0 : theme_1.palette) === null || _g === void 0 ? void 0 : _g.dark }, formatPrice(sumOfBags.cancelledAmount))),
47
57
  React.createElement(H3, { fontWeight: 'semiBold' }, formatPrice(sumOfBags.amount))))),
48
58
  groceries.length > 0 && (React.createElement(CartLine, null,
49
59
  React.createElement(BodyText, null,
@@ -51,9 +61,9 @@ function CartSummary(_a) {
51
61
  sumOfGroceries.quantity,
52
62
  " st"),
53
63
  React.createElement(AmountWrapper, null,
54
- sumOfGroceries.cancelledAmount > 0 && (React.createElement(BodyText, { lineThrough: true, color: (_f = theme_1 === null || theme_1 === void 0 ? void 0 : theme_1.palette) === null || _f === void 0 ? void 0 : _f.dark }, formatPrice(sumOfGroceries.cancelledAmount))),
64
+ sumOfGroceries.cancelledAmount > 0 && (React.createElement(BodyText, { lineThrough: true, color: (_h = theme_1 === null || theme_1 === void 0 ? void 0 : theme_1.palette) === null || _h === void 0 ? void 0 : _h.dark }, formatPrice(sumOfGroceries.cancelledAmount))),
55
65
  React.createElement(H3, { fontWeight: 'semiBold' }, formatPrice(sumOfGroceries.amount))))),
56
- (charges === null || charges === void 0 ? void 0 : charges.length) > 0 && (React.createElement(Divider, { xsSpacing: (_g = theme_1.spacings) === null || _g === void 0 ? void 0 : _g.xs, lgSpacing: (_h = theme_1.spacings) === null || _h === void 0 ? void 0 : _h.xs })), charges === null || charges === void 0 ? void 0 :
66
+ (charges === null || charges === void 0 ? void 0 : charges.length) > 0 && (React.createElement(Divider, { xsSpacing: (_j = theme_1.spacings) === null || _j === void 0 ? void 0 : _j.xs, lgSpacing: (_k = theme_1.spacings) === null || _k === void 0 ? void 0 : _k.xs })), charges === null || charges === void 0 ? void 0 :
57
67
  charges.map(function (charge) {
58
68
  var _a, _b;
59
69
  return (React.createElement(CartLine, { key: charge.name },
@@ -63,10 +73,10 @@ function CartSummary(_a) {
63
73
  React.createElement(BodyText, null, formatPrice(charge.amount)))));
64
74
  }),
65
75
  cartSummary.totalDiscount > 0 && (React.createElement(CartLine, null,
66
- React.createElement(BodyText, { color: (_j = theme_1 === null || theme_1 === void 0 ? void 0 : theme_1.palette) === null || _j === void 0 ? void 0 : _j.alertRed }, saveLabel),
67
- React.createElement(BodyText, { color: (_k = theme_1 === null || theme_1 === void 0 ? void 0 : theme_1.palette) === null || _k === void 0 ? void 0 : _k.alertRed }, formatPrice(cartSummary.totalDiscount))))),
76
+ React.createElement(BodyText, { color: (_l = theme_1 === null || theme_1 === void 0 ? void 0 : theme_1.palette) === null || _l === void 0 ? void 0 : _l.alertRed }, saveLabel),
77
+ React.createElement(BodyText, { color: (_m = theme_1 === null || theme_1 === void 0 ? void 0 : theme_1.palette) === null || _m === void 0 ? void 0 : _m.alertRed }, formatPrice(cartSummary.totalDiscount))))),
68
78
  React.createElement(CartSummaryFooter, null,
69
- ((_l = cartSummary.deliveryFee) === null || _l === void 0 ? void 0 : _l.amount) &&
79
+ ((_o = cartSummary.deliveryFee) === null || _o === void 0 ? void 0 : _o.amount) &&
70
80
  cartSummary.deliveryFee.amount > 0 && (React.createElement(CartLine, null,
71
81
  React.createElement(BodyText, null, shippingLabel),
72
82
  React.createElement(BodyText, null, formatPrice(cartSummary.deliveryFee.amount)))),
@@ -1 +1 @@
1
- {"version":3,"file":"CartSummary.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"CartSummary.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -21,6 +21,27 @@ var formatPrice = function (price, withParenthesis) {
21
21
  return "".concat(withParenthesis ? "(".concat(formattedPrice, " kr)") : "".concat(formattedPrice, " kr"));
22
22
  };
23
23
 
24
+ var formatPriceWithDecimalsReduced = function (price) {
25
+ if ((price !== 0 && !price) || isNaN(price)) {
26
+ return null;
27
+ }
28
+ var priceArr = price && price.toString().split('.');
29
+ var decimalCount = priceArr && priceArr[1] ? priceArr[1].length : 0;
30
+ //Remove decimals
31
+ var priceInteger = Math.trunc(price);
32
+ // Avoid rounding errors, since JS can't do math
33
+ var priceDecimals = (price - priceInteger).toFixed(2).toString();
34
+ var decimalsArr = priceDecimals.split('.');
35
+ priceDecimals = decimalsArr.length > 1 ? decimalsArr[1] : priceDecimals;
36
+ // Pad with leading 0 if single number
37
+ var priceDecimalsReduced = priceDecimals.length < 2 ? '0' + priceDecimals : priceDecimals;
38
+ return {
39
+ value: priceInteger,
40
+ decimal: priceDecimalsReduced,
41
+ decimalCount: decimalCount
42
+ };
43
+ };
44
+
24
45
  var capitalizeFirstLetter = function (string) {
25
46
  if (string.length > 1) {
26
47
  return string.charAt(0).toUpperCase() + string.slice(1);
@@ -18592,6 +18613,7 @@ moment.locale(Locale.swedish);
18592
18613
  build.capitalizeFirstLetter = capitalizeFirstLetter;
18593
18614
  build.emailRegex = emailRegex;
18594
18615
  build.formatPrice = formatPrice;
18616
+ build.formatPriceWithDecimalsReduced = formatPriceWithDecimalsReduced;
18595
18617
  build.getCountryFromLanguageCode = getCountryFromLanguageCode;
18596
18618
  build.languageCodeToCountryMap = languageCodeToCountryMap;
18597
18619
  build.moment = moment;