@citygross/components 0.8.14 → 0.8.16

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.
@@ -21,12 +21,11 @@ exports.ECartSubTotalTypes = void 0;
21
21
  var CartSubTotal = function (_a) {
22
22
  var _b;
23
23
  var label = _a.label, value = _a.value, children = _a.children, info = _a.info, type = _a.type, fromPriceLabel = _a.fromPriceLabel, infoOnBottom = _a.infoOnBottom, _c = _a.priceColor, priceColor = _c === void 0 ? (_b = designTokens.theme.palette) === null || _b === void 0 ? void 0 : _b.darkest : _c;
24
- var formattedPrice = utils.formatPriceWithDecimalsReduced(value);
24
+ var formattedPrice = utils.formatPriceWithNoZero(value);
25
25
  var _d = React.useState(false), infoOpen = _d[0], setInfoOpen = _d[1];
26
26
  var toggleInfoOpen = function () {
27
27
  setInfoOpen(!infoOpen);
28
28
  };
29
- console.log('formattedPrice', formattedPrice);
30
29
  return info !== undefined ? (React__default["default"].createElement(CartSubTotal_styles.CartSubTotalContainer, { type: type },
31
30
  React__default["default"].createElement(CartSubTotal_styles.SubTotalLabel, null,
32
31
  label,
@@ -35,19 +34,14 @@ var CartSubTotal = function (_a) {
35
34
  React__default["default"].createElement(icons.Icons.Info, { height: 16, width: 16 }))),
36
35
  React__default["default"].createElement(CartSubTotal_styles.Price, { priceColor: priceColor }, (value !== 0 && !value) || isNaN(value)
37
36
  ? '-'
38
- : "".concat(fromPriceLabel || '', " ").concat("".concat(formattedPrice === null || formattedPrice === void 0 ? void 0 : formattedPrice.value).concat((formattedPrice === null || formattedPrice === void 0 ? void 0 : formattedPrice.decimal) !== '00'
39
- ? ",".concat(formattedPrice === null || formattedPrice === void 0 ? void 0 : formattedPrice.decimal)
40
- : ''), " kr")),
37
+ : "".concat(fromPriceLabel || '', " ").concat(formattedPrice, " kr")),
41
38
  infoOpen && (React__default["default"].createElement(ToolTipDialog.ToolTipDialog, { onBottom: infoOnBottom, info: info, toggle: toggleInfoOpen })))) : (React__default["default"].createElement(CartSubTotal_styles.CartSubTotalContainer, { type: type },
42
39
  React__default["default"].createElement(CartSubTotal_styles.SubTotalLabel, null,
43
40
  label,
44
41
  children),
45
- value !== undefined ? (React__default["default"].createElement(CartSubTotal_styles.Price, { priceColor: priceColor }, formattedPrice === null || formattedPrice === void 0 ? void 0 :
46
- formattedPrice.value, "".concat((formattedPrice === null || formattedPrice === void 0 ? void 0 : formattedPrice.decimal) !== '00'
47
- ? ",".concat(formattedPrice === null || formattedPrice === void 0 ? void 0 : formattedPrice.decimal)
48
- : ''),
49
- ' ',
50
- "kr")) : null));
42
+ value !== undefined ? (React__default["default"].createElement(CartSubTotal_styles.Price, { priceColor: priceColor },
43
+ formattedPrice,
44
+ " kr")) : null));
51
45
  };
52
46
 
53
47
  exports.CartSubTotal = CartSubTotal;
@@ -1 +1 @@
1
- {"version":3,"file":"CartSubTotal.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"CartSubTotal.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -24,7 +24,10 @@ var formatPrice = function (price, withParenthesis) {
24
24
  }
25
25
  var formattedPrice = price === 0
26
26
  ? 0
27
- : (Math.round(price * 100) / 100).toFixed(2).replace('.', ',');
27
+ : (Math.round(price * 100) / 100)
28
+ .toFixed(2)
29
+ .replace('.', ',')
30
+ .replace(',00', '');
28
31
  return "".concat(withParenthesis ? "(".concat(formattedPrice, " kr)") : "".concat(formattedPrice, " kr"));
29
32
  };
30
33
 
@@ -49,6 +52,14 @@ var formatPriceWithDecimalsReduced = function (price) {
49
52
  };
50
53
  };
51
54
 
55
+ var formatPriceWithNoZero = function (price) {
56
+ if ((price !== 0 && !price) || isNaN(price)) {
57
+ return null;
58
+ }
59
+ var formattedPrice = formatPriceWithDecimalsReduced(price);
60
+ return "".concat(formattedPrice === null || formattedPrice === void 0 ? void 0 : formattedPrice.value).concat("".concat((formattedPrice === null || formattedPrice === void 0 ? void 0 : formattedPrice.decimal) !== '00' ? ",".concat(formattedPrice === null || formattedPrice === void 0 ? void 0 : formattedPrice.decimal) : ''));
61
+ };
62
+
52
63
  var capitalizeFirstLetter = function (string) {
53
64
  if (string.length > 1) {
54
65
  return string.charAt(0).toUpperCase() + string.slice(1);
@@ -18715,6 +18726,7 @@ index.__exports.formatLeadingZero = formatLeadingZero;
18715
18726
  index.__exports.formatPostalCode = formatPostalCode;
18716
18727
  index.__exports.formatPrice = formatPrice;
18717
18728
  index.__exports.formatPriceWithDecimalsReduced = formatPriceWithDecimalsReduced;
18729
+ index.__exports.formatPriceWithNoZero = formatPriceWithNoZero;
18718
18730
  index.__exports.getCountryFromLanguageCode = getCountryFromLanguageCode;
18719
18731
  index.__exports.languageCodeToCountryMap = languageCodeToCountryMap;
18720
18732
  index.__exports.makeCateringPortionsString = makeCateringPortionsString;