@open-tender/store 0.1.10 → 0.2.0

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.
@@ -6,6 +6,7 @@ export interface ConfigApp {
6
6
  export interface ConfigState {
7
7
  api: any;
8
8
  app: ConfigApp | null;
9
+ version: string | null;
9
10
  name: string | null;
10
11
  ipAddress: IpAddress | null;
11
12
  hasPinpad: boolean;
@@ -21,13 +22,17 @@ export interface ConfigState {
21
22
  export declare enum ConfigActionType {
22
23
  FetchConfig = "config/getConfig"
23
24
  }
24
- export declare const fetchConfig: import("@reduxjs/toolkit").AsyncThunk<ConfigState, string, {
25
+ export declare const fetchConfig: import("@reduxjs/toolkit").AsyncThunk<ConfigState, {
26
+ apiUrl: string;
27
+ version: string;
28
+ }, {
25
29
  state: AppState;
26
30
  rejectValue: RequestError;
27
31
  }>;
28
32
  export declare const resetConfig: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetRetries: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, incrementRetries: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
29
33
  export declare const selectConfig: (state: AppState) => ConfigState;
30
34
  export declare const selectApi: (state: AppState) => any;
35
+ export declare const selectVersion: (state: AppState) => string | null;
31
36
  export declare const selectPinpad: (state: AppState) => boolean;
32
37
  export declare const selectCashDrawer: (state: AppState) => boolean;
33
38
  export declare const selectRevenueCenterId: (state: AppState) => number | null;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.configReducer = exports.selectLoyalty = exports.selectTimezone = exports.selectSelectOptions = exports.selectStore = exports.selectRevenueCenterId = exports.selectCashDrawer = exports.selectPinpad = exports.selectApi = exports.selectConfig = exports.incrementRetries = exports.resetRetries = exports.resetConfig = exports.fetchConfig = exports.ConfigActionType = void 0;
4
+ exports.configReducer = exports.selectLoyalty = exports.selectTimezone = exports.selectSelectOptions = exports.selectStore = exports.selectRevenueCenterId = exports.selectCashDrawer = exports.selectPinpad = exports.selectVersion = exports.selectApi = exports.selectConfig = exports.incrementRetries = exports.resetRetries = exports.resetConfig = exports.fetchConfig = exports.ConfigActionType = void 0;
5
5
  var tslib_1 = require("tslib");
6
6
  var toolkit_1 = require("@reduxjs/toolkit");
7
7
  var services_1 = require("../services");
@@ -13,6 +13,7 @@ var orders_1 = require("./orders");
13
13
  var initialState = {
14
14
  api: null,
15
15
  app: null,
16
+ version: null,
16
17
  name: null,
17
18
  ipAddress: null,
18
19
  hasPinpad: false,
@@ -29,14 +30,15 @@ var ConfigActionType;
29
30
  (function (ConfigActionType) {
30
31
  ConfigActionType["FetchConfig"] = "config/getConfig";
31
32
  })(ConfigActionType = exports.ConfigActionType || (exports.ConfigActionType = {}));
32
- exports.fetchConfig = (0, toolkit_1.createAsyncThunk)(ConfigActionType.FetchConfig, function (apiUrl, _a) {
33
- var dispatch = _a.dispatch, getState = _a.getState, rejectWithValue = _a.rejectWithValue;
33
+ exports.fetchConfig = (0, toolkit_1.createAsyncThunk)(ConfigActionType.FetchConfig, function (_a, _b) {
34
+ var apiUrl = _a.apiUrl, version = _a.version;
35
+ var dispatch = _b.dispatch, getState = _b.getState, rejectWithValue = _b.rejectWithValue;
34
36
  return tslib_1.__awaiter(void 0, void 0, void 0, function () {
35
- var app, api, _b, config, store, _c, selectOptions, _d, itemTypes, _e, levelup, err, cashier, employee, tz, businessDate, err_1, revenueCenterId, name_1, ipAddress, hasPinpad, hasCashDrawer, err_2;
36
- return tslib_1.__generator(this, function (_f) {
37
- switch (_f.label) {
37
+ var app, api, _c, config, store, _d, selectOptions, _e, itemTypes, _f, levelup, err, cashier, employee, tz, businessDate, err_1, revenueCenterId, name_1, ipAddress, hasPinpad, hasCashDrawer, err_2;
38
+ return tslib_1.__generator(this, function (_g) {
39
+ switch (_g.label) {
38
40
  case 0:
39
- _f.trys.push([0, 6, , 7]);
41
+ _g.trys.push([0, 6, , 7]);
40
42
  app = { apiUrl: apiUrl };
41
43
  api = new services_1.PosAPI(app);
42
44
  return [4 /*yield*/, Promise.all([
@@ -47,33 +49,34 @@ exports.fetchConfig = (0, toolkit_1.createAsyncThunk)(ConfigActionType.FetchConf
47
49
  api.getLevelUpSettings()
48
50
  ])];
49
51
  case 1:
50
- _b = _f.sent(), config = _b[0], store = _b[1], _c = _b[2], selectOptions = _c === void 0 ? null : _c, _d = _b[3], itemTypes = _d === void 0 ? null : _d, _e = _b[4], levelup = _e === void 0 ? null : _e;
52
+ _c = _g.sent(), config = _c[0], store = _c[1], _d = _c[2], selectOptions = _d === void 0 ? null : _d, _e = _c[3], itemTypes = _e === void 0 ? null : _e, _f = _c[4], levelup = _f === void 0 ? null : _f;
51
53
  if (!config || !store) {
52
54
  err = errors_1.errorsApi.internalServerError;
53
55
  return [2 /*return*/, rejectWithValue(err)];
54
56
  }
55
57
  cashier = getState().pos.cashier;
56
58
  if (!!cashier) return [3 /*break*/, 5];
57
- _f.label = 2;
59
+ _g.label = 2;
58
60
  case 2:
59
- _f.trys.push([2, 4, , 5]);
61
+ _g.trys.push([2, 4, , 5]);
60
62
  return [4 /*yield*/, api.getCashier()];
61
63
  case 3:
62
- employee = _f.sent();
64
+ employee = _g.sent();
63
65
  tz = utils_1.timezoneMap[store.timezone];
64
66
  businessDate = (0, utils_1.currentLocalDateStr)(tz);
65
67
  dispatch((0, pos_1.setCashier)(tslib_1.__assign(tslib_1.__assign({}, employee), { businessDate: businessDate })));
66
68
  return [3 /*break*/, 5];
67
69
  case 4:
68
- err_1 = _f.sent();
70
+ err_1 = _g.sent();
69
71
  return [3 /*break*/, 5];
70
72
  case 5:
71
73
  dispatch((0, orders_1.setOrdersItemTypes)(itemTypes));
72
74
  revenueCenterId = store.revenue_center_id;
73
75
  name_1 = config.name, ipAddress = config.ip_address, hasPinpad = config.has_pinpad, hasCashDrawer = config.has_cashdrawer;
74
76
  return [2 /*return*/, {
75
- app: app,
76
77
  api: api,
78
+ app: app,
79
+ version: version || null,
77
80
  store: store,
78
81
  revenueCenterId: revenueCenterId,
79
82
  name: name_1,
@@ -87,7 +90,7 @@ exports.fetchConfig = (0, toolkit_1.createAsyncThunk)(ConfigActionType.FetchConf
87
90
  retries: 0
88
91
  }];
89
92
  case 6:
90
- err_2 = _f.sent();
93
+ err_2 = _g.sent();
91
94
  return [2 /*return*/, rejectWithValue(err_2)];
92
95
  case 7: return [2 /*return*/];
93
96
  }
@@ -109,9 +112,10 @@ var configSlice = (0, toolkit_1.createSlice)({
109
112
  extraReducers: function (builder) {
110
113
  builder
111
114
  .addCase(exports.fetchConfig.fulfilled, function (state, action) {
112
- var _a = action.payload, app = _a.app, api = _a.api, store = _a.store, revenueCenterId = _a.revenueCenterId, name = _a.name, ipAddress = _a.ipAddress, hasPinpad = _a.hasPinpad, hasCashDrawer = _a.hasCashDrawer, selectOptions = _a.selectOptions, levelup = _a.levelup;
113
- state.app = app;
115
+ var _a = action.payload, api = _a.api, app = _a.app, version = _a.version, store = _a.store, revenueCenterId = _a.revenueCenterId, name = _a.name, ipAddress = _a.ipAddress, hasPinpad = _a.hasPinpad, hasCashDrawer = _a.hasCashDrawer, selectOptions = _a.selectOptions, levelup = _a.levelup;
114
116
  state.api = api;
117
+ state.app = app;
118
+ state.version = version;
115
119
  state.name = name;
116
120
  state.ipAddress = ipAddress;
117
121
  state.hasPinpad = hasPinpad;
@@ -138,6 +142,8 @@ var selectConfig = function (state) { return state.config; };
138
142
  exports.selectConfig = selectConfig;
139
143
  var selectApi = function (state) { return state.config.api; };
140
144
  exports.selectApi = selectApi;
145
+ var selectVersion = function (state) { return state.config.version; };
146
+ exports.selectVersion = selectVersion;
141
147
  var selectPinpad = function (state) { return state.config.hasPinpad; };
142
148
  exports.selectPinpad = selectPinpad;
143
149
  var selectCashDrawer = function (state) { return state.config.hasCashDrawer; };
@@ -6,6 +6,7 @@ export interface ConfigApp {
6
6
  export interface ConfigState {
7
7
  api: any;
8
8
  app: ConfigApp | null;
9
+ version: string | null;
9
10
  name: string | null;
10
11
  ipAddress: IpAddress | null;
11
12
  hasPinpad: boolean;
@@ -21,13 +22,17 @@ export interface ConfigState {
21
22
  export declare enum ConfigActionType {
22
23
  FetchConfig = "config/getConfig"
23
24
  }
24
- export declare const fetchConfig: import("@reduxjs/toolkit").AsyncThunk<ConfigState, string, {
25
+ export declare const fetchConfig: import("@reduxjs/toolkit").AsyncThunk<ConfigState, {
26
+ apiUrl: string;
27
+ version: string;
28
+ }, {
25
29
  state: AppState;
26
30
  rejectValue: RequestError;
27
31
  }>;
28
32
  export declare const resetConfig: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetRetries: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, incrementRetries: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
29
33
  export declare const selectConfig: (state: AppState) => ConfigState;
30
34
  export declare const selectApi: (state: AppState) => any;
35
+ export declare const selectVersion: (state: AppState) => string | null;
31
36
  export declare const selectPinpad: (state: AppState) => boolean;
32
37
  export declare const selectCashDrawer: (state: AppState) => boolean;
33
38
  export declare const selectRevenueCenterId: (state: AppState) => number | null;
@@ -10,6 +10,7 @@ import { setOrdersItemTypes } from './orders';
10
10
  var initialState = {
11
11
  api: null,
12
12
  app: null,
13
+ version: null,
13
14
  name: null,
14
15
  ipAddress: null,
15
16
  hasPinpad: false,
@@ -26,14 +27,15 @@ export var ConfigActionType;
26
27
  (function (ConfigActionType) {
27
28
  ConfigActionType["FetchConfig"] = "config/getConfig";
28
29
  })(ConfigActionType || (ConfigActionType = {}));
29
- export var fetchConfig = createAsyncThunk(ConfigActionType.FetchConfig, function (apiUrl, _a) {
30
- var dispatch = _a.dispatch, getState = _a.getState, rejectWithValue = _a.rejectWithValue;
30
+ export var fetchConfig = createAsyncThunk(ConfigActionType.FetchConfig, function (_a, _b) {
31
+ var apiUrl = _a.apiUrl, version = _a.version;
32
+ var dispatch = _b.dispatch, getState = _b.getState, rejectWithValue = _b.rejectWithValue;
31
33
  return __awaiter(void 0, void 0, void 0, function () {
32
- var app, api, _b, config, store, _c, selectOptions, _d, itemTypes, _e, levelup, err, cashier, employee, tz, businessDate, err_1, revenueCenterId, name_1, ipAddress, hasPinpad, hasCashDrawer, err_2;
33
- return __generator(this, function (_f) {
34
- switch (_f.label) {
34
+ var app, api, _c, config, store, _d, selectOptions, _e, itemTypes, _f, levelup, err, cashier, employee, tz, businessDate, err_1, revenueCenterId, name_1, ipAddress, hasPinpad, hasCashDrawer, err_2;
35
+ return __generator(this, function (_g) {
36
+ switch (_g.label) {
35
37
  case 0:
36
- _f.trys.push([0, 6, , 7]);
38
+ _g.trys.push([0, 6, , 7]);
37
39
  app = { apiUrl: apiUrl };
38
40
  api = new PosAPI(app);
39
41
  return [4 /*yield*/, Promise.all([
@@ -44,33 +46,34 @@ export var fetchConfig = createAsyncThunk(ConfigActionType.FetchConfig, function
44
46
  api.getLevelUpSettings()
45
47
  ])];
46
48
  case 1:
47
- _b = _f.sent(), config = _b[0], store = _b[1], _c = _b[2], selectOptions = _c === void 0 ? null : _c, _d = _b[3], itemTypes = _d === void 0 ? null : _d, _e = _b[4], levelup = _e === void 0 ? null : _e;
49
+ _c = _g.sent(), config = _c[0], store = _c[1], _d = _c[2], selectOptions = _d === void 0 ? null : _d, _e = _c[3], itemTypes = _e === void 0 ? null : _e, _f = _c[4], levelup = _f === void 0 ? null : _f;
48
50
  if (!config || !store) {
49
51
  err = errorsApi.internalServerError;
50
52
  return [2 /*return*/, rejectWithValue(err)];
51
53
  }
52
54
  cashier = getState().pos.cashier;
53
55
  if (!!cashier) return [3 /*break*/, 5];
54
- _f.label = 2;
56
+ _g.label = 2;
55
57
  case 2:
56
- _f.trys.push([2, 4, , 5]);
58
+ _g.trys.push([2, 4, , 5]);
57
59
  return [4 /*yield*/, api.getCashier()];
58
60
  case 3:
59
- employee = _f.sent();
61
+ employee = _g.sent();
60
62
  tz = timezoneMap[store.timezone];
61
63
  businessDate = currentLocalDateStr(tz);
62
64
  dispatch(setCashier(__assign(__assign({}, employee), { businessDate: businessDate })));
63
65
  return [3 /*break*/, 5];
64
66
  case 4:
65
- err_1 = _f.sent();
67
+ err_1 = _g.sent();
66
68
  return [3 /*break*/, 5];
67
69
  case 5:
68
70
  dispatch(setOrdersItemTypes(itemTypes));
69
71
  revenueCenterId = store.revenue_center_id;
70
72
  name_1 = config.name, ipAddress = config.ip_address, hasPinpad = config.has_pinpad, hasCashDrawer = config.has_cashdrawer;
71
73
  return [2 /*return*/, {
72
- app: app,
73
74
  api: api,
75
+ app: app,
76
+ version: version || null,
74
77
  store: store,
75
78
  revenueCenterId: revenueCenterId,
76
79
  name: name_1,
@@ -84,7 +87,7 @@ export var fetchConfig = createAsyncThunk(ConfigActionType.FetchConfig, function
84
87
  retries: 0
85
88
  }];
86
89
  case 6:
87
- err_2 = _f.sent();
90
+ err_2 = _g.sent();
88
91
  return [2 /*return*/, rejectWithValue(err_2)];
89
92
  case 7: return [2 /*return*/];
90
93
  }
@@ -106,9 +109,10 @@ var configSlice = createSlice({
106
109
  extraReducers: function (builder) {
107
110
  builder
108
111
  .addCase(fetchConfig.fulfilled, function (state, action) {
109
- var _a = action.payload, app = _a.app, api = _a.api, store = _a.store, revenueCenterId = _a.revenueCenterId, name = _a.name, ipAddress = _a.ipAddress, hasPinpad = _a.hasPinpad, hasCashDrawer = _a.hasCashDrawer, selectOptions = _a.selectOptions, levelup = _a.levelup;
110
- state.app = app;
112
+ var _a = action.payload, api = _a.api, app = _a.app, version = _a.version, store = _a.store, revenueCenterId = _a.revenueCenterId, name = _a.name, ipAddress = _a.ipAddress, hasPinpad = _a.hasPinpad, hasCashDrawer = _a.hasCashDrawer, selectOptions = _a.selectOptions, levelup = _a.levelup;
111
113
  state.api = api;
114
+ state.app = app;
115
+ state.version = version;
112
116
  state.name = name;
113
117
  state.ipAddress = ipAddress;
114
118
  state.hasPinpad = hasPinpad;
@@ -133,6 +137,7 @@ var configSlice = createSlice({
133
137
  export var resetConfig = (_a = configSlice.actions, _a.resetConfig), resetRetries = _a.resetRetries, incrementRetries = _a.incrementRetries;
134
138
  export var selectConfig = function (state) { return state.config; };
135
139
  export var selectApi = function (state) { return state.config.api; };
140
+ export var selectVersion = function (state) { return state.config.version; };
136
141
  export var selectPinpad = function (state) { return state.config.hasPinpad; };
137
142
  export var selectCashDrawer = function (state) { return state.config.hasCashDrawer; };
138
143
  export var selectRevenueCenterId = function (state) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/store",
3
- "version": "0.1.10",
3
+ "version": "0.2.0",
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",