@widergy/utilitygo-smart-bill-web 3.11.0 → 3.12.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 +8 -0
- package/README.md +1 -0
- package/dist/components/SmartBillSummary/constants.js +12 -1
- package/dist/components/SmartBillSummary/index.js +43 -8
- package/dist/components/SmartBillSummary/styles.module.scss +5 -0
- package/dist/components/SmartBillSummary/tabs/Consumptions/components/Billing/index.js +1 -1
- package/dist/components/SmartBillSummary/utils.js +30 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# [3.12.0](https://github.com/widergy/UtilityGO-Smart-Bill-Web/compare/v3.11.0...v3.12.0) (2025-08-27)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* [EVEP-27] smartbill onboarding ([#62](https://github.com/widergy/UtilityGO-Smart-Bill-Web/issues/62)) ([d7bdeac](https://github.com/widergy/UtilityGO-Smart-Bill-Web/commit/d7bdeac4050d6ebf615a00a05eddae36de48fa07)), closes [#60](https://github.com/widergy/UtilityGO-Smart-Bill-Web/issues/60) [#60](https://github.com/widergy/UtilityGO-Smart-Bill-Web/issues/60) [#59](https://github.com/widergy/UtilityGO-Smart-Bill-Web/issues/59) [#59](https://github.com/widergy/UtilityGO-Smart-Bill-Web/issues/59)
|
|
7
|
+
* updates readme ([cc9caa2](https://github.com/widergy/UtilityGO-Smart-Bill-Web/commit/cc9caa29601d5052e9b260e057184f6f8d39d3c8))
|
|
8
|
+
|
|
1
9
|
# [3.11.0](https://github.com/widergy/UtilityGO-Smart-Bill-Web/compare/v3.10.0...v3.11.0) (2025-08-25)
|
|
2
10
|
|
|
3
11
|
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TAB_COMPONENT_MAPPER = exports.BIMESTRAL_PERIODICITY = void 0;
|
|
6
|
+
exports.TAB_VALUE_REGEX = exports.TAB_SELECTOR = exports.TAB_COMPONENT_MAPPER = exports.ONBOARDING_OPTIONS = exports.CAPTURED_VALUE_REGEX = exports.BIMESTRAL_PERIODICITY = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _tabs = require("../../shared/constants/tabs");
|
|
9
9
|
var _Consumptions = _interopRequireDefault(require("./tabs/Consumptions"));
|
|
@@ -12,6 +12,17 @@ var _Billing = _interopRequireDefault(require("./tabs/Billing"));
|
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
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 */
|
|
14
14
|
const BIMESTRAL_PERIODICITY = exports.BIMESTRAL_PERIODICITY = 'BIMESTRAL';
|
|
15
|
+
const TAB_SELECTOR = exports.TAB_SELECTOR = '[data-tab-value=';
|
|
16
|
+
const TAB_VALUE_REGEX = exports.TAB_VALUE_REGEX = /\[data-tab-value="([^"]+)"\]/;
|
|
17
|
+
const CAPTURED_VALUE_REGEX = exports.CAPTURED_VALUE_REGEX = 1;
|
|
18
|
+
const ONBOARDING_OPTIONS = exports.ONBOARDING_OPTIONS = {
|
|
19
|
+
overlayOpacity: 1,
|
|
20
|
+
positionPrecedence: ['top', 'left', 'bottom', 'right'],
|
|
21
|
+
scrollPadding: 5,
|
|
22
|
+
scrollTo: 'tooltip',
|
|
23
|
+
scrollToElement: false,
|
|
24
|
+
tooltipPosition: 'top'
|
|
25
|
+
};
|
|
15
26
|
const renderComponentWithProps = (Component, tab) => props => /*#__PURE__*/_react.default.createElement(Component, _extends({}, props, {
|
|
16
27
|
assets: props?.assets?.[tab] || {},
|
|
17
28
|
translations: props?.translations?.[tab] || {}
|
|
@@ -27,6 +27,9 @@ const SmartBillSummary = _ref => {
|
|
|
27
27
|
components,
|
|
28
28
|
handlers,
|
|
29
29
|
loading,
|
|
30
|
+
showOnboarding = false,
|
|
31
|
+
onCloseOnboarding,
|
|
32
|
+
onboardingSteps,
|
|
30
33
|
reverseRow,
|
|
31
34
|
smartBill,
|
|
32
35
|
tabOptions,
|
|
@@ -57,10 +60,27 @@ const SmartBillSummary = _ref => {
|
|
|
57
60
|
trackAIFloatingButtonClick,
|
|
58
61
|
trackTabChange
|
|
59
62
|
} = handlers;
|
|
60
|
-
const
|
|
61
|
-
|
|
63
|
+
const {
|
|
64
|
+
tabs,
|
|
65
|
+
onboardingSteps: filteredOnboardingSteps
|
|
66
|
+
} = loading ? {
|
|
67
|
+
tabs: [],
|
|
68
|
+
onboardingSteps: []
|
|
69
|
+
} : (0, _utils.getTabOptions)(isDesktopSize, onboardingSteps, tabOptions, smartBill);
|
|
70
|
+
const defaultCurrentTab = (0, _utils.getDefaultCurrentTab)(tabs);
|
|
62
71
|
const [currentTab, setCurrentTab] = (0, _react.useState)(defaultCurrentTab);
|
|
63
72
|
const [aiPanelIsOpen, setAiPanelIsOpen] = (0, _react.useState)(false);
|
|
73
|
+
const [stableLoading, setStableLoading] = (0, _react.useState)(true);
|
|
74
|
+
(0, _react.useEffect)(() => {
|
|
75
|
+
if (loading) {
|
|
76
|
+
setStableLoading(true);
|
|
77
|
+
} else {
|
|
78
|
+
const timer = setTimeout(() => {
|
|
79
|
+
setStableLoading(false);
|
|
80
|
+
}, 200);
|
|
81
|
+
return () => clearTimeout(timer);
|
|
82
|
+
}
|
|
83
|
+
}, [loading]);
|
|
64
84
|
const changeCurrentTab = newTab => setCurrentTab(newTab);
|
|
65
85
|
const openAIPanel = () => {
|
|
66
86
|
trackAIFloatingButtonClick();
|
|
@@ -82,25 +102,31 @@ const SmartBillSummary = _ref => {
|
|
|
82
102
|
return /*#__PURE__*/_react.default.createElement(_energyUi.UTLoading, {
|
|
83
103
|
className: _stylesModule.default.loadingContainer,
|
|
84
104
|
loading: loading
|
|
105
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
106
|
+
className: showOnboarding ? _stylesModule.default.tabs : ''
|
|
85
107
|
}, /*#__PURE__*/_react.default.createElement(_energyUi.UTTabs, {
|
|
86
108
|
classNames: {
|
|
87
109
|
baseLabel: _stylesModule.default.tabLabel,
|
|
88
110
|
baseSelected: _stylesModule.default.baseSelected,
|
|
89
|
-
flexContainer: _stylesModule.default.tabsContainer
|
|
111
|
+
flexContainer: _stylesModule.default.tabsContainer,
|
|
112
|
+
tabRoot: 'smartbill-tab'
|
|
90
113
|
},
|
|
91
114
|
onChange: newTab => {
|
|
92
115
|
trackTabChange(newTab);
|
|
93
116
|
changeCurrentTab(newTab);
|
|
94
117
|
},
|
|
95
|
-
options:
|
|
118
|
+
options: tabs.map(tab => ({
|
|
119
|
+
...tab,
|
|
120
|
+
'data-tab-value': tab.value
|
|
121
|
+
})),
|
|
96
122
|
tabsProps: {
|
|
97
123
|
orientation: 'horizontal',
|
|
98
124
|
variant: 'fullWidth'
|
|
99
125
|
},
|
|
100
126
|
value: currentTab
|
|
101
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
127
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
102
128
|
className: _stylesModule.default.contentContainer
|
|
103
|
-
},
|
|
129
|
+
}, tabs.find(tab => tab.value === currentTab)?.header && /*#__PURE__*/_react.default.createElement(_BillHeader.default, {
|
|
104
130
|
annex,
|
|
105
131
|
UtilityLogo: assets.billingTab.UtilityLogo,
|
|
106
132
|
billNumber: smartBill.bill_number,
|
|
@@ -128,7 +154,7 @@ const SmartBillSummary = _ref => {
|
|
|
128
154
|
translations,
|
|
129
155
|
utils
|
|
130
156
|
})), aiQuestionsPanelEnabled && /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_energyUi.UTTouchableWithoutFeedback, {
|
|
131
|
-
className: _stylesModule.default.AIFloatButton
|
|
157
|
+
className: `${_stylesModule.default.AIFloatButton} smartbill-ai-float-button`,
|
|
132
158
|
onClick: openAIPanel,
|
|
133
159
|
withRipple: true
|
|
134
160
|
}, /*#__PURE__*/_react.default.createElement(_energyUi.UTIcon, {
|
|
@@ -147,7 +173,13 @@ const SmartBillSummary = _ref => {
|
|
|
147
173
|
notEnoughBillsErrorType: notEnoughBillsErrorType,
|
|
148
174
|
onClose: closeAIPanel,
|
|
149
175
|
translations: translations
|
|
150
|
-
}))
|
|
176
|
+
})), !stableLoading && showOnboarding && /*#__PURE__*/_react.default.createElement(_energyUi.UTOnboarding, {
|
|
177
|
+
options: _constants.ONBOARDING_OPTIONS,
|
|
178
|
+
enabled: showOnboarding,
|
|
179
|
+
handleComplete: onCloseOnboarding,
|
|
180
|
+
handleOnClose: onCloseOnboarding,
|
|
181
|
+
steps: filteredOnboardingSteps
|
|
182
|
+
}));
|
|
151
183
|
};
|
|
152
184
|
SmartBillSummary.propTypes = {
|
|
153
185
|
annex: _propTypes.bool,
|
|
@@ -161,6 +193,9 @@ SmartBillSummary.propTypes = {
|
|
|
161
193
|
[_propTypes.string]: _propTypes.func
|
|
162
194
|
}),
|
|
163
195
|
loading: _propTypes.bool,
|
|
196
|
+
showOnboarding: _propTypes.bool,
|
|
197
|
+
onCloseOnboarding: _propTypes.func,
|
|
198
|
+
onboardingSteps: (0, _propTypes.arrayOf)(_propTypes.object),
|
|
164
199
|
reverseRow: _propTypes.object,
|
|
165
200
|
smartBill: _billDataTypes.billDataTypes,
|
|
166
201
|
tabOptions: (0, _propTypes.arrayOf)((0, _propTypes.shape)({
|
|
@@ -26,7 +26,7 @@ const Billing = _ref => {
|
|
|
26
26
|
clarification,
|
|
27
27
|
periodDetail
|
|
28
28
|
} = texts?.billing || {};
|
|
29
|
-
const currentPeriod = smartBill?.periods
|
|
29
|
+
const currentPeriod = smartBill?.periods?.find(period => period.current);
|
|
30
30
|
const billingsToShow = (0, _utils.getBillingsToShow)(currentPeriod?.settlements);
|
|
31
31
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
32
32
|
className: _stylesModule.default.container
|
|
@@ -6,13 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getTabOptions = exports.getDefaultCurrentTab = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _energyUi = require("@widergy/energy-ui");
|
|
9
|
-
var
|
|
9
|
+
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
10
10
|
var _tabs = require("../../shared/constants/tabs");
|
|
11
11
|
var _constants = require("./constants");
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
const getTabOptions = (isDesktopSize, tabOptions, smartBill) => {
|
|
13
|
+
const getTabOptions = (isDesktopSize, onboardingSteps, tabOptions, smartBill) => {
|
|
14
14
|
const hasBimestralPeriodicity = smartBill?.periods?.some(period => period.settlements?.periodicity === _constants.BIMESTRAL_PERIODICITY);
|
|
15
|
-
|
|
15
|
+
const filteredTabs = tabOptions.map(tab => ({
|
|
16
16
|
...tab,
|
|
17
17
|
icon: isDesktopSize ? /*#__PURE__*/_react.default.createElement(_energyUi.UTIcon, {
|
|
18
18
|
name: tab.icon
|
|
@@ -24,7 +24,33 @@ const getTabOptions = (isDesktopSize, tabOptions, smartBill) => {
|
|
|
24
24
|
} = _ref;
|
|
25
25
|
return enabled && (value !== _tabs.SMARTBILL_TABS.CONSUMPTIONS || hasBimestralPeriodicity);
|
|
26
26
|
});
|
|
27
|
+
if (!(0, _isEmpty.default)(onboardingSteps)) {
|
|
28
|
+
const tabPositions = {};
|
|
29
|
+
filteredTabs.forEach((tab, index) => {
|
|
30
|
+
tabPositions[tab.value] = index + 1;
|
|
31
|
+
});
|
|
32
|
+
const filteredOnboardingSteps = [...onboardingSteps].reduce((acc, step) => {
|
|
33
|
+
if (step.element && step.element.includes(_constants.TAB_SELECTOR)) {
|
|
34
|
+
const match = step.element.match(_constants.TAB_VALUE_REGEX);
|
|
35
|
+
if (match && tabPositions[match[_constants.CAPTURED_VALUE_REGEX]]) {
|
|
36
|
+
return [...acc, {
|
|
37
|
+
...step,
|
|
38
|
+
element: `.smartbill-tab:nth-child(${tabPositions[match[_constants.CAPTURED_VALUE_REGEX]]})`
|
|
39
|
+
}];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return [...acc, step];
|
|
43
|
+
}, []);
|
|
44
|
+
return {
|
|
45
|
+
tabs: filteredTabs,
|
|
46
|
+
onboardingSteps: filteredOnboardingSteps
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
tabs: filteredTabs,
|
|
51
|
+
onboardingSteps
|
|
52
|
+
};
|
|
27
53
|
};
|
|
28
54
|
exports.getTabOptions = getTabOptions;
|
|
29
|
-
const getDefaultCurrentTab = tabOptions => !(0,
|
|
55
|
+
const getDefaultCurrentTab = tabOptions => !(0, _isEmpty.default)(tabOptions) && (tabOptions.find(tab => tab?.defaultSelected) || tabOptions?.[0])?.value;
|
|
30
56
|
exports.getDefaultCurrentTab = getDefaultCurrentTab;
|