@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,95 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
exports.useQueryParams = void 0;
|
18
|
+
var react_1 = require("react");
|
19
|
+
var react_router_dom_1 = require("react-router-dom");
|
20
|
+
var query_string_1 = __importDefault(require("query-string"));
|
21
|
+
/**
|
22
|
+
* Removes queries that matches defaultQuery. E.g you typically set { page: 1 } as the default query.
|
23
|
+
* This function will ensure that the URL is shown as `/url` instead of `/url?page=1` when that page is opened. It
|
24
|
+
* removes ?page=1 because it is the default value. But will still show `/url?page=[2...n]`.
|
25
|
+
* @param defaultQuery
|
26
|
+
* @param params
|
27
|
+
*/
|
28
|
+
var removeDefaultParamsFromQuery = function (defaultQuery, params) {
|
29
|
+
var _default = defaultQuery;
|
30
|
+
return Object.keys(params).reduce(function (_params, key) {
|
31
|
+
_params[key] = params[key] === _default[key] ? undefined : params[key];
|
32
|
+
return _params;
|
33
|
+
}, {});
|
34
|
+
};
|
35
|
+
exports.useQueryParams = function (defaultQuery) {
|
36
|
+
if (defaultQuery === void 0) { defaultQuery = {
|
37
|
+
gopay_ref_id: "",
|
38
|
+
transaction_id: "",
|
39
|
+
min_amount: "",
|
40
|
+
max_amount: "",
|
41
|
+
features: "",
|
42
|
+
payment_type: "",
|
43
|
+
qris_charging_type: "",
|
44
|
+
qris_issuer: "",
|
45
|
+
transaction_status: "",
|
46
|
+
page: 1,
|
47
|
+
merchant_id: "",
|
48
|
+
date_range: "",
|
49
|
+
start_date: "",
|
50
|
+
end_date: "",
|
51
|
+
merchant_name: "",
|
52
|
+
phone: "",
|
53
|
+
email: "",
|
54
|
+
full_name: "",
|
55
|
+
outlet_name: "",
|
56
|
+
reset_password_token: "",
|
57
|
+
email_user_name: "",
|
58
|
+
ip_address: "",
|
59
|
+
action: "",
|
60
|
+
time: "",
|
61
|
+
}; }
|
62
|
+
var push = react_router_dom_1.useHistory().push;
|
63
|
+
var location = react_router_dom_1.useLocation();
|
64
|
+
var initialValue = query_string_1.default.parse(location.search, {
|
65
|
+
parseNumbers: true,
|
66
|
+
parseBooleans: true,
|
67
|
+
});
|
68
|
+
var _a = react_1.useState(__assign(__assign({}, defaultQuery), initialValue)), queryParams = _a[0], setQueryParams = _a[1];
|
69
|
+
var _b = react_1.useState(location.search.replace(/^\?/, "")), _string = _b[0], _setString = _b[1];
|
70
|
+
var _pushQueryParams = function (query) {
|
71
|
+
var _mergedQuery = __assign(__assign({}, queryParams), query);
|
72
|
+
var _withDefaultParams = removeDefaultParamsFromQuery(defaultQuery, _mergedQuery);
|
73
|
+
var _queryString = query_string_1.default.stringify(_withDefaultParams);
|
74
|
+
_setString(_queryString);
|
75
|
+
var _pathToPush = location.pathname + "?" + _queryString;
|
76
|
+
push(_pathToPush);
|
77
|
+
};
|
78
|
+
react_1.useEffect(function () {
|
79
|
+
var parsed = query_string_1.default.parse(location.search, {
|
80
|
+
parseNumbers: true,
|
81
|
+
parseBooleans: true,
|
82
|
+
});
|
83
|
+
var withDefaultState = __assign(__assign({}, defaultQuery), parsed);
|
84
|
+
var toSet = __assign(__assign({}, queryParams), withDefaultState);
|
85
|
+
setQueryParams(toSet);
|
86
|
+
// Removing this will cause compiler to complain about `queryParams` not being included in the deps array. But
|
87
|
+
// including it will cause the hook to re-render continuously, causing performance issues.
|
88
|
+
// eslint-disable-next-line
|
89
|
+
}, [location.search]);
|
90
|
+
return {
|
91
|
+
query: queryParams,
|
92
|
+
queryString: _string,
|
93
|
+
push: _pushQueryParams,
|
94
|
+
};
|
95
|
+
};
|
@@ -0,0 +1,101 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
exports.useShowGlobalFilter = void 0;
|
18
|
+
var react_1 = require("react");
|
19
|
+
var moment_1 = __importDefault(require("moment"));
|
20
|
+
var useQueryParams_1 = require("./useQueryParams");
|
21
|
+
var GlobalFilter_1 = require("../components/GlobalFilter");
|
22
|
+
var datePresets_1 = require("../helpers/datePresets");
|
23
|
+
var Outlets_provider_1 = require("../providers/Outlets.provider");
|
24
|
+
exports.useShowGlobalFilter = function (config) {
|
25
|
+
if (config === void 0) { config = {}; }
|
26
|
+
var globalFilterState = GlobalFilter_1.useGlobalFilter();
|
27
|
+
var filter = globalFilterState.filter, enableFilter = globalFilterState.enableFilter, disableFilter = globalFilterState.disableFilter, initFilter = globalFilterState.initFilter, resetFilter = globalFilterState.resetFilter;
|
28
|
+
var outlets = Outlets_provider_1.useOutlets().outlets;
|
29
|
+
var _a = useQueryParams_1.useQueryParams(), query = _a.query, push = _a.push;
|
30
|
+
var newFilter = Object.assign({}, filter);
|
31
|
+
react_1.useEffect(function () {
|
32
|
+
var _a;
|
33
|
+
var merchant_id = query.merchant_id, start_date = query.start_date, end_date = query.end_date, date_range = query.date_range;
|
34
|
+
if (merchant_id) {
|
35
|
+
newFilter.merchant_id = merchant_id;
|
36
|
+
}
|
37
|
+
else if (config.hideAllOutlet) {
|
38
|
+
newFilter.merchant_id = (_a = outlets === null || outlets === void 0 ? void 0 : outlets[0]) === null || _a === void 0 ? void 0 : _a.id;
|
39
|
+
}
|
40
|
+
if (start_date) {
|
41
|
+
newFilter.start_time = start_date;
|
42
|
+
}
|
43
|
+
if (end_date) {
|
44
|
+
newFilter.end_time = end_date;
|
45
|
+
}
|
46
|
+
var setDateRange = function (range) {
|
47
|
+
var _a = datePresets_1.datesFromTimeRange({
|
48
|
+
timeRange: range,
|
49
|
+
previousEndTime: moment_1.default(newFilter.end_time),
|
50
|
+
previousStartTime: moment_1.default(newFilter.start_time),
|
51
|
+
}), startTime = _a.startTime, endTime = _a.endTime;
|
52
|
+
newFilter.date_range = range;
|
53
|
+
newFilter.start_time = startTime.toISOString();
|
54
|
+
newFilter.end_time = endTime.toISOString();
|
55
|
+
};
|
56
|
+
if (start_date || end_date) {
|
57
|
+
setDateRange("custom");
|
58
|
+
}
|
59
|
+
else if (date_range) {
|
60
|
+
// Do not let date_range be undefined
|
61
|
+
setDateRange(date_range);
|
62
|
+
}
|
63
|
+
initFilter(newFilter);
|
64
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
65
|
+
}, []);
|
66
|
+
react_1.useEffect(function () {
|
67
|
+
var _a;
|
68
|
+
var newQuery = {};
|
69
|
+
if (config.hideAllOutlet && filter.merchant_id === "all") {
|
70
|
+
newQuery = __assign(__assign({}, newQuery), { merchant_id: (_a = outlets === null || outlets === void 0 ? void 0 : outlets[0]) === null || _a === void 0 ? void 0 : _a.id });
|
71
|
+
}
|
72
|
+
else {
|
73
|
+
newQuery = __assign(__assign({}, newQuery), { merchant_id: filter.merchant_id });
|
74
|
+
}
|
75
|
+
if (config.showDateFilter) {
|
76
|
+
newQuery = __assign(__assign({}, newQuery), { date_range: filter.date_range });
|
77
|
+
if (filter.date_range === "custom") {
|
78
|
+
newQuery = __assign(__assign({}, newQuery), { start_date: filter.start_time, end_date: filter.end_time });
|
79
|
+
}
|
80
|
+
else {
|
81
|
+
newQuery = __assign(__assign({}, newQuery), { start_date: "", end_date: "" });
|
82
|
+
}
|
83
|
+
}
|
84
|
+
push(newQuery);
|
85
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
86
|
+
}, [
|
87
|
+
filter.date_range,
|
88
|
+
filter.start_time,
|
89
|
+
filter.end_time,
|
90
|
+
filter.merchant_id,
|
91
|
+
]);
|
92
|
+
react_1.useEffect(function () {
|
93
|
+
enableFilter(config);
|
94
|
+
return function () {
|
95
|
+
disableFilter();
|
96
|
+
resetFilter();
|
97
|
+
};
|
98
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
99
|
+
}, []);
|
100
|
+
return globalFilterState;
|
101
|
+
};
|
@@ -0,0 +1,48 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.useWebViewNavigation = void 0;
|
4
|
+
var BrowserEnvironment_1 = require("../helpers/BrowserEnvironment");
|
5
|
+
var env_1 = require("../helpers/env");
|
6
|
+
var path_1 = require("../helpers/path");
|
7
|
+
var GoogleAnalytics_provider_1 = require("../providers/GoogleAnalytics.provider");
|
8
|
+
exports.useWebViewNavigation = function () {
|
9
|
+
var sendEvent = GoogleAnalytics_provider_1.useGoogleAnalytics().sendEvent;
|
10
|
+
return {
|
11
|
+
closeWebView: function (state, nonWebViewFallback) {
|
12
|
+
if (!BrowserEnvironment_1.isWebView()) {
|
13
|
+
if (typeof nonWebViewFallback === "function") {
|
14
|
+
return nonWebViewFallback();
|
15
|
+
}
|
16
|
+
console.warn("WebView Navigation: " + state + " called outside of WebView");
|
17
|
+
return (window.location.href = env_1.env("REACT_APP_ROUTE_PREFIX") + "/");
|
18
|
+
}
|
19
|
+
sendEvent("WebView Navigation: " + state);
|
20
|
+
window.location.href = path_1.PATH[state];
|
21
|
+
},
|
22
|
+
closeShuffleWebView: function (nonWebViewFallback) {
|
23
|
+
if (!BrowserEnvironment_1.isWebView()) {
|
24
|
+
if (typeof nonWebViewFallback === "function") {
|
25
|
+
return nonWebViewFallback();
|
26
|
+
}
|
27
|
+
console.warn("Close Shuffle WebView is called outside of WebView");
|
28
|
+
return (window.location.href = env_1.env("REACT_APP_ROUTE_PREFIX") + "/");
|
29
|
+
}
|
30
|
+
sendEvent("WebView Navigation: Close");
|
31
|
+
var urlParams = new URLSearchParams(window.location.search);
|
32
|
+
urlParams.set("gobiz_action", "close");
|
33
|
+
window.location.search = urlParams.toString();
|
34
|
+
},
|
35
|
+
openExternalBrowser: function (url, nonWebviewFallback) {
|
36
|
+
console.log(url);
|
37
|
+
if (!BrowserEnvironment_1.isWebView()) {
|
38
|
+
if (typeof nonWebviewFallback === "function") {
|
39
|
+
return nonWebviewFallback();
|
40
|
+
}
|
41
|
+
}
|
42
|
+
console.warn("WebView Navigation: Open External Browser");
|
43
|
+
var urlParams = new URLSearchParams(window.location.search);
|
44
|
+
urlParams.set("gobiz_action", decodeURI("launch_browser#" + url));
|
45
|
+
window.location.search = urlParams.toString();
|
46
|
+
},
|
47
|
+
};
|
48
|
+
};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.useWindow = void 0;
|
4
|
+
var react_1 = require("react");
|
5
|
+
var useEventListener_1 = require("./useEventListener");
|
6
|
+
var debounce_1 = require("../helpers/debounce");
|
7
|
+
exports.useWindow = function () {
|
8
|
+
var _a = react_1.useState(window.innerHeight), refresh = _a[0], setRefresh = _a[1];
|
9
|
+
var _b = react_1.useState(window), windowState = _b[0], setWindowState = _b[1];
|
10
|
+
var onWindowChange = react_1.useCallback(debounce_1.debounce(function () {
|
11
|
+
setRefresh(window.innerHeight);
|
12
|
+
}, 200), [setWindowState]);
|
13
|
+
react_1.useEffect(function () {
|
14
|
+
setWindowState(window);
|
15
|
+
}, [refresh]);
|
16
|
+
useEventListener_1.useEventListener("resize", onWindowChange);
|
17
|
+
useEventListener_1.useEventListener("orientationchange", onWindowChange);
|
18
|
+
return windowState;
|
19
|
+
};
|
@@ -0,0 +1,159 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
3
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
4
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
5
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
6
|
+
r[k] = a[j];
|
7
|
+
return r;
|
8
|
+
};
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
10
|
+
exports.AuthUser = void 0;
|
11
|
+
var roles_1 = require("../constants/roles");
|
12
|
+
var AuthUser = /** @class */ (function () {
|
13
|
+
function AuthUser() {
|
14
|
+
this.json = {};
|
15
|
+
this.hermesJson = {};
|
16
|
+
this.country = "";
|
17
|
+
this.language = "";
|
18
|
+
}
|
19
|
+
Object.defineProperty(AuthUser.prototype, "id", {
|
20
|
+
get: function () {
|
21
|
+
return parseInt(this.json.id, 10);
|
22
|
+
},
|
23
|
+
enumerable: false,
|
24
|
+
configurable: true
|
25
|
+
});
|
26
|
+
Object.defineProperty(AuthUser.prototype, "merchantId", {
|
27
|
+
get: function () {
|
28
|
+
return this.hermesJson.merchant_id;
|
29
|
+
},
|
30
|
+
enumerable: false,
|
31
|
+
configurable: true
|
32
|
+
});
|
33
|
+
Object.defineProperty(AuthUser.prototype, "fullName", {
|
34
|
+
get: function () {
|
35
|
+
return this.hermesJson.full_name;
|
36
|
+
},
|
37
|
+
enumerable: false,
|
38
|
+
configurable: true
|
39
|
+
});
|
40
|
+
Object.defineProperty(AuthUser.prototype, "email", {
|
41
|
+
get: function () {
|
42
|
+
return this.hermesJson.email;
|
43
|
+
},
|
44
|
+
enumerable: false,
|
45
|
+
configurable: true
|
46
|
+
});
|
47
|
+
Object.defineProperty(AuthUser.prototype, "phone", {
|
48
|
+
get: function () {
|
49
|
+
return this.hermesJson.phone;
|
50
|
+
},
|
51
|
+
enumerable: false,
|
52
|
+
configurable: true
|
53
|
+
});
|
54
|
+
Object.defineProperty(AuthUser.prototype, "roles", {
|
55
|
+
get: function () {
|
56
|
+
try {
|
57
|
+
return JSON.parse(this.json.user_role);
|
58
|
+
}
|
59
|
+
catch (e) {
|
60
|
+
return [];
|
61
|
+
}
|
62
|
+
},
|
63
|
+
enumerable: false,
|
64
|
+
configurable: true
|
65
|
+
});
|
66
|
+
Object.defineProperty(AuthUser.prototype, "isOwner", {
|
67
|
+
get: function () {
|
68
|
+
return this.roles.includes(roles_1.ROLES.OWNER);
|
69
|
+
},
|
70
|
+
enumerable: false,
|
71
|
+
configurable: true
|
72
|
+
});
|
73
|
+
Object.defineProperty(AuthUser.prototype, "isMidtransOwner", {
|
74
|
+
get: function () {
|
75
|
+
return this.roles.includes(roles_1.ROLES.ADMIN);
|
76
|
+
},
|
77
|
+
enumerable: false,
|
78
|
+
configurable: true
|
79
|
+
});
|
80
|
+
Object.defineProperty(AuthUser.prototype, "isTemp", {
|
81
|
+
get: function () {
|
82
|
+
return this.roles.includes(roles_1.ROLES.TEMP);
|
83
|
+
},
|
84
|
+
enumerable: false,
|
85
|
+
configurable: true
|
86
|
+
});
|
87
|
+
Object.defineProperty(AuthUser.prototype, "isAdmin", {
|
88
|
+
get: function () {
|
89
|
+
return this.roles.includes(roles_1.ROLES.ADMIN) || this.roles.includes(roles_1.ROLES.OWNER);
|
90
|
+
},
|
91
|
+
enumerable: false,
|
92
|
+
configurable: true
|
93
|
+
});
|
94
|
+
Object.defineProperty(AuthUser.prototype, "permissions", {
|
95
|
+
get: function () {
|
96
|
+
return this.json.permissions;
|
97
|
+
},
|
98
|
+
enumerable: false,
|
99
|
+
configurable: true
|
100
|
+
});
|
101
|
+
Object.defineProperty(AuthUser.prototype, "isManager", {
|
102
|
+
get: function () {
|
103
|
+
return this.roles.includes(roles_1.ROLES.MANAGER);
|
104
|
+
},
|
105
|
+
enumerable: false,
|
106
|
+
configurable: true
|
107
|
+
});
|
108
|
+
Object.defineProperty(AuthUser.prototype, "isBrandUser", {
|
109
|
+
get: function () {
|
110
|
+
return this.brand !== null;
|
111
|
+
},
|
112
|
+
enumerable: false,
|
113
|
+
configurable: true
|
114
|
+
});
|
115
|
+
Object.defineProperty(AuthUser.prototype, "hasTags", {
|
116
|
+
get: function () {
|
117
|
+
return this.tagsHumanized.length !== 0;
|
118
|
+
},
|
119
|
+
enumerable: false,
|
120
|
+
configurable: true
|
121
|
+
});
|
122
|
+
Object.defineProperty(AuthUser.prototype, "tagsHumanized", {
|
123
|
+
get: function () {
|
124
|
+
return this.tagsToArrayOfStrings(this.tags);
|
125
|
+
},
|
126
|
+
enumerable: false,
|
127
|
+
configurable: true
|
128
|
+
});
|
129
|
+
AuthUser.prototype.tagsToArrayOfStrings = function (tags, stringTags) {
|
130
|
+
var _this = this;
|
131
|
+
if (stringTags === void 0) { stringTags = []; }
|
132
|
+
if (!tags) {
|
133
|
+
return [];
|
134
|
+
}
|
135
|
+
var reduced = Object.keys(tags).reduce(function (all, current) {
|
136
|
+
if (["and", "or"].includes(current)) {
|
137
|
+
var _mapped = tags[current].map(function (_current) {
|
138
|
+
return _this.tagsToArrayOfStrings(_current, all);
|
139
|
+
});
|
140
|
+
return __spreadArrays(all, _mapped);
|
141
|
+
}
|
142
|
+
return __spreadArrays(all, [tags[current]]);
|
143
|
+
}, []);
|
144
|
+
return __spreadArrays(stringTags, reduced).flat();
|
145
|
+
};
|
146
|
+
AuthUser.fromJSON = function (json, hermesJson) {
|
147
|
+
var authUser = new AuthUser();
|
148
|
+
authUser.json = json;
|
149
|
+
authUser.hermesJson = hermesJson;
|
150
|
+
authUser.country = json.country_id;
|
151
|
+
authUser.language = hermesJson.language || "en";
|
152
|
+
authUser.brand = hermesJson.brand;
|
153
|
+
authUser.tags = hermesJson.tags;
|
154
|
+
authUser.brand = hermesJson.brand;
|
155
|
+
return authUser;
|
156
|
+
};
|
157
|
+
return AuthUser;
|
158
|
+
}());
|
159
|
+
exports.AuthUser = AuthUser;
|