@widergy/utilitygo-smart-bill-mobile 3.9.0 → 3.11.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 +15 -0
- package/package.json +1 -1
- package/src/lib/components/SmartBillSummary/constants.js +0 -2
- package/src/lib/components/SmartBillSummary/index.js +8 -2
- package/src/lib/components/SmartBillSummary/tabs/Consumptions/components/Billing/index.js +1 -1
- package/src/lib/components/SmartBillSummary/tabs/Consumptions/components/ProgressBarCard/components/ProgressBarItem/index.js +90 -0
- package/src/lib/components/SmartBillSummary/tabs/Consumptions/components/ProgressBarCard/components/ProgressBarItem/styles.js +60 -0
- package/src/lib/components/SmartBillSummary/tabs/Consumptions/components/ProgressBarCard/components/ProgressBarItem/utils.js +6 -0
- package/src/lib/components/SmartBillSummary/tabs/Consumptions/components/ProgressBarCard/components/ReiterationBanner/index.js +40 -0
- package/src/lib/components/SmartBillSummary/tabs/Consumptions/components/ProgressBarCard/components/ReiterationBanner/styles.js +36 -0
- package/src/lib/components/SmartBillSummary/tabs/Consumptions/components/ProgressBarCard/components/SimpleBanner/index.js +25 -0
- package/src/lib/components/SmartBillSummary/tabs/Consumptions/components/ProgressBarCard/components/SimpleBanner/styles.js +19 -0
- package/src/lib/components/SmartBillSummary/tabs/Consumptions/components/ProgressBarCard/constants.js +5 -0
- package/src/lib/components/SmartBillSummary/tabs/Consumptions/components/ProgressBarCard/index.js +56 -0
- package/src/lib/components/SmartBillSummary/tabs/Consumptions/components/ProgressBarCard/utils.js +29 -0
- package/src/lib/components/SmartBillSummary/tabs/Consumptions/constants.js +9 -0
- package/src/lib/components/SmartBillSummary/tabs/Consumptions/index.js +31 -6
- package/src/lib/components/SmartBillSummary/utils.js +2 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# [3.11.0](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/compare/v3.10.0...v3.11.0) (2026-02-26)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* [EVEP-273] smartbill t2 t3 ([#66](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/issues/66)) ([ddef20b](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/commit/ddef20b121aeec0510b49d2ba2e7e9056c10ffc9))
|
|
7
|
+
|
|
8
|
+
# [3.10.0](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/compare/v3.9.0...v3.10.0) (2026-02-26)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* [EVEP-273] smartbill t2 t3 ([#64](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/issues/64)) ([1f9a6fc](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/commit/1f9a6fcc56eeb5cacf5ae290e0b1496d6d1b6792))
|
|
14
|
+
* [EVEP-273] smartbill t2 t3 ([#65](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/issues/65)) ([387c186](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/commit/387c186d6469976b1985809e32e5e75e49c48d21))
|
|
15
|
+
|
|
1
16
|
# [3.9.0](https://github.com/widergy/UtilityGO-Smart-Bill-Mobile/compare/v3.8.0...v3.9.0) (2026-02-10)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
|
@@ -7,8 +7,6 @@ import Consumptions from './tabs/Consumptions';
|
|
|
7
7
|
import Billing from './tabs/Billing';
|
|
8
8
|
import Glossary from './tabs/Glossary';
|
|
9
9
|
|
|
10
|
-
export const BIMESTRAL_PERIODICITY = 'BIMESTRAL';
|
|
11
|
-
|
|
12
10
|
// eslint-disable-next-line react/display-name
|
|
13
11
|
const renderComponentWithProps = (Component, tab) => props => (
|
|
14
12
|
<Component {...props} assets={props?.assets?.[tab] || {}} translations={props?.translations?.[tab] || {}} />
|
|
@@ -19,6 +19,7 @@ const SmartBillSummary = ({
|
|
|
19
19
|
colors,
|
|
20
20
|
components,
|
|
21
21
|
constants = {},
|
|
22
|
+
consumptionLayout,
|
|
22
23
|
FabComponent,
|
|
23
24
|
handlers,
|
|
24
25
|
loading,
|
|
@@ -27,6 +28,7 @@ const SmartBillSummary = ({
|
|
|
27
28
|
translations,
|
|
28
29
|
utils,
|
|
29
30
|
periodSpan,
|
|
31
|
+
progressBarConcept,
|
|
30
32
|
walkthroughStep
|
|
31
33
|
}) => {
|
|
32
34
|
const styles = getStyles(colors);
|
|
@@ -50,7 +52,7 @@ const SmartBillSummary = ({
|
|
|
50
52
|
trackAIFloatingButtonClick,
|
|
51
53
|
trackTabChange
|
|
52
54
|
} = handlers;
|
|
53
|
-
const filteredTabOptions = getTabOptions([...(tabOptions || [])]
|
|
55
|
+
const filteredTabOptions = getTabOptions([...(tabOptions || [])]) || [];
|
|
54
56
|
const defaultCurrentTab = getDefaultCurrentTab(filteredTabOptions);
|
|
55
57
|
const [currentTab, setCurrentTab] = useState(defaultCurrentTab);
|
|
56
58
|
const [tabsKey, setTabsKey] = useState(0);
|
|
@@ -240,13 +242,15 @@ const SmartBillSummary = ({
|
|
|
240
242
|
billingLayout,
|
|
241
243
|
colors,
|
|
242
244
|
constants,
|
|
245
|
+
consumptionLayout,
|
|
243
246
|
handlers,
|
|
244
247
|
loading,
|
|
245
248
|
smartBill,
|
|
246
249
|
tabOptions: [...(tabOptions || [])],
|
|
247
250
|
translations,
|
|
248
251
|
utils,
|
|
249
|
-
periodSpan
|
|
252
|
+
periodSpan,
|
|
253
|
+
progressBarConcept
|
|
250
254
|
})}
|
|
251
255
|
</ScrollView>
|
|
252
256
|
|
|
@@ -302,6 +306,7 @@ SmartBillSummary.propTypes = {
|
|
|
302
306
|
colors: object,
|
|
303
307
|
components: object,
|
|
304
308
|
constants: object,
|
|
309
|
+
consumptionLayout: array,
|
|
305
310
|
FabComponent: object,
|
|
306
311
|
handlers: shape({ [string]: func }),
|
|
307
312
|
loading: bool,
|
|
@@ -318,6 +323,7 @@ SmartBillSummary.propTypes = {
|
|
|
318
323
|
translations: object,
|
|
319
324
|
utils: object,
|
|
320
325
|
periodSpan: string,
|
|
326
|
+
progressBarConcept: array,
|
|
321
327
|
walkthroughStep: object
|
|
322
328
|
};
|
|
323
329
|
|
|
@@ -19,7 +19,7 @@ const Billing = ({
|
|
|
19
19
|
}) => {
|
|
20
20
|
const styles = createStyles(colors);
|
|
21
21
|
const { dateRange, title, tagLabel, clarification, periodDetail } = texts?.billing || {};
|
|
22
|
-
const currentPeriod = smartBill?.periods
|
|
22
|
+
const currentPeriod = smartBill?.periods?.find(period => period.current);
|
|
23
23
|
const billingsToShow = getBillingsToShow(currentPeriod?.settlements, periodSpan);
|
|
24
24
|
|
|
25
25
|
const { start_date: startDate, end_date: endDate } = currentPeriod?.settlements || {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { UTIcon, UTLabel, UTProgressBar, UTTooltip } from '@widergy/mobile-ui';
|
|
3
|
+
import { object } from 'prop-types';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
|
|
6
|
+
import { VARIANT } from '../../constants';
|
|
7
|
+
|
|
8
|
+
import { formatNumber } from './utils';
|
|
9
|
+
import { createStyles, getBarCustomStyles } from './styles';
|
|
10
|
+
|
|
11
|
+
const ProgressBarItem = ({ colors, item }) => {
|
|
12
|
+
const { title, tooltip, isExceeded, registered, limit, unit, excess, progressValue, variant } = item;
|
|
13
|
+
|
|
14
|
+
const styles = useMemo(() => createStyles(colors), [colors]);
|
|
15
|
+
const barThemeOverride = useMemo(() => getBarCustomStyles(colors, item), [colors, item]);
|
|
16
|
+
|
|
17
|
+
const [leftData, rightData] = registered.value >= limit.value ? [limit, registered] : [registered, limit];
|
|
18
|
+
|
|
19
|
+
const colorConfig = {
|
|
20
|
+
[VARIANT.DEFAULT]: { left: 'gray', right: 'gray' },
|
|
21
|
+
[VARIANT.EXCEEDED]: { left: 'gray', right: 'error' },
|
|
22
|
+
[VARIANT.PENALTY]: { left: 'error', right: 'gray' }
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const { left: leftColor, right: rightColor } = colorConfig[variant] || colorConfig[VARIANT.DEFAULT];
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<View style={styles.card}>
|
|
29
|
+
<View style={styles.mainSection}>
|
|
30
|
+
<UTLabel variant="small" colorTheme="gray">
|
|
31
|
+
{title}
|
|
32
|
+
</UTLabel>
|
|
33
|
+
|
|
34
|
+
<View style={styles.progressBarWrapper}>
|
|
35
|
+
<UTProgressBar value={progressValue} styles={barThemeOverride} showPercentage={false} />
|
|
36
|
+
|
|
37
|
+
<View style={styles.rowSpaceBetween}>
|
|
38
|
+
<View style={styles.valueGroup}>
|
|
39
|
+
<UTLabel colorTheme={leftColor} variant="title2">
|
|
40
|
+
{formatNumber(leftData.value)}
|
|
41
|
+
</UTLabel>
|
|
42
|
+
<UTLabel colorTheme={leftColor} variant="subtitle2">
|
|
43
|
+
{unit}
|
|
44
|
+
</UTLabel>
|
|
45
|
+
</View>
|
|
46
|
+
<View style={styles.valueGroup}>
|
|
47
|
+
<UTLabel variant="title1" colorTheme={rightColor}>
|
|
48
|
+
{formatNumber(rightData.value)}
|
|
49
|
+
</UTLabel>
|
|
50
|
+
<UTLabel variant="subtitle2" colorTheme={rightColor}>
|
|
51
|
+
{unit}
|
|
52
|
+
</UTLabel>
|
|
53
|
+
</View>
|
|
54
|
+
</View>
|
|
55
|
+
|
|
56
|
+
<View style={styles.rowSpaceBetween}>
|
|
57
|
+
<UTLabel variant="small">{leftData.label}</UTLabel>
|
|
58
|
+
<UTLabel variant="small">{rightData.label}</UTLabel>
|
|
59
|
+
</View>
|
|
60
|
+
</View>
|
|
61
|
+
</View>
|
|
62
|
+
|
|
63
|
+
{isExceeded && (
|
|
64
|
+
<View>
|
|
65
|
+
<View style={styles.divider} />
|
|
66
|
+
<View style={styles.footerSection}>
|
|
67
|
+
<View style={styles.rowSpaceBetween}>
|
|
68
|
+
<UTLabel variant="subtitle2">{excess.label}</UTLabel>
|
|
69
|
+
<View style={styles.rowGap}>
|
|
70
|
+
<UTTooltip content={<UTLabel>{tooltip}</UTLabel>}>
|
|
71
|
+
<UTIcon colorTheme="error" name="IconInfoCircle" size={24} />
|
|
72
|
+
</UTTooltip>
|
|
73
|
+
<UTLabel variant="subtitle2" colorTheme="error">
|
|
74
|
+
{formatNumber(excess.value)} {unit}
|
|
75
|
+
</UTLabel>
|
|
76
|
+
</View>
|
|
77
|
+
</View>
|
|
78
|
+
</View>
|
|
79
|
+
</View>
|
|
80
|
+
)}
|
|
81
|
+
</View>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
ProgressBarItem.propTypes = {
|
|
86
|
+
colors: object.isRequired,
|
|
87
|
+
item: object.isRequired
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export default ProgressBarItem;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { VARIANT } from '../../constants';
|
|
4
|
+
|
|
5
|
+
export const createStyles = colors =>
|
|
6
|
+
StyleSheet.create({
|
|
7
|
+
card: {
|
|
8
|
+
backgroundColor: colors.light01,
|
|
9
|
+
borderRadius: 8,
|
|
10
|
+
elevation: 3,
|
|
11
|
+
marginBottom: 16,
|
|
12
|
+
maxWidth: '100%'
|
|
13
|
+
},
|
|
14
|
+
divider: { backgroundColor: colors.light04, height: 1 },
|
|
15
|
+
footerSection: { padding: 16 },
|
|
16
|
+
mainSection: { gap: 16, padding: 16 },
|
|
17
|
+
progressBarWrapper: { gap: 8 },
|
|
18
|
+
rowGap: { alignItems: 'center', flexDirection: 'row', gap: 8 },
|
|
19
|
+
rowSpaceBetween: {
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
flexDirection: 'row',
|
|
22
|
+
justifyContent: 'space-between'
|
|
23
|
+
},
|
|
24
|
+
valueGroup: {
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
flexDirection: 'row',
|
|
27
|
+
gap: 4
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const getBarCustomStyles = (colors, item) => {
|
|
32
|
+
const { min, variant } = item;
|
|
33
|
+
const isExceeded = variant === VARIANT.EXCEEDED || variant === VARIANT.PENALTY;
|
|
34
|
+
const barColor = colors.actionAccent04;
|
|
35
|
+
const trackColor = min ? colors.actionAccent03 : colors.light04;
|
|
36
|
+
const overheadFill = colors.semanticError04;
|
|
37
|
+
const overheadStroke = min ? '#FFFFFF' : 'transparent';
|
|
38
|
+
const overheadStrokeWidth = min ? 14 : 1;
|
|
39
|
+
const overheadTransform = min ? [{ scaleX: -1 }] : [];
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
barContainer: {
|
|
43
|
+
backgroundColor: trackColor,
|
|
44
|
+
borderRadius: 100,
|
|
45
|
+
height: 12
|
|
46
|
+
},
|
|
47
|
+
progressBar: {
|
|
48
|
+
backgroundColor: barColor,
|
|
49
|
+
borderRadius: 100,
|
|
50
|
+
borderRightColor: '#FFFFFF',
|
|
51
|
+
borderRightWidth: min && !isExceeded ? 2 : 0
|
|
52
|
+
},
|
|
53
|
+
overheadBar: {
|
|
54
|
+
fill: overheadFill,
|
|
55
|
+
stroke: overheadStroke,
|
|
56
|
+
strokeWidth: overheadStrokeWidth,
|
|
57
|
+
transform: overheadTransform
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { UTButton, UTIcon, UTLabel } from '@widergy/mobile-ui';
|
|
4
|
+
import { string, object, func } from 'prop-types';
|
|
5
|
+
|
|
6
|
+
import { createStyles } from './styles';
|
|
7
|
+
|
|
8
|
+
const ReiterationBanner = ({ bannerText, colors, handleGoToReiteration, texts }) => {
|
|
9
|
+
const { title, description, button } = texts;
|
|
10
|
+
const styles = createStyles(colors);
|
|
11
|
+
return (
|
|
12
|
+
<View style={styles.reiterationContainer}>
|
|
13
|
+
<View style={styles.reiterationContent}>
|
|
14
|
+
<View style={styles.reiterationSubcontent}>
|
|
15
|
+
<UTIcon name="IconReceipt2" size={24} colorTheme="error" />
|
|
16
|
+
<View style={styles.reiterationTexts}>
|
|
17
|
+
<UTLabel variant="subtitle1" weight="medium">
|
|
18
|
+
{title}
|
|
19
|
+
</UTLabel>
|
|
20
|
+
<UTLabel>{description}</UTLabel> {bannerText && <UTLabel>{bannerText}</UTLabel>}
|
|
21
|
+
</View>
|
|
22
|
+
</View>
|
|
23
|
+
</View>
|
|
24
|
+
{button && (
|
|
25
|
+
<View style={styles.actionButton}>
|
|
26
|
+
<UTButton onPress={handleGoToReiteration} variant="text">
|
|
27
|
+
{button}
|
|
28
|
+
</UTButton>
|
|
29
|
+
</View>
|
|
30
|
+
)}
|
|
31
|
+
</View>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
ReiterationBanner.propTypes = {
|
|
35
|
+
bannerText: string,
|
|
36
|
+
colors: object,
|
|
37
|
+
handleGoToReiteration: func,
|
|
38
|
+
texts: object
|
|
39
|
+
};
|
|
40
|
+
export default ReiterationBanner;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export const createStyles = colors =>
|
|
4
|
+
StyleSheet.create({
|
|
5
|
+
actionButton: {
|
|
6
|
+
borderTopColor: colors.semanticError02,
|
|
7
|
+
borderTopWidth: 1,
|
|
8
|
+
flexDirection: 'row',
|
|
9
|
+
justifyContent: 'flex-end',
|
|
10
|
+
padding: 8
|
|
11
|
+
},
|
|
12
|
+
reiterationContainer: {
|
|
13
|
+
backgroundColor: colors.semanticError01,
|
|
14
|
+
borderRadius: 8,
|
|
15
|
+
flexDirection: 'column',
|
|
16
|
+
marginBottom: 16,
|
|
17
|
+
width: '100%'
|
|
18
|
+
},
|
|
19
|
+
reiterationContent: {
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
flexDirection: 'row',
|
|
22
|
+
gap: 16,
|
|
23
|
+
padding: 16
|
|
24
|
+
},
|
|
25
|
+
reiterationSubcontent: {
|
|
26
|
+
alignItems: 'flex-start',
|
|
27
|
+
flexDirection: 'row',
|
|
28
|
+
gap: 16
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
reiterationTexts: {
|
|
32
|
+
flexDirection: 'column',
|
|
33
|
+
flexShrink: 1,
|
|
34
|
+
gap: 8
|
|
35
|
+
}
|
|
36
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { UTIcon, UTLabel } from '@widergy/mobile-ui';
|
|
3
|
+
import { object, string } from 'prop-types';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
|
|
6
|
+
import { createStyles } from './styles';
|
|
7
|
+
|
|
8
|
+
const SimpleBanner = ({ bannerText, colors }) => {
|
|
9
|
+
const styles = createStyles(colors);
|
|
10
|
+
return (
|
|
11
|
+
<View style={styles.bannerDetail}>
|
|
12
|
+
<UTIcon name="IconReceipt2" colorTheme="error" size={24} />
|
|
13
|
+
<View style={styles.textContainer}>
|
|
14
|
+
<UTLabel>{bannerText}</UTLabel>
|
|
15
|
+
</View>
|
|
16
|
+
</View>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
SimpleBanner.propTypes = {
|
|
21
|
+
bannerText: string.isRequired,
|
|
22
|
+
colors: object
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default SimpleBanner;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export const createStyles = colors =>
|
|
4
|
+
StyleSheet.create({
|
|
5
|
+
bannerDetail: {
|
|
6
|
+
alignItems: 'flex-start',
|
|
7
|
+
backgroundColor: colors.semanticError01,
|
|
8
|
+
borderRadius: 8,
|
|
9
|
+
display: 'flex',
|
|
10
|
+
flexDirection: 'row',
|
|
11
|
+
gap: 8,
|
|
12
|
+
marginBottom: 16,
|
|
13
|
+
maxWidth: '100%',
|
|
14
|
+
padding: 8
|
|
15
|
+
},
|
|
16
|
+
textContainer: {
|
|
17
|
+
flexShrink: 1
|
|
18
|
+
}
|
|
19
|
+
});
|
package/src/lib/components/SmartBillSummary/tabs/Consumptions/components/ProgressBarCard/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { object, array, func } from 'prop-types';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import ProgressBarItem from './components/ProgressBarItem';
|
|
6
|
+
import ReiterationBanner from './components/ReiterationBanner';
|
|
7
|
+
import SimpleBanner from './components/SimpleBanner';
|
|
8
|
+
import { getInfo } from './utils';
|
|
9
|
+
|
|
10
|
+
const ProgressBarCard = ({ colors, handleGoToReiteration, progressBarConcept, smartBill, texts }) => {
|
|
11
|
+
const itemsWithStatus = progressBarConcept
|
|
12
|
+
.filter(concept =>
|
|
13
|
+
concept.accountConditions.some(condition =>
|
|
14
|
+
smartBill?.client?.rate?.purchased?.includes(condition.rate)
|
|
15
|
+
)
|
|
16
|
+
)
|
|
17
|
+
.map(concept => {
|
|
18
|
+
const info = getInfo(concept, smartBill);
|
|
19
|
+
return { ...concept, ...info };
|
|
20
|
+
});
|
|
21
|
+
const renderedProgressBars = itemsWithStatus.map(item => (
|
|
22
|
+
<ProgressBarItem colors={colors} key={item.id} item={item} />
|
|
23
|
+
));
|
|
24
|
+
const exceededItems = itemsWithStatus.filter(item => item.isExceeded);
|
|
25
|
+
const reiteration = !!smartBill.reiteration;
|
|
26
|
+
const bannerText =
|
|
27
|
+
exceededItems.length === 1 && !reiteration
|
|
28
|
+
? exceededItems[0].banner
|
|
29
|
+
: exceededItems.length === 2
|
|
30
|
+
? reiteration
|
|
31
|
+
? exceededItems[1]?.banner
|
|
32
|
+
: exceededItems[1].doubleBanner
|
|
33
|
+
: null;
|
|
34
|
+
return (
|
|
35
|
+
<View>
|
|
36
|
+
{reiteration && (
|
|
37
|
+
<ReiterationBanner
|
|
38
|
+
bannerText={bannerText}
|
|
39
|
+
colors={colors}
|
|
40
|
+
handleGoToReiteration={handleGoToReiteration}
|
|
41
|
+
texts={texts.reiterationBanner}
|
|
42
|
+
/>
|
|
43
|
+
)}
|
|
44
|
+
{bannerText && !reiteration && <SimpleBanner bannerText={bannerText} colors={colors} />}
|
|
45
|
+
{renderedProgressBars}
|
|
46
|
+
</View>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
ProgressBarCard.propTypes = {
|
|
50
|
+
colors: object,
|
|
51
|
+
handleGoToReiteration: func,
|
|
52
|
+
progressBarConcept: array,
|
|
53
|
+
smartBill: object,
|
|
54
|
+
texts: object
|
|
55
|
+
};
|
|
56
|
+
export default ProgressBarCard;
|
package/src/lib/components/SmartBillSummary/tabs/Consumptions/components/ProgressBarCard/utils.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { VARIANT } from './constants';
|
|
2
|
+
|
|
3
|
+
const getValue = (smartBill, magnitudeName) => {
|
|
4
|
+
const item = smartBill?.periods?.[0]?.consumptions?.find(c => c.magnitude === magnitudeName);
|
|
5
|
+
return item ? { value: item.value || 0, unit: item.unit || '' } : { value: 0, unit: '' };
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const getInfo = (concept, smartBill) => {
|
|
9
|
+
const { data, min } = concept;
|
|
10
|
+
const { registered, limit, excess } = data;
|
|
11
|
+
const { value: registeredVal, unit } = getValue(smartBill, registered.magnitude);
|
|
12
|
+
const { value: limitVal } = getValue(smartBill, limit.magnitude);
|
|
13
|
+
const { value: excessVal } = getValue(smartBill, excess.magnitude);
|
|
14
|
+
const isExceeded = excessVal > 0;
|
|
15
|
+
const variant = isExceeded ? (min ? VARIANT.PENALTY : VARIANT.EXCEEDED) : VARIANT.DEFAULT;
|
|
16
|
+
const progressValue =
|
|
17
|
+
limitVal > 0 && registeredVal > 0 ? (min ? limitVal / registeredVal : registeredVal / limitVal) : 0;
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
...concept,
|
|
21
|
+
variant,
|
|
22
|
+
progressValue,
|
|
23
|
+
isExceeded,
|
|
24
|
+
unit,
|
|
25
|
+
registered: { ...registered, value: registeredVal },
|
|
26
|
+
limit: { ...limit, value: limitVal },
|
|
27
|
+
excess: { ...excess, value: excessVal }
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { UTLabel } from '@widergy/mobile-ui';
|
|
3
3
|
import { View } from 'react-native';
|
|
4
|
-
import { object, string } from 'prop-types';
|
|
4
|
+
import { object, string, array } from 'prop-types';
|
|
5
5
|
|
|
6
6
|
import styles from './styles';
|
|
7
7
|
import BimestralConsumption from './components/BimestralConsumption';
|
|
8
|
-
import
|
|
9
|
-
import CurrentConsumption from './components/CurrentConsumption';
|
|
8
|
+
import { COMPONENTS } from './constants';
|
|
10
9
|
|
|
11
|
-
const Consumptions = ({
|
|
10
|
+
const Consumptions = ({
|
|
11
|
+
assets,
|
|
12
|
+
colors,
|
|
13
|
+
consumptionLayout,
|
|
14
|
+
handlers,
|
|
15
|
+
progressBarConcept,
|
|
16
|
+
smartBill,
|
|
17
|
+
translations,
|
|
18
|
+
periodSpan
|
|
19
|
+
}) => {
|
|
12
20
|
const { title, description } = translations?.consumptions || {};
|
|
21
|
+
const props = {
|
|
22
|
+
assets,
|
|
23
|
+
colors,
|
|
24
|
+
smartBill,
|
|
25
|
+
texts: translations,
|
|
26
|
+
periodSpan,
|
|
27
|
+
handleGoToReiteration: handlers?.handleGoToReiteration,
|
|
28
|
+
progressBarConcept
|
|
29
|
+
};
|
|
13
30
|
|
|
14
31
|
return (
|
|
15
32
|
<View style={styles.generalContainer}>
|
|
@@ -24,8 +41,13 @@ const Consumptions = ({ assets, colors, smartBill, translations, periodSpan }) =
|
|
|
24
41
|
</View>
|
|
25
42
|
|
|
26
43
|
<View style={styles.consumptionDetailColumns}>
|
|
27
|
-
|
|
28
|
-
|
|
44
|
+
{consumptionLayout.map(item => {
|
|
45
|
+
if (item.enabled) {
|
|
46
|
+
const Component = COMPONENTS[item.name];
|
|
47
|
+
return Component && <Component key={item.name} {...props} />;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
})}
|
|
29
51
|
</View>
|
|
30
52
|
</View>
|
|
31
53
|
</View>
|
|
@@ -35,6 +57,9 @@ const Consumptions = ({ assets, colors, smartBill, translations, periodSpan }) =
|
|
|
35
57
|
Consumptions.propTypes = {
|
|
36
58
|
assets: object,
|
|
37
59
|
colors: object,
|
|
60
|
+
consumptionLayout: array,
|
|
61
|
+
handlers: object,
|
|
62
|
+
progressBarConcept: array,
|
|
38
63
|
smartBill: object,
|
|
39
64
|
translations: object,
|
|
40
65
|
periodSpan: string
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import { isEmpty } from 'lodash';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { BIMESTRAL_PERIODICITY } from './constants';
|
|
6
|
-
|
|
7
|
-
export const getTabOptions = (tabOptions, smartBill) => {
|
|
8
|
-
const hasBimestralPeriodicity = smartBill?.periods?.some(
|
|
9
|
-
period => period.settlements?.periodicity === BIMESTRAL_PERIODICITY
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
return tabOptions.filter(
|
|
13
|
-
({ enabled, value }) => enabled && (value !== SMARTBILL_TABS.CONSUMPTIONS || hasBimestralPeriodicity)
|
|
14
|
-
);
|
|
3
|
+
export const getTabOptions = tabOptions => {
|
|
4
|
+
return tabOptions.filter(({ enabled }) => enabled);
|
|
15
5
|
};
|
|
16
6
|
|
|
17
7
|
export const getDefaultCurrentTab = tabOptions =>
|