@widergy/utilitygo-smart-bill-web 3.7.1 → 3.8.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 CHANGED
@@ -1,3 +1,10 @@
1
+ # [3.8.0](https://github.com/widergy/UtilityGO-Smart-Bill-Web/compare/v3.7.1...v3.8.0) (2025-06-27)
2
+
3
+
4
+ ### Features
5
+
6
+ * [CX-833, CX-851] smartbill analytics ([#55](https://github.com/widergy/UtilityGO-Smart-Bill-Web/issues/55)) ([312e83b](https://github.com/widergy/UtilityGO-Smart-Bill-Web/commit/312e83b9ffe4c350164667f2628ae10f0b2eab7e))
7
+
1
8
  ## [3.7.1](https://github.com/widergy/UtilityGO-Smart-Bill-Web/compare/v3.7.0...v3.7.1) (2025-06-18)
2
9
 
3
10
 
@@ -20,6 +20,7 @@ const AIPanel = _ref => {
20
20
  answer,
21
21
  error,
22
22
  getAnswer,
23
+ handlers = {},
23
24
  isOpen,
24
25
  loading,
25
26
  notEnoughBillsErrorType,
@@ -30,12 +31,19 @@ const AIPanel = _ref => {
30
31
  generatedByLabel,
31
32
  title: panelTitle
32
33
  } = translations?.AIPanel || {};
34
+ const {
35
+ trackOpenAIQuestion
36
+ } = handlers;
33
37
  const [openCards, setOpenCards] = (0, _react.useState)([]);
34
- const toggleCard = id => {
38
+ const toggleCard = (id, question) => {
35
39
  if (!answer?.[id] && !openCards.includes(id)) {
36
40
  getAnswer(id);
37
41
  }
38
- setOpenCards(prevOpenCards => prevOpenCards.includes(id) ? prevOpenCards.filter(openId => openId !== id) : [...prevOpenCards, id]);
42
+ setOpenCards(prevOpenCards => {
43
+ if (prevOpenCards.includes(id)) return prevOpenCards.filter(openId => openId !== id);
44
+ trackOpenAIQuestion?.(question);
45
+ return [...prevOpenCards, id];
46
+ });
39
47
  };
40
48
  const handleClose = () => {
41
49
  onClose?.();
@@ -82,7 +90,7 @@ const AIPanel = _ref => {
82
90
  isCollapsible: true,
83
91
  isOpen: openCards.includes(id),
84
92
  key: id,
85
- onClick: () => toggleCard(id)
93
+ onClick: () => toggleCard(id, question)
86
94
  }, renderAnswer ? /*#__PURE__*/_react.default.createElement("div", {
87
95
  className: `${_stylesModule.default.answer} ${errorContent && !isLoading ? notEnoughBills ? _stylesModule.default.notEnoughBillsContainer : _stylesModule.default.errorAnswer : ''}`
88
96
  }, isLoading ? /*#__PURE__*/_react.default.createElement("section", null, /*#__PURE__*/_react.default.createElement(_reactLoadingSkeleton.default, {
@@ -129,6 +137,7 @@ AIPanel.propTypes = {
129
137
  answer: _propTypes.object,
130
138
  error: _propTypes.object,
131
139
  getAnswer: _propTypes.func,
140
+ handlers: _propTypes.object,
132
141
  isOpen: _propTypes.bool,
133
142
  loading: _propTypes.object,
134
143
  notEnoughBillsErrorType: _propTypes.string,
@@ -48,7 +48,9 @@ const SmartBillSummary = _ref => {
48
48
  getGlossaryData,
49
49
  getSmartBillAIAnswer,
50
50
  getSmartBillAIQuestions,
51
- resetSmartBillAIAnswers
51
+ resetSmartBillAIAnswers,
52
+ trackAIFloatingButtonClick,
53
+ trackTabChange
52
54
  } = handlers;
53
55
  const filteredTabOptions = loading ? [] : (0, _utils.getTabOptions)(isDesktopSize, tabOptions, smartBill);
54
56
  const defaultCurrentTab = (0, _utils.getDefaultCurrentTab)(filteredTabOptions);
@@ -56,6 +58,7 @@ const SmartBillSummary = _ref => {
56
58
  const [aiPanelIsOpen, setAiPanelIsOpen] = (0, _react.useState)(false);
57
59
  const changeCurrentTab = newTab => setCurrentTab(newTab);
58
60
  const openAIPanel = () => {
61
+ trackAIFloatingButtonClick();
59
62
  if ((0, _isEmpty.default)(aiQuestionsList)) getSmartBillAIQuestions();
60
63
  setAiPanelIsOpen(true);
61
64
  };
@@ -80,7 +83,10 @@ const SmartBillSummary = _ref => {
80
83
  baseSelected: _stylesModule.default.baseSelected,
81
84
  flexContainer: _stylesModule.default.tabsContainer
82
85
  },
83
- onChange: changeCurrentTab,
86
+ onChange: newTab => {
87
+ trackTabChange(newTab);
88
+ changeCurrentTab(newTab);
89
+ },
84
90
  options: filteredTabOptions,
85
91
  tabsProps: {
86
92
  orientation: 'horizontal',
@@ -118,6 +124,7 @@ const SmartBillSummary = _ref => {
118
124
  answer: smartBillAIAnswer,
119
125
  error: smartBillAIAnswerError,
120
126
  getAnswer: getSmartBillAIAnswer,
127
+ handlers: handlers,
121
128
  isOpen: aiPanelIsOpen,
122
129
  loading: smartBillAIAnswerLoading,
123
130
  notEnoughBillsErrorType: notEnoughBillsErrorType,
@@ -4,15 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _react = _interopRequireDefault(require("react"));
7
+ var _react = _interopRequireWildcard(require("react"));
8
8
  var _energyUi = require("@widergy/energy-ui");
9
9
  var _propTypes = require("prop-types");
10
10
  var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
11
+ var _debounce = _interopRequireDefault(require("lodash/debounce"));
11
12
  var _utils = require("../../../Consumptions/components/CurrentConsumption/utils");
12
13
  var _utils2 = require("./utils");
13
14
  var _ProgressBar = _interopRequireDefault(require("./components/ProgressBar"));
14
15
  var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
15
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+ 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); }
18
+ 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
19
  const RateCard = _ref => {
17
20
  let {
18
21
  components,
@@ -24,7 +27,8 @@ const RateCard = _ref => {
24
27
  ratesTableLink,
25
28
  smartBill = {},
26
29
  subsidy = '',
27
- subsidyLevels
30
+ subsidyLevels,
31
+ trackRedirectionToExternalLink
28
32
  } = _ref;
29
33
  const {
30
34
  helpText,
@@ -76,6 +80,18 @@ const RateCard = _ref => {
76
80
  const isT1 = purchasedRate.includes('T1');
77
81
  const noLevels = (0, _isEmpty.default)(consumptionLevels);
78
82
  const showRateLabel = !isT1 || startRateValue === false || limitRateValue === false;
83
+ const debouncedTrackRedirection = (0, _react.useMemo)(() => (0, _debounce.default)(link => {
84
+ trackRedirectionToExternalLink(link);
85
+ }, 300), [trackRedirectionToExternalLink]);
86
+ (0, _react.useEffect)(() => {
87
+ return () => {
88
+ debouncedTrackRedirection.cancel();
89
+ };
90
+ }, [debouncedTrackRedirection]);
91
+ const handleClickButton = () => {
92
+ debouncedTrackRedirection(ratesTableLink);
93
+ if (ratesTableLink) window.open(ratesTableLink, '_blank');
94
+ };
79
95
  return /*#__PURE__*/_react.default.createElement("div", {
80
96
  className: _stylesModule.default.container
81
97
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -129,19 +145,17 @@ const RateCard = _ref => {
129
145
  variant: "subtitle1",
130
146
  weight: "medium"
131
147
  }, formatAmount?.(amount)));
132
- }), /*#__PURE__*/_react.default.createElement("a", {
133
- className: _stylesModule.default.footerAction,
134
- href: ratesTableLink,
135
- rel: "noopener noreferrer",
136
- target: "_blank"
137
- }, /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
138
- colorTheme: "neutral",
139
- weight: "medium"
140
- }, seeRatesTable), /*#__PURE__*/_react.default.createElement(_energyUi.UTIcon, {
141
- colorTheme: "neutral",
142
- name: "IconChevronRight",
143
- size: 20
144
- }))));
148
+ }), /*#__PURE__*/_react.default.createElement(_energyUi.UTButton, {
149
+ classNames: {
150
+ childrenContainer: _stylesModule.default.footerActionChildren,
151
+ root: _stylesModule.default.footerAction
152
+ },
153
+ colorTheme: "secondary",
154
+ Icon: "IconChevronRight",
155
+ iconPlacement: "right",
156
+ onClick: handleClickButton,
157
+ variant: "text"
158
+ }, seeRatesTable)));
145
159
  };
146
160
  RateCard.propTypes = {
147
161
  components: _propTypes.object,
@@ -153,6 +167,7 @@ RateCard.propTypes = {
153
167
  ratesTableLink: _propTypes.string,
154
168
  smartBill: _propTypes.object,
155
169
  subsidy: _propTypes.string,
156
- subsidyLevels: (0, _propTypes.objectOf)(_propTypes.string)
170
+ subsidyLevels: (0, _propTypes.objectOf)(_propTypes.string),
171
+ trackRedirectionToExternalLink: _propTypes.func
157
172
  };
158
173
  var _default = exports.default = RateCard;
@@ -38,20 +38,19 @@
38
38
  align-items: center;
39
39
  background-color: transparent;
40
40
  border-top: 1px solid var(--light04);
41
+ border-top-left-radius: 0;
42
+ border-top-right-radius: 0;
41
43
  display: flex;
42
44
  grid-gap: 8px;
43
45
  justify-content: space-between;
44
46
  padding: 16px;
45
47
  text-decoration: none;
46
- transition: all 0.2s ease;
47
-
48
- &:hover {
49
- background-color: var(--light03);
50
- }
48
+ width: 100%;
49
+ }
51
50
 
52
- &:active {
53
- background-color: var(--light04);
54
- }
51
+ .footerActionChildren {
52
+ flex: 1;
53
+ justify-content: space-between;
55
54
  }
56
55
 
57
56
  .detail {
@@ -44,7 +44,8 @@ const Billing = _ref => {
44
44
  const {
45
45
  handleAutomaticDebitAdherence = () => {},
46
46
  handleDownloadBill = () => {},
47
- handleGoToDigitalBill = () => {}
47
+ handleGoToDigitalBill = () => {},
48
+ trackRedirectionToExternalLink = () => {}
48
49
  } = handlers;
49
50
  const {
50
51
  adhered,
@@ -255,6 +256,7 @@ const Billing = _ref => {
255
256
  smartBill,
256
257
  subsidy,
257
258
  subsidyLevels,
259
+ trackRedirectionToExternalLink,
258
260
  translations
259
261
  }))));
260
262
  };
@@ -16,6 +16,7 @@ const Glossary = _ref => {
16
16
  getGlossaryData,
17
17
  glossaryData,
18
18
  glossaryLoading,
19
+ handlers,
19
20
  translations
20
21
  } = _ref;
21
22
  const {
@@ -32,15 +33,17 @@ const Glossary = _ref => {
32
33
  size: 80,
33
34
  thickness: 5
34
35
  })) : /*#__PURE__*/_react.default.createElement(_energyUi.UTDocumentWizard, {
36
+ handlers: handlers,
37
+ labels: translations,
35
38
  pages: pages,
36
- sections: sections,
37
- labels: translations
39
+ sections: sections
38
40
  });
39
41
  };
40
42
  Glossary.propTypes = {
41
43
  getGlossaryData: _propTypes.func,
42
44
  glossaryData: undefined || _propTypes.object,
43
45
  glossaryLoading: _propTypes.bool,
46
+ handlers: _propTypes.object,
44
47
  translations: _propTypes.object
45
48
  };
46
49
  var _default = exports.default = Glossary;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/utilitygo-smart-bill-web",
3
- "version": "3.7.1",
3
+ "version": "3.8.0",
4
4
  "description": "UtilityGO SmartBill Web",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",