@widergy/utilitygo-smart-bill-mobile 2.5.1 → 2.5.2

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.2](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/compare/v2.5.1...v2.5.2) (2025-06-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * levels loop error fixed ([#40](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/issues/40)) ([56f4a7f](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/commit/56f4a7f190094c6f6a5f4dcfde9eed7edca54d01))
7
+
1
8
  ## [2.5.1](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/compare/v2.5.0...v2.5.1) (2025-06-13)
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.5.1",
3
+ "version": "2.5.2",
4
4
  "description": "UtilityGO SmartBill Mobile",
5
5
  "license": "MIT",
6
6
  "main": "src/lib/index.js",
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import { Linking, View } from 'react-native';
4
4
  import { Surface, UTButton, UTLabel } from '@widergy/mobile-ui';
5
5
  import { object, string, func, objectOf, array } from 'prop-types';
6
+ import isEmpty from 'lodash/isEmpty';
6
7
 
7
8
  import {
8
9
  getConsumptionLabels,
@@ -42,7 +43,9 @@ const RateCard = ({
42
43
  const periodsToCompare = getConsumptionPeriodsToCompare(periods);
43
44
  const { totalConsumption, totalConsumptionFormatted } = getConsumptionLabels(periodsToCompare) || {};
44
45
  const { levels = [] } =
45
- consumptionLevels.find(({ rate }) => rate === normalizedRate) || consumptionLevels[0] || {};
46
+ (consumptionLevels || []).find(({ rate }) => rate === normalizedRate) ||
47
+ (consumptionLevels || [])[0] ||
48
+ {};
46
49
  const { rates = [] } =
47
50
  levels.find(({ name }) => name && name === subsidyLevels[subsidy]) || levels[0] || {};
48
51
  const currentIndex = rates.findIndex(({ range }) => range[1] >= totalConsumption);
@@ -54,6 +57,8 @@ const RateCard = ({
54
57
  currentRate.range[currentRate.range.length - 1];
55
58
  const charges = client?.rate?.charges || [];
56
59
  const isT1 = purchasedRate.includes('T1');
60
+ const noLevels = isEmpty(consumptionLevels);
61
+ const showRateLabel = !isT1 || startRateValue === false || limitRateValue === false;
57
62
 
58
63
  const openExternalLink = () => ratesTableLink && Linking.openURL(ratesTableLink);
59
64
 
@@ -66,25 +71,27 @@ const RateCard = ({
66
71
  <UTLabel colorTheme="gray">{helpText}</UTLabel>
67
72
  </View>
68
73
 
69
- <ProgressBar
70
- colors={colors}
71
- currentPeriod={currentPeriod}
72
- data={rates}
73
- isT1={isT1}
74
- limitValue={limitRateValue}
75
- specificRate={currentRate}
76
- tooltipContent={tooltipContent}
77
- translations={rateCardTranslations}
78
- value={Number(totalConsumption) || 0}
79
- />
74
+ {!noLevels && (
75
+ <ProgressBar
76
+ colors={colors}
77
+ currentPeriod={currentPeriod}
78
+ data={rates}
79
+ isT1={isT1}
80
+ limitValue={limitRateValue}
81
+ specificRate={currentRate}
82
+ tooltipContent={tooltipContent}
83
+ translations={rateCardTranslations}
84
+ value={Number(totalConsumption) || 0}
85
+ />
86
+ )}
80
87
 
81
- <View style={styles.consumptionDataContainer}>
88
+ <View style={[styles.consumptionDataContainer, noLevels && styles.noLevels]}>
82
89
  <View style={styles.consumptionContent}>
83
90
  <UTLabel variant="title3" weight="medium">
84
91
  {getCurrentRate(purchasedRate, currentRate)}
85
92
  </UTLabel>
86
93
  <UTLabel colorTheme="gray" variant="small">
87
- {!isT1
94
+ {showRateLabel
88
95
  ? yourRate
89
96
  : limitRateValue === 'Infinity'
90
97
  ? startRateValueLabel?.(startRateValue)
@@ -109,7 +116,7 @@ const RateCard = ({
109
116
  {concept}
110
117
  </UTLabel>
111
118
  <UTLabel variant="subtitle1" weight="medium">
112
- {formatAmount?.(amount)}
119
+ {formatAmount?.(amount) || '-'}
113
120
  </UTLabel>
114
121
  </View>
115
122
  ))}
@@ -22,6 +22,9 @@ export const createStyles = colors =>
22
22
  paddingTop: 16,
23
23
  paddingHorizontal: 16
24
24
  },
25
+ noLevels: {
26
+ paddingTop: 0
27
+ },
25
28
  consumptionContent: {
26
29
  flex: 1
27
30
  },
@@ -1,9 +1,8 @@
1
1
  /* eslint-disable react/forbid-prop-types */
2
- import React, { useEffect } from 'react';
2
+ import React from 'react';
3
3
  import { Image, ScrollView, View } from 'react-native';
4
4
  import { Surface, UTActionCard, UTLabel } from '@widergy/mobile-ui';
5
5
  import { func, object, shape, string } from 'prop-types';
6
- import isEmpty from 'lodash/isEmpty';
7
6
 
8
7
  import { getCurrentPeriod, getFormattedDate } from './utils';
9
8
  import { createStyles } from './styles';
@@ -69,8 +68,7 @@ const Billing = ({
69
68
  const {
70
69
  handleAutomaticDebitAdherence = () => {},
71
70
  handleDownloadBill = () => {},
72
- handleGoToDigitalBill = () => {},
73
- getConsumptionLevels = () => {}
71
+ handleGoToDigitalBill = () => {}
74
72
  } = handlers;
75
73
  const {
76
74
  adherence_to_automatic_debit: adherenceToAutomaticDebit,
@@ -118,11 +116,6 @@ const Billing = ({
118
116
  };
119
117
  });
120
118
 
121
- useEffect(() => {
122
- if (isEmpty(consumptionLevels)) getConsumptionLevels();
123
- // eslint-disable-next-line react-hooks/exhaustive-deps
124
- }, []);
125
-
126
119
  return (
127
120
  <ScrollView>
128
121
  <View style={styles.generalContainer}>
@@ -168,23 +161,21 @@ const Billing = ({
168
161
  </UTLabel>
169
162
  </Surface>
170
163
 
171
- {!isEmpty(consumptionLevels) && (
172
- <RateCard
173
- {...{
174
- colors,
175
- consumptionLevels,
176
- currentPeriod,
177
- formatAmount,
178
- normalizedRate,
179
- rateCardTranslations,
180
- ratesTableLink,
181
- smartBill,
182
- subsidy,
183
- subsidyLevels,
184
- translations
185
- }}
186
- />
187
- )}
164
+ <RateCard
165
+ {...{
166
+ colors,
167
+ consumptionLevels,
168
+ currentPeriod,
169
+ formatAmount,
170
+ normalizedRate,
171
+ rateCardTranslations,
172
+ ratesTableLink,
173
+ smartBill,
174
+ subsidy,
175
+ subsidyLevels,
176
+ translations
177
+ }}
178
+ />
188
179
 
189
180
  {actionCards?.map(({ onPress, Icon = 'IconChevronRight', statusAttributes = {}, title }) => (
190
181
  <UTActionCard