@widergy/utilitygo-smart-bill-mobile 2.4.4 → 2.5.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
+ # [2.5.0](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/compare/v2.4.4...v2.5.0) (2025-05-28)
2
+
3
+
4
+ ### Features
5
+
6
+ * smartbill ai question list new services ([#38](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/issues/38)) ([aca26cf](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/commit/aca26cf09a18b4cf49689a79a70aecba510cccfc))
7
+
1
8
  ## [2.4.4](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/compare/v2.4.3...v2.4.4) (2025-05-23)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/utilitygo-smart-bill-mobile",
3
- "version": "2.4.4",
3
+ "version": "2.5.0",
4
4
  "description": "UtilityGO SmartBill Mobile",
5
5
  "license": "MIT",
6
6
  "main": "src/lib/index.js",
@@ -1,15 +1,17 @@
1
1
  /* eslint-disable react/no-unstable-nested-components */
2
2
  /* eslint-disable react/forbid-prop-types */
3
- import React, { useState } from 'react';
4
- import { UTBottomSheet, UTLabel, UTIcon } from '@widergy/mobile-ui';
3
+ import React, { useEffect, useState } from 'react';
4
+ import { UTBottomSheet, UTLabel, UTLoading, UTIcon } from '@widergy/mobile-ui';
5
5
  import { FlatList, View } from 'react-native';
6
- import { arrayOf, bool, func, object, shape, string } from 'prop-types';
6
+ import { arrayOf, bool, func, number, object, shape, string } from 'prop-types';
7
7
 
8
8
  import { SKELETON_LOADING_HEIGHT } from './constants';
9
9
  import { createStyles } from './styles';
10
10
 
11
11
  const AIDrawer = ({
12
- aiQuestionsList,
12
+ aiQuestionsList = [],
13
+ aiQuestionsListError,
14
+ aiQuestionsListLoading,
13
15
  answer,
14
16
  colors,
15
17
  components = {},
@@ -41,7 +43,7 @@ const AIDrawer = ({
41
43
  };
42
44
 
43
45
  const renderItem = ({ item }) => {
44
- const { id, title } = item || {};
46
+ const { id, question } = item || {};
45
47
  const isLoading = loading?.[id];
46
48
  const errorContent = error?.[id];
47
49
  const answerContent = answer?.[id];
@@ -121,11 +123,16 @@ const AIDrawer = ({
121
123
  touchableContainer: styles.collapsibleCardContainer,
122
124
  outerContainer: styles.collapsibleCardOuterContainer
123
125
  }}
124
- title={title}
126
+ title={question}
125
127
  />
126
128
  );
127
129
  };
128
130
 
131
+ useEffect(() => {
132
+ if (aiQuestionsListError && !aiQuestionsListLoading) handleClose();
133
+ // eslint-disable-next-line react-hooks/exhaustive-deps
134
+ }, [isOpen, aiQuestionsListError, aiQuestionsListLoading]);
135
+
129
136
  return (
130
137
  <UTBottomSheet
131
138
  onClose={handleClose}
@@ -133,18 +140,22 @@ const AIDrawer = ({
133
140
  titleProps={{ variant: 'title3', weight: 'medium' }}
134
141
  visible={isOpen}
135
142
  withBodyPadding={false}>
136
- <FlatList
137
- contentContainerStyle={styles.flatListContainer}
138
- data={aiQuestionsList}
139
- keyExtractor={row => row.id.toString()}
140
- renderItem={renderItem}
141
- />
143
+ <UTLoading loading={aiQuestionsListLoading} style={styles.loadingContainer}>
144
+ <FlatList
145
+ contentContainerStyle={styles.flatListContainer}
146
+ data={aiQuestionsList}
147
+ keyExtractor={row => row.id.toString()}
148
+ renderItem={renderItem}
149
+ />
150
+ </UTLoading>
142
151
  </UTBottomSheet>
143
152
  );
144
153
  };
145
154
 
146
155
  AIDrawer.propTypes = {
147
- aiQuestionsList: arrayOf(shape({ id: string, title: string })),
156
+ aiQuestionsList: arrayOf(shape({ id: number, question: string })),
157
+ aiQuestionsListError: bool,
158
+ aiQuestionsListLoading: bool,
148
159
  answer: object,
149
160
  colors: object,
150
161
  components: object,
@@ -53,5 +53,8 @@ export const createStyles = colors =>
53
53
  },
54
54
  flatListContainer: {
55
55
  paddingBottom: 6
56
+ },
57
+ loadingContainer: {
58
+ flex: 1
56
59
  }
57
60
  });
@@ -4,6 +4,7 @@ import React, { Fragment, useEffect, useState } from 'react';
4
4
  import { UTButton, UTLoading, UTTabs } from '@widergy/mobile-ui';
5
5
  import { View } from 'react-native';
6
6
  import { arrayOf, bool, func, object, shape, string } from 'prop-types';
7
+ import isEmpty from 'lodash/isEmpty';
7
8
 
8
9
  import { TAB_COMPONENT_MAPPER } from './constants';
9
10
  import { getDefaultCurrentTab, getTabOptions } from './utils';
@@ -24,6 +25,8 @@ const SmartBillSummary = ({
24
25
  }) => {
25
26
  const {
26
27
  aiQuestionsList,
28
+ aiQuestionsListError,
29
+ aiQuestionsListLoading,
27
30
  aiQuestionsPanelEnabled,
28
31
  glossaryError,
29
32
  glossaryLoading,
@@ -32,7 +35,7 @@ const SmartBillSummary = ({
32
35
  smartBillAIAnswerError,
33
36
  smartBillAIAnswerLoading
34
37
  } = constants;
35
- const { getSmartBillAIAnswer, resetSmartBillAIAnswers } = handlers;
38
+ const { getSmartBillAIAnswer, getSmartBillAIQuestions, resetSmartBillAIAnswers } = handlers;
36
39
  const filteredTabOptions = getTabOptions(tabOptions, smartBill) || [];
37
40
  const defaultCurrentTab = getDefaultCurrentTab(filteredTabOptions);
38
41
  const [currentTab, setCurrentTab] = useState(defaultCurrentTab);
@@ -40,7 +43,10 @@ const SmartBillSummary = ({
40
43
  const [aiDrawerIsOpen, setAiDrawerIsOpen] = useState(false);
41
44
 
42
45
  const changeCurrentTab = newTab => setCurrentTab(newTab?.value || newTab);
43
- const openAIDrawer = () => setAiDrawerIsOpen(true);
46
+ const openAIDrawer = () => {
47
+ if (isEmpty(aiQuestionsList)) getSmartBillAIQuestions();
48
+ setAiDrawerIsOpen(true);
49
+ };
44
50
  const closeAIDrawer = () => {
45
51
  setAiDrawerIsOpen(false);
46
52
  resetSmartBillAIAnswers();
@@ -92,6 +98,8 @@ const SmartBillSummary = ({
92
98
 
93
99
  <AIDrawer
94
100
  aiQuestionsList={aiQuestionsList}
101
+ aiQuestionsListError={aiQuestionsListError}
102
+ aiQuestionsListLoading={aiQuestionsListLoading}
95
103
  answer={smartBillAIAnswer}
96
104
  colors={colors}
97
105
  components={components}