@gobizweb/core 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +56 -0
- package/assets/icons/arrow_left.svg +1 -0
- package/assets/icons/right_pointing.svg +1 -0
- package/assets/icons/thumb-up.svg +1 -0
- package/assets/images/server_error_dino.svg +1 -0
- package/assets/images/spot_hero_empty_list.svg +1 -0
- package/lib/bootstrap.js +39 -0
- package/lib/components/AccordionSelect/AccordionSelect.component.js +131 -0
- package/lib/components/AccordionSelect/AccordionSelect.styled.js +18 -0
- package/lib/components/AccordionSelect/index.js +13 -0
- package/lib/components/AlertBox/AlertBox.component.js +54 -0
- package/lib/components/AlertBox/AlertBox.styled.js +32 -0
- package/lib/components/AlertBox/index.js +13 -0
- package/lib/components/AlertDialog/AlertDialog.js +66 -0
- package/lib/components/AlertDialog/AlertDialog.styled.js +13 -0
- package/lib/components/AlertDialog/index.js +13 -0
- package/lib/components/Asphalt/Input.component.js +59 -0
- package/lib/components/Asphalt/index.js +13 -0
- package/lib/components/AsphaltPolyfill/AsphaltPolyfill.component.js +26 -0
- package/lib/components/AsphaltPolyfill/AsphaltPolyfill.loader.js +8 -0
- package/lib/components/AsphaltPolyfill/index.js +13 -0
- package/lib/components/Box/index.js +51 -0
- package/lib/components/Breakpoint/Breakpoint.component.js +63 -0
- package/lib/components/Breakpoint/index.js +13 -0
- package/lib/components/Button/Button.js +109 -0
- package/lib/components/Button/index.js +13 -0
- package/lib/components/Card/Card.js +75 -0
- package/lib/components/Card/Card.styled.js +60 -0
- package/lib/components/Card/index.js +13 -0
- package/lib/components/CardList/CardList.component.js +55 -0
- package/lib/components/CardList/index.js +13 -0
- package/lib/components/Checkbox/Checkbox.js +60 -0
- package/lib/components/Checkbox/index.js +13 -0
- package/lib/components/Container/Container.js +74 -0
- package/lib/components/Container/index.js +13 -0
- package/lib/components/DatePicker/Datepicker.component.js +57 -0
- package/lib/components/DatePicker/index.js +13 -0
- package/lib/components/Dropdown/Dropdown.component.js +63 -0
- package/lib/components/Dropdown/index.js +13 -0
- package/lib/components/EmptyState/EmptyState.component.js +47 -0
- package/lib/components/EmptyState/index.js +13 -0
- package/lib/components/ErrorModal/ErrorModal.component.js +41 -0
- package/lib/components/ErrorModal/ErrorModal.store.js +43 -0
- package/lib/components/ErrorModal/index.js +14 -0
- package/lib/components/ErrorScreen/ErrorScreen.js +19 -0
- package/lib/components/ErrorScreen/index.js +13 -0
- package/lib/components/FilterModal/FilterModal.js +41 -0
- package/lib/components/FilterModal/FilterModal.state.js +139 -0
- package/lib/components/FilterModal/index.js +13 -0
- package/lib/components/GlobalFilter/GlobalFilter.component.js +32 -0
- package/lib/components/GlobalFilter/GlobalFilter.component.state.js +116 -0
- package/lib/components/GlobalFilter/GlobalFilter.constant.js +17 -0
- package/lib/components/GlobalFilter/GlobalFilter.date.component.js +34 -0
- package/lib/components/GlobalFilter/GlobalFilter.interface.js +2 -0
- package/lib/components/GlobalFilter/GlobalFilter.provider.js +169 -0
- package/lib/components/GlobalFilter/GlobalFilter.styled.js +16 -0
- package/lib/components/GlobalFilter/index.js +16 -0
- package/lib/components/Guard/Guard.component.js +18 -0
- package/lib/components/Guard/index.js +13 -0
- package/lib/components/IframeLoader/IframeLoader.js +47 -0
- package/lib/components/IframeLoader/index.js +13 -0
- package/lib/components/Input/Input.component.js +167 -0
- package/lib/components/Input/index.js +13 -0
- package/lib/components/LanguageSwitcher/LanguageSwitcher.component.js +78 -0
- package/lib/components/LanguageSwitcher/LanguageSwitcher.state.js +20 -0
- package/lib/components/LanguageSwitcher/LanguageSwitcher.styled.js +40 -0
- package/lib/components/LanguageSwitcher/index.js +13 -0
- package/lib/components/List/List.js +46 -0
- package/lib/components/List/index.js +13 -0
- package/lib/components/ListSelector/ListSelector.component.js +22 -0
- package/lib/components/ListSelector/ListSelector.state.js +11 -0
- package/lib/components/ListSelector/ListSelector.styled.js +15 -0
- package/lib/components/ListSelector/index.js +13 -0
- package/lib/components/Loading/Loading.js +52 -0
- package/lib/components/Loading/Loading.styled.js +45 -0
- package/lib/components/Loading/index.js +13 -0
- package/lib/components/LoadingModule/LoadingModule.component.js +49 -0
- package/lib/components/LoadingModule/index.js +13 -0
- package/lib/components/MobileAppBar/MobileAppBar.js +90 -0
- package/lib/components/MobileAppBar/MobileAppBar.styled.js +36 -0
- package/lib/components/MobileAppBar/WithMobileAppBar.js +43 -0
- package/lib/components/MobileAppBar/index.js +14 -0
- package/lib/components/Modal/Modal.js +149 -0
- package/lib/components/Modal/ModalManager.context.js +6 -0
- package/lib/components/Modal/ModalManager.js +118 -0
- package/lib/components/Modal/index.js +15 -0
- package/lib/components/Navigation/Navigation.component.js +25 -0
- package/lib/components/Navigation/Navigation.provider.js +69 -0
- package/lib/components/Navigation/Navigation.styled.js +33 -0
- package/lib/components/Navigation/index.js +14 -0
- package/lib/components/PageTitle/PageTitle.component.js +47 -0
- package/lib/components/PageTitle/index.js +13 -0
- package/lib/components/Pagination/Pagination.component.js +49 -0
- package/lib/components/Pagination/index.js +13 -0
- package/lib/components/Radio/Radio.component.js +69 -0
- package/lib/components/Radio/Radio.styled.js +44 -0
- package/lib/components/Radio/RadioGroup.component.js +24 -0
- package/lib/components/Radio/RadioGroup.context.js +6 -0
- package/lib/components/Radio/index.js +15 -0
- package/lib/components/Separator/Separator.component.js +59 -0
- package/lib/components/Separator/index.js +13 -0
- package/lib/components/Skeleton/SkeletonApp.component.js +90 -0
- package/lib/components/Skeleton/SkeletonTable.component.js +36 -0
- package/lib/components/Skeleton/SkeletonText.component.js +62 -0
- package/lib/components/Skeleton/SkeletonWrapper.component.js +46 -0
- package/lib/components/Skeleton/index.js +16 -0
- package/lib/components/Stepper/Stepper.component.js +126 -0
- package/lib/components/Stepper/WithStepper.js +65 -0
- package/lib/components/Stepper/index.js +16 -0
- package/lib/components/Table/Table.component.js +71 -0
- package/lib/components/Table/Table.styled.js +51 -0
- package/lib/components/Table/index.js +13 -0
- package/lib/components/TableContainer/TableContainer.js +32 -0
- package/lib/components/TableContainer/index.js +13 -0
- package/lib/components/Text/Text.component.js +90 -0
- package/lib/components/Text/index.js +13 -0
- package/lib/components/Toast/Toast.component.js +65 -0
- package/lib/components/Toast/Toast.interface.js +2 -0
- package/lib/components/Toast/Toast.manager.js +61 -0
- package/lib/components/Toast/Toast.provider.js +85 -0
- package/lib/components/Toast/Toast.styled.js +18 -0
- package/lib/components/Toast/index.js +15 -0
- package/lib/components/Tours/index.js +100 -0
- package/lib/components/index.js +51 -0
- package/lib/constants/AndroidVersions.js +6 -0
- package/lib/constants/AppNames.js +10 -0
- package/lib/constants/AsphaltTheme.js +43 -0
- package/lib/constants/GobizApp.js +11 -0
- package/lib/constants/MediaQueries.js +30 -0
- package/lib/constants/PostalCodes.js +8382 -0
- package/lib/constants/PubsubEvents.js +12 -0
- package/lib/constants/TnCFiles.js +77 -0
- package/lib/constants/ValidationRegex.js +6 -0
- package/lib/constants/cookies.js +38 -0
- package/lib/constants/datetime.js +103 -0
- package/lib/constants/index.js +24 -0
- package/lib/constants/roles.js +17 -0
- package/lib/contexts/AppTheme.js +221 -0
- package/lib/decorators/utility-classes.js +78 -0
- package/lib/decorators/withStyles.js +73 -0
- package/lib/helpers/BrowserEnvironment.js +22 -0
- package/lib/helpers/ESQuery.js +98 -0
- package/lib/helpers/chart.js +251 -0
- package/lib/helpers/cleanObject.js +15 -0
- package/lib/helpers/conversion.js +4 -0
- package/lib/helpers/cookies.js +54 -0
- package/lib/helpers/copywrite.js +15 -0
- package/lib/helpers/currency.js +73 -0
- package/lib/helpers/dateFormat.js +47 -0
- package/lib/helpers/datePresets.js +77 -0
- package/lib/helpers/debounce.js +31 -0
- package/lib/helpers/deepMerge.js +81 -0
- package/lib/helpers/downloadURL.js +11 -0
- package/lib/helpers/enumReverseMap.js +12 -0
- package/lib/helpers/env.js +18 -0
- package/lib/helpers/fileDownloader.js +33 -0
- package/lib/helpers/formatNumber.js +10 -0
- package/lib/helpers/formatPercentage.js +13 -0
- package/lib/helpers/gobizApp.js +27 -0
- package/lib/helpers/identityValidator.js +6 -0
- package/lib/helpers/index.js +50 -0
- package/lib/helpers/json.js +17 -0
- package/lib/helpers/logger.js +93 -0
- package/lib/helpers/maskAccount.js +26 -0
- package/lib/helpers/numbers.js +6 -0
- package/lib/helpers/path.js +27 -0
- package/lib/helpers/paymentTypeHuman.js +62 -0
- package/lib/helpers/refreshConfig.js +12 -0
- package/lib/helpers/refreshToken.js +108 -0
- package/lib/helpers/safeParse.js +31 -0
- package/lib/helpers/scrollToTop.js +9 -0
- package/lib/helpers/shortID.js +17 -0
- package/lib/helpers/textParser.js +10 -0
- package/lib/helpers/time.js +54 -0
- package/lib/helpers/tour.js +38 -0
- package/lib/helpers/transform.js +24 -0
- package/lib/helpers/url.js +30 -0
- package/lib/helpers/wildcardToRegEx.js +15 -0
- package/lib/hooks/index.js +26 -0
- package/lib/hooks/useBreakpoint.js +35 -0
- package/lib/hooks/useCurrency.js +27 -0
- package/lib/hooks/useDatesFromTimeRange.js +40 -0
- package/lib/hooks/useEventListener.js +24 -0
- package/lib/hooks/useFormValidator.js +38 -0
- package/lib/hooks/useHttpOptions.js +104 -0
- package/lib/hooks/useLogger.js +57 -0
- package/lib/hooks/useNavigation.js +16 -0
- package/lib/hooks/usePhone.js +14 -0
- package/lib/hooks/useQueryInit.js +21 -0
- package/lib/hooks/useQueryParams.js +95 -0
- package/lib/hooks/useShowGlobalFilter.js +101 -0
- package/lib/hooks/useWebview.js +48 -0
- package/lib/hooks/useWindow.js +19 -0
- package/lib/models/AuthUser.model.js +159 -0
- package/lib/models/Outlet.model.js +274 -0
- package/lib/models/User.model.js +106 -0
- package/lib/models/index.js +15 -0
- package/lib/providers/Alert.provider.js +65 -0
- package/lib/providers/AppTheme.provider.js +75 -0
- package/lib/providers/Auth.provider.js +239 -0
- package/lib/providers/Clevertap.provider.js +117 -0
- package/lib/providers/GoogleAnalytics.provider.js +113 -0
- package/lib/providers/Host.provider.js +71 -0
- package/lib/providers/Language.provider.js +127 -0
- package/lib/providers/Logger.provider.js +32 -0
- package/lib/providers/MicroApp.provider.js +63 -0
- package/lib/providers/Outlets.provider.js +180 -0
- package/lib/providers/Token.provider.js +101 -0
- package/lib/providers/Translation.provider.js +56 -0
- package/lib/providers/index.js +24 -0
- package/package.json +47 -0
@@ -0,0 +1,98 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.generateComparingAggs = void 0;
|
7
|
+
var moment_1 = __importDefault(require("moment"));
|
8
|
+
var formatNumber_1 = require("./formatNumber");
|
9
|
+
exports.generateComparingAggs = function (_a) {
|
10
|
+
var dateRange = _a.dateRange, _b = _a.timeRangeDates, compareStartTime = _b.compareStartTime, endTime = _b.endTime, startTime = _b.startTime;
|
11
|
+
var aggs = {};
|
12
|
+
// `chunkUnit` and `chunkIncrement` must work in conjunction
|
13
|
+
// today and yesterday will use '2 hours' as period intervals,
|
14
|
+
// while other presets will use '1 day'.
|
15
|
+
var CHUNK_INCREMENT = 1;
|
16
|
+
var CHUNK_UNIT = "day";
|
17
|
+
// Defaults for today, yesterday
|
18
|
+
var _c = [12, 12], prevIteratorLimit = _c[0], currIteratorLimit = _c[1];
|
19
|
+
switch (dateRange) {
|
20
|
+
case "today":
|
21
|
+
CHUNK_UNIT = "hour";
|
22
|
+
CHUNK_INCREMENT = 2;
|
23
|
+
currIteratorLimit =
|
24
|
+
moment_1.default().diff(moment_1.default().startOf("day"), "hours") / 2 + 1;
|
25
|
+
break;
|
26
|
+
case "yesterday":
|
27
|
+
CHUNK_UNIT = "hour";
|
28
|
+
CHUNK_INCREMENT = 2;
|
29
|
+
break;
|
30
|
+
case "this_week":
|
31
|
+
currIteratorLimit = moment_1.default().weekday();
|
32
|
+
prevIteratorLimit = 7;
|
33
|
+
break;
|
34
|
+
case "last_week":
|
35
|
+
currIteratorLimit = 7;
|
36
|
+
prevIteratorLimit = 7;
|
37
|
+
break;
|
38
|
+
case "this_month":
|
39
|
+
currIteratorLimit = moment_1.default().date();
|
40
|
+
prevIteratorLimit = moment_1.default().subtract(1, "month").daysInMonth();
|
41
|
+
break;
|
42
|
+
case "last_month":
|
43
|
+
currIteratorLimit = moment_1.default().subtract(1, "month").daysInMonth();
|
44
|
+
prevIteratorLimit = moment_1.default().subtract(2, "month").daysInMonth();
|
45
|
+
break;
|
46
|
+
case "custom":
|
47
|
+
var startEndDiff = endTime.diff(startTime, "days") + 1;
|
48
|
+
if (endTime.diff(startTime, "days") < 2) {
|
49
|
+
CHUNK_UNIT = "hour";
|
50
|
+
CHUNK_INCREMENT = 2;
|
51
|
+
startEndDiff = endTime.diff(startTime, "hours") / 2 + 1;
|
52
|
+
}
|
53
|
+
currIteratorLimit = startEndDiff;
|
54
|
+
prevIteratorLimit = startEndDiff;
|
55
|
+
break;
|
56
|
+
}
|
57
|
+
if (CHUNK_UNIT === "hour") {
|
58
|
+
startTime = startTime.clone().subtract(1, "hour");
|
59
|
+
compareStartTime = compareStartTime.clone().subtract(1, "hour");
|
60
|
+
}
|
61
|
+
var appendAggs = function (_startTime, index, prefix) {
|
62
|
+
var chunkStart = _startTime
|
63
|
+
.clone()
|
64
|
+
.add((index * CHUNK_INCREMENT), CHUNK_UNIT);
|
65
|
+
var chunkEnd = chunkStart.clone().add(CHUNK_INCREMENT, CHUNK_UNIT);
|
66
|
+
aggs[prefix + formatNumber_1.force2Digits(index)] = {
|
67
|
+
filter: {
|
68
|
+
clauses: [
|
69
|
+
{
|
70
|
+
field: "transaction.transaction_time",
|
71
|
+
op: "gte",
|
72
|
+
value: chunkStart.toISOString(true),
|
73
|
+
},
|
74
|
+
{
|
75
|
+
field: "transaction.transaction_time",
|
76
|
+
op: "lte",
|
77
|
+
value: chunkEnd.toISOString(true),
|
78
|
+
},
|
79
|
+
],
|
80
|
+
op: "and",
|
81
|
+
},
|
82
|
+
aggs: {
|
83
|
+
transactions_volume: {
|
84
|
+
sum: {
|
85
|
+
field: "transaction.real_gross_amount",
|
86
|
+
},
|
87
|
+
},
|
88
|
+
},
|
89
|
+
};
|
90
|
+
};
|
91
|
+
for (var i = 0; i < prevIteratorLimit; i++) {
|
92
|
+
appendAggs(compareStartTime, i, "previous_");
|
93
|
+
}
|
94
|
+
for (var i = 0; i < currIteratorLimit; i++) {
|
95
|
+
appendAggs(startTime, i, "current_");
|
96
|
+
}
|
97
|
+
return aggs;
|
98
|
+
};
|
@@ -0,0 +1,251 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.getNumberChartOptions = exports.getChartOptions = exports.getXAxisLabel = exports.generateHoursLabel = exports.generateLabels = exports.processChartData = exports.processChartScales = exports.processChartOptions = exports.processComparableData = exports.createYAxesOption = exports.createXAxesOption = void 0;
|
7
|
+
var moment_1 = __importDefault(require("moment"));
|
8
|
+
var currency_1 = require("./currency");
|
9
|
+
var LEGEND_COLORS = {
|
10
|
+
previous: "rgb(250, 207, 153, .9)",
|
11
|
+
current: "rgb(210, 168, 207, .9)",
|
12
|
+
};
|
13
|
+
exports.createXAxesOption = function (labelString) { return [
|
14
|
+
{
|
15
|
+
gridLines: {
|
16
|
+
display: false,
|
17
|
+
},
|
18
|
+
scaleLabel: {
|
19
|
+
display: true,
|
20
|
+
labelString: labelString,
|
21
|
+
},
|
22
|
+
},
|
23
|
+
]; };
|
24
|
+
exports.createYAxesOption = function (labelString, lang, formatterType, numberFormat) {
|
25
|
+
if (formatterType === void 0) { formatterType = "amount"; }
|
26
|
+
return [
|
27
|
+
{
|
28
|
+
scaleLabel: {
|
29
|
+
display: true,
|
30
|
+
labelString: labelString,
|
31
|
+
},
|
32
|
+
ticks: {
|
33
|
+
padding: 10,
|
34
|
+
beginAtZero: true,
|
35
|
+
userCallback: function (label) {
|
36
|
+
//to differentiate y axis format
|
37
|
+
if (formatterType === "number") {
|
38
|
+
//prevent decimal number on y axis
|
39
|
+
if (Math.floor(label) === label) {
|
40
|
+
return numberFormat(label * 100);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
else if (formatterType === "amount") {
|
44
|
+
if (Math.floor(label) === label) {
|
45
|
+
return currency_1.amountFormat(label, lang);
|
46
|
+
}
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
},
|
50
|
+
},
|
51
|
+
gridLines: {
|
52
|
+
display: false,
|
53
|
+
},
|
54
|
+
},
|
55
|
+
];
|
56
|
+
};
|
57
|
+
exports.processComparableData = function (data) {
|
58
|
+
var keys = Object.keys(data)
|
59
|
+
.sort()
|
60
|
+
.filter(function (key) { return !key.match(/_data/); });
|
61
|
+
var previousData = keys
|
62
|
+
.filter(function (k) { return k.match(/^previous_/); })
|
63
|
+
.map(function (k) { return data === null || data === void 0 ? void 0 : data[k]; });
|
64
|
+
var prevTransactionsCount = previousData.map(function (d) { return d === null || d === void 0 ? void 0 : d.doc_count; });
|
65
|
+
var currentData = keys
|
66
|
+
.filter(function (k) { return k.match(/^current_/); })
|
67
|
+
.map(function (k) { return data === null || data === void 0 ? void 0 : data[k]; });
|
68
|
+
var currTransactionsCount = currentData.map(function (d) { return d === null || d === void 0 ? void 0 : d.doc_count; });
|
69
|
+
var tempComparableData = {
|
70
|
+
previousData: previousData.map(function (d) { return d.transactions_volume.value; }),
|
71
|
+
currentData: currentData.map(function (d) { return d.transactions_volume.value; }),
|
72
|
+
};
|
73
|
+
return {
|
74
|
+
transactionCount: {
|
75
|
+
prevTransactionsCount: prevTransactionsCount,
|
76
|
+
currTransactionsCount: currTransactionsCount,
|
77
|
+
},
|
78
|
+
tempComparableData: tempComparableData,
|
79
|
+
};
|
80
|
+
};
|
81
|
+
exports.processChartOptions = function (options, dateRange, timeRangeDates, transactionCount, formatType, formatter) {
|
82
|
+
if (formatType === void 0) { formatType = "currency"; }
|
83
|
+
var newOptions = Object.assign({}, options);
|
84
|
+
newOptions.tooltips.callbacks = {
|
85
|
+
title: function (tooltipItems, data) {
|
86
|
+
var actualTooltipItem = tooltipItems[0];
|
87
|
+
if (dateRange && ["today", "yesterday"].includes(dateRange)) {
|
88
|
+
var time = actualTooltipItem.xLabel.split(":")[0];
|
89
|
+
var currTime = parseInt(time, 10);
|
90
|
+
return currTime + ":00 - " + (currTime + 2) + ":00";
|
91
|
+
}
|
92
|
+
if (dateRange === "this_month") {
|
93
|
+
var month = actualTooltipItem.datasetIndex === 0
|
94
|
+
? moment_1.default().month()
|
95
|
+
: moment_1.default().subtract(1, "month").month();
|
96
|
+
return moment_1.default()
|
97
|
+
.set({ date: actualTooltipItem.index + 1, month: month })
|
98
|
+
.format("DD/MM/YYYY");
|
99
|
+
}
|
100
|
+
if (dateRange === "last_month") {
|
101
|
+
var month = actualTooltipItem.datasetIndex === 0
|
102
|
+
? moment_1.default().subtract(1, "month").month()
|
103
|
+
: moment_1.default().subtract(2, "month").month();
|
104
|
+
return moment_1.default()
|
105
|
+
.set({ date: actualTooltipItem.index + 1, month: month })
|
106
|
+
.format("DD/MM/YYYY");
|
107
|
+
}
|
108
|
+
if (dateRange === "custom") {
|
109
|
+
var time = actualTooltipItem.datasetIndex === 0
|
110
|
+
? timeRangeDates.startTime
|
111
|
+
: timeRangeDates.compareStartTime;
|
112
|
+
return time
|
113
|
+
.clone()
|
114
|
+
.add(actualTooltipItem.index, "days")
|
115
|
+
.format("DD/MM/YYYY");
|
116
|
+
}
|
117
|
+
return actualTooltipItem.xLabel;
|
118
|
+
},
|
119
|
+
label: function (tooltipItem) {
|
120
|
+
if (formatType === "number") {
|
121
|
+
return "" + formatter(tooltipItem.yLabel * 100);
|
122
|
+
}
|
123
|
+
else if (formatType === "currency") {
|
124
|
+
var setToShow = [
|
125
|
+
transactionCount.currTransactionsCount,
|
126
|
+
transactionCount.prevTransactionsCount,
|
127
|
+
][tooltipItem.datasetIndex];
|
128
|
+
return formatter(tooltipItem.yLabel) + " (" + setToShow[tooltipItem.index] + " txn)";
|
129
|
+
}
|
130
|
+
},
|
131
|
+
};
|
132
|
+
return newOptions;
|
133
|
+
};
|
134
|
+
exports.processChartScales = function (options, timeRangeDates, translate, dateRange, language, translationModule, yAxisTranslation, formatterType, numberFormat) {
|
135
|
+
if (formatterType === void 0) { formatterType = "amount"; }
|
136
|
+
var newOptions = Object.assign({}, options);
|
137
|
+
var diffDaysCustomRange = moment_1.default(timeRangeDates.endTime).diff(moment_1.default(timeRangeDates.startTime), "days");
|
138
|
+
newOptions.scales.xAxes = exports.createXAxesOption(translate(exports.getXAxisLabel(dateRange, diffDaysCustomRange, translationModule)));
|
139
|
+
newOptions.scales.yAxes = exports.createYAxesOption(translate((yAxisTranslation || translationModule) + ".labels.y_axis"), language, formatterType, numberFormat);
|
140
|
+
return newOptions;
|
141
|
+
};
|
142
|
+
exports.processChartData = function (_dateRange, timeRangeDates, comparableData) { return ({
|
143
|
+
labels: exports.generateLabels(_dateRange, timeRangeDates),
|
144
|
+
datasets: [
|
145
|
+
{
|
146
|
+
backgroundColor: LEGEND_COLORS.current,
|
147
|
+
label: "Current",
|
148
|
+
borderWidth: 0,
|
149
|
+
data: comparableData.currentData,
|
150
|
+
},
|
151
|
+
{
|
152
|
+
label: "Previous",
|
153
|
+
backgroundColor: LEGEND_COLORS.previous,
|
154
|
+
borderWidth: 0,
|
155
|
+
data: comparableData.previousData,
|
156
|
+
},
|
157
|
+
],
|
158
|
+
}); };
|
159
|
+
exports.generateLabels = function (dateRange, _a) {
|
160
|
+
var endTime = _a.endTime, startTime = _a.startTime;
|
161
|
+
if (dateRange === "custom") {
|
162
|
+
if (endTime.diff(startTime, "days") < 2) {
|
163
|
+
var iterator = endTime.diff(startTime, "hours") / 2 + 1;
|
164
|
+
return exports.generateHoursLabel(iterator, startTime);
|
165
|
+
}
|
166
|
+
else {
|
167
|
+
var startEndDiff = moment_1.default(endTime).diff(moment_1.default(startTime), "days") + 1;
|
168
|
+
return new Array(startEndDiff).fill("").map(function (_, i) {
|
169
|
+
return moment_1.default(startTime).clone().add(i, "days").format("YYYY/MM/DD");
|
170
|
+
});
|
171
|
+
}
|
172
|
+
}
|
173
|
+
if (dateRange && ["today", "yesterday"].includes(dateRange)) {
|
174
|
+
return exports.generateHoursLabel(12, moment_1.default().startOf("day"));
|
175
|
+
}
|
176
|
+
if (dateRange && ["this_week", "last_week"].includes(dateRange)) {
|
177
|
+
return ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
|
178
|
+
}
|
179
|
+
var daysInCurrentMonth = moment_1.default().daysInMonth();
|
180
|
+
var daysInPreviousMonth = moment_1.default().subtract(1, "month").daysInMonth();
|
181
|
+
if (dateRange === "last_month") {
|
182
|
+
daysInCurrentMonth = moment_1.default().subtract(1, "month").daysInMonth();
|
183
|
+
daysInPreviousMonth = moment_1.default().subtract(2, "month").daysInMonth();
|
184
|
+
}
|
185
|
+
return new Array(Math.max(daysInPreviousMonth, daysInCurrentMonth))
|
186
|
+
.fill("")
|
187
|
+
.map(function (_, i) {
|
188
|
+
return i < daysInCurrentMonth ? "" + (i + 1) : "";
|
189
|
+
});
|
190
|
+
};
|
191
|
+
exports.generateHoursLabel = function (iterator, startTime) {
|
192
|
+
var hourLabels = [];
|
193
|
+
for (var i = 0; i < iterator; i++) {
|
194
|
+
var iterated = startTime.clone().add(i * 2, "hour");
|
195
|
+
hourLabels.push(iterated.format("H:00"));
|
196
|
+
}
|
197
|
+
return hourLabels;
|
198
|
+
};
|
199
|
+
exports.getXAxisLabel = function (dateRange, diffDays, translationModule) {
|
200
|
+
if (diffDays === void 0) { diffDays = 0; }
|
201
|
+
switch (dateRange) {
|
202
|
+
case "today":
|
203
|
+
case "yesterday":
|
204
|
+
return translationModule + ".labels.x_axis.time";
|
205
|
+
case "this_week":
|
206
|
+
case "last_week":
|
207
|
+
return translationModule + ".labels.x_axis.day";
|
208
|
+
case "custom":
|
209
|
+
if (diffDays > 1)
|
210
|
+
return translationModule + ".labels.x_axis.date";
|
211
|
+
if (diffDays > 0)
|
212
|
+
return translationModule + ".labels.x_axis.date_time";
|
213
|
+
return translationModule + ".labels.x_axis.time";
|
214
|
+
case "this_month":
|
215
|
+
case "last_month":
|
216
|
+
default:
|
217
|
+
return translationModule + ".labels.x_axis.date";
|
218
|
+
}
|
219
|
+
};
|
220
|
+
exports.getChartOptions = function (currencyFormat) { return ({
|
221
|
+
animation: {
|
222
|
+
duration: 0,
|
223
|
+
},
|
224
|
+
legend: {
|
225
|
+
display: false,
|
226
|
+
},
|
227
|
+
scales: {},
|
228
|
+
tooltips: {
|
229
|
+
callbacks: {
|
230
|
+
label: function (tooltipItem, data) {
|
231
|
+
return currencyFormat(tooltipItem.yLabel);
|
232
|
+
},
|
233
|
+
},
|
234
|
+
},
|
235
|
+
}); };
|
236
|
+
exports.getNumberChartOptions = function (numberFormat) { return ({
|
237
|
+
animation: {
|
238
|
+
duration: 0,
|
239
|
+
},
|
240
|
+
legend: {
|
241
|
+
display: false,
|
242
|
+
},
|
243
|
+
scales: {},
|
244
|
+
tooltips: {
|
245
|
+
callbacks: {
|
246
|
+
label: function (tooltipItem, data) {
|
247
|
+
return numberFormat(tooltipItem.yLabel * 100);
|
248
|
+
},
|
249
|
+
},
|
250
|
+
},
|
251
|
+
}); };
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.cleanObject = void 0;
|
4
|
+
exports.cleanObject = function (object) {
|
5
|
+
Object.keys(object).forEach(function (key) {
|
6
|
+
if (object[key] && typeof object[key] === "object")
|
7
|
+
exports.cleanObject(object[key]);
|
8
|
+
// recurse
|
9
|
+
else if (object[key] === null ||
|
10
|
+
object[key] === undefined ||
|
11
|
+
object[key] === "")
|
12
|
+
delete object[key]; // delete
|
13
|
+
});
|
14
|
+
return object;
|
15
|
+
};
|
@@ -0,0 +1,54 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.setBoolCookie = exports.getBoolCookie = exports.deleteCookie = exports.setCookie = exports.getCookie = exports.CookieConfig = void 0;
|
4
|
+
var CookieConfig = /** @class */ (function () {
|
5
|
+
function CookieConfig() {
|
6
|
+
}
|
7
|
+
CookieConfig.scopedCookieName = function (key) {
|
8
|
+
if (key.match(/^\$_/i)) {
|
9
|
+
return key + ":" + CookieConfig.userId;
|
10
|
+
}
|
11
|
+
return key;
|
12
|
+
};
|
13
|
+
return CookieConfig;
|
14
|
+
}());
|
15
|
+
exports.CookieConfig = CookieConfig;
|
16
|
+
exports.getCookie = function (cookieName, _document) {
|
17
|
+
if (_document === void 0) { _document = document; }
|
18
|
+
var scopedName = CookieConfig.scopedCookieName(cookieName);
|
19
|
+
var cookie = scopedName + "=";
|
20
|
+
var cookies = _document.cookie.split(";");
|
21
|
+
for (var _i = 0, cookies_1 = cookies; _i < cookies_1.length; _i++) {
|
22
|
+
var value = cookies_1[_i];
|
23
|
+
while (value.charAt(0) === " ") {
|
24
|
+
value = value.substring(1);
|
25
|
+
}
|
26
|
+
if (value.indexOf(cookie) === 0) {
|
27
|
+
return value.substring(cookie.length, value.length);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
return "";
|
31
|
+
};
|
32
|
+
exports.setCookie = function (cookieName, cookieValue, expiryDays, _document) {
|
33
|
+
if (expiryDays === void 0) { expiryDays = 10 * 365; }
|
34
|
+
if (_document === void 0) { _document = document; }
|
35
|
+
if (typeof expiryDays === "string") {
|
36
|
+
expiryDays = 10 * 365;
|
37
|
+
}
|
38
|
+
var scopedName = CookieConfig.scopedCookieName(cookieName);
|
39
|
+
var expiryDate = new Date();
|
40
|
+
expiryDate.setTime(expiryDate.getTime() + expiryDays * 24 * 60 * 60 * 1000);
|
41
|
+
var expires = "expires=" + expiryDate.toUTCString();
|
42
|
+
_document.cookie = scopedName + "=" + cookieValue + ";" + expires + ";path=/";
|
43
|
+
};
|
44
|
+
exports.deleteCookie = function (cookieName, _document) {
|
45
|
+
if (_document === void 0) { _document = document; }
|
46
|
+
exports.setCookie(cookieName, "", -1, _document);
|
47
|
+
};
|
48
|
+
exports.getBoolCookie = function (cookieName) {
|
49
|
+
return exports.getCookie(cookieName) === "true";
|
50
|
+
};
|
51
|
+
exports.setBoolCookie = function (cookieName, value) {
|
52
|
+
if (value === void 0) { value = true; }
|
53
|
+
return value ? exports.setCookie(cookieName, "true") : exports.deleteCookie(cookieName);
|
54
|
+
};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.localizePhone = exports.localizeCurrency = void 0;
|
4
|
+
exports.localizeCurrency = function (copy, country) {
|
5
|
+
if (country === "ID")
|
6
|
+
return copy;
|
7
|
+
// if country === "VN"
|
8
|
+
return copy.replace("Rp", "đ");
|
9
|
+
};
|
10
|
+
exports.localizePhone = function (copy, country) {
|
11
|
+
if (country === "ID")
|
12
|
+
return copy;
|
13
|
+
// if country === "VN"
|
14
|
+
return copy.replace("+62", "+84").replace("81", "902");
|
15
|
+
};
|
@@ -0,0 +1,73 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.amountFormat = exports.numberFormat = exports.currencyFormatNoDivide = exports.currencyFormat = exports.currencyFormatFromString = void 0;
|
4
|
+
exports.currencyFormatFromString = function (amount, country, options) {
|
5
|
+
if (country === void 0) { country = "ID"; }
|
6
|
+
if (!amount) {
|
7
|
+
return "-";
|
8
|
+
}
|
9
|
+
var _amount;
|
10
|
+
try {
|
11
|
+
_amount = parseInt(amount, 10);
|
12
|
+
}
|
13
|
+
catch (err) {
|
14
|
+
return "-";
|
15
|
+
}
|
16
|
+
if (Number.isNaN(_amount)) {
|
17
|
+
return "-";
|
18
|
+
}
|
19
|
+
return exports.currencyFormat(_amount, country, options);
|
20
|
+
};
|
21
|
+
exports.currencyFormat = function (amount, country, options) {
|
22
|
+
var _a;
|
23
|
+
if (country === void 0) { country = "ID"; }
|
24
|
+
var locale = country === "ID" ? "id-ID" : "vi-VN";
|
25
|
+
var localeCurrency = country === "ID" ? "IDR" : "VND";
|
26
|
+
return new Intl.NumberFormat(locale, {
|
27
|
+
currency: (options === null || options === void 0 ? void 0 : options.currency) || localeCurrency,
|
28
|
+
style: "currency",
|
29
|
+
minimumFractionDigits: 0,
|
30
|
+
}).format(amount / Math.pow(10, (_a = options === null || options === void 0 ? void 0 : options.decimal) !== null && _a !== void 0 ? _a : 2));
|
31
|
+
};
|
32
|
+
exports.currencyFormatNoDivide = function (amount, country) {
|
33
|
+
if (country === void 0) { country = "ID"; }
|
34
|
+
var locale = country === "ID" ? "id-ID" : "vi-VN";
|
35
|
+
var localeCurrency = country === "ID" ? "IDR" : "VND";
|
36
|
+
return new Intl.NumberFormat(locale, {
|
37
|
+
currency: localeCurrency,
|
38
|
+
style: "currency",
|
39
|
+
minimumFractionDigits: 0,
|
40
|
+
}).format(amount);
|
41
|
+
};
|
42
|
+
exports.numberFormat = function (amount, country) {
|
43
|
+
if (country === void 0) { country = "ID"; }
|
44
|
+
var locale = country === "ID" ? "id-ID" : "vi-VN";
|
45
|
+
return new Intl.NumberFormat(locale, {
|
46
|
+
maximumFractionDigits: 2,
|
47
|
+
}).format(amount / 100);
|
48
|
+
};
|
49
|
+
exports.amountFormat = function (amount, lang) {
|
50
|
+
if (lang === void 0) { lang = "id"; }
|
51
|
+
var formattedAmount = amount / 100000;
|
52
|
+
var unit = lang === "id" ? "rb" : "k";
|
53
|
+
if (amount === 0) {
|
54
|
+
formattedAmount = "";
|
55
|
+
unit = "";
|
56
|
+
}
|
57
|
+
// > 1.000.000
|
58
|
+
if (amount >= 100000000) {
|
59
|
+
formattedAmount = amount / 100000000;
|
60
|
+
unit = lang === "id" ? "jt" : "m";
|
61
|
+
}
|
62
|
+
// > 1.000.000.000
|
63
|
+
if (amount >= 100000000000) {
|
64
|
+
formattedAmount = amount / 100000000000;
|
65
|
+
unit = lang === "id" ? "miliar" : "b";
|
66
|
+
}
|
67
|
+
// > 1.000.000.000.000
|
68
|
+
if (amount >= 100000000000000) {
|
69
|
+
formattedAmount = amount / 100000000000000;
|
70
|
+
unit = lang === "id" ? "triliun" : "tr";
|
71
|
+
}
|
72
|
+
return (formattedAmount + " " + unit).trim();
|
73
|
+
};
|
@@ -0,0 +1,47 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.protobufTimestampToDate = exports.localDateFormat = exports.dateFormat = void 0;
|
7
|
+
var moment_1 = __importDefault(require("moment"));
|
8
|
+
require("moment/locale/id");
|
9
|
+
require("moment/locale/vi");
|
10
|
+
var PREFIX = {
|
11
|
+
id: ["Kemarin", "Hari ini"],
|
12
|
+
en: ["Yesterday", "Today"],
|
13
|
+
vi: ["Hôm qua", "Hôm nay"],
|
14
|
+
};
|
15
|
+
// Today, 23:05
|
16
|
+
// Yesterday, 07:40
|
17
|
+
// 12/11/2018 18:52
|
18
|
+
exports.dateFormat = function (date, lang) {
|
19
|
+
var _moment = typeof date === "string" ? moment_1.default(date) : date;
|
20
|
+
if (!(_moment === null || _moment === void 0 ? void 0 : _moment.isValid()) || !date) {
|
21
|
+
return "";
|
22
|
+
}
|
23
|
+
if (!!lang)
|
24
|
+
_moment.locale(lang);
|
25
|
+
var today = moment_1.default().startOf("day");
|
26
|
+
var endOfToday = moment_1.default().endOf("day");
|
27
|
+
var yesterday = today.clone().subtract(1, "day");
|
28
|
+
if (_moment.isBefore(yesterday) || _moment.isAfter(endOfToday)) {
|
29
|
+
return _moment.format("DD MMMM YYYY, HH:mm");
|
30
|
+
}
|
31
|
+
var prefix = "";
|
32
|
+
if (_moment.isBefore(today)) {
|
33
|
+
prefix = lang ? PREFIX[lang][0] : "Yesterday";
|
34
|
+
}
|
35
|
+
else {
|
36
|
+
prefix = lang ? PREFIX[lang][1] : "Today";
|
37
|
+
}
|
38
|
+
return prefix + ", " + _moment.format("HH:mm");
|
39
|
+
};
|
40
|
+
exports.localDateFormat = function (date, format) {
|
41
|
+
if (format === void 0) { format = "dddd - DD MMMM YYYY, HH:mm"; }
|
42
|
+
return moment_1.default(date).utc(true).format(format);
|
43
|
+
};
|
44
|
+
exports.protobufTimestampToDate = function (protobufObj, lang) {
|
45
|
+
if (lang === void 0) { lang = "en"; }
|
46
|
+
return exports.dateFormat(moment_1.default(new Date(protobufObj.seconds * 1000 + protobufObj.nanos / 1000)), lang);
|
47
|
+
};
|
@@ -0,0 +1,77 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.datesFromTimeRange = void 0;
|
7
|
+
var moment_1 = __importDefault(require("moment"));
|
8
|
+
/**
|
9
|
+
* This helper attempts to translate a human readable date preset, such as 'today', into instances of Moment to be used
|
10
|
+
* within queries or filters.
|
11
|
+
* Example:
|
12
|
+
* Input => 'today'
|
13
|
+
* Output => [01-01-2020 00:00, 01-01-2020 23:59]
|
14
|
+
*
|
15
|
+
* @return [startDate, endDate, previousStartTime, previousEndTime] - previousStartTime and previousEndTime are used
|
16
|
+
* for comparable date range such in POS page
|
17
|
+
* @param params
|
18
|
+
*/
|
19
|
+
exports.datesFromTimeRange = function (params) {
|
20
|
+
var timeRange = params.timeRange, previousStartTime = params.previousStartTime, previousEndTime = params.previousEndTime;
|
21
|
+
var now = moment_1.default();
|
22
|
+
// Defaults to today
|
23
|
+
var startTime = now.clone().startOf("day");
|
24
|
+
var endTime = now.clone().endOf("day");
|
25
|
+
var compareStartTime = now.clone().subtract(1, "day").startOf("day");
|
26
|
+
switch (timeRange) {
|
27
|
+
case "custom":
|
28
|
+
startTime = previousStartTime || startTime;
|
29
|
+
endTime = previousEndTime || endTime;
|
30
|
+
var startEndDiff = endTime.diff(startTime, "ms");
|
31
|
+
compareStartTime = startTime.clone().subtract(startEndDiff, "ms");
|
32
|
+
break;
|
33
|
+
case "yesterday":
|
34
|
+
startTime.subtract(1, "day");
|
35
|
+
endTime.subtract(1, "day");
|
36
|
+
compareStartTime = startTime.clone().subtract(1, "day").startOf("day");
|
37
|
+
break;
|
38
|
+
case "this_week":
|
39
|
+
startTime.startOf("isoWeek");
|
40
|
+
endTime.endOf("isoWeek");
|
41
|
+
compareStartTime = startTime
|
42
|
+
.clone()
|
43
|
+
.subtract(1, "week")
|
44
|
+
.startOf("isoWeek");
|
45
|
+
break;
|
46
|
+
case "last_week":
|
47
|
+
endTime = endTime.subtract(1, "week").endOf("isoWeek");
|
48
|
+
startTime = endTime.clone().startOf("isoWeek");
|
49
|
+
compareStartTime = startTime
|
50
|
+
.clone()
|
51
|
+
.subtract(1, "week")
|
52
|
+
.startOf("isoWeek");
|
53
|
+
break;
|
54
|
+
case "this_month":
|
55
|
+
startTime.startOf("month");
|
56
|
+
endTime.endOf("month");
|
57
|
+
compareStartTime = startTime
|
58
|
+
.clone()
|
59
|
+
.subtract(1, "month")
|
60
|
+
.startOf("month");
|
61
|
+
break;
|
62
|
+
case "last_month":
|
63
|
+
endTime = endTime.subtract(1, "month").endOf("month");
|
64
|
+
startTime = endTime.clone().startOf("month");
|
65
|
+
compareStartTime = startTime
|
66
|
+
.clone()
|
67
|
+
.subtract(1, "month")
|
68
|
+
.startOf("month");
|
69
|
+
break;
|
70
|
+
}
|
71
|
+
return {
|
72
|
+
startTime: startTime,
|
73
|
+
endTime: endTime,
|
74
|
+
compareStartTime: compareStartTime,
|
75
|
+
compareEndTime: startTime,
|
76
|
+
};
|
77
|
+
};
|
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.debounce = void 0;
|
4
|
+
/**
|
5
|
+
* Debounce function. Used to throttle the calling of multiple subsequent functions.
|
6
|
+
* @param func
|
7
|
+
* @param wait
|
8
|
+
* @param immediate
|
9
|
+
*/
|
10
|
+
function debounce(func, wait, immediate) {
|
11
|
+
if (immediate === void 0) { immediate = false; }
|
12
|
+
var timeout;
|
13
|
+
return function () {
|
14
|
+
var args = [];
|
15
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
16
|
+
args[_i] = arguments[_i];
|
17
|
+
}
|
18
|
+
// @ts-ignore
|
19
|
+
var context = this;
|
20
|
+
// let args = arguments;
|
21
|
+
clearTimeout(timeout);
|
22
|
+
timeout = setTimeout(function () {
|
23
|
+
timeout = null;
|
24
|
+
if (!immediate)
|
25
|
+
func.apply(context, args);
|
26
|
+
}, wait);
|
27
|
+
if (immediate && !timeout)
|
28
|
+
func.apply(context, args);
|
29
|
+
};
|
30
|
+
}
|
31
|
+
exports.debounce = debounce;
|