@open-tender/store 0.7.18 → 0.8.2
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/dist/cjs/slices/kiosk.d.ts +2 -7
- package/dist/cjs/slices/kiosk.js +20 -47
- package/dist/esm/slices/kiosk.d.ts +2 -7
- package/dist/esm/slices/kiosk.js +20 -44
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KioskBrand, KioskContent,
|
|
1
|
+
import { KioskBrand, KioskContent, RequestError, RequestStatus, Store, Devices } from '../types';
|
|
2
2
|
import { AppState } from '../app';
|
|
3
3
|
export interface KioskApp {
|
|
4
4
|
apiUrl: string;
|
|
@@ -6,13 +6,11 @@ export interface KioskApp {
|
|
|
6
6
|
export interface KioskState {
|
|
7
7
|
app: KioskApp | null;
|
|
8
8
|
version?: string | null;
|
|
9
|
+
devices: Devices | null;
|
|
9
10
|
store: Store | null;
|
|
10
|
-
revenueCenterId: number | null;
|
|
11
11
|
brand: KioskBrand | null;
|
|
12
12
|
content: KioskContent | null;
|
|
13
|
-
theme: ThemeCloud | null;
|
|
14
13
|
ratio: number;
|
|
15
|
-
displaySettings: any;
|
|
16
14
|
loading: RequestStatus;
|
|
17
15
|
error: RequestError | null;
|
|
18
16
|
retries: number;
|
|
@@ -36,11 +34,8 @@ export declare const resetKiosk: import("@reduxjs/toolkit").ActionCreatorWithout
|
|
|
36
34
|
export declare const selectKiosk: (state: AppState) => KioskState;
|
|
37
35
|
export declare const selectKioskVersion: (state: AppState) => string | null | undefined;
|
|
38
36
|
export declare const selectKioskStore: (state: AppState) => Store | null;
|
|
39
|
-
export declare const selectKioskRcId: (state: AppState) => number | null;
|
|
40
37
|
export declare const selectKioskBrand: (state: AppState) => KioskBrand | null;
|
|
41
38
|
export declare const selectKioskContent: (state: AppState) => KioskContent | null;
|
|
42
|
-
export declare const selectKioskTheme: (state: AppState) => ThemeCloud | null;
|
|
43
39
|
export declare const selectKioskRatio: (state: AppState) => number;
|
|
44
|
-
export declare const selectKioskDisplay: (state: AppState) => any;
|
|
45
40
|
export declare const selectKioskContentSection: (page: string) => (state: AppState) => unknown;
|
|
46
41
|
export declare const kioskReducer: import("redux").Reducer<KioskState>;
|
package/dist/cjs/slices/kiosk.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.kioskReducer = exports.selectKioskContentSection = exports.
|
|
4
|
+
exports.kioskReducer = exports.selectKioskContentSection = exports.selectKioskRatio = exports.selectKioskContent = exports.selectKioskBrand = exports.selectKioskStore = exports.selectKioskVersion = exports.selectKiosk = exports.setKioskRatio = exports.setKioskVersion = exports.incrementKioskRetries = exports.resetKioskRetries = exports.resetKiosk = exports.fetchKioskConfig = exports.KioskActionType = void 0;
|
|
5
5
|
var tslib_1 = require("tslib");
|
|
6
6
|
var toolkit_1 = require("@reduxjs/toolkit");
|
|
7
7
|
var services_1 = require("../services");
|
|
8
8
|
var types_1 = require("./types");
|
|
9
9
|
var errors_1 = require("../services/errors");
|
|
10
10
|
var config_1 = require("./config");
|
|
11
|
-
var utils_1 = require("../utils");
|
|
12
11
|
var initialState = {
|
|
13
12
|
app: null,
|
|
14
13
|
version: null,
|
|
14
|
+
devices: null,
|
|
15
15
|
store: null,
|
|
16
|
-
revenueCenterId: null,
|
|
17
16
|
brand: null,
|
|
18
17
|
content: null,
|
|
19
|
-
|
|
20
|
-
ratio: 2,
|
|
21
|
-
displaySettings: null,
|
|
18
|
+
ratio: 1,
|
|
22
19
|
loading: 'idle',
|
|
23
20
|
error: null,
|
|
24
21
|
retries: 0
|
|
@@ -27,57 +24,43 @@ var KioskActionType;
|
|
|
27
24
|
(function (KioskActionType) {
|
|
28
25
|
KioskActionType["FetchKiosk"] = "kiosk/getKiosk";
|
|
29
26
|
})(KioskActionType || (exports.KioskActionType = KioskActionType = {}));
|
|
30
|
-
var enhanceTheme = function (theme) {
|
|
31
|
-
var icons = tslib_1.__assign(tslib_1.__assign({}, theme.icons), { strokeLinejoin: 'miter', strokeLinecap: 'square' });
|
|
32
|
-
var kiosk = {
|
|
33
|
-
padding: '2rem',
|
|
34
|
-
gutter: '1rem',
|
|
35
|
-
gutterSmall: '0.5rem'
|
|
36
|
-
};
|
|
37
|
-
return tslib_1.__assign(tslib_1.__assign({}, theme), { icons: icons, kiosk: kiosk });
|
|
38
|
-
};
|
|
39
27
|
exports.fetchKioskConfig = (0, toolkit_1.createAsyncThunk)(KioskActionType.FetchKiosk, function (_a, _b) {
|
|
40
28
|
var apiUrl = _a.apiUrl;
|
|
41
29
|
var dispatch = _b.dispatch, rejectWithValue = _b.rejectWithValue;
|
|
42
30
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
43
|
-
var app, api, _c,
|
|
44
|
-
return tslib_1.__generator(this, function (
|
|
45
|
-
switch (
|
|
31
|
+
var app, api, _c, _d, devicesList, _e, stores, store, devices, err, err_1;
|
|
32
|
+
return tslib_1.__generator(this, function (_f) {
|
|
33
|
+
switch (_f.label) {
|
|
46
34
|
case 0:
|
|
47
|
-
|
|
35
|
+
_f.trys.push([0, 2, , 3]);
|
|
48
36
|
app = { apiUrl: apiUrl };
|
|
49
37
|
api = new services_1.PosAPI(app);
|
|
50
38
|
return [4 /*yield*/, Promise.all([
|
|
51
|
-
api.
|
|
52
|
-
api.
|
|
39
|
+
api.getSettings('DEVICES'),
|
|
40
|
+
api.getSettings('STORE')
|
|
53
41
|
])];
|
|
54
42
|
case 1:
|
|
55
|
-
_c =
|
|
56
|
-
|
|
43
|
+
_c = _f.sent(), _d = _c[0], devicesList = _d === void 0 ? [] : _d, _e = _c[1], stores = _e === void 0 ? [] : _e;
|
|
44
|
+
store = stores[0] || null;
|
|
45
|
+
devices = devicesList[0] || null;
|
|
46
|
+
if (!store || !devices) {
|
|
57
47
|
err = errors_1.errorsApi.internalServerError;
|
|
58
48
|
return [2 /*return*/, rejectWithValue(err)];
|
|
59
49
|
}
|
|
60
50
|
dispatch((0, config_1.setApi)(api));
|
|
61
|
-
brand = kioskConfig.brand, content = kioskConfig.content, theme = kioskConfig.theme, settings = kioskConfig.settings;
|
|
62
|
-
ratio = settings.ratio, displaySettings = settings.displaySettings;
|
|
63
|
-
revenueCenterId = store.revenue_center_id;
|
|
64
|
-
themeEnhanced = enhanceTheme(theme);
|
|
65
|
-
themeDevice = (0, utils_1.decorateTheme)(themeEnhanced, ratio);
|
|
66
51
|
return [2 /*return*/, {
|
|
67
52
|
app: app,
|
|
53
|
+
devices: devices,
|
|
68
54
|
store: store,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
theme: themeDevice,
|
|
73
|
-
ratio: ratio,
|
|
74
|
-
displaySettings: displaySettings,
|
|
55
|
+
brand: null,
|
|
56
|
+
content: null,
|
|
57
|
+
ratio: 1,
|
|
75
58
|
error: null,
|
|
76
59
|
loading: 'idle',
|
|
77
60
|
retries: 0
|
|
78
61
|
}];
|
|
79
62
|
case 2:
|
|
80
|
-
err_1 =
|
|
63
|
+
err_1 = _f.sent();
|
|
81
64
|
return [2 /*return*/, rejectWithValue(err_1)];
|
|
82
65
|
case 3: return [2 /*return*/];
|
|
83
66
|
}
|
|
@@ -105,15 +88,13 @@ var kioskSlice = (0, toolkit_1.createSlice)({
|
|
|
105
88
|
extraReducers: function (builder) {
|
|
106
89
|
builder
|
|
107
90
|
.addCase(exports.fetchKioskConfig.fulfilled, function (state, action) {
|
|
108
|
-
var _a = action.payload, app = _a.app,
|
|
91
|
+
var _a = action.payload, app = _a.app, devices = _a.devices, store = _a.store, brand = _a.brand, content = _a.content, ratio = _a.ratio;
|
|
109
92
|
state.app = app;
|
|
93
|
+
state.devices = devices;
|
|
110
94
|
state.store = store;
|
|
111
|
-
state.revenueCenterId = revenueCenterId;
|
|
112
95
|
state.brand = brand;
|
|
113
96
|
state.content = content;
|
|
114
|
-
state.theme = theme;
|
|
115
97
|
state.ratio = ratio;
|
|
116
|
-
state.displaySettings = displaySettings;
|
|
117
98
|
state.loading = 'idle';
|
|
118
99
|
state.retries = 0;
|
|
119
100
|
state.error = null;
|
|
@@ -134,20 +115,12 @@ var selectKioskVersion = function (state) { return state.kiosk.version; };
|
|
|
134
115
|
exports.selectKioskVersion = selectKioskVersion;
|
|
135
116
|
var selectKioskStore = function (state) { return state.kiosk.store; };
|
|
136
117
|
exports.selectKioskStore = selectKioskStore;
|
|
137
|
-
var selectKioskRcId = function (state) { return state.kiosk.revenueCenterId; };
|
|
138
|
-
exports.selectKioskRcId = selectKioskRcId;
|
|
139
118
|
var selectKioskBrand = function (state) { return state.kiosk.brand; };
|
|
140
119
|
exports.selectKioskBrand = selectKioskBrand;
|
|
141
120
|
var selectKioskContent = function (state) { return state.kiosk.content; };
|
|
142
121
|
exports.selectKioskContent = selectKioskContent;
|
|
143
|
-
var selectKioskTheme = function (state) { return state.kiosk.theme; };
|
|
144
|
-
exports.selectKioskTheme = selectKioskTheme;
|
|
145
122
|
var selectKioskRatio = function (state) { return state.kiosk.ratio; };
|
|
146
123
|
exports.selectKioskRatio = selectKioskRatio;
|
|
147
|
-
var selectKioskDisplay = function (state) {
|
|
148
|
-
return state.kiosk.displaySettings;
|
|
149
|
-
};
|
|
150
|
-
exports.selectKioskDisplay = selectKioskDisplay;
|
|
151
124
|
var selectKioskContentSection = function (page) { return function (state) {
|
|
152
125
|
var _a;
|
|
153
126
|
return (_a = state.kiosk.content) === null || _a === void 0 ? void 0 : _a[page];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KioskBrand, KioskContent,
|
|
1
|
+
import { KioskBrand, KioskContent, RequestError, RequestStatus, Store, Devices } from '../types';
|
|
2
2
|
import { AppState } from '../app';
|
|
3
3
|
export interface KioskApp {
|
|
4
4
|
apiUrl: string;
|
|
@@ -6,13 +6,11 @@ export interface KioskApp {
|
|
|
6
6
|
export interface KioskState {
|
|
7
7
|
app: KioskApp | null;
|
|
8
8
|
version?: string | null;
|
|
9
|
+
devices: Devices | null;
|
|
9
10
|
store: Store | null;
|
|
10
|
-
revenueCenterId: number | null;
|
|
11
11
|
brand: KioskBrand | null;
|
|
12
12
|
content: KioskContent | null;
|
|
13
|
-
theme: ThemeCloud | null;
|
|
14
13
|
ratio: number;
|
|
15
|
-
displaySettings: any;
|
|
16
14
|
loading: RequestStatus;
|
|
17
15
|
error: RequestError | null;
|
|
18
16
|
retries: number;
|
|
@@ -36,11 +34,8 @@ export declare const resetKiosk: import("@reduxjs/toolkit").ActionCreatorWithout
|
|
|
36
34
|
export declare const selectKiosk: (state: AppState) => KioskState;
|
|
37
35
|
export declare const selectKioskVersion: (state: AppState) => string | null | undefined;
|
|
38
36
|
export declare const selectKioskStore: (state: AppState) => Store | null;
|
|
39
|
-
export declare const selectKioskRcId: (state: AppState) => number | null;
|
|
40
37
|
export declare const selectKioskBrand: (state: AppState) => KioskBrand | null;
|
|
41
38
|
export declare const selectKioskContent: (state: AppState) => KioskContent | null;
|
|
42
|
-
export declare const selectKioskTheme: (state: AppState) => ThemeCloud | null;
|
|
43
39
|
export declare const selectKioskRatio: (state: AppState) => number;
|
|
44
|
-
export declare const selectKioskDisplay: (state: AppState) => any;
|
|
45
40
|
export declare const selectKioskContentSection: (page: string) => (state: AppState) => unknown;
|
|
46
41
|
export declare const kioskReducer: import("redux").Reducer<KioskState>;
|
package/dist/esm/slices/kiosk.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
var _a;
|
|
2
|
-
import {
|
|
2
|
+
import { __awaiter, __generator } from "tslib";
|
|
3
3
|
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
|
|
4
4
|
import { PosAPI } from '../services';
|
|
5
5
|
import { ReducerType } from './types';
|
|
6
6
|
import { errorsApi } from '../services/errors';
|
|
7
7
|
import { setApi } from './config';
|
|
8
|
-
import { decorateTheme } from '../utils';
|
|
9
8
|
var initialState = {
|
|
10
9
|
app: null,
|
|
11
10
|
version: null,
|
|
11
|
+
devices: null,
|
|
12
12
|
store: null,
|
|
13
|
-
revenueCenterId: null,
|
|
14
13
|
brand: null,
|
|
15
14
|
content: null,
|
|
16
|
-
|
|
17
|
-
ratio: 2,
|
|
18
|
-
displaySettings: null,
|
|
15
|
+
ratio: 1,
|
|
19
16
|
loading: 'idle',
|
|
20
17
|
error: null,
|
|
21
18
|
retries: 0
|
|
@@ -24,57 +21,43 @@ export var KioskActionType;
|
|
|
24
21
|
(function (KioskActionType) {
|
|
25
22
|
KioskActionType["FetchKiosk"] = "kiosk/getKiosk";
|
|
26
23
|
})(KioskActionType || (KioskActionType = {}));
|
|
27
|
-
var enhanceTheme = function (theme) {
|
|
28
|
-
var icons = __assign(__assign({}, theme.icons), { strokeLinejoin: 'miter', strokeLinecap: 'square' });
|
|
29
|
-
var kiosk = {
|
|
30
|
-
padding: '2rem',
|
|
31
|
-
gutter: '1rem',
|
|
32
|
-
gutterSmall: '0.5rem'
|
|
33
|
-
};
|
|
34
|
-
return __assign(__assign({}, theme), { icons: icons, kiosk: kiosk });
|
|
35
|
-
};
|
|
36
24
|
export var fetchKioskConfig = createAsyncThunk(KioskActionType.FetchKiosk, function (_a, _b) {
|
|
37
25
|
var apiUrl = _a.apiUrl;
|
|
38
26
|
var dispatch = _b.dispatch, rejectWithValue = _b.rejectWithValue;
|
|
39
27
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
40
|
-
var app, api, _c,
|
|
41
|
-
return __generator(this, function (
|
|
42
|
-
switch (
|
|
28
|
+
var app, api, _c, _d, devicesList, _e, stores, store, devices, err, err_1;
|
|
29
|
+
return __generator(this, function (_f) {
|
|
30
|
+
switch (_f.label) {
|
|
43
31
|
case 0:
|
|
44
|
-
|
|
32
|
+
_f.trys.push([0, 2, , 3]);
|
|
45
33
|
app = { apiUrl: apiUrl };
|
|
46
34
|
api = new PosAPI(app);
|
|
47
35
|
return [4 /*yield*/, Promise.all([
|
|
48
|
-
api.
|
|
49
|
-
api.
|
|
36
|
+
api.getSettings('DEVICES'),
|
|
37
|
+
api.getSettings('STORE')
|
|
50
38
|
])];
|
|
51
39
|
case 1:
|
|
52
|
-
_c =
|
|
53
|
-
|
|
40
|
+
_c = _f.sent(), _d = _c[0], devicesList = _d === void 0 ? [] : _d, _e = _c[1], stores = _e === void 0 ? [] : _e;
|
|
41
|
+
store = stores[0] || null;
|
|
42
|
+
devices = devicesList[0] || null;
|
|
43
|
+
if (!store || !devices) {
|
|
54
44
|
err = errorsApi.internalServerError;
|
|
55
45
|
return [2 /*return*/, rejectWithValue(err)];
|
|
56
46
|
}
|
|
57
47
|
dispatch(setApi(api));
|
|
58
|
-
brand = kioskConfig.brand, content = kioskConfig.content, theme = kioskConfig.theme, settings = kioskConfig.settings;
|
|
59
|
-
ratio = settings.ratio, displaySettings = settings.displaySettings;
|
|
60
|
-
revenueCenterId = store.revenue_center_id;
|
|
61
|
-
themeEnhanced = enhanceTheme(theme);
|
|
62
|
-
themeDevice = decorateTheme(themeEnhanced, ratio);
|
|
63
48
|
return [2 /*return*/, {
|
|
64
49
|
app: app,
|
|
50
|
+
devices: devices,
|
|
65
51
|
store: store,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
theme: themeDevice,
|
|
70
|
-
ratio: ratio,
|
|
71
|
-
displaySettings: displaySettings,
|
|
52
|
+
brand: null,
|
|
53
|
+
content: null,
|
|
54
|
+
ratio: 1,
|
|
72
55
|
error: null,
|
|
73
56
|
loading: 'idle',
|
|
74
57
|
retries: 0
|
|
75
58
|
}];
|
|
76
59
|
case 2:
|
|
77
|
-
err_1 =
|
|
60
|
+
err_1 = _f.sent();
|
|
78
61
|
return [2 /*return*/, rejectWithValue(err_1)];
|
|
79
62
|
case 3: return [2 /*return*/];
|
|
80
63
|
}
|
|
@@ -102,15 +85,13 @@ var kioskSlice = createSlice({
|
|
|
102
85
|
extraReducers: function (builder) {
|
|
103
86
|
builder
|
|
104
87
|
.addCase(fetchKioskConfig.fulfilled, function (state, action) {
|
|
105
|
-
var _a = action.payload, app = _a.app,
|
|
88
|
+
var _a = action.payload, app = _a.app, devices = _a.devices, store = _a.store, brand = _a.brand, content = _a.content, ratio = _a.ratio;
|
|
106
89
|
state.app = app;
|
|
90
|
+
state.devices = devices;
|
|
107
91
|
state.store = store;
|
|
108
|
-
state.revenueCenterId = revenueCenterId;
|
|
109
92
|
state.brand = brand;
|
|
110
93
|
state.content = content;
|
|
111
|
-
state.theme = theme;
|
|
112
94
|
state.ratio = ratio;
|
|
113
|
-
state.displaySettings = displaySettings;
|
|
114
95
|
state.loading = 'idle';
|
|
115
96
|
state.retries = 0;
|
|
116
97
|
state.error = null;
|
|
@@ -128,14 +109,9 @@ export var resetKiosk = (_a = kioskSlice.actions, _a.resetKiosk), resetKioskRetr
|
|
|
128
109
|
export var selectKiosk = function (state) { return state.kiosk; };
|
|
129
110
|
export var selectKioskVersion = function (state) { return state.kiosk.version; };
|
|
130
111
|
export var selectKioskStore = function (state) { return state.kiosk.store; };
|
|
131
|
-
export var selectKioskRcId = function (state) { return state.kiosk.revenueCenterId; };
|
|
132
112
|
export var selectKioskBrand = function (state) { return state.kiosk.brand; };
|
|
133
113
|
export var selectKioskContent = function (state) { return state.kiosk.content; };
|
|
134
|
-
export var selectKioskTheme = function (state) { return state.kiosk.theme; };
|
|
135
114
|
export var selectKioskRatio = function (state) { return state.kiosk.ratio; };
|
|
136
|
-
export var selectKioskDisplay = function (state) {
|
|
137
|
-
return state.kiosk.displaySettings;
|
|
138
|
-
};
|
|
139
115
|
export var selectKioskContentSection = function (page) { return function (state) {
|
|
140
116
|
var _a;
|
|
141
117
|
return (_a = state.kiosk.content) === null || _a === void 0 ? void 0 : _a[page];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/store",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our in-store POS API",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|