@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
|
@@ -10,44 +10,42 @@ var _WithContextApi = _interopRequireDefault(require("../../../../../../../WithC
|
|
|
10
10
|
var _smartBillTypes = require("../../../../../../../../shared/types/smartBillTypes");
|
|
11
11
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
const Stages = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
stagesFormattedData,
|
|
16
|
+
contextApiInfo
|
|
17
|
+
} = _ref;
|
|
18
|
+
const {
|
|
19
|
+
Label
|
|
20
|
+
} = contextApiInfo;
|
|
21
|
+
const toFinalWidth = val => ({
|
|
22
|
+
width: "".concat(val * 100, "%")
|
|
23
|
+
});
|
|
22
24
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
23
25
|
className: _stylesModule.default.stagesContainer
|
|
24
|
-
}, stagesFormattedData.map(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
}, /*#__PURE__*/_react.default.createElement(Label, null, substage.name)));
|
|
49
|
-
})));
|
|
50
|
-
}));
|
|
26
|
+
}, stagesFormattedData.map(stage => /*#__PURE__*/_react.default.createElement("div", {
|
|
27
|
+
className: _stylesModule.default.stage,
|
|
28
|
+
style: toFinalWidth(stage.width, 0.2)
|
|
29
|
+
}, /*#__PURE__*/_react.default.createElement(Label, {
|
|
30
|
+
className: _stylesModule.default.group,
|
|
31
|
+
weight: "medium"
|
|
32
|
+
}, stage.group), /*#__PURE__*/_react.default.createElement("div", {
|
|
33
|
+
className: _stylesModule.default.substagesContainer
|
|
34
|
+
}, stage.sub_rate_stages.map(substage => /*#__PURE__*/_react.default.createElement("div", {
|
|
35
|
+
className: _stylesModule.default.substage,
|
|
36
|
+
style: toFinalWidth(substage.width)
|
|
37
|
+
}, substage.label && /*#__PURE__*/_react.default.createElement(Label, {
|
|
38
|
+
className: _stylesModule.default.substageValue,
|
|
39
|
+
colorTheme: "gray",
|
|
40
|
+
variant: "small",
|
|
41
|
+
weight: "medium",
|
|
42
|
+
withoutMarkdown: true
|
|
43
|
+
}, substage.label), /*#__PURE__*/_react.default.createElement("div", {
|
|
44
|
+
className: _stylesModule.default.substageName,
|
|
45
|
+
style: {
|
|
46
|
+
backgroundColor: substage.color
|
|
47
|
+
}
|
|
48
|
+
}, /*#__PURE__*/_react.default.createElement(Label, null, substage.name))))))));
|
|
51
49
|
};
|
|
52
50
|
Stages.propTypes = {
|
|
53
51
|
contextApiInfo: _smartBillTypes.contextApiInfoTypes,
|
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.MIN_STAGE_WIDTH = exports.DEFAULT_LAST_INFINITE_RANGE = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const DEFAULT_LAST_INFINITE_RANGE = exports.DEFAULT_LAST_INFINITE_RANGE = 200; // kWh
|
|
8
|
+
const MIN_STAGE_WIDTH = exports.MIN_STAGE_WIDTH = 0.2;
|
|
@@ -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
|
});
|
|
@@ -16,38 +15,26 @@ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
|
16
15
|
var _utils = require("./utils");
|
|
17
16
|
var _Legend = _interopRequireDefault(require("./components/Legend"));
|
|
18
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
function _getRequireWildcardCache(
|
|
20
|
-
function _interopRequireWildcard(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
getStageColor = _ref.getStageColor;
|
|
32
|
-
var _useState = (0, _react.useState)((0, _browser.isDesktop)(_deviceSizes.TabletBreakpoint)),
|
|
33
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
34
|
-
isDesktopSize = _useState2[0],
|
|
35
|
-
setIsDesktopSize = _useState2[1];
|
|
36
|
-
var handleResizeScreen = function handleResizeScreen() {
|
|
37
|
-
return setIsDesktopSize((0, _browser.isDesktop)(_deviceSizes.TabletBreakpoint));
|
|
38
|
-
};
|
|
39
|
-
(0, _react.useEffect)(function () {
|
|
18
|
+
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); }
|
|
19
|
+
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; }
|
|
20
|
+
const RateStagesGraph = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
value,
|
|
23
|
+
unit,
|
|
24
|
+
rateStages,
|
|
25
|
+
getStageColor
|
|
26
|
+
} = _ref;
|
|
27
|
+
const [isDesktopSize, setIsDesktopSize] = (0, _react.useState)((0, _browser.isDesktop)(_deviceSizes.TabletBreakpoint));
|
|
28
|
+
const handleResizeScreen = () => setIsDesktopSize((0, _browser.isDesktop)(_deviceSizes.TabletBreakpoint));
|
|
29
|
+
(0, _react.useEffect)(() => {
|
|
40
30
|
window.addEventListener(_browser.RESIZE_EVENT, handleResizeScreen);
|
|
41
31
|
handleResizeScreen();
|
|
42
|
-
return
|
|
43
|
-
return window.removeEventListener(_browser.RESIZE_EVENT, handleResizeScreen);
|
|
44
|
-
};
|
|
32
|
+
return () => window.removeEventListener(_browser.RESIZE_EVENT, handleResizeScreen);
|
|
45
33
|
}, []);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
indicatorPosition = _useMemo.indicatorPosition;
|
|
34
|
+
const {
|
|
35
|
+
stagesFormattedData,
|
|
36
|
+
indicatorPosition
|
|
37
|
+
} = (0, _react.useMemo)(() => (0, _utils.getStagesFormattedData)(value, rateStages, getStageColor, isDesktopSize), [isDesktopSize, value, rateStages, getStageColor]);
|
|
51
38
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
52
39
|
className: _stylesModule.default.container
|
|
53
40
|
}, /*#__PURE__*/_react.default.createElement(_Stages.default, {
|
|
@@ -7,69 +7,58 @@ exports.getStagesFormattedData = void 0;
|
|
|
7
7
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
8
|
var _constants = require("./constants");
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
|
-
var getResponsiveStageWidth = function getResponsiveStageWidth(rateStages, stage, totalSubStages) {
|
|
17
|
-
var totalWidth = 1;
|
|
10
|
+
const getResponsiveStageWidth = (rateStages, stage, totalSubStages) => {
|
|
11
|
+
let totalWidth = 1;
|
|
18
12
|
// if we have only one rate, then return max width.
|
|
19
13
|
if (rateStages.length === 1) {
|
|
20
14
|
return totalWidth;
|
|
21
15
|
}
|
|
22
16
|
// We sort the stages based in sub stages in cases that former stages are larger than later ones.
|
|
23
|
-
|
|
24
|
-
return _stage.sub_rate_stages.length;
|
|
25
|
-
});
|
|
17
|
+
const sortedRateStages = _lodash.default.sortBy(rateStages, _stage => _stage.sub_rate_stages.length);
|
|
26
18
|
// Iterate over the sorted array until finished.
|
|
27
|
-
for (
|
|
19
|
+
for (let index = 0; index < sortedRateStages.length; index += 1) {
|
|
28
20
|
// If we reached our stage then we break, we need to know the space former ones ocuppy and not the laters.
|
|
29
21
|
if (sortedRateStages[index].group === stage.group) {
|
|
30
22
|
break;
|
|
31
23
|
}
|
|
32
|
-
|
|
24
|
+
const currentSubStages = sortedRateStages[index].sub_rate_stages.length;
|
|
33
25
|
// Maximum a stage can ocuppy (since minimum is MIN_STAGE_WIDTH), is MIN_STAGE_WIDTH times the other stages.
|
|
34
|
-
|
|
26
|
+
const width = Math.min(Math.max(currentSubStages / totalSubStages, _constants.MIN_STAGE_WIDTH), _constants.MIN_STAGE_WIDTH * rateStages.length);
|
|
35
27
|
totalWidth -= width;
|
|
36
28
|
}
|
|
37
29
|
// Final width will be the minimum value between the calculated width and the total width left.
|
|
38
30
|
return Math.min(Math.max(stage.sub_rate_stages.length / totalSubStages, _constants.MIN_STAGE_WIDTH), totalWidth);
|
|
39
31
|
};
|
|
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
|
-
if (!isCurrentStage && substage.i === totalSubstagesCount - 1) indicatorPosition += Math.min(currentDeltaWidth / _constants.DEFAULT_LAST_INFINITE_RANGE * currentWidth, currentWidth);else if (!isCurrentStage) indicatorPosition += currentWidth;else indicatorPosition += currentDeltaWidth / (substage.range[1] - substage.range[0]) * currentWidth;
|
|
68
|
-
return isCurrentStage;
|
|
69
|
-
});
|
|
70
|
-
});
|
|
32
|
+
const getStagesFormattedData = (value, rateStages, getStageColor, isDesktop) => {
|
|
33
|
+
const totalSubstagesCount = rateStages.reduce((count, stage) => count += stage.sub_rate_stages.length, 0);
|
|
34
|
+
let i = -1;
|
|
35
|
+
const stagesFormattedData = rateStages.map(stage => ({
|
|
36
|
+
...stage,
|
|
37
|
+
width: isDesktop ? stage.sub_rate_stages.length / totalSubstagesCount : getResponsiveStageWidth(rateStages, stage, totalSubstagesCount),
|
|
38
|
+
sub_rate_stages: stage.sub_rate_stages.map(substage => {
|
|
39
|
+
i += 1;
|
|
40
|
+
const labelValue = "".concat(substage.range[i === 0 ? 1 : 0], " ").concat(stage.unit);
|
|
41
|
+
return {
|
|
42
|
+
...substage,
|
|
43
|
+
i,
|
|
44
|
+
width: 1 / stage.sub_rate_stages.length,
|
|
45
|
+
color: substage.color || getStageColor && getStageColor(i, totalSubstagesCount),
|
|
46
|
+
label: isDesktop && "".concat(i === 0 ? '< ' : i === 1 ? '> ' : '').concat(labelValue),
|
|
47
|
+
legend: !isDesktop && labelValue
|
|
48
|
+
};
|
|
49
|
+
})
|
|
50
|
+
}));
|
|
51
|
+
let indicatorPosition = 0;
|
|
52
|
+
stagesFormattedData.find(stage => stage.sub_rate_stages.find(substage => {
|
|
53
|
+
const isCurrentStage = substage.range[1] >= value;
|
|
54
|
+
const currentWidth = substage.width * stage.width;
|
|
55
|
+
const currentDeltaWidth = value - substage.range[0];
|
|
56
|
+
if (!isCurrentStage && substage.i === totalSubstagesCount - 1) indicatorPosition += Math.min(currentDeltaWidth / _constants.DEFAULT_LAST_INFINITE_RANGE * currentWidth, currentWidth);else if (!isCurrentStage) indicatorPosition += currentWidth;else indicatorPosition += currentDeltaWidth / (substage.range[1] - substage.range[0]) * currentWidth;
|
|
57
|
+
return isCurrentStage;
|
|
58
|
+
}));
|
|
71
59
|
return {
|
|
72
|
-
stagesFormattedData
|
|
73
|
-
indicatorPosition
|
|
60
|
+
stagesFormattedData,
|
|
61
|
+
indicatorPosition
|
|
74
62
|
};
|
|
75
|
-
};
|
|
63
|
+
};
|
|
64
|
+
exports.getStagesFormattedData = getStagesFormattedData;
|
|
@@ -4,21 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.THIGT_RANGE_BREAKPOINT_RATIO = exports.SUB_STAGE_MARGIN_MOBILE = exports.SUB_STAGE_MARGIN_DESKTOP = exports.STAGE_MARGIN_MOBILE = exports.STAGE_MARGIN_DESKTOP = exports.MIN_VALUE = exports.MAX_VALUE = exports.MAX_RANGE_LIMIT = exports.LAST_SUB_STAGE_MARGIN = exports.LAST_STAGE_MARGIN = exports.INITIAL_INDICATOR_POSITION = exports.INFINITE = exports.INDICATOR_LABEL_LAST_OFFSET = exports.INDICATOR_LABEL_FIRST_OFFSET = exports.INDICATOR_LABEL_DEFAULT_OFFSET = exports.DEFAULT_INFINITE_SUB_STAGE_RANGE_WIDTH = exports.BARS_MARGIN_MOBILE = exports.BARS_MARGIN_DESKTOP = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
const INFINITE = exports.INFINITE = null;
|
|
8
|
+
const MAX_VALUE = exports.MAX_VALUE = 1;
|
|
9
|
+
const MIN_VALUE = exports.MIN_VALUE = 0;
|
|
10
|
+
const MAX_RANGE_LIMIT = exports.MAX_RANGE_LIMIT = 9999999;
|
|
11
|
+
const DEFAULT_INFINITE_SUB_STAGE_RANGE_WIDTH = exports.DEFAULT_INFINITE_SUB_STAGE_RANGE_WIDTH = 200;
|
|
12
|
+
const INITIAL_INDICATOR_POSITION = exports.INITIAL_INDICATOR_POSITION = '-6px';
|
|
13
|
+
const BARS_MARGIN_DESKTOP = exports.BARS_MARGIN_DESKTOP = '0px';
|
|
14
|
+
const BARS_MARGIN_MOBILE = exports.BARS_MARGIN_MOBILE = '0px';
|
|
15
|
+
const LAST_STAGE_MARGIN = exports.LAST_STAGE_MARGIN = '0px';
|
|
16
|
+
const STAGE_MARGIN_DESKTOP = exports.STAGE_MARGIN_DESKTOP = '4px';
|
|
17
|
+
const STAGE_MARGIN_MOBILE = exports.STAGE_MARGIN_MOBILE = '2px';
|
|
18
|
+
const SUB_STAGE_MARGIN_DESKTOP = exports.SUB_STAGE_MARGIN_DESKTOP = '4px';
|
|
19
|
+
const SUB_STAGE_MARGIN_MOBILE = exports.SUB_STAGE_MARGIN_MOBILE = '2px';
|
|
20
|
+
const LAST_SUB_STAGE_MARGIN = exports.LAST_SUB_STAGE_MARGIN = '0px';
|
|
21
|
+
const INDICATOR_LABEL_FIRST_OFFSET = exports.INDICATOR_LABEL_FIRST_OFFSET = '0px';
|
|
22
|
+
const INDICATOR_LABEL_LAST_OFFSET = exports.INDICATOR_LABEL_LAST_OFFSET = '-8px';
|
|
23
|
+
const INDICATOR_LABEL_DEFAULT_OFFSET = exports.INDICATOR_LABEL_DEFAULT_OFFSET = '-48px';
|
|
24
|
+
const THIGT_RANGE_BREAKPOINT_RATIO = exports.THIGT_RANGE_BREAKPOINT_RATIO = 0.1;
|
|
@@ -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
|
});
|
|
@@ -16,39 +15,32 @@ var _RateStagesGraph = _interopRequireDefault(require("./components/RateStagesGr
|
|
|
16
15
|
var _Category = _interopRequireDefault(require("./components/Category"));
|
|
17
16
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
18
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
function _getRequireWildcardCache(
|
|
20
|
-
function _interopRequireWildcard(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
setIsDesktopSize = _useState2[1];
|
|
41
|
-
var handleResizeScreen = function handleResizeScreen() {
|
|
42
|
-
return setIsDesktopSize((0, _browser.isDesktop)(_deviceSizes.TabletBreakpoint));
|
|
43
|
-
};
|
|
44
|
-
(0, _react.useEffect)(function () {
|
|
18
|
+
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); }
|
|
19
|
+
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; }
|
|
20
|
+
const CategoryByConsumption = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
contextApiInfo,
|
|
23
|
+
value,
|
|
24
|
+
unit,
|
|
25
|
+
category
|
|
26
|
+
} = _ref;
|
|
27
|
+
const {
|
|
28
|
+
config,
|
|
29
|
+
Label
|
|
30
|
+
} = contextApiInfo;
|
|
31
|
+
const {
|
|
32
|
+
rateStages,
|
|
33
|
+
texts,
|
|
34
|
+
getStageColor
|
|
35
|
+
} = config;
|
|
36
|
+
const [isDesktopSize, setIsDesktopSize] = (0, _react.useState)((0, _browser.isDesktop)(_deviceSizes.TabletBreakpoint));
|
|
37
|
+
const handleResizeScreen = () => setIsDesktopSize((0, _browser.isDesktop)(_deviceSizes.TabletBreakpoint));
|
|
38
|
+
(0, _react.useEffect)(() => {
|
|
45
39
|
window.addEventListener(_browser.RESIZE_EVENT, handleResizeScreen);
|
|
46
40
|
handleResizeScreen();
|
|
47
|
-
return
|
|
48
|
-
return window.removeEventListener(_browser.RESIZE_EVENT, handleResizeScreen);
|
|
49
|
-
};
|
|
41
|
+
return () => window.removeEventListener(_browser.RESIZE_EVENT, handleResizeScreen);
|
|
50
42
|
}, []);
|
|
51
|
-
|
|
43
|
+
const valueCorrected = value < 0 ? 0 : value && Math.round(value);
|
|
52
44
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
53
45
|
className: _stylesModule.default.container
|
|
54
46
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -5,8 +5,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getCurrentStage = void 0;
|
|
7
7
|
var _constants = require("./constants");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return stage.range[_constants.MIN_VALUE] <= value && (value <= stage.range[_constants.MAX_VALUE] || stage.range[_constants.MAX_VALUE] === _constants.INFINITE);
|
|
11
|
-
});
|
|
12
|
-
};
|
|
8
|
+
const getCurrentStage = (value, rateStages) => rateStages.find(stage => stage.range[_constants.MIN_VALUE] <= value && (value <= stage.range[_constants.MAX_VALUE] || stage.range[_constants.MAX_VALUE] === _constants.INFINITE));
|
|
9
|
+
exports.getCurrentStage = getCurrentStage;
|
|
@@ -12,19 +12,25 @@ var _aliases = require("../../../../shared/constants/aliases");
|
|
|
12
12
|
var _RateAndCategory = _interopRequireDefault(require("../../../RateAndCategory"));
|
|
13
13
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
classes =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
const PurchasedRate = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
contextApiInfo,
|
|
18
|
+
rate,
|
|
19
|
+
category,
|
|
20
|
+
classes = {}
|
|
21
|
+
} = _ref;
|
|
22
|
+
const {
|
|
23
|
+
config,
|
|
24
|
+
ExternalLink,
|
|
25
|
+
Label
|
|
26
|
+
} = contextApiInfo;
|
|
27
|
+
const {
|
|
28
|
+
purchasedRateErrorLink
|
|
29
|
+
} = config.externalLinks;
|
|
30
|
+
const {
|
|
31
|
+
purchasedRateTitle,
|
|
32
|
+
purchasedRateError
|
|
33
|
+
} = config.texts.ratesDefinition;
|
|
28
34
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
29
35
|
className: "".concat(_stylesModule.default.container, " ").concat(classes.container)
|
|
30
36
|
}, /*#__PURE__*/_react.default.createElement(Label, {
|
|
@@ -21,21 +21,26 @@ var _PurchasedRate = _interopRequireDefault(require("./components/PurchasedRate"
|
|
|
21
21
|
var _BillRate = _interopRequireDefault(require("./components/BillRate"));
|
|
22
22
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
23
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
const RatesDefinition = _ref => {
|
|
25
|
+
let {
|
|
26
|
+
contextApiInfo,
|
|
27
|
+
billData
|
|
28
|
+
} = _ref;
|
|
29
|
+
const rate = (0, _seamlessImmutable.getIn)(billData, ['client', 'rate', 'purchased']);
|
|
30
|
+
const category = (0, _seamlessImmutable.getIn)(billData, ['client', 'rate', 'category']);
|
|
31
|
+
const description = (0, _seamlessImmutable.getIn)(billData, ['client', 'rate', 'description']);
|
|
32
|
+
const fixedCharge = (0, _rates.getCharge)(billData, _rates2.CHARGE_TYPES.FIXED).amount;
|
|
33
|
+
const variableCharge = (0, _rates.getCharge)(billData, _rates2.CHARGE_TYPES.VARIABLE).amount;
|
|
34
|
+
const {
|
|
35
|
+
Label
|
|
36
|
+
} = contextApiInfo;
|
|
37
|
+
const currentPeriod = (0, _periods.getCurrentPeriod)(billData);
|
|
38
|
+
const currentConsumption = (0, _consumptions.getCurrentConsumption)(currentPeriod, _consumptions2.ENERGY_TYPES.ACTIVE);
|
|
39
|
+
const {
|
|
40
|
+
adviceTitle,
|
|
41
|
+
adviceText,
|
|
42
|
+
rateDataTitle
|
|
43
|
+
} = contextApiInfo.config.texts.ratesDefinition;
|
|
39
44
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
40
45
|
className: _stylesModule.default.container
|
|
41
46
|
}, /*#__PURE__*/_react.default.createElement(_CategoryByConsumption.default, {
|
|
@@ -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
|
});
|
|
@@ -8,40 +7,19 @@ exports.default = void 0;
|
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
8
|
var _Context = require("../../shared/Context");
|
|
10
9
|
var _smartBillTypes = require("../../shared/types/smartBillTypes");
|
|
11
|
-
function _getRequireWildcardCache(
|
|
12
|
-
function _interopRequireWildcard(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
23
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
24
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
25
|
-
var SmartBillProvider = /*#__PURE__*/function (_PureComponent) {
|
|
26
|
-
_inherits(SmartBillProvider, _PureComponent);
|
|
27
|
-
var _super = _createSuper(SmartBillProvider);
|
|
28
|
-
function SmartBillProvider() {
|
|
29
|
-
_classCallCheck(this, SmartBillProvider);
|
|
30
|
-
return _super.apply(this, arguments);
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
12
|
+
class SmartBillProvider extends _react.PureComponent {
|
|
13
|
+
render() {
|
|
14
|
+
const {
|
|
15
|
+
children,
|
|
16
|
+
contextApiInfo
|
|
17
|
+
} = this.props;
|
|
18
|
+
return /*#__PURE__*/_react.default.createElement(_Context.SmartBillProvider, {
|
|
19
|
+
value: contextApiInfo
|
|
20
|
+
}, children);
|
|
31
21
|
}
|
|
32
|
-
|
|
33
|
-
key: "render",
|
|
34
|
-
value: function render() {
|
|
35
|
-
var _this$props = this.props,
|
|
36
|
-
children = _this$props.children,
|
|
37
|
-
contextApiInfo = _this$props.contextApiInfo;
|
|
38
|
-
return /*#__PURE__*/_react.default.createElement(_Context.SmartBillProvider, {
|
|
39
|
-
value: contextApiInfo
|
|
40
|
-
}, children);
|
|
41
|
-
}
|
|
42
|
-
}]);
|
|
43
|
-
return SmartBillProvider;
|
|
44
|
-
}(_react.PureComponent);
|
|
22
|
+
}
|
|
45
23
|
SmartBillProvider.propTypes = {
|
|
46
24
|
contextApiInfo: _smartBillTypes.contextApiInfoTypes
|
|
47
25
|
};
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.VARIANTS = void 0;
|
|
7
7
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
|
|
9
|
+
const VARIANTS = exports.VARIANTS = {
|
|
10
10
|
small: {
|
|
11
11
|
currencyLabelStyle: _stylesModule.default.smallCurrency,
|
|
12
12
|
decimalLabelStyle: _stylesModule.default.smallDecimalPart
|