@widergy/utilitygo-smart-bill-web 3.1.0 → 3.3.0

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 (40) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/components/SmartBillSummary/constants.js +24 -0
  3. package/dist/components/SmartBillSummary/index.js +95 -0
  4. package/dist/components/SmartBillSummary/styles.module.scss +48 -0
  5. package/dist/components/SmartBillSummary/tabs/Billing/components/DebtStatusLabel/constants.js +9 -0
  6. package/dist/components/SmartBillSummary/tabs/Billing/components/DebtStatusLabel/index.js +34 -0
  7. package/dist/components/SmartBillSummary/tabs/Billing/components/DebtStatusLabel/styles.module.scss +16 -0
  8. package/dist/components/SmartBillSummary/tabs/Billing/components/RateCard/components/ProgressBar/constants.js +8 -0
  9. package/dist/components/SmartBillSummary/tabs/Billing/components/RateCard/components/ProgressBar/index.js +154 -0
  10. package/dist/components/SmartBillSummary/tabs/Billing/components/RateCard/components/ProgressBar/styles.module.scss +174 -0
  11. package/dist/components/SmartBillSummary/tabs/Billing/components/RateCard/components/ProgressBar/utils.js +88 -0
  12. package/dist/components/SmartBillSummary/tabs/Billing/components/RateCard/index.js +165 -0
  13. package/dist/components/SmartBillSummary/tabs/Billing/components/RateCard/styles.module.scss +60 -0
  14. package/dist/components/SmartBillSummary/tabs/Billing/components/RateCard/utils.js +14 -0
  15. package/dist/components/SmartBillSummary/tabs/Billing/index.js +288 -0
  16. package/dist/components/SmartBillSummary/tabs/Billing/styles.module.scss +132 -0
  17. package/dist/components/SmartBillSummary/tabs/Billing/utils.js +13 -0
  18. package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/constants.js +9 -0
  19. package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/index.js +90 -0
  20. package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/styles.module.scss +55 -0
  21. package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/utils.js +32 -0
  22. package/dist/components/SmartBillSummary/tabs/Consumptions/components/BimestralConsumption/constants.js +13 -0
  23. package/dist/components/SmartBillSummary/tabs/Consumptions/components/BimestralConsumption/index.js +78 -0
  24. package/dist/components/SmartBillSummary/tabs/Consumptions/components/BimestralConsumption/styles.module.scss +43 -0
  25. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionComparison/constants.js +9 -0
  26. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionComparison/index.js +68 -0
  27. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionComparison/styles.module.scss +43 -0
  28. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionComparison/utils.js +35 -0
  29. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionEvolution/index.js +72 -0
  30. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionEvolution/styles.module.scss +29 -0
  31. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionEvolution/utils.js +71 -0
  32. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/index.js +64 -0
  33. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/styles.module.scss +22 -0
  34. package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/utils.js +56 -0
  35. package/dist/components/SmartBillSummary/tabs/Consumptions/index.js +54 -0
  36. package/dist/components/SmartBillSummary/tabs/Consumptions/styles.module.scss +31 -0
  37. package/dist/components/SmartBillSummary/utils.js +30 -0
  38. package/dist/index.js +14 -0
  39. package/dist/shared/constants/tabs.js +11 -0
  40. package/package.json +1 -1
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = require("prop-types");
9
+ var _energyUi = require("@widergy/energy-ui");
10
+ var _lodash = require("lodash");
11
+ var _billDataTypes = require("../../../../../../shared/types/billDataTypes");
12
+ var _utils = require("./utils");
13
+ var _constants = require("./constants");
14
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ const Billing = _ref => {
17
+ let {
18
+ smartBill,
19
+ texts
20
+ } = _ref;
21
+ const {
22
+ title,
23
+ tagLabel,
24
+ clarification,
25
+ periodDetail
26
+ } = texts?.billing || {};
27
+ const currentPeriod = smartBill?.periods.find(period => period.current);
28
+ const billingsToShow = (0, _utils.getBillingsToShow)(currentPeriod?.settlements);
29
+ return /*#__PURE__*/_react.default.createElement("div", {
30
+ className: _stylesModule.default.container
31
+ }, /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
32
+ colorTheme: "gray",
33
+ variant: "small"
34
+ }, title), /*#__PURE__*/_react.default.createElement("div", {
35
+ className: _stylesModule.default.details
36
+ }, billingsToShow.map(_ref2 => {
37
+ let {
38
+ colorTheme,
39
+ consumptions,
40
+ current,
41
+ icon,
42
+ issued_on: issuedOn,
43
+ number
44
+ } = _ref2;
45
+ const monthName = (0, _utils.getMonthName)(issuedOn);
46
+ const consumptionValue = consumptions?.[0].value;
47
+ const consumptionUnit = consumptions?.[0].unit;
48
+ return /*#__PURE__*/_react.default.createElement("div", {
49
+ key: issuedOn,
50
+ className: `${_stylesModule.default.billing} ${current ? _stylesModule.default.currentBilling : ''}`
51
+ }, /*#__PURE__*/_react.default.createElement("div", {
52
+ className: _stylesModule.default.consumptionDetail
53
+ }, /*#__PURE__*/_react.default.createElement("div", {
54
+ className: _stylesModule.default.consumption
55
+ }, /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
56
+ variant: "title3",
57
+ weight: "medium"
58
+ }, consumptionValue), /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
59
+ variant: "subtitle1",
60
+ weight: "medium"
61
+ }, consumptionUnit)), /*#__PURE__*/_react.default.createElement("div", {
62
+ className: `${_stylesModule.default.tag} ${current ? _stylesModule.default.billedTag : ''}`
63
+ }, /*#__PURE__*/_react.default.createElement(_energyUi.UTIcon, {
64
+ colorTheme: colorTheme || _constants.DEFAULT_TAG_COLOR_THEME,
65
+ name: icon || _constants.DEFAULT_TAG_ICON,
66
+ size: _constants.TAG_ICON_SIZE
67
+ }), /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
68
+ colorTheme: current ? 'success' : 'gray',
69
+ variant: "xsmall",
70
+ weight: "medium",
71
+ withMarkdown: true
72
+ }, tagLabel(current)))), /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
73
+ colorTheme: "gray"
74
+ }, periodDetail({
75
+ monthName,
76
+ number
77
+ })));
78
+ })), /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
79
+ className: _stylesModule.default.clarifications,
80
+ withMarkdown: true
81
+ }, clarification({
82
+ firstMonth: (0, _lodash.capitalize)((0, _utils.getMonthName)(billingsToShow?.[1]?.issued_on)),
83
+ secondMonth: (0, _lodash.capitalize)((0, _utils.getMonthName)(billingsToShow?.[0]?.issued_on))
84
+ })));
85
+ };
86
+ Billing.propTypes = {
87
+ smartBill: _billDataTypes.billDataTypes,
88
+ texts: _propTypes.object
89
+ };
90
+ var _default = exports.default = Billing;
@@ -0,0 +1,55 @@
1
+ .container {
2
+ background-color: var(--light01);
3
+ border-radius: 8px;
4
+ box-shadow: var(--shadowGrayBottom1);
5
+ flex: 1;
6
+ height: fit-content;
7
+ padding: 24px;
8
+ }
9
+
10
+ .details {
11
+ margin: 24px -24px 0;
12
+ }
13
+
14
+ .billing {
15
+ border-bottom: 1px solid var(--light04);
16
+ display: flex;
17
+ flex-direction: column;
18
+ grid-gap: 12px;
19
+ padding: 16px 24px;
20
+ }
21
+
22
+ .currentBilling {
23
+ background-color: var(--semanticSuccess01);
24
+ }
25
+
26
+ .consumption {
27
+ align-items: flex-end;
28
+ display: flex;
29
+ grid-gap: 8px;
30
+ }
31
+
32
+ .consumptionDetail {
33
+ align-items: center;
34
+ display: flex;
35
+ grid-gap: 12px;
36
+ justify-content: space-between;
37
+ }
38
+
39
+ .tag {
40
+ align-items: center;
41
+ background-color: var(--light04);
42
+ border-radius: 4px;
43
+ display: flex;
44
+ grid-gap: 4px;
45
+ justify-content: space-between;
46
+ padding: 4px 8px;
47
+ }
48
+
49
+ .billedTag {
50
+ background-color: var(--semanticSuccess02);
51
+ }
52
+
53
+ .clarifications {
54
+ padding: 16px 0;
55
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getMonthName = exports.getConsumptionLabel = exports.getBillingsToShow = void 0;
7
+ var _dayjs = _interopRequireDefault(require("dayjs"));
8
+ require("dayjs/locale/es");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ _dayjs.default.locale('es');
11
+ const getBillingsToShow = settlements => {
12
+ const currentBilling = {
13
+ ...settlements?.current,
14
+ colorTheme: 'success',
15
+ current: true,
16
+ icon: 'IconCheck'
17
+ };
18
+ const remainingBillings = settlements?.remaining || [];
19
+ return [currentBilling, ...remainingBillings];
20
+ };
21
+ exports.getBillingsToShow = getBillingsToShow;
22
+ const getMonthName = date => (0, _dayjs.default)(date).format('MMMM');
23
+ exports.getMonthName = getMonthName;
24
+ const getConsumptionLabel = consumptions => {
25
+ const consumption = consumptions?.[0];
26
+ const {
27
+ value,
28
+ unit
29
+ } = consumption || {};
30
+ return `${value} ${unit}`;
31
+ };
32
+ exports.getConsumptionLabel = getConsumptionLabel;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CONSUMPTION_CARDS = void 0;
7
+ const CONSUMPTION_CARDS = exports.CONSUMPTION_CARDS = [{
8
+ icon: 'EnergyIconConsumptionBoxFilled',
9
+ key: 'consumptionCalculationCard'
10
+ }, {
11
+ icon: 'IconReceipt2',
12
+ key: 'billingCard'
13
+ }];
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _energyUi = require("@widergy/energy-ui");
9
+ var _propTypes = require("prop-types");
10
+ var _constants = require("./constants");
11
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ const BimestralConsumption = _ref => {
14
+ let {
15
+ assets,
16
+ texts
17
+ } = _ref;
18
+ const bimestralConsumptionTexts = texts?.bimestralConsumption;
19
+ const {
20
+ title: bimestralTitle,
21
+ description: bimestralDescription
22
+ } = bimestralConsumptionTexts || {};
23
+ const {
24
+ BackgroundVector
25
+ } = assets?.bimestral || {};
26
+ return /*#__PURE__*/_react.default.createElement("div", {
27
+ className: _stylesModule.default.bimestralConsumption
28
+ }, /*#__PURE__*/_react.default.createElement("div", {
29
+ className: _stylesModule.default.bimestralConsumptionTitles
30
+ }, /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
31
+ variant: "title3",
32
+ weight: "medium"
33
+ }, bimestralTitle), /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, null, bimestralDescription)), /*#__PURE__*/_react.default.createElement("div", {
34
+ className: _stylesModule.default.bimestralConsumptionCards
35
+ }, _constants.CONSUMPTION_CARDS.map(_ref2 => {
36
+ let {
37
+ icon,
38
+ key
39
+ } = _ref2;
40
+ const title = bimestralConsumptionTexts?.[key]?.title;
41
+ const description = bimestralConsumptionTexts?.[key]?.description;
42
+ return /*#__PURE__*/_react.default.createElement(_energyUi.UTActionCard, {
43
+ adornment: {
44
+ position: 'left',
45
+ type: 'icon',
46
+ props: {
47
+ colorTheme: 'accent',
48
+ name: icon,
49
+ shade: '04',
50
+ size: 100
51
+ }
52
+ },
53
+ BackgroundImage: BackgroundVector,
54
+ classNames: {
55
+ backgroundImage: _stylesModule.default.backgroundImage,
56
+ container: _stylesModule.default.bimestralConsumptionCardContainer,
57
+ header: _stylesModule.default.bimestralConsumptionCardHeader
58
+ },
59
+ description: description,
60
+ descriptionProps: {
61
+ className: _stylesModule.default.bimestralConsumptionCardDescription,
62
+ withMarkdown: true
63
+ },
64
+ key: key,
65
+ size: "small",
66
+ title: title,
67
+ titleProps: {
68
+ variant: 'subtitle2',
69
+ weight: 'medium'
70
+ }
71
+ });
72
+ })));
73
+ };
74
+ BimestralConsumption.propTypes = {
75
+ assets: _propTypes.object,
76
+ texts: _propTypes.object
77
+ };
78
+ var _default = exports.default = BimestralConsumption;
@@ -0,0 +1,43 @@
1
+ $bimestral-consumption-card-min-width: 328px;
2
+
3
+ .bimestralConsumption {
4
+ display: flex;
5
+ flex-direction: column;
6
+ grid-gap: 24px;
7
+ }
8
+
9
+ .bimestralConsumptionTitles {
10
+ display: flex;
11
+ flex-direction: column;
12
+ grid-gap: 8px;
13
+ }
14
+
15
+ .bimestralConsumptionCards {
16
+ align-items: stretch;
17
+ display: flex;
18
+ flex-wrap: wrap;
19
+ grid-gap: 32px;
20
+ justify-content: space-between;
21
+ }
22
+
23
+ .bimestralConsumptionCardHeader {
24
+ align-items: center;
25
+ grid-gap: 12px;
26
+ }
27
+
28
+ .bimestralConsumptionCardContainer {
29
+ flex: 1;
30
+ min-width: $bimestral-consumption-card-min-width;
31
+ }
32
+
33
+ .bimestralConsumptionCardDescription {
34
+ strong {
35
+ color: var(--actionAccent05);
36
+ }
37
+ }
38
+
39
+ .backgroundImage {
40
+ height: 120%;
41
+ object-fit: cover;
42
+ right: -20%;
43
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SCALE_FACTOR = exports.MIN_HEIGHT = exports.MAX_HEIGHT = void 0;
7
+ const MIN_HEIGHT = exports.MIN_HEIGHT = 8;
8
+ const MAX_HEIGHT = exports.MAX_HEIGHT = 160;
9
+ const SCALE_FACTOR = exports.SCALE_FACTOR = 6;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _energyUi = require("@widergy/energy-ui");
9
+ var _billDataTypes = require("@widergy/utilitygo-smart-bill-web/dist/shared/types/billDataTypes");
10
+ var _propTypes = require("prop-types");
11
+ var _utils = require("./utils");
12
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ const ConsumptionComparison = _ref => {
17
+ let {
18
+ periodsToCompare = [],
19
+ texts
20
+ } = _ref;
21
+ const maxValue = (0, _utils.getMaxValue)(periodsToCompare);
22
+ const title = texts?.consumptions?.comparisonTitle;
23
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
24
+ className: _stylesModule.default.consumptionComparisonLabel,
25
+ colorTheme: "gray",
26
+ variant: "small"
27
+ }, title), /*#__PURE__*/_react.default.createElement("div", {
28
+ className: _stylesModule.default.container
29
+ }, periodsToCompare.map(_ref2 => {
30
+ let {
31
+ consumptions,
32
+ current,
33
+ number,
34
+ settlements,
35
+ year
36
+ } = _ref2;
37
+ const {
38
+ value,
39
+ unit
40
+ } = consumptions?.[0] || {};
41
+ const barHeight = (0, _utils.getBarHeight)(maxValue, value);
42
+ return /*#__PURE__*/_react.default.createElement("div", {
43
+ key: number + year,
44
+ className: _stylesModule.default.barContainer
45
+ }, /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
46
+ className: _stylesModule.default.value,
47
+ variant: "small"
48
+ }, (0, _utils.getFormattedValue)(value, unit)), /*#__PURE__*/_react.default.createElement("div", {
49
+ className: `${_stylesModule.default.bar} ${current ? _stylesModule.default.currentBar : ''}`,
50
+ style: {
51
+ height: `${barHeight}px`
52
+ }
53
+ }), /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
54
+ className: _stylesModule.default.year,
55
+ variant: "small",
56
+ weight: "medium"
57
+ }, year), /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
58
+ className: _stylesModule.default.period,
59
+ colorTheme: "gray",
60
+ variant: "small"
61
+ }, (0, _utils.getPeriod)(settlements)));
62
+ })));
63
+ };
64
+ ConsumptionComparison.propTypes = {
65
+ periodsToCompare: _billDataTypes.periodsTypes,
66
+ texts: _propTypes.object
67
+ };
68
+ var _default = exports.default = ConsumptionComparison;
@@ -0,0 +1,43 @@
1
+ .consumptionComparisonLabel {
2
+ margin: 12px 0;
3
+ }
4
+
5
+ .container {
6
+ align-items: flex-end;
7
+ display: flex;
8
+ grid-gap: 16px;
9
+ height: 240px;
10
+ justify-content: center;
11
+ }
12
+
13
+ .barContainer {
14
+ align-items: center;
15
+ display: flex;
16
+ flex: 1;
17
+ flex-direction: column;
18
+ height: 100%;
19
+ justify-content: flex-end;
20
+ }
21
+
22
+ .bar {
23
+ background: var(--chartGradientVertical2);
24
+ border-radius: 6px 6px 0 0;
25
+ transition: height 0.3s ease;
26
+ width: 100%;
27
+ }
28
+
29
+ .currentBar {
30
+ background: var(--chartGradientVertical1);
31
+ }
32
+
33
+ .value {
34
+ margin: 12px 0 4px;
35
+ }
36
+
37
+ .year {
38
+ margin-top: 12px;
39
+ }
40
+
41
+ .period {
42
+ color: var(--gray02);
43
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPeriod = exports.getMaxValue = exports.getFormattedValue = exports.getBarHeight = void 0;
7
+ var _lodash = require("lodash");
8
+ var _dayjs = _interopRequireDefault(require("dayjs"));
9
+ var _numeral = _interopRequireDefault(require("numeral"));
10
+ require("dayjs/locale/es");
11
+ var _constants = require("./constants");
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ _dayjs.default.locale('es');
14
+ const getMaxValue = consumptionData => Math.max(...consumptionData.map(d => d.consumptions?.[0]?.value || 0));
15
+ exports.getMaxValue = getMaxValue;
16
+ const getBarHeight = (maxValue, value) => {
17
+ const adjustedValue = value ** _constants.SCALE_FACTOR;
18
+ const adjustedMax = maxValue ** _constants.SCALE_FACTOR;
19
+ return _constants.MIN_HEIGHT + adjustedValue / adjustedMax * (_constants.MAX_HEIGHT - _constants.MIN_HEIGHT);
20
+ };
21
+ exports.getBarHeight = getBarHeight;
22
+ const getPeriod = function () {
23
+ let settlements = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
24
+ const {
25
+ end_date: endDate,
26
+ start_date: startDate
27
+ } = settlements;
28
+ const previousMonth = (0, _dayjs.default)(startDate);
29
+ const currentMonth = (0, _dayjs.default)(endDate);
30
+ const formattedPeriod = `${(0, _lodash.capitalize)(previousMonth.format('MMM'))} - ${(0, _lodash.capitalize)(currentMonth.format('MMM'))}`;
31
+ return formattedPeriod;
32
+ };
33
+ exports.getPeriod = getPeriod;
34
+ const getFormattedValue = (value, unit) => value ? `${(0, _numeral.default)(value).format('0,0.[00]')} ${unit || ''}` : '-';
35
+ exports.getFormattedValue = getFormattedValue;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _energyUi = require("@widergy/energy-ui");
9
+ var _propTypes = require("prop-types");
10
+ var _billDataTypes = require("@widergy/utilitygo-smart-bill-web/dist/shared/types/billDataTypes");
11
+ var _utils = require("./utils");
12
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ const ConsumptionEvolution = _ref => {
15
+ let {
16
+ assets,
17
+ periods,
18
+ texts
19
+ } = _ref;
20
+ const {
21
+ consumptionEvolution: backgroundImages
22
+ } = assets || {};
23
+ const {
24
+ consumptionEvolution: consumptionEvolutionLabels
25
+ } = texts || {};
26
+ const {
27
+ title
28
+ } = consumptionEvolutionLabels || {};
29
+ const {
30
+ colorTheme,
31
+ description,
32
+ icon,
33
+ Image,
34
+ percentage,
35
+ period
36
+ } = (0, _utils.getConsumptionComparison)(backgroundImages, consumptionEvolutionLabels, periods);
37
+ return /*#__PURE__*/_react.default.createElement(_energyUi.UTActionCard, {
38
+ BackgroundImage: Image,
39
+ classNames: {
40
+ container: _stylesModule.default.container,
41
+ backgroundImage: _stylesModule.default.backgroundImage
42
+ },
43
+ description: description,
44
+ title: title,
45
+ titleProps: {
46
+ variant: 'subtitle1',
47
+ weight: 'medium'
48
+ }
49
+ }, /*#__PURE__*/_react.default.createElement("div", {
50
+ className: _stylesModule.default.childrenContainer
51
+ }, /*#__PURE__*/_react.default.createElement("div", {
52
+ className: _stylesModule.default.chipContainer
53
+ }, /*#__PURE__*/_react.default.createElement(_energyUi.UTIcon, {
54
+ area: true,
55
+ colorTheme: colorTheme,
56
+ name: icon,
57
+ shade: "04",
58
+ size: 24
59
+ }), percentage && /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
60
+ colorTheme: colorTheme,
61
+ variant: "title2",
62
+ weight: "medium"
63
+ }, percentage)), /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
64
+ colorTheme: colorTheme
65
+ }, period)));
66
+ };
67
+ ConsumptionEvolution.propTypes = {
68
+ assets: _propTypes.object,
69
+ periods: _billDataTypes.periodsTypes,
70
+ texts: _propTypes.object
71
+ };
72
+ var _default = exports.default = ConsumptionEvolution;
@@ -0,0 +1,29 @@
1
+ .container {
2
+ background-color: var(--light02);
3
+ box-shadow: none;
4
+ margin-top: 32px;
5
+ }
6
+
7
+ .backgroundImage {
8
+ right: 0;
9
+ width: auto;
10
+ }
11
+
12
+ .chipContainer {
13
+ align-items: center;
14
+ background-color: var(--light01);
15
+ border-radius: 100px;
16
+ box-shadow: var(--shadow);
17
+ display: flex;
18
+ flex-direction: row;
19
+ grid-gap: 8px;
20
+ justify-content: center;
21
+ padding: 4px 8px;
22
+ width: fit-content;
23
+ }
24
+
25
+ .childrenContainer {
26
+ align-items: center;
27
+ display: flex;
28
+ grid-gap: 12px;
29
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getConsumptionComparison = void 0;
7
+ var _lodash = require("lodash");
8
+ const getConsumptionComparison = (backgroundImages, labels, periods) => {
9
+ const {
10
+ noData,
11
+ description,
12
+ successDescription,
13
+ warningDescription,
14
+ bimester
15
+ } = labels || {};
16
+ const {
17
+ LightEvolutionImage,
18
+ WarningEvolutionImage,
19
+ SuccessEvolutionImage
20
+ } = backgroundImages || {};
21
+ const {
22
+ current,
23
+ previous
24
+ } = periods?.reduce((acc, period) => {
25
+ if (period?.current && !acc.current) {
26
+ acc.current = period;
27
+ } else if (!period?.current && !acc.previous) {
28
+ acc.previous = period;
29
+ }
30
+ return acc;
31
+ }, {
32
+ current: null,
33
+ previous: null
34
+ }) || {};
35
+ const currentConsumption = current?.consumptions?.[0]?.value;
36
+ const previousConsumption = previous?.consumptions?.[0]?.value;
37
+ const period = current?.number;
38
+ if (!periods || (0, _lodash.isEmpty)(periods) || !currentConsumption || !previousConsumption) {
39
+ return {
40
+ colorTheme: 'gray',
41
+ description,
42
+ icon: 'IconEyeOff',
43
+ Image: LightEvolutionImage,
44
+ percentage: null,
45
+ period: noData
46
+ };
47
+ }
48
+ const percentageChange = previousConsumption === 0 && currentConsumption === 0 ? 0 : previousConsumption !== 0 ? (currentConsumption - previousConsumption) / previousConsumption * 100 : 100;
49
+ const formattedPercentage = `${Math.abs(Math.round(percentageChange))}%`;
50
+ if (currentConsumption > previousConsumption) {
51
+ return {
52
+ colorTheme: 'warning',
53
+ description: warningDescription(formattedPercentage),
54
+ icon: 'IconArrowUpRight',
55
+ Image: WarningEvolutionImage,
56
+ percentage: formattedPercentage,
57
+ period: bimester(period)
58
+ };
59
+ }
60
+ if (currentConsumption <= previousConsumption) {
61
+ return {
62
+ colorTheme: 'success',
63
+ description: successDescription(formattedPercentage),
64
+ icon: 'IconArrowDownRight',
65
+ Image: SuccessEvolutionImage,
66
+ percentage: formattedPercentage,
67
+ period: bimester(period)
68
+ };
69
+ }
70
+ };
71
+ exports.getConsumptionComparison = getConsumptionComparison;