@widergy/utilitygo-smart-bill-web 2.2.1 → 3.0.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 +20 -0
- package/dist/components/Advice/index.js +11 -8
- package/dist/components/Amount/index.js +27 -23
- package/dist/components/Amount/utils.js +1 -5
- package/dist/components/Banner/index.js +11 -8
- package/dist/components/BarChart/constants.js +3 -6
- package/dist/components/BarChart/index.js +29 -24
- package/dist/components/BarChart/utils.js +15 -15
- package/dist/components/BillCalculation/components/ConceptCard/index.js +53 -47
- package/dist/components/BillCalculation/components/Glossary/index.js +49 -66
- package/dist/components/BillCalculation/components/Glossary/styles.module.scss +1 -0
- package/dist/components/BillCalculation/constants.js +1 -2
- package/dist/components/BillCalculation/index.js +49 -53
- package/dist/components/BillCalculation/utils.js +19 -22
- package/dist/components/BillSummary/components/BilledConcepts/components/Concept/index.js +26 -24
- package/dist/components/BillSummary/components/BilledConcepts/components/PieChartContainer/constants.js +2 -3
- package/dist/components/BillSummary/components/BilledConcepts/components/PieChartContainer/index.js +16 -17
- package/dist/components/BillSummary/components/BilledConcepts/components/PieChartContainer/styles.module.scss +3 -3
- package/dist/components/BillSummary/components/BilledConcepts/constants.js +12 -17
- package/dist/components/BillSummary/components/BilledConcepts/index.js +30 -41
- package/dist/components/BillSummary/components/BilledConcepts/utils.js +44 -68
- package/dist/components/BillSummary/index.js +71 -71
- package/dist/components/ConsumptionComparison/components/ComparisonTable/components/DataLine/index.js +9 -10
- package/dist/components/ConsumptionComparison/components/ComparisonTable/components/Season/index.js +18 -12
- package/dist/components/ConsumptionComparison/components/ComparisonTable/components/Season/utils.js +1 -1
- package/dist/components/ConsumptionComparison/components/ComparisonTable/constants.js +144 -143
- package/dist/components/ConsumptionComparison/components/ComparisonTable/index.js +17 -16
- package/dist/components/ConsumptionComparison/components/ComparisonTable/utils.js +84 -88
- package/dist/components/ConsumptionComparison/components/ConsumptionAdvice/index.js +22 -13
- package/dist/components/ConsumptionComparison/components/ConsumptionAdvice/utils.js +1 -1
- package/dist/components/ConsumptionComparison/components/PercentageComparison/index.js +22 -16
- package/dist/components/ConsumptionComparison/components/PercentageComparison/utils.js +13 -9
- package/dist/components/ConsumptionComparison/index.js +42 -47
- package/dist/components/ConsumptionEnergyDetails/components/ConsumptionEnergyComparison/index.js +28 -24
- package/dist/components/ConsumptionEnergyDetails/components/ConsumptionEnergyComparison/styles.module.scss +1 -1
- package/dist/components/ConsumptionEnergyDetails/components/ConsumptionInDaysLabel/index.js +19 -15
- package/dist/components/ConsumptionEnergyDetails/components/EnergyTotalConsumption/index.js +16 -14
- package/dist/components/ConsumptionEnergyDetails/components/PercentageComparison/index.js +22 -17
- package/dist/components/ConsumptionEnergyDetails/components/PercentageComparison/utils.js +1 -1
- package/dist/components/ConsumptionEnergyDetails/index.js +47 -43
- package/dist/components/ConsumptionEnergyDetails/styles.module.scss +2 -2
- package/dist/components/ConsumptionIncluded/components/TimelineRow/components/Card/index.js +65 -62
- package/dist/components/ConsumptionIncluded/components/TimelineRow/components/Card/utils.js +11 -13
- package/dist/components/ConsumptionIncluded/components/TimelineRow/components/HeaderConsumption/index.js +21 -19
- package/dist/components/ConsumptionIncluded/components/TimelineRow/components/HeaderSettlement/index.js +17 -12
- package/dist/components/ConsumptionIncluded/components/TimelineRow/index.js +43 -39
- package/dist/components/ConsumptionIncluded/components/TimelineRow/styles.module.scss +2 -2
- package/dist/components/ConsumptionIncluded/index.js +32 -34
- package/dist/components/ConsumptionIncluded/utils.js +29 -33
- package/dist/components/ConsumptionPeriod/components/ConsumptionSummary/components/ReadingRow/index.js +15 -12
- package/dist/components/ConsumptionPeriod/components/ConsumptionSummary/index.js +24 -22
- package/dist/components/ConsumptionPeriod/components/HistoryGraph/index.js +19 -28
- package/dist/components/ConsumptionPeriod/components/Reading/index.js +36 -34
- package/dist/components/ConsumptionPeriod/index.js +13 -10
- package/dist/components/ConsumptionPeriod/utils.js +13 -15
- package/dist/components/Date/index.js +13 -11
- package/dist/components/DebtState/index.js +15 -10
- package/dist/components/IconAndDetails/index.js +20 -19
- package/dist/components/Magnitude/index.js +16 -14
- package/dist/components/Magnitude/utils.js +2 -8
- package/dist/components/MainBillData/components/BillAlert/components/BillParticularConditions/index.js +19 -16
- package/dist/components/MainBillData/components/BillAlert/index.js +25 -33
- package/dist/components/MainBillData/components/BillBody/components/ClientData/index.js +20 -13
- package/dist/components/MainBillData/components/BillBody/components/Consumption/index.js +15 -13
- package/dist/components/MainBillData/components/BillBody/components/Consumption/utils.js +1 -3
- package/dist/components/MainBillData/components/BillBody/components/ReadingDetails/index.js +24 -17
- package/dist/components/MainBillData/components/BillBody/components/ReadingDetails/styles.module.scss +2 -2
- package/dist/components/MainBillData/components/BillBody/components/ReadingDetails/utils.js +1 -1
- package/dist/components/MainBillData/components/BillBody/index.js +43 -46
- package/dist/components/MainBillData/components/BillHeader/components/TypeAndNumber/index.js +17 -13
- package/dist/components/MainBillData/components/BillHeader/index.js +30 -26
- package/dist/components/MainBillData/components/BillHeader/styles.module.scss +1 -1
- package/dist/components/MainBillData/index.js +8 -7
- package/dist/components/MainBillData/theme.js +7 -9
- package/dist/components/MainBillData/utils.js +1 -5
- package/dist/components/Period/index.js +55 -45
- package/dist/components/PowerProgresBar/components/PowerConsumption/index.js +16 -13
- package/dist/components/PowerProgresBar/index.js +32 -32
- package/dist/components/RateAndCategory/index.js +26 -29
- package/dist/components/RatesDefinition/components/BillRate/components/RatePrices/index.js +21 -15
- package/dist/components/RatesDefinition/components/BillRate/index.js +25 -16
- package/dist/components/RatesDefinition/components/BillRate/styles.module.scss +1 -1
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/Category/index.js +15 -11
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/components/Indicator/components/IndicatorLabel/index.js +27 -23
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/components/Indicator/index.js +12 -9
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/components/Indicator/styles.module.scss +1 -1
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/components/Indicator/utils.js +9 -9
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/components/Legend/index.js +22 -21
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/components/Stages/index.js +35 -38
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/components/Stages/styles.module.scss +0 -1
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/constants.js +2 -4
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/index.js +18 -32
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/utils.js +35 -47
- package/dist/components/RatesDefinition/components/CategoryByConsumption/constants.js +18 -36
- package/dist/components/RatesDefinition/components/CategoryByConsumption/index.js +24 -33
- package/dist/components/RatesDefinition/components/CategoryByConsumption/utils.js +1 -5
- package/dist/components/RatesDefinition/components/PurchasedRate/index.js +20 -15
- package/dist/components/RatesDefinition/index.js +21 -17
- package/dist/components/RatesDefinition/styles.module.scss +1 -1
- package/dist/components/SmartBillProvider/index.js +13 -36
- package/dist/components/StyledAmount/constants.js +2 -3
- package/dist/components/StyledAmount/index.js +20 -29
- package/dist/components/WithContextApi/index.js +19 -27
- package/dist/components/WithContextApi/layout.js +3 -4
- package/dist/components/WithSeason/index.js +7 -11
- package/dist/constants/deviceSizes.js +27 -24
- package/dist/constants/seasons.js +3 -5
- package/dist/index.js +19 -19
- package/dist/scss/variables/commonColors.module.scss +1 -1
- package/dist/shared/Context/index.js +5 -3
- package/dist/shared/constants/aliases.js +691 -694
- package/dist/shared/constants/consumptions.js +5 -9
- package/dist/shared/constants/periodicities.js +2 -3
- package/dist/shared/constants/rates.js +2 -3
- package/dist/shared/constants/readings.js +3 -5
- package/dist/shared/constants/seasons.js +3 -5
- package/dist/shared/constants/stagesGraph.js +4 -8
- package/dist/shared/types/assetsTypes.js +1 -2
- package/dist/shared/types/billDataTypes.js +6 -11
- package/dist/shared/types/componentsTypes.js +19 -14
- package/dist/shared/types/formattersTypes.js +2 -3
- package/dist/shared/types/rateStagesTypes.js +3 -6
- package/dist/shared/types/smartBillTypes.js +5 -11
- package/dist/shared/types/textsTypes.js +2 -3
- package/dist/shared/utils/billCalculation.js +9 -9
- package/dist/shared/utils/consumptions.js +27 -55
- package/dist/shared/utils/context.js +6 -5
- package/dist/shared/utils/expirations.js +1 -5
- package/dist/shared/utils/periods.js +14 -20
- package/dist/shared/utils/rates.js +1 -5
- package/dist/shared/utils/readings.js +2 -10
- package/dist/shared/utils/season.js +1 -5
- package/dist/shared/utils/stagesGraph.js +11 -15
- package/dist/utils/hooks.js +2 -3
- package/dist/utils.js +4 -8
- package/package.json +26 -63
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -17,56 +16,54 @@ var _ConceptCard = _interopRequireDefault(require("./components/ConceptCard"));
|
|
|
17
16
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
18
17
|
var _Glossary = _interopRequireDefault(require("./components/Glossary"));
|
|
19
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
function _getRequireWildcardCache(
|
|
21
|
-
function _interopRequireWildcard(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
};
|
|
19
|
+
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); }
|
|
20
|
+
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 && Object.prototype.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; }
|
|
21
|
+
const BillCalculation = _ref => {
|
|
22
|
+
let {
|
|
23
|
+
billData,
|
|
24
|
+
contextApiInfo
|
|
25
|
+
} = _ref;
|
|
26
|
+
const {
|
|
27
|
+
Label,
|
|
28
|
+
config
|
|
29
|
+
} = contextApiInfo;
|
|
30
|
+
const {
|
|
31
|
+
texts,
|
|
32
|
+
showZeroConcepts,
|
|
33
|
+
stylesConfig,
|
|
34
|
+
formatters,
|
|
35
|
+
colors
|
|
36
|
+
} = config;
|
|
37
|
+
const {
|
|
38
|
+
periodFormatter
|
|
39
|
+
} = formatters;
|
|
40
|
+
const {
|
|
41
|
+
withBillCalcTitleDate
|
|
42
|
+
} = config.validations;
|
|
43
|
+
const {
|
|
44
|
+
detail
|
|
45
|
+
} = billData;
|
|
46
|
+
const [openedConcept, setOpenedConcept] = (0, _react.useState)(null);
|
|
47
|
+
const {
|
|
48
|
+
isDesktopSize
|
|
49
|
+
} = (0, _hooks.useScreenSize)();
|
|
50
|
+
const handleClick = index => setOpenedConcept(openedConcept !== index ? index : null);
|
|
51
|
+
const glossaryConcepts = (0, _utils.filterGlossaryConcepts)(detail.concepts, showZeroConcepts);
|
|
52
|
+
const title = (0, _utils.periodToTitleMapper)(billData, texts, periodFormatter, withBillCalcTitleDate(billData));
|
|
53
|
+
const handleRenderConceptCard = (concept, index) => (0, _utils.shouldShowConcept)(concept, showZeroConcepts) && /*#__PURE__*/_react.default.createElement(_ConceptCard.default, {
|
|
54
|
+
titleHeader: concept.title,
|
|
55
|
+
total: concept.total,
|
|
56
|
+
lines: concept.lines,
|
|
57
|
+
index: index,
|
|
58
|
+
isOpen: openedConcept === index,
|
|
59
|
+
onClick: handleClick,
|
|
60
|
+
key: concept.title
|
|
61
|
+
});
|
|
62
|
+
const GlossaryRenderer = () => glossaryConcepts.length > 0 && /*#__PURE__*/_react.default.createElement(_Glossary.default, {
|
|
63
|
+
glossaryConcepts: glossaryConcepts,
|
|
64
|
+
isDesktopSize: isDesktopSize,
|
|
65
|
+
showZeroConcepts: showZeroConcepts
|
|
66
|
+
});
|
|
70
67
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
71
68
|
className: _stylesModule.default.container
|
|
72
69
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -91,5 +88,4 @@ BillCalculation.propTypes = {
|
|
|
91
88
|
billData: _billDataTypes.billDataTypes,
|
|
92
89
|
contextApiInfo: _smartBillTypes.contextApiInfoTypes
|
|
93
90
|
};
|
|
94
|
-
var _default = (0, _WithContextApi.default)()(BillCalculation);
|
|
95
|
-
exports.default = _default;
|
|
91
|
+
var _default = exports.default = (0, _WithContextApi.default)()(BillCalculation);
|
|
@@ -9,21 +9,24 @@ var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
|
9
9
|
var _periodicities = require("../../shared/constants/periodicities");
|
|
10
10
|
var _periods = require("../../shared/utils/periods");
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
12
|
+
const periodToTitleMapper = (billData, texts, periodFormatter, withBillCalcTitleDate) => {
|
|
13
13
|
var _settlements$current, _settlements$current2;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
const currentPeriod = (0, _periods.getCurrentPeriod)(billData) || {};
|
|
15
|
+
const {
|
|
16
|
+
settlements
|
|
17
|
+
} = currentPeriod;
|
|
18
|
+
const periodicity = settlements === null || settlements === void 0 ? void 0 : settlements.periodicity;
|
|
19
|
+
const currentSettlement = (settlements === null || settlements === void 0 || (_settlements$current = settlements.current) === null || _settlements$current === void 0 ? void 0 : _settlements$current.number) || '-';
|
|
20
|
+
const totalSettlements = (settlements === null || settlements === void 0 ? void 0 : settlements.total_settlements) || '-';
|
|
21
|
+
const periodNumber = (currentPeriod === null || currentPeriod === void 0 ? void 0 : currentPeriod.number) || '-';
|
|
22
|
+
const year = (currentPeriod === null || currentPeriod === void 0 ? void 0 : currentPeriod.year) || '-';
|
|
23
|
+
const {
|
|
24
|
+
settlement,
|
|
25
|
+
period,
|
|
26
|
+
bimester
|
|
27
|
+
} = texts.commons;
|
|
28
|
+
const issuedDate = settlements === null || settlements === void 0 || (_settlements$current2 = settlements.current) === null || _settlements$current2 === void 0 ? void 0 : _settlements$current2.issued_on;
|
|
29
|
+
const issuedDateLabel = withBillCalcTitleDate ? " (".concat((0, _dayjs.default)(issuedDate, 'YYYY-MM-DD').format('MM/YYYY'), ")") : '';
|
|
27
30
|
if (periodFormatter) return periodFormatter({
|
|
28
31
|
startDate: settlements === null || settlements === void 0 ? void 0 : settlements.start_date,
|
|
29
32
|
endDate: settlements === null || settlements === void 0 ? void 0 : settlements.end_date
|
|
@@ -33,13 +36,7 @@ var periodToTitleMapper = function periodToTitleMapper(billData, texts, periodFo
|
|
|
33
36
|
return '-';
|
|
34
37
|
};
|
|
35
38
|
exports.periodToTitleMapper = periodToTitleMapper;
|
|
36
|
-
|
|
37
|
-
return concept.total !== 0 || showZeroConcepts;
|
|
38
|
-
};
|
|
39
|
+
const shouldShowConcept = (concept, showZeroConcepts) => concept.total !== 0 || showZeroConcepts;
|
|
39
40
|
exports.shouldShowConcept = shouldShowConcept;
|
|
40
|
-
|
|
41
|
-
return concepts.filter(function (concept) {
|
|
42
|
-
return concept.description && shouldShowConcept(concept, showZeroConcepts);
|
|
43
|
-
});
|
|
44
|
-
};
|
|
41
|
+
const filterGlossaryConcepts = (concepts, showZeroConcepts) => concepts.filter(concept => concept.description && shouldShowConcept(concept, showZeroConcepts));
|
|
45
42
|
exports.filterGlossaryConcepts = filterGlossaryConcepts;
|
|
@@ -14,28 +14,31 @@ var _hooks = require("../../../../../../utils/hooks");
|
|
|
14
14
|
var _aliases = require("../../../../../../shared/constants/aliases");
|
|
15
15
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
const Concept = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
contextApiInfo,
|
|
20
|
+
isFirst,
|
|
21
|
+
title,
|
|
22
|
+
percentage,
|
|
23
|
+
progressBarPercentage,
|
|
24
|
+
value,
|
|
25
|
+
showPercentage,
|
|
26
|
+
negativeAmmount,
|
|
27
|
+
showProgressBar,
|
|
28
|
+
color
|
|
29
|
+
} = _ref;
|
|
30
|
+
const {
|
|
31
|
+
Label,
|
|
32
|
+
ProgressBar
|
|
33
|
+
} = contextApiInfo;
|
|
34
|
+
const {
|
|
35
|
+
isDesktopSize
|
|
36
|
+
} = (0, _hooks.useScreenSize)();
|
|
37
|
+
const alias = isFirst ? _aliases.CONCEPT_FIRST_AMOUNT : _aliases.CONCEPT_SECONDARY_AMOUNT;
|
|
38
|
+
const aliasDecimal = isFirst ? _aliases.CONCEPT_FIRST_AMOUNT_DECIMAL : _aliases.CONCEPT_SECONDARY_AMOUNT_DECIMAL;
|
|
39
|
+
const aliasName = isFirst ? _aliases.CONCEPT_FIRST_NAME : _aliases.CONCEPT_SECONDARY_NAME;
|
|
40
|
+
const percentageValue = "".concat((0, _numeral.default)(percentage).format('0,0.0'), "%");
|
|
41
|
+
const renderPercentageValidation = withProgresBar => showPercentage && percentage && (withProgresBar ? showProgressBar : !showProgressBar);
|
|
39
42
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
40
43
|
className: _stylesModule.default.container
|
|
41
44
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -87,5 +90,4 @@ Concept.propTypes = {
|
|
|
87
90
|
showProgressBar: _propTypes.bool,
|
|
88
91
|
color: _propTypes.string
|
|
89
92
|
};
|
|
90
|
-
var _default = (0, _WithContextApi.default)()(Concept);
|
|
91
|
-
exports.default = _default;
|
|
93
|
+
var _default = exports.default = (0, _WithContextApi.default)()(Concept);
|
|
@@ -4,11 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.PIE_CHART_CUSTOMIZATION = void 0;
|
|
7
|
-
|
|
7
|
+
const PIE_CHART_CUSTOMIZATION = exports.PIE_CHART_CUSTOMIZATION = {
|
|
8
8
|
animationLength: 800,
|
|
9
9
|
height: 200,
|
|
10
10
|
minAngle: 0.1,
|
|
11
11
|
outerRadius: 100,
|
|
12
12
|
width: 200
|
|
13
|
-
};
|
|
14
|
-
exports.PIE_CHART_CUSTOMIZATION = PIE_CHART_CUSTOMIZATION;
|
|
13
|
+
};
|
package/dist/components/BillSummary/components/BilledConcepts/components/PieChartContainer/index.js
CHANGED
|
@@ -13,18 +13,20 @@ var _constants = require("./constants");
|
|
|
13
13
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
const PieChartContainer = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
concepts,
|
|
19
|
+
additionalInfo,
|
|
20
|
+
contextApiInfo
|
|
21
|
+
} = _ref;
|
|
22
|
+
const {
|
|
23
|
+
PieChart
|
|
24
|
+
} = contextApiInfo;
|
|
25
|
+
const pieConceptsData = concepts.map(concept => ({
|
|
26
|
+
color: concept.color,
|
|
27
|
+
name: concept.title,
|
|
28
|
+
value: concept.total
|
|
29
|
+
}));
|
|
28
30
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
29
31
|
className: _stylesModule.default.container
|
|
30
32
|
}, !additionalInfo.negativeAmmount && /*#__PURE__*/_react.default.createElement(PieChart, _extends({
|
|
@@ -32,14 +34,11 @@ var PieChartContainer = function PieChartContainer(_ref) {
|
|
|
32
34
|
data: pieConceptsData,
|
|
33
35
|
withLabels: false,
|
|
34
36
|
withLegend: false
|
|
35
|
-
}, _constants.PIE_CHART_CUSTOMIZATION)), concepts.map(
|
|
36
|
-
return (0, _utils.renderConcept)(concept, additionalInfo, index === 0);
|
|
37
|
-
}));
|
|
37
|
+
}, _constants.PIE_CHART_CUSTOMIZATION)), concepts.map((concept, index) => (0, _utils.renderConcept)(concept, additionalInfo, index === 0)));
|
|
38
38
|
};
|
|
39
39
|
PieChartContainer.propTypes = {
|
|
40
40
|
additionalInfo: (0, _propTypes.shape)((0, _propTypes.objectOf)(_propTypes.any)),
|
|
41
41
|
concepts: (0, _propTypes.shape)((0, _propTypes.objectOf)(_propTypes.any)),
|
|
42
42
|
contextApiInfo: _smartBillTypes.contextApiInfoTypes
|
|
43
43
|
};
|
|
44
|
-
var _default = (0, _WithContextApi.default)()(PieChartContainer);
|
|
45
|
-
exports.default = _default;
|
|
44
|
+
var _default = exports.default = (0, _WithContextApi.default)()(PieChartContainer);
|
|
@@ -5,21 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.toggleOptions = exports.progressBar = exports.pieChart = exports.COLORS = void 0;
|
|
7
7
|
var _colorsExportModule = require("../../../../scss/variables/colorsExport.module.scss");
|
|
8
|
-
|
|
9
|
-
exports.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Icon: assets.PieGrayIcon,
|
|
20
|
-
SelectedIcon: assets.PieWhiteIcon
|
|
21
|
-
}];
|
|
22
|
-
};
|
|
8
|
+
const pieChart = exports.pieChart = 'pieChart';
|
|
9
|
+
const progressBar = exports.progressBar = 'progressBar';
|
|
10
|
+
const toggleOptions = assets => [{
|
|
11
|
+
value: progressBar,
|
|
12
|
+
Icon: assets.ListGrayIcon,
|
|
13
|
+
SelectedIcon: assets.ListWhiteIcon
|
|
14
|
+
}, {
|
|
15
|
+
value: pieChart,
|
|
16
|
+
Icon: assets.PieGrayIcon,
|
|
17
|
+
SelectedIcon: assets.PieWhiteIcon
|
|
18
|
+
}];
|
|
23
19
|
exports.toggleOptions = toggleOptions;
|
|
24
|
-
|
|
25
|
-
exports.COLORS = COLORS;
|
|
20
|
+
const COLORS = exports.COLORS = [_colorsExportModule.primary, _colorsExportModule.darkGray, _colorsExportModule.pieChartGray, _colorsExportModule.pieChartLightGray];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -15,46 +14,39 @@ var _PieChartContainer = _interopRequireDefault(require("./components/PieChartCo
|
|
|
15
14
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
16
15
|
var _utils = require("./utils");
|
|
17
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
function _getRequireWildcardCache(
|
|
19
|
-
function _interopRequireWildcard(
|
|
20
|
-
|
|
21
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
22
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
23
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
24
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
25
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
26
|
-
var BilledConcepts = function BilledConcepts(_ref) {
|
|
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 && Object.prototype.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; }
|
|
19
|
+
const BilledConcepts = _ref => {
|
|
27
20
|
var _billData$detail;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
21
|
+
let {
|
|
22
|
+
contextApiInfo,
|
|
23
|
+
billData
|
|
24
|
+
} = _ref;
|
|
25
|
+
const {
|
|
26
|
+
config,
|
|
27
|
+
Label,
|
|
28
|
+
Toggle,
|
|
29
|
+
assets
|
|
30
|
+
} = contextApiInfo;
|
|
31
|
+
const {
|
|
32
|
+
showZeroConcepts,
|
|
33
|
+
colors
|
|
34
|
+
} = config;
|
|
35
|
+
const {
|
|
36
|
+
billedConceptsTitle
|
|
37
|
+
} = config.texts.billSummary;
|
|
38
|
+
const [toggleOption, setToggleOption] = (0, _react.useState)(_constants.progressBar);
|
|
39
|
+
const handleChangeToggleOption = newOption => setToggleOption(newOption);
|
|
40
|
+
const totalAmount = billData === null || billData === void 0 || (_billData$detail = billData.detail) === null || _billData$detail === void 0 ? void 0 : _billData$detail.total_amount;
|
|
41
|
+
const concepts = (0, _react.useMemo)(() => {
|
|
46
42
|
var _billData$detail2;
|
|
47
43
|
return (0, _utils.getOrderedAndColoredConcepts)(billData === null || billData === void 0 || (_billData$detail2 = billData.detail) === null || _billData$detail2 === void 0 ? void 0 : _billData$detail2.concepts, totalAmount, showZeroConcepts, (0, _utils.getColorsDefinition)(colors));
|
|
48
44
|
}, []);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
52
|
-
var additionalInfo = {
|
|
45
|
+
const negativeAmmount = concepts.some(concept => concept.total < 0);
|
|
46
|
+
const additionalInfo = {
|
|
53
47
|
showProgressBar: toggleOption === _constants.progressBar,
|
|
54
|
-
negativeAmmount: concepts.some(
|
|
55
|
-
|
|
56
|
-
}),
|
|
57
|
-
totalAmount: totalAmount
|
|
48
|
+
negativeAmmount: concepts.some(concept => concept.total < 0),
|
|
49
|
+
totalAmount
|
|
58
50
|
};
|
|
59
51
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
60
52
|
className: _stylesModule.default.container
|
|
@@ -69,9 +61,7 @@ var BilledConcepts = function BilledConcepts(_ref) {
|
|
|
69
61
|
className: _stylesModule.default.toggle,
|
|
70
62
|
optionClassName: _stylesModule.default.toggleOption,
|
|
71
63
|
orientation: "horizontal"
|
|
72
|
-
})), !negativeAmmount && toggleOption === _constants.progressBar ? concepts.map(
|
|
73
|
-
return (0, _utils.renderConcept)(concept, additionalInfo, index === 0);
|
|
74
|
-
}) : /*#__PURE__*/_react.default.createElement(_PieChartContainer.default, {
|
|
64
|
+
})), !negativeAmmount && toggleOption === _constants.progressBar ? concepts.map((concept, index) => (0, _utils.renderConcept)(concept, additionalInfo, index === 0)) : /*#__PURE__*/_react.default.createElement(_PieChartContainer.default, {
|
|
75
65
|
concepts: concepts,
|
|
76
66
|
additionalInfo: additionalInfo
|
|
77
67
|
}));
|
|
@@ -80,5 +70,4 @@ BilledConcepts.propTypes = {
|
|
|
80
70
|
contextApiInfo: _smartBillTypes.contextApiInfoTypes,
|
|
81
71
|
billData: _billDataTypes.billDataTypes
|
|
82
72
|
};
|
|
83
|
-
var _default = (0, _WithContextApi.default)()(BilledConcepts);
|
|
84
|
-
exports.default = _default;
|
|
73
|
+
var _default = exports.default = (0, _WithContextApi.default)()(BilledConcepts);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -9,45 +8,28 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
8
|
var _constants = require("./constants");
|
|
10
9
|
var _Concept = _interopRequireDefault(require("./components/Concept"));
|
|
11
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
18
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
21
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
22
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
23
|
-
var roundPercentage = function roundPercentage(value) {
|
|
24
|
-
return Math.round(value * 10) / 10;
|
|
25
|
-
};
|
|
26
|
-
var calculatePercentages = function calculatePercentages(billConcepts, totalAmount) {
|
|
27
|
-
var indexToAdjust = billConcepts.findIndex(function (concept) {
|
|
28
|
-
return concept.total !== 0;
|
|
29
|
-
});
|
|
30
|
-
var adjustValue = 100 - billConcepts.reduce(function (accum, concept) {
|
|
31
|
-
return accum + roundPercentage(concept.total / totalAmount * 100);
|
|
32
|
-
}, 0);
|
|
33
|
-
return billConcepts.map(function (concept, index) {
|
|
34
|
-
return roundPercentage(concept.total / totalAmount * 100 + (index === indexToAdjust ? adjustValue : 0));
|
|
35
|
-
});
|
|
11
|
+
const roundPercentage = value => Math.round(value * 10) / 10;
|
|
12
|
+
const calculatePercentages = (billConcepts, totalAmount) => {
|
|
13
|
+
const indexToAdjust = billConcepts.findIndex(concept => concept.total !== 0);
|
|
14
|
+
const adjustValue = 100 - billConcepts.reduce((accum, concept) => accum + roundPercentage(concept.total / totalAmount * 100), 0);
|
|
15
|
+
return billConcepts.map((concept, index) => roundPercentage(concept.total / totalAmount * 100 + (index === indexToAdjust ? adjustValue : 0)));
|
|
36
16
|
};
|
|
37
17
|
exports.calculatePercentages = calculatePercentages;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
18
|
+
const getProgressBarPercentage = (maxPercentage, percentage) => percentage / maxPercentage * 100;
|
|
19
|
+
const renderConcept = (conceptData, additionalInfo, isFirst) => {
|
|
20
|
+
const {
|
|
21
|
+
title,
|
|
22
|
+
total,
|
|
23
|
+
color,
|
|
24
|
+
percentage,
|
|
25
|
+
progressBarPercentage
|
|
26
|
+
} = conceptData;
|
|
27
|
+
const {
|
|
28
|
+
showProgressBar,
|
|
29
|
+
negativeAmmount,
|
|
30
|
+
totalAmount
|
|
31
|
+
} = additionalInfo;
|
|
32
|
+
const showPercentage = !(percentage === 0);
|
|
51
33
|
return /*#__PURE__*/_react.default.createElement(_Concept.default, {
|
|
52
34
|
key: title,
|
|
53
35
|
title: title,
|
|
@@ -63,43 +45,37 @@ var renderConcept = function renderConcept(conceptData, additionalInfo, isFirst)
|
|
|
63
45
|
});
|
|
64
46
|
};
|
|
65
47
|
exports.renderConcept = renderConcept;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
var nonZeroConcepts = concepts === null || concepts === void 0 ? void 0 : concepts.filter(function (concept) {
|
|
71
|
-
return !isZeroConcept(concept);
|
|
72
|
-
});
|
|
73
|
-
var zeroConcepts = showZeroConcepts && (concepts === null || concepts === void 0 ? void 0 : concepts.filter(isZeroConcept)) || [];
|
|
48
|
+
const isZeroConcept = concept => concept.total === 0;
|
|
49
|
+
const getSortedData = (concepts, showZeroConcepts) => {
|
|
50
|
+
const nonZeroConcepts = concepts === null || concepts === void 0 ? void 0 : concepts.filter(concept => !isZeroConcept(concept));
|
|
51
|
+
const zeroConcepts = showZeroConcepts && (concepts === null || concepts === void 0 ? void 0 : concepts.filter(isZeroConcept)) || [];
|
|
74
52
|
return {
|
|
75
|
-
sortedConcepts: [
|
|
53
|
+
sortedConcepts: [...nonZeroConcepts, ...zeroConcepts],
|
|
76
54
|
nonZeroLength: nonZeroConcepts.length
|
|
77
55
|
};
|
|
78
56
|
};
|
|
79
|
-
|
|
80
|
-
return [externalColors.primary || _constants.COLORS.primary].concat(_toConsumableArray(_constants.COLORS.slice(1)));
|
|
81
|
-
};
|
|
57
|
+
const getColorsDefinition = externalColors => [externalColors.primary || _constants.COLORS.primary, ..._constants.COLORS.slice(1)];
|
|
82
58
|
exports.getColorsDefinition = getColorsDefinition;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
59
|
+
const getItemColor = (index, nonZeroLength, colorsDefinition) => {
|
|
60
|
+
const colorsLen = _constants.COLORS.length;
|
|
61
|
+
const colorIndex = index % colorsLen;
|
|
62
|
+
const isLastNonZero = index === nonZeroLength - 1;
|
|
63
|
+
const nextColorIndex = (index + 1) % colorsLen;
|
|
88
64
|
return colorsDefinition[isLastNonZero && colorsDefinition[colorIndex] === colorsDefinition[0] ? nextColorIndex : colorIndex];
|
|
89
65
|
};
|
|
90
66
|
exports.getItemColor = getItemColor;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
sortedConcepts
|
|
94
|
-
nonZeroLength
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
});
|
|
67
|
+
const getOrderedAndColoredConcepts = (concepts, totalAmount, showZeroConcepts, colorsDefinition) => {
|
|
68
|
+
const {
|
|
69
|
+
sortedConcepts,
|
|
70
|
+
nonZeroLength
|
|
71
|
+
} = getSortedData(concepts, showZeroConcepts);
|
|
72
|
+
const percentages = calculatePercentages(sortedConcepts, totalAmount);
|
|
73
|
+
const maxPercentage = Math.max(...percentages);
|
|
74
|
+
return sortedConcepts.map((concept, index) => ({
|
|
75
|
+
...concept,
|
|
76
|
+
percentage: percentages[index],
|
|
77
|
+
progressBarPercentage: getProgressBarPercentage(maxPercentage, percentages[index]),
|
|
78
|
+
color: !isZeroConcept(concept) && getItemColor(index, nonZeroLength, colorsDefinition)
|
|
79
|
+
}));
|
|
104
80
|
};
|
|
105
81
|
exports.getOrderedAndColoredConcepts = getOrderedAndColoredConcepts;
|