@widergy/utilitygo-smart-bill-web 3.6.2 → 3.7.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.7.0](https://github.com/widergy/UtilityGO-Smart-Bill-Web/compare/v3.6.2...v3.7.0) (2025-05-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* [CX-746] smartbill ai question list new services ([#52](https://github.com/widergy/UtilityGO-Smart-Bill-Web/issues/52)) ([ba403da](https://github.com/widergy/UtilityGO-Smart-Bill-Web/commit/ba403da3cef06f935d585e282355d641ae4b79e9))
|
|
7
|
+
|
|
1
8
|
## [3.6.2](https://github.com/widergy/UtilityGO-Smart-Bill-Web/compare/v3.6.1...v3.6.2) (2025-05-26)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -7,7 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _energyUi = require("@widergy/energy-ui");
|
|
9
9
|
var _propTypes = require("prop-types");
|
|
10
|
-
var _i18next = _interopRequireDefault(require("i18next"));
|
|
11
10
|
var _reactLoadingSkeleton = _interopRequireDefault(require("react-loading-skeleton"));
|
|
12
11
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
13
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -15,15 +14,22 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
15
14
|
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
15
|
const AIPanel = _ref => {
|
|
17
16
|
let {
|
|
18
|
-
aiQuestionsList,
|
|
17
|
+
aiQuestionsList = [],
|
|
18
|
+
aiQuestionsListError,
|
|
19
|
+
aiQuestionsListLoading,
|
|
19
20
|
answer,
|
|
20
21
|
error,
|
|
21
22
|
getAnswer,
|
|
22
23
|
isOpen,
|
|
23
24
|
loading,
|
|
24
25
|
notEnoughBillsErrorType,
|
|
25
|
-
onClose
|
|
26
|
+
onClose,
|
|
27
|
+
translations
|
|
26
28
|
} = _ref;
|
|
29
|
+
const {
|
|
30
|
+
generatedByLabel,
|
|
31
|
+
title: panelTitle
|
|
32
|
+
} = translations?.AIPanel || {};
|
|
27
33
|
const [openCards, setOpenCards] = (0, _react.useState)([]);
|
|
28
34
|
const toggleCard = id => {
|
|
29
35
|
if (!answer?.[id] && !openCards.includes(id)) {
|
|
@@ -35,6 +41,9 @@ const AIPanel = _ref => {
|
|
|
35
41
|
onClose?.();
|
|
36
42
|
setOpenCards([]);
|
|
37
43
|
};
|
|
44
|
+
(0, _react.useEffect)(() => {
|
|
45
|
+
if (aiQuestionsListError && !aiQuestionsListLoading) handleClose();
|
|
46
|
+
}, [isOpen, aiQuestionsListError, aiQuestionsListLoading]);
|
|
38
47
|
return /*#__PURE__*/_react.default.createElement(_energyUi.UTPanel, {
|
|
39
48
|
classes: {
|
|
40
49
|
paper: _stylesModule.default.paper,
|
|
@@ -48,12 +57,14 @@ const AIPanel = _ref => {
|
|
|
48
57
|
}, /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
|
|
49
58
|
weight: "medium",
|
|
50
59
|
variant: "title2"
|
|
51
|
-
},
|
|
60
|
+
}, panelTitle), /*#__PURE__*/_react.default.createElement(_energyUi.UTLoading, {
|
|
61
|
+
loading: aiQuestionsListLoading
|
|
62
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
52
63
|
className: _stylesModule.default.questionsContainer
|
|
53
64
|
}, aiQuestionsList.map(_ref2 => {
|
|
54
65
|
let {
|
|
55
66
|
id,
|
|
56
|
-
|
|
67
|
+
question
|
|
57
68
|
} = _ref2;
|
|
58
69
|
const isLoading = loading?.[id];
|
|
59
70
|
const errorContent = error?.[id];
|
|
@@ -67,14 +78,14 @@ const AIPanel = _ref => {
|
|
|
67
78
|
expandableContent: _stylesModule.default.expandableContent,
|
|
68
79
|
expandableContentActive: _stylesModule.default.activeCard
|
|
69
80
|
},
|
|
70
|
-
header:
|
|
81
|
+
header: question,
|
|
71
82
|
isCollapsible: true,
|
|
72
83
|
isOpen: openCards.includes(id),
|
|
73
84
|
key: id,
|
|
74
85
|
onClick: () => toggleCard(id)
|
|
75
86
|
}, renderAnswer ? /*#__PURE__*/_react.default.createElement("div", {
|
|
76
87
|
className: `${_stylesModule.default.answer} ${errorContent && !isLoading ? notEnoughBills ? _stylesModule.default.notEnoughBillsContainer : _stylesModule.default.errorAnswer : ''}`
|
|
77
|
-
}, isLoading ? /*#__PURE__*/_react.default.createElement(
|
|
88
|
+
}, isLoading ? /*#__PURE__*/_react.default.createElement("section", null, /*#__PURE__*/_react.default.createElement(_reactLoadingSkeleton.default, {
|
|
78
89
|
containerClassName: _stylesModule.default.skeletonContainer,
|
|
79
90
|
count: 3,
|
|
80
91
|
height: 22
|
|
@@ -83,17 +94,17 @@ const AIPanel = _ref => {
|
|
|
83
94
|
}, /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
|
|
84
95
|
colorTheme: "gray",
|
|
85
96
|
variant: "small"
|
|
86
|
-
},
|
|
97
|
+
}, generatedByLabel), /*#__PURE__*/_react.default.createElement(_energyUi.UTIcon, {
|
|
87
98
|
colorTheme: "neutral",
|
|
88
99
|
name: "IconSparkles",
|
|
89
100
|
size: 18
|
|
90
|
-
}))) : errorContent ? /*#__PURE__*/_react.default.createElement("
|
|
101
|
+
}))) : errorContent ? /*#__PURE__*/_react.default.createElement("section", {
|
|
91
102
|
className: _stylesModule.default.errorCard
|
|
92
103
|
}, /*#__PURE__*/_react.default.createElement(_energyUi.UTIcon, {
|
|
93
104
|
colorTheme: notEnoughBills ? 'gray' : 'error',
|
|
94
105
|
name: notEnoughBills ? 'IconFileX' : 'IconCircleX',
|
|
95
106
|
shade: "04"
|
|
96
|
-
}), /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, null, notEnoughBills ? notEnoughBillsContent : errorContent)) : answerContent ? /*#__PURE__*/_react.default.createElement(
|
|
107
|
+
}), /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, null, notEnoughBills ? notEnoughBillsContent : errorContent)) : answerContent ? /*#__PURE__*/_react.default.createElement("section", null, /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
|
|
97
108
|
className: _stylesModule.default.answerContent,
|
|
98
109
|
withMarkdown: true
|
|
99
110
|
}, answerContent), /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -101,24 +112,27 @@ const AIPanel = _ref => {
|
|
|
101
112
|
}, /*#__PURE__*/_react.default.createElement(_energyUi.UTLabel, {
|
|
102
113
|
colorTheme: "gray",
|
|
103
114
|
variant: "small"
|
|
104
|
-
},
|
|
115
|
+
}, generatedByLabel), /*#__PURE__*/_react.default.createElement(_energyUi.UTIcon, {
|
|
105
116
|
colorTheme: "neutral",
|
|
106
117
|
name: "IconSparkles",
|
|
107
118
|
size: 18
|
|
108
119
|
}))) : null) : null);
|
|
109
|
-
}))));
|
|
120
|
+
})))));
|
|
110
121
|
};
|
|
111
122
|
AIPanel.propTypes = {
|
|
112
123
|
aiQuestionsList: (0, _propTypes.arrayOf)((0, _propTypes.shape)({
|
|
113
|
-
id: _propTypes.
|
|
114
|
-
|
|
124
|
+
id: _propTypes.number,
|
|
125
|
+
question: _propTypes.string
|
|
115
126
|
})),
|
|
127
|
+
aiQuestionsListLoading: _propTypes.bool,
|
|
128
|
+
aiQuestionsListError: _propTypes.bool,
|
|
116
129
|
answer: _propTypes.object,
|
|
117
130
|
error: _propTypes.object,
|
|
118
131
|
getAnswer: _propTypes.func,
|
|
119
132
|
isOpen: _propTypes.bool,
|
|
120
133
|
loading: _propTypes.object,
|
|
121
134
|
notEnoughBillsErrorType: _propTypes.string,
|
|
122
|
-
onClose: _propTypes.func
|
|
135
|
+
onClose: _propTypes.func,
|
|
136
|
+
translations: _propTypes.object
|
|
123
137
|
};
|
|
124
138
|
var _default = exports.default = AIPanel;
|
|
@@ -7,6 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _energyUi = require("@widergy/energy-ui");
|
|
9
9
|
var _propTypes = require("prop-types");
|
|
10
|
+
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
10
11
|
var _billDataTypes = require("../../shared/types/billDataTypes");
|
|
11
12
|
var _constants = require("./constants");
|
|
12
13
|
var _utils = require("./utils");
|
|
@@ -29,6 +30,8 @@ const SmartBillSummary = _ref => {
|
|
|
29
30
|
} = _ref;
|
|
30
31
|
const {
|
|
31
32
|
aiQuestionsList,
|
|
33
|
+
aiQuestionsListError,
|
|
34
|
+
aiQuestionsListLoading,
|
|
32
35
|
aiQuestionsPanelEnabled,
|
|
33
36
|
consumptionLevels,
|
|
34
37
|
currentAccount,
|
|
@@ -44,6 +47,7 @@ const SmartBillSummary = _ref => {
|
|
|
44
47
|
const {
|
|
45
48
|
getGlossaryData,
|
|
46
49
|
getSmartBillAIAnswer,
|
|
50
|
+
getSmartBillAIQuestions,
|
|
47
51
|
resetSmartBillAIAnswers
|
|
48
52
|
} = handlers;
|
|
49
53
|
const filteredTabOptions = loading ? [] : (0, _utils.getTabOptions)(isDesktopSize, tabOptions, smartBill);
|
|
@@ -51,7 +55,10 @@ const SmartBillSummary = _ref => {
|
|
|
51
55
|
const [currentTab, setCurrentTab] = (0, _react.useState)(defaultCurrentTab);
|
|
52
56
|
const [aiPanelIsOpen, setAiPanelIsOpen] = (0, _react.useState)(false);
|
|
53
57
|
const changeCurrentTab = newTab => setCurrentTab(newTab);
|
|
54
|
-
const openAIPanel = () =>
|
|
58
|
+
const openAIPanel = () => {
|
|
59
|
+
if ((0, _isEmpty.default)(aiQuestionsList)) getSmartBillAIQuestions();
|
|
60
|
+
setAiPanelIsOpen(true);
|
|
61
|
+
};
|
|
55
62
|
const closeAIPanel = () => {
|
|
56
63
|
setAiPanelIsOpen(false);
|
|
57
64
|
resetSmartBillAIAnswers();
|
|
@@ -106,13 +113,16 @@ const SmartBillSummary = _ref => {
|
|
|
106
113
|
name: "EnergyIconChatSparkFilled"
|
|
107
114
|
})), /*#__PURE__*/_react.default.createElement(_AIPanel.default, {
|
|
108
115
|
aiQuestionsList: aiQuestionsList,
|
|
116
|
+
aiQuestionsListError: aiQuestionsListError,
|
|
117
|
+
aiQuestionsListLoading: aiQuestionsListLoading,
|
|
109
118
|
answer: smartBillAIAnswer,
|
|
110
119
|
error: smartBillAIAnswerError,
|
|
111
120
|
getAnswer: getSmartBillAIAnswer,
|
|
112
121
|
isOpen: aiPanelIsOpen,
|
|
113
122
|
loading: smartBillAIAnswerLoading,
|
|
114
123
|
notEnoughBillsErrorType: notEnoughBillsErrorType,
|
|
115
|
-
onClose: closeAIPanel
|
|
124
|
+
onClose: closeAIPanel,
|
|
125
|
+
translations: translations
|
|
116
126
|
})));
|
|
117
127
|
};
|
|
118
128
|
SmartBillSummary.propTypes = {
|