@widergy/utilitygo-smart-bill-web 3.1.0 → 3.2.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.
- package/CHANGELOG.md +7 -0
- package/dist/components/SmartBillSummary/constants.js +25 -0
- package/dist/components/SmartBillSummary/index.js +70 -0
- package/dist/components/SmartBillSummary/styles.module.scss +48 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/constants.js +9 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/index.js +90 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/styles.module.scss +55 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/utils.js +32 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/BimestralConsumption/constants.js +13 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/BimestralConsumption/index.js +78 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/BimestralConsumption/styles.module.scss +43 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionComparison/constants.js +9 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionComparison/index.js +68 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionComparison/styles.module.scss +43 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionComparison/utils.js +35 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionEvolution/index.js +72 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionEvolution/styles.module.scss +29 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/components/ConsumptionEvolution/utils.js +71 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/index.js +64 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/styles.module.scss +22 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/utils.js +56 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/index.js +54 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/styles.module.scss +31 -0
- package/dist/components/SmartBillSummary/utils.js +30 -0
- package/dist/index.js +14 -0
- package/dist/shared/constants/tabs.js +11 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [3.2.0](https://github.com/widergy/UtilityGO-Smart-Bill-Web/compare/v3.1.0...v3.2.0) (2025-03-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* [CX-199] smartbill new experience consumption tab ([#41](https://github.com/widergy/UtilityGO-Smart-Bill-Web/issues/41)) ([ac3a0ef](https://github.com/widergy/UtilityGO-Smart-Bill-Web/commit/ac3a0efc5fa2c9b2c2deca2f9aa9dedbdfd38e42))
|
|
7
|
+
|
|
1
8
|
# [3.1.0](https://github.com/widergy/UtilityGO-Smart-Bill-Web/compare/v3.0.4...v3.1.0) (2025-03-07)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TAB_COMPONENT_MAPPER = exports.BIMESTRAL_PERIODICITY = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _tabs = require("../../shared/constants/tabs");
|
|
9
|
+
var _Consumptions = _interopRequireDefault(require("./tabs/Consumptions"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } /* eslint-disable react/prop-types */
|
|
12
|
+
const BIMESTRAL_PERIODICITY = exports.BIMESTRAL_PERIODICITY = 'BIMESTRAL';
|
|
13
|
+
const renderComponentWithProps = (Component, tab) => props => /*#__PURE__*/_react.default.createElement(Component, _extends({}, props, {
|
|
14
|
+
assets: props?.assets?.[tab],
|
|
15
|
+
translations: props?.translations?.[tab]
|
|
16
|
+
}));
|
|
17
|
+
const TAB_COMPONENT_MAPPER = exports.TAB_COMPONENT_MAPPER = {
|
|
18
|
+
[_tabs.SMARTBILL_TABS.CONSUMPTIONS]: renderComponentWithProps(_Consumptions.default, _tabs.SMARTBILL_TABS.CONSUMPTIONS),
|
|
19
|
+
[_tabs.SMARTBILL_TABS.BILLING]: renderComponentWithProps(() => /*#__PURE__*/_react.default.createElement("div", null, "Facturaci\xF3n: CX-201"),
|
|
20
|
+
// TODO
|
|
21
|
+
_tabs.SMARTBILL_TABS.BILLING),
|
|
22
|
+
[_tabs.SMARTBILL_TABS.GLOSSARY]: renderComponentWithProps(() => /*#__PURE__*/_react.default.createElement("div", null, "Glosario: CX-243"),
|
|
23
|
+
// TODO
|
|
24
|
+
_tabs.SMARTBILL_TABS.GLOSSARY)
|
|
25
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
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 _propTypes = require("prop-types");
|
|
10
|
+
var _billDataTypes = require("../../shared/types/billDataTypes");
|
|
11
|
+
var _constants = require("./constants");
|
|
12
|
+
var _utils = require("./utils");
|
|
13
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
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); }
|
|
16
|
+
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; }
|
|
17
|
+
const SmartBillSummary = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
assets,
|
|
20
|
+
loading,
|
|
21
|
+
smartBill,
|
|
22
|
+
tabOptions,
|
|
23
|
+
translations
|
|
24
|
+
} = _ref;
|
|
25
|
+
const filteredTabOptions = loading ? [] : (0, _utils.getTabOptions)(tabOptions, smartBill);
|
|
26
|
+
const defaultCurrentTab = (0, _utils.getDefaultCurrentTab)(filteredTabOptions);
|
|
27
|
+
const [currentTab, setCurrentTab] = (0, _react.useState)(defaultCurrentTab);
|
|
28
|
+
const changeCurrentTab = newTab => setCurrentTab(newTab);
|
|
29
|
+
(0, _react.useEffect)(() => {
|
|
30
|
+
if (defaultCurrentTab) changeCurrentTab(defaultCurrentTab);
|
|
31
|
+
}, [defaultCurrentTab]);
|
|
32
|
+
return /*#__PURE__*/_react.default.createElement(_energyUi.UTLoading, {
|
|
33
|
+
className: _stylesModule.default.loadingContainer,
|
|
34
|
+
loading: loading
|
|
35
|
+
}, /*#__PURE__*/_react.default.createElement(_energyUi.UTTabs, {
|
|
36
|
+
classNames: {
|
|
37
|
+
baseLabel: _stylesModule.default.tabLabel,
|
|
38
|
+
baseSelected: _stylesModule.default.baseSelected,
|
|
39
|
+
flexContainer: _stylesModule.default.tabsContainer
|
|
40
|
+
},
|
|
41
|
+
onChange: changeCurrentTab,
|
|
42
|
+
options: filteredTabOptions,
|
|
43
|
+
tabsProps: {
|
|
44
|
+
orientation: 'horizontal',
|
|
45
|
+
variant: 'fullWidth'
|
|
46
|
+
},
|
|
47
|
+
value: currentTab
|
|
48
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
49
|
+
className: _stylesModule.default.contentContainer
|
|
50
|
+
}, _constants.TAB_COMPONENT_MAPPER[currentTab]({
|
|
51
|
+
assets,
|
|
52
|
+
loading,
|
|
53
|
+
smartBill,
|
|
54
|
+
translations
|
|
55
|
+
})));
|
|
56
|
+
};
|
|
57
|
+
SmartBillSummary.propTypes = {
|
|
58
|
+
assets: _propTypes.object,
|
|
59
|
+
loading: _propTypes.bool,
|
|
60
|
+
smartBill: _billDataTypes.billDataTypes,
|
|
61
|
+
tabOptions: (0, _propTypes.arrayOf)((0, _propTypes.shape)({
|
|
62
|
+
defaultSelected: _propTypes.bool,
|
|
63
|
+
enabled: _propTypes.bool,
|
|
64
|
+
icon: _propTypes.string,
|
|
65
|
+
label: _propTypes.string,
|
|
66
|
+
value: _propTypes.string
|
|
67
|
+
})),
|
|
68
|
+
translations: _propTypes.object
|
|
69
|
+
};
|
|
70
|
+
var _default = exports.default = SmartBillSummary;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
@import '_sizes.scss';
|
|
2
|
+
|
|
3
|
+
$max-content-width: 1264px;
|
|
4
|
+
$tab-height: 48px;
|
|
5
|
+
|
|
6
|
+
.tabsContainer {
|
|
7
|
+
> button {
|
|
8
|
+
border-bottom: 1px solid var(--light04);
|
|
9
|
+
height: $tab-height;
|
|
10
|
+
max-width: unset;
|
|
11
|
+
min-height: $tab-height;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.contentContainer {
|
|
16
|
+
flex: 1;
|
|
17
|
+
margin: 0 auto;
|
|
18
|
+
max-height: calc(100vh - var(--workflowTopbarHeight) - #{$tab-height});
|
|
19
|
+
max-width: $max-content-width;
|
|
20
|
+
overflow-y: auto;
|
|
21
|
+
width: 100%;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.tabLabel {
|
|
25
|
+
align-items: center;
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: row;
|
|
28
|
+
grid-gap: 8px;
|
|
29
|
+
|
|
30
|
+
svg {
|
|
31
|
+
margin-bottom: 0 !important;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.baseSelected {
|
|
36
|
+
svg {
|
|
37
|
+
stroke: var(--actionAccent04);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.loadingContainer {
|
|
42
|
+
align-items: center;
|
|
43
|
+
display: flex;
|
|
44
|
+
flex: 1;
|
|
45
|
+
height: 100%;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
width: 100%;
|
|
48
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TAG_ICON_SIZE = exports.DEFAULT_TAG_ICON = exports.DEFAULT_TAG_COLOR_THEME = void 0;
|
|
7
|
+
const DEFAULT_TAG_ICON = exports.DEFAULT_TAG_ICON = 'IconCalendarEvent';
|
|
8
|
+
const TAG_ICON_SIZE = exports.TAG_ICON_SIZE = 14;
|
|
9
|
+
const DEFAULT_TAG_COLOR_THEME = exports.DEFAULT_TAG_COLOR_THEME = 'gray';
|
|
@@ -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;
|
package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/styles.module.scss
ADDED
|
@@ -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
|
+
}];
|
package/dist/components/SmartBillSummary/tabs/Consumptions/components/BimestralConsumption/index.js
ADDED
|
@@ -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;
|
package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
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("../../../../../../shared/types/billDataTypes");
|
|
11
|
+
var _ConsumptionComparison = _interopRequireDefault(require("./components/ConsumptionComparison"));
|
|
12
|
+
var _ConsumptionEvolution = _interopRequireDefault(require("./components/ConsumptionEvolution"));
|
|
13
|
+
var _utils = require("./utils");
|
|
14
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
const CurrentConsumption = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
assets,
|
|
19
|
+
smartBill,
|
|
20
|
+
texts
|
|
21
|
+
} = _ref;
|
|
22
|
+
const {
|
|
23
|
+
periods
|
|
24
|
+
} = smartBill || {};
|
|
25
|
+
const periodsToCompare = (0, _utils.getConsumptionPeriodsToCompare)(periods);
|
|
26
|
+
const {
|
|
27
|
+
totalConsumption,
|
|
28
|
+
unit,
|
|
29
|
+
description
|
|
30
|
+
} = (0, _utils.getConsumptionLabels)(periodsToCompare, texts) || {};
|
|
31
|
+
const title = texts?.consumptions?.youConsumedTitle;
|
|
32
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
33
|
+
className: _stylesModule.default.container
|
|
34
|
+
}, /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
|
|
35
|
+
colorTheme: "gray",
|
|
36
|
+
variant: "small"
|
|
37
|
+
}, title), /*#__PURE__*/_react.default.createElement("div", {
|
|
38
|
+
className: _stylesModule.default.details
|
|
39
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
40
|
+
className: _stylesModule.default.consumption
|
|
41
|
+
}, /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
|
|
42
|
+
variant: "title1",
|
|
43
|
+
weight: "medium"
|
|
44
|
+
}, totalConsumption), /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
|
|
45
|
+
variant: "subtitle1",
|
|
46
|
+
weight: "medium"
|
|
47
|
+
}, unit)), /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
|
|
48
|
+
colorTheme: "gray",
|
|
49
|
+
withMarkdown: true
|
|
50
|
+
}, description)), /*#__PURE__*/_react.default.createElement(_ConsumptionComparison.default, {
|
|
51
|
+
periodsToCompare: periodsToCompare,
|
|
52
|
+
texts: texts
|
|
53
|
+
}), /*#__PURE__*/_react.default.createElement(_ConsumptionEvolution.default, {
|
|
54
|
+
assets: assets,
|
|
55
|
+
periods: periodsToCompare,
|
|
56
|
+
texts: texts
|
|
57
|
+
}));
|
|
58
|
+
};
|
|
59
|
+
CurrentConsumption.propTypes = {
|
|
60
|
+
assets: _propTypes.object,
|
|
61
|
+
smartBill: _billDataTypes.billDataTypes,
|
|
62
|
+
texts: _propTypes.object
|
|
63
|
+
};
|
|
64
|
+
var _default = exports.default = CurrentConsumption;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
background-color: var(--light01);
|
|
3
|
+
border-radius: 8px;
|
|
4
|
+
box-shadow: var(--shadowGrayBottom1);
|
|
5
|
+
flex: 1;
|
|
6
|
+
padding: 24px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.details {
|
|
10
|
+
border-bottom: 1px solid var(--light04);
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
grid-gap: 12px;
|
|
14
|
+
margin: 0 -24px;
|
|
15
|
+
padding: 24px 24px 12px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.consumption {
|
|
19
|
+
align-items: flex-end;
|
|
20
|
+
display: flex;
|
|
21
|
+
grid-gap: 8px;
|
|
22
|
+
}
|
package/dist/components/SmartBillSummary/tabs/Consumptions/components/CurrentConsumption/utils.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getConsumptionPeriodsToCompare = exports.getConsumptionLabels = void 0;
|
|
7
|
+
var _lodash = require("lodash");
|
|
8
|
+
var _numeral = _interopRequireDefault(require("numeral"));
|
|
9
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
10
|
+
require("dayjs/locale/es");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
_dayjs.default.locale('es');
|
|
13
|
+
const getConsumptionPeriodsToCompare = function () {
|
|
14
|
+
let periods = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
15
|
+
if (!(0, _lodash.isEmpty)(periods)) {
|
|
16
|
+
const currentPeriod = periods.find(period => period.current);
|
|
17
|
+
const previousYearPeriod = periods.find(period => period.number === currentPeriod.number && parseInt(period.year, 10) === parseInt(currentPeriod.year, 10) - 1);
|
|
18
|
+
return [currentPeriod, previousYearPeriod];
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.getConsumptionPeriodsToCompare = getConsumptionPeriodsToCompare;
|
|
22
|
+
const formatDate = date => {
|
|
23
|
+
if (!date) return '';
|
|
24
|
+
const day = (0, _dayjs.default)(date).format('D');
|
|
25
|
+
const month = (0, _lodash.capitalize)((0, _dayjs.default)(date).format('MMM'));
|
|
26
|
+
return `${day} de ${month}`;
|
|
27
|
+
};
|
|
28
|
+
const getConsumptionLabels = function () {
|
|
29
|
+
let periods = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
30
|
+
let texts = arguments.length > 1 ? arguments[1] : undefined;
|
|
31
|
+
const currentPeriod = periods?.find(period => period?.current);
|
|
32
|
+
const totalConsumption = currentPeriod?.consumptions?.[0];
|
|
33
|
+
const dailyConsumption = currentPeriod?.consumptions?.[1];
|
|
34
|
+
const {
|
|
35
|
+
value: totalConsumptionValue,
|
|
36
|
+
unit: totalConsumptionUnit
|
|
37
|
+
} = totalConsumption || {};
|
|
38
|
+
const {
|
|
39
|
+
value: dailyConsumptionValue,
|
|
40
|
+
unit: dailyConsumptionUnit
|
|
41
|
+
} = dailyConsumption || {};
|
|
42
|
+
const startDate = currentPeriod?.settlements?.start_date;
|
|
43
|
+
const endDate = currentPeriod?.settlements?.end_date;
|
|
44
|
+
const description = texts.consumptions.youConsumedDescription({
|
|
45
|
+
dailyConsumptionUnit,
|
|
46
|
+
dailyConsumptionValue: (0, _numeral.default)(dailyConsumptionValue).format('0,0.[00]'),
|
|
47
|
+
endDate: formatDate(endDate),
|
|
48
|
+
startDate: formatDate(startDate)
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
description,
|
|
52
|
+
totalConsumption: (0, _numeral.default)(totalConsumptionValue).format('0,0.[00]'),
|
|
53
|
+
unit: totalConsumptionUnit
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
exports.getConsumptionLabels = getConsumptionLabels;
|
|
@@ -0,0 +1,54 @@
|
|
|
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("../../../../shared/types/billDataTypes");
|
|
11
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
12
|
+
var _BimestralConsumption = _interopRequireDefault(require("./components/BimestralConsumption"));
|
|
13
|
+
var _CurrentConsumption = _interopRequireDefault(require("./components/CurrentConsumption"));
|
|
14
|
+
var _Billing = _interopRequireDefault(require("./components/Billing"));
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
const Consumptions = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
assets,
|
|
19
|
+
smartBill,
|
|
20
|
+
translations
|
|
21
|
+
} = _ref;
|
|
22
|
+
const {
|
|
23
|
+
title,
|
|
24
|
+
description
|
|
25
|
+
} = translations?.consumptions || {};
|
|
26
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
27
|
+
className: _stylesModule.default.generalContainer
|
|
28
|
+
}, /*#__PURE__*/_react.default.createElement(_BimestralConsumption.default, {
|
|
29
|
+
assets: assets,
|
|
30
|
+
texts: translations
|
|
31
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
32
|
+
className: _stylesModule.default.consumptionDetail
|
|
33
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
34
|
+
className: _stylesModule.default.consumptionDetailTitles
|
|
35
|
+
}, /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
|
|
36
|
+
variant: "title3",
|
|
37
|
+
weight: "medium"
|
|
38
|
+
}, title), /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, null, description)), /*#__PURE__*/_react.default.createElement("div", {
|
|
39
|
+
className: _stylesModule.default.consumptionDetailColumns
|
|
40
|
+
}, /*#__PURE__*/_react.default.createElement(_CurrentConsumption.default, {
|
|
41
|
+
assets: assets,
|
|
42
|
+
smartBill: smartBill,
|
|
43
|
+
texts: translations
|
|
44
|
+
}), /*#__PURE__*/_react.default.createElement(_Billing.default, {
|
|
45
|
+
smartBill: smartBill,
|
|
46
|
+
texts: translations
|
|
47
|
+
}))));
|
|
48
|
+
};
|
|
49
|
+
Consumptions.propTypes = {
|
|
50
|
+
assets: _propTypes.object,
|
|
51
|
+
smartBill: _billDataTypes.billDataTypes,
|
|
52
|
+
translations: _propTypes.object
|
|
53
|
+
};
|
|
54
|
+
var _default = exports.default = Consumptions;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
@import '../../../../scss/variables/mediaQueries.module.scss';
|
|
2
|
+
|
|
3
|
+
.generalContainer {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
grid-gap: 32px;
|
|
7
|
+
padding: 24px 32px;
|
|
8
|
+
|
|
9
|
+
@media #{$mobile} {
|
|
10
|
+
padding: 24px 16px;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.consumptionDetailTitles {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
grid-gap: 8px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.consumptionDetailColumns {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex: 1;
|
|
23
|
+
flex-wrap: wrap;
|
|
24
|
+
grid-gap: 32px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.consumptionDetail {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
grid-gap: 24px;
|
|
31
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getTabOptions = exports.getDefaultCurrentTab = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _energyUi = require("@widergy/energy-ui");
|
|
9
|
+
var _lodash = require("lodash");
|
|
10
|
+
var _tabs = require("../../shared/constants/tabs");
|
|
11
|
+
var _constants = require("./constants");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const getTabOptions = (tabOptions, smartBill) => {
|
|
14
|
+
const hasBimestralPeriodicity = smartBill?.periods?.some(period => period.settlements?.periodicity === _constants.BIMESTRAL_PERIODICITY);
|
|
15
|
+
return tabOptions.map(tab => ({
|
|
16
|
+
...tab,
|
|
17
|
+
icon: /*#__PURE__*/_react.default.createElement(_energyUi.UTIcon, {
|
|
18
|
+
name: tab.icon
|
|
19
|
+
})
|
|
20
|
+
})).filter(_ref => {
|
|
21
|
+
let {
|
|
22
|
+
enabled,
|
|
23
|
+
value
|
|
24
|
+
} = _ref;
|
|
25
|
+
return enabled && (value !== _tabs.SMARTBILL_TABS.CONSUMPTIONS || hasBimestralPeriodicity);
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
exports.getTabOptions = getTabOptions;
|
|
29
|
+
const getDefaultCurrentTab = tabOptions => !(0, _lodash.isEmpty)(tabOptions) && (tabOptions.find(tab => tab?.defaultSelected) || tabOptions?.[0])?.value;
|
|
30
|
+
exports.getDefaultCurrentTab = getDefaultCurrentTab;
|
package/dist/index.js
CHANGED
|
@@ -65,6 +65,18 @@ Object.defineProperty(exports, "SmartBillProvider", {
|
|
|
65
65
|
return _SmartBillProvider.default;
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
|
+
Object.defineProperty(exports, "SmartBillSummary", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () {
|
|
71
|
+
return _SmartBillSummary.default;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(exports, "Tabs", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
get: function () {
|
|
77
|
+
return _tabs.SMARTBILL_TABS;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
68
80
|
Object.defineProperty(exports, "billDataTypes", {
|
|
69
81
|
enumerable: true,
|
|
70
82
|
get: function () {
|
|
@@ -77,6 +89,7 @@ Object.defineProperty(exports, "rateStagesTypes", {
|
|
|
77
89
|
return _rateStagesTypes.rateStagesTypes;
|
|
78
90
|
}
|
|
79
91
|
});
|
|
92
|
+
var _SmartBillSummary = _interopRequireDefault(require("./components/SmartBillSummary"));
|
|
80
93
|
var _SmartBillProvider = _interopRequireDefault(require("./components/SmartBillProvider"));
|
|
81
94
|
var _MainBillData = _interopRequireDefault(require("./components/MainBillData"));
|
|
82
95
|
var _ConsumptionPeriod = _interopRequireDefault(require("./components/ConsumptionPeriod"));
|
|
@@ -92,6 +105,7 @@ var Aliases = _aliases;
|
|
|
92
105
|
exports.Aliases = _aliases;
|
|
93
106
|
var _billDataTypes = require("./shared/types/billDataTypes");
|
|
94
107
|
var _rateStagesTypes = require("./shared/types/rateStagesTypes");
|
|
108
|
+
var _tabs = require("./shared/constants/tabs");
|
|
95
109
|
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); }
|
|
96
110
|
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; }
|
|
97
111
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SMARTBILL_TABS = void 0;
|
|
7
|
+
const SMARTBILL_TABS = exports.SMARTBILL_TABS = {
|
|
8
|
+
CONSUMPTIONS: 'consumptionsTab',
|
|
9
|
+
BILLING: 'billingTab',
|
|
10
|
+
GLOSSARY: 'glossaryTab'
|
|
11
|
+
};
|