@widergy/utilitygo-smart-bill-web 2.2.2 → 3.0.1
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 +10 -6
- package/dist/components/Amount/index.js +26 -21
- package/dist/components/Amount/utils.js +2 -5
- package/dist/components/Banner/index.js +10 -6
- package/dist/components/BarChart/constants.js +3 -3
- package/dist/components/BarChart/index.js +28 -22
- package/dist/components/BarChart/utils.js +17 -16
- package/dist/components/BillCalculation/components/ConceptCard/index.js +52 -45
- package/dist/components/BillCalculation/components/Glossary/index.js +48 -64
- package/dist/components/BillCalculation/components/Glossary/styles.module.scss +1 -0
- package/dist/components/BillCalculation/constants.js +1 -1
- package/dist/components/BillCalculation/index.js +48 -51
- package/dist/components/BillCalculation/utils.js +22 -22
- package/dist/components/BillSummary/components/BilledConcepts/components/Concept/index.js +25 -22
- package/dist/components/BillSummary/components/BilledConcepts/components/PieChartContainer/constants.js +1 -1
- package/dist/components/BillSummary/components/BilledConcepts/components/PieChartContainer/index.js +15 -15
- package/dist/components/BillSummary/components/BilledConcepts/components/PieChartContainer/styles.module.scss +3 -3
- package/dist/components/BillSummary/components/BilledConcepts/constants.js +13 -14
- package/dist/components/BillSummary/components/BilledConcepts/index.js +29 -39
- package/dist/components/BillSummary/components/BilledConcepts/utils.js +50 -69
- package/dist/components/BillSummary/index.js +70 -69
- package/dist/components/ConsumptionComparison/components/ComparisonTable/components/DataLine/index.js +8 -8
- package/dist/components/ConsumptionComparison/components/ComparisonTable/components/Season/index.js +17 -10
- package/dist/components/ConsumptionComparison/components/ComparisonTable/components/Season/utils.js +3 -2
- package/dist/components/ConsumptionComparison/components/ComparisonTable/constants.js +147 -133
- package/dist/components/ConsumptionComparison/components/ComparisonTable/index.js +16 -14
- package/dist/components/ConsumptionComparison/components/ComparisonTable/styles.module.scss +1 -0
- package/dist/components/ConsumptionComparison/components/ComparisonTable/utils.js +88 -89
- package/dist/components/ConsumptionComparison/components/ConsumptionAdvice/index.js +21 -11
- package/dist/components/ConsumptionComparison/components/ConsumptionAdvice/utils.js +3 -2
- package/dist/components/ConsumptionComparison/components/PercentageComparison/index.js +21 -14
- package/dist/components/ConsumptionComparison/components/PercentageComparison/styles.module.scss +1 -0
- package/dist/components/ConsumptionComparison/components/PercentageComparison/utils.js +15 -10
- package/dist/components/ConsumptionComparison/index.js +41 -45
- package/dist/components/ConsumptionEnergyDetails/components/ConsumptionEnergyComparison/index.js +27 -22
- package/dist/components/ConsumptionEnergyDetails/components/ConsumptionEnergyComparison/styles.module.scss +1 -1
- package/dist/components/ConsumptionEnergyDetails/components/ConsumptionInDaysLabel/index.js +18 -13
- package/dist/components/ConsumptionEnergyDetails/components/EnergyTotalConsumption/index.js +15 -12
- package/dist/components/ConsumptionEnergyDetails/components/PercentageComparison/index.js +21 -15
- package/dist/components/ConsumptionEnergyDetails/components/PercentageComparison/utils.js +3 -2
- package/dist/components/ConsumptionEnergyDetails/index.js +46 -41
- package/dist/components/ConsumptionEnergyDetails/styles.module.scss +2 -2
- package/dist/components/ConsumptionIncluded/components/TimelineRow/components/Card/index.js +64 -60
- package/dist/components/ConsumptionIncluded/components/TimelineRow/components/Card/utils.js +12 -13
- package/dist/components/ConsumptionIncluded/components/TimelineRow/components/HeaderConsumption/index.js +20 -17
- package/dist/components/ConsumptionIncluded/components/TimelineRow/components/HeaderSettlement/index.js +16 -10
- package/dist/components/ConsumptionIncluded/components/TimelineRow/index.js +42 -37
- package/dist/components/ConsumptionIncluded/components/TimelineRow/styles.module.scss +2 -2
- package/dist/components/ConsumptionIncluded/index.js +31 -32
- package/dist/components/ConsumptionIncluded/utils.js +32 -34
- package/dist/components/ConsumptionPeriod/components/ConsumptionSummary/components/ReadingRow/index.js +14 -10
- package/dist/components/ConsumptionPeriod/components/ConsumptionSummary/components/ReadingRow/styles.module.scss +1 -0
- package/dist/components/ConsumptionPeriod/components/ConsumptionSummary/index.js +23 -20
- package/dist/components/ConsumptionPeriod/components/ConsumptionSummary/styles.module.scss +1 -0
- package/dist/components/ConsumptionPeriod/components/HistoryGraph/index.js +18 -26
- package/dist/components/ConsumptionPeriod/components/Reading/index.js +35 -32
- package/dist/components/ConsumptionPeriod/index.js +12 -8
- package/dist/components/ConsumptionPeriod/styles.module.scss +1 -0
- package/dist/components/ConsumptionPeriod/utils.js +14 -15
- package/dist/components/Date/index.js +12 -9
- package/dist/components/DebtState/index.js +14 -8
- package/dist/components/IconAndDetails/index.js +19 -17
- package/dist/components/Magnitude/index.js +15 -12
- package/dist/components/Magnitude/utils.js +3 -8
- package/dist/components/MainBillData/components/BillAlert/components/BillParticularConditions/index.js +18 -14
- package/dist/components/MainBillData/components/BillAlert/index.js +24 -31
- package/dist/components/MainBillData/components/BillBody/components/ClientData/index.js +19 -11
- package/dist/components/MainBillData/components/BillBody/components/Consumption/index.js +14 -11
- package/dist/components/MainBillData/components/BillBody/components/Consumption/utils.js +2 -3
- package/dist/components/MainBillData/components/BillBody/components/ReadingDetails/index.js +23 -15
- package/dist/components/MainBillData/components/BillBody/components/ReadingDetails/styles.module.scss +3 -2
- package/dist/components/MainBillData/components/BillBody/components/ReadingDetails/utils.js +3 -2
- package/dist/components/MainBillData/components/BillBody/index.js +42 -44
- package/dist/components/MainBillData/components/BillHeader/components/TypeAndNumber/index.js +16 -11
- package/dist/components/MainBillData/components/BillHeader/index.js +29 -24
- package/dist/components/MainBillData/components/BillHeader/styles.module.scss +1 -1
- package/dist/components/MainBillData/index.js +7 -5
- package/dist/components/MainBillData/theme.js +8 -9
- package/dist/components/MainBillData/utils.js +2 -5
- package/dist/components/Period/index.js +54 -43
- package/dist/components/Period/styles.module.scss +0 -6
- package/dist/components/PowerProgresBar/components/PowerConsumption/index.js +15 -11
- package/dist/components/PowerProgresBar/index.js +31 -30
- package/dist/components/RateAndCategory/index.js +25 -27
- package/dist/components/RatesDefinition/components/BillRate/components/RatePrices/index.js +20 -13
- package/dist/components/RatesDefinition/components/BillRate/index.js +24 -14
- package/dist/components/RatesDefinition/components/BillRate/styles.module.scss +1 -1
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/Category/index.js +14 -9
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/components/Indicator/components/IndicatorLabel/index.js +26 -21
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/components/Indicator/index.js +11 -7
- 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 +11 -10
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/components/Legend/index.js +21 -19
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/components/Stages/index.js +34 -36
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/constants.js +2 -2
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/index.js +17 -30
- package/dist/components/RatesDefinition/components/CategoryByConsumption/components/RateStagesGraph/utils.js +37 -48
- package/dist/components/RatesDefinition/components/CategoryByConsumption/constants.js +18 -18
- package/dist/components/RatesDefinition/components/CategoryByConsumption/index.js +23 -31
- package/dist/components/RatesDefinition/components/CategoryByConsumption/utils.js +2 -5
- package/dist/components/RatesDefinition/components/PurchasedRate/index.js +19 -13
- package/dist/components/RatesDefinition/index.js +20 -15
- package/dist/components/RatesDefinition/styles.module.scss +1 -1
- package/dist/components/SmartBillProvider/index.js +12 -34
- package/dist/components/StyledAmount/constants.js +1 -1
- package/dist/components/StyledAmount/index.js +19 -27
- package/dist/components/WithContextApi/index.js +18 -25
- package/dist/components/WithContextApi/layout.js +2 -2
- package/dist/components/WithSeason/index.js +6 -9
- package/dist/constants/deviceSizes.js +33 -18
- package/dist/constants/seasons.js +2 -2
- package/dist/index.js +14 -15
- package/dist/scss/variables/commonColors.module.scss +1 -1
- package/dist/shared/Context/index.js +7 -3
- package/dist/shared/constants/aliases.js +691 -556
- package/dist/shared/constants/consumptions.js +4 -4
- package/dist/shared/constants/periodicities.js +1 -1
- package/dist/shared/constants/rates.js +1 -1
- package/dist/shared/constants/readings.js +2 -2
- package/dist/shared/constants/seasons.js +2 -2
- package/dist/shared/constants/stagesGraph.js +4 -4
- package/dist/shared/types/assetsTypes.js +1 -1
- package/dist/shared/types/billDataTypes.js +5 -5
- package/dist/shared/types/componentsTypes.js +18 -10
- package/dist/shared/types/formattersTypes.js +1 -1
- package/dist/shared/types/rateStagesTypes.js +3 -3
- package/dist/shared/types/smartBillTypes.js +5 -10
- package/dist/shared/types/textsTypes.js +1 -1
- package/dist/shared/utils/billCalculation.js +11 -10
- package/dist/shared/utils/consumptions.js +34 -56
- package/dist/shared/utils/context.js +8 -6
- package/dist/shared/utils/expirations.js +2 -5
- package/dist/shared/utils/periods.js +20 -21
- package/dist/shared/utils/rates.js +2 -5
- package/dist/shared/utils/readings.js +4 -10
- package/dist/shared/utils/season.js +2 -5
- package/dist/shared/utils/stagesGraph.js +15 -15
- package/dist/utils/hooks.js +1 -1
- package/dist/utils.js +7 -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", {
|
|
@@ -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
|
|
@@ -32,11 +35,8 @@ var periodToTitleMapper = exports.periodToTitleMapper = function periodToTitleMa
|
|
|
32
35
|
if ((0, _string.stringToCompareWithoutAccentsInclusive)(periodicity, _periodicities.PERIODICITY.BIMONTHLY)) return "".concat(settlement, " ").concat(currentSettlement, " ").concat(texts.commons.ofPreposition, " ").concat(totalSettlements, " - ").concat(bimester, " ").concat(periodNumber).concat(issuedDateLabel);
|
|
33
36
|
return '-';
|
|
34
37
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return concept.description && shouldShowConcept(concept, showZeroConcepts);
|
|
41
|
-
});
|
|
42
|
-
};
|
|
38
|
+
exports.periodToTitleMapper = periodToTitleMapper;
|
|
39
|
+
const shouldShowConcept = (concept, showZeroConcepts) => concept.total !== 0 || showZeroConcepts;
|
|
40
|
+
exports.shouldShowConcept = shouldShowConcept;
|
|
41
|
+
const filterGlossaryConcepts = (concepts, showZeroConcepts) => concepts.filter(concept => concept.description && shouldShowConcept(concept, showZeroConcepts));
|
|
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", {
|
|
@@ -4,7 +4,7 @@ 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,
|
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,9 +34,7 @@ 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)),
|
|
@@ -5,17 +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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var COLORS = exports.COLORS = [_colorsExportModule.primary, _colorsExportModule.darkGray, _colorsExportModule.pieChartGray, _colorsExportModule.pieChartLightGray];
|
|
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
|
+
}];
|
|
19
|
+
exports.toggleOptions = toggleOptions;
|
|
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
|
}));
|
|
@@ -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,44 +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;
|
|
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)));
|
|
25
16
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
total = conceptData.total,
|
|
43
|
-
color = conceptData.color,
|
|
44
|
-
percentage = conceptData.percentage,
|
|
45
|
-
progressBarPercentage = conceptData.progressBarPercentage;
|
|
46
|
-
var showProgressBar = additionalInfo.showProgressBar,
|
|
47
|
-
negativeAmmount = additionalInfo.negativeAmmount,
|
|
48
|
-
totalAmount = additionalInfo.totalAmount;
|
|
49
|
-
var showPercentage = !(percentage === 0);
|
|
17
|
+
exports.calculatePercentages = calculatePercentages;
|
|
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);
|
|
50
33
|
return /*#__PURE__*/_react.default.createElement(_Concept.default, {
|
|
51
34
|
key: title,
|
|
52
35
|
title: title,
|
|
@@ -61,40 +44,38 @@ var renderConcept = exports.renderConcept = function renderConcept(conceptData,
|
|
|
61
44
|
color: !showProgressBar && color
|
|
62
45
|
});
|
|
63
46
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return !isZeroConcept(concept);
|
|
70
|
-
});
|
|
71
|
-
var zeroConcepts = showZeroConcepts && (concepts === null || concepts === void 0 ? void 0 : concepts.filter(isZeroConcept)) || [];
|
|
47
|
+
exports.renderConcept = renderConcept;
|
|
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)) || [];
|
|
72
52
|
return {
|
|
73
|
-
sortedConcepts: [
|
|
53
|
+
sortedConcepts: [...nonZeroConcepts, ...zeroConcepts],
|
|
74
54
|
nonZeroLength: nonZeroConcepts.length
|
|
75
55
|
};
|
|
76
56
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
var nextColorIndex = (index + 1) % colorsLen;
|
|
57
|
+
const getColorsDefinition = externalColors => [externalColors.primary || _constants.COLORS.primary, ..._constants.COLORS.slice(1)];
|
|
58
|
+
exports.getColorsDefinition = getColorsDefinition;
|
|
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;
|
|
85
64
|
return colorsDefinition[isLastNonZero && colorsDefinition[colorIndex] === colorsDefinition[0] ? nextColorIndex : colorIndex];
|
|
86
65
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
};
|
|
66
|
+
exports.getItemColor = getItemColor;
|
|
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
|
+
}));
|
|
80
|
+
};
|
|
81
|
+
exports.getOrderedAndColoredConcepts = getOrderedAndColoredConcepts;
|