@open-tender/store 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { IpAddress, LevelUp, MenuColors, RequestError, RequestStatus, SelectOptions, Store, Timezone } from '../types';
1
+ import { IpAddress, MenuColors, RequestError, RequestStatus, SelectOptions, Store, Timezone } from '../types';
2
2
  import { AppState } from '../app';
3
3
  export interface ConfigApp {
4
4
  apiUrl: string;
@@ -15,7 +15,6 @@ export interface ConfigState {
15
15
  revenueCenterId: number | null;
16
16
  selectOptions: SelectOptions | null;
17
17
  menuColors: MenuColors | null;
18
- levelup: LevelUp | null;
19
18
  loading: RequestStatus;
20
19
  error: RequestError | null;
21
20
  retries: number;
@@ -22,7 +22,6 @@ var initialState = {
22
22
  revenueCenterId: null,
23
23
  selectOptions: null,
24
24
  menuColors: null,
25
- levelup: null,
26
25
  loading: 'idle',
27
26
  error: null,
28
27
  retries: 0
@@ -35,47 +34,56 @@ exports.fetchConfig = (0, toolkit_1.createAsyncThunk)(ConfigActionType.FetchConf
35
34
  var apiUrl = _a.apiUrl;
36
35
  var dispatch = _b.dispatch, getState = _b.getState, rejectWithValue = _b.rejectWithValue;
37
36
  return tslib_1.__awaiter(void 0, void 0, void 0, function () {
38
- var app, api, _c, config, store, _d, selectOptions, _e, menuColors, _f, itemTypes, _g, levelup, err, cashier, employee, tz, businessDate, err_1, revenueCenterId, name_1, ipAddress, hasPinpad, hasCashDrawer, prep_stations, err_2;
39
- return tslib_1.__generator(this, function (_h) {
40
- switch (_h.label) {
37
+ var app, api, _c,
38
+ // config,
39
+ store, _d,
40
+ // selectOptions = null,
41
+ // menuColors = null,
42
+ itemTypes, err, cashier, employee, tz, businessDate, err_1, revenueCenterId, name_1, ipAddress, hasPinpad, hasCashDrawer, selectOptions, menuColors, err_2;
43
+ return tslib_1.__generator(this, function (_e) {
44
+ switch (_e.label) {
41
45
  case 0:
42
- _h.trys.push([0, 6, , 7]);
46
+ _e.trys.push([0, 6, , 7]);
43
47
  app = { apiUrl: apiUrl };
44
48
  api = new services_1.PosAPI(app);
45
49
  return [4 /*yield*/, Promise.all([
46
- api.getConfig(),
50
+ // api.getConfig(),
47
51
  api.getStore(),
48
- api.getSelectOptions(),
49
- api.getMenuColors(),
50
- api.getItemTypes(),
51
- api.getLevelUpSettings()
52
+ // api.getSelectOptions(),
53
+ // api.getMenuColors(),
54
+ api.getItemTypes()
52
55
  ])];
53
56
  case 1:
54
- _c = _h.sent(), config = _c[0], store = _c[1], _d = _c[2], selectOptions = _d === void 0 ? null : _d, _e = _c[3], menuColors = _e === void 0 ? null : _e, _f = _c[4], itemTypes = _f === void 0 ? null : _f, _g = _c[5], levelup = _g === void 0 ? null : _g;
55
- if (!config || !store) {
57
+ _c = _e.sent(), store = _c[0], _d = _c[1], itemTypes = _d === void 0 ? null : _d;
58
+ if (!store) {
56
59
  err = errors_1.errorsApi.internalServerError;
57
60
  return [2 /*return*/, rejectWithValue(err)];
58
61
  }
59
62
  cashier = getState().pos.cashier;
60
63
  if (!!cashier) return [3 /*break*/, 5];
61
- _h.label = 2;
64
+ _e.label = 2;
62
65
  case 2:
63
- _h.trys.push([2, 4, , 5]);
66
+ _e.trys.push([2, 4, , 5]);
64
67
  return [4 /*yield*/, api.getCashier()];
65
68
  case 3:
66
- employee = _h.sent();
69
+ employee = _e.sent();
67
70
  tz = utils_1.timezoneMap[store.timezone];
68
71
  businessDate = (0, utils_1.currentLocalDateStr)(tz);
69
72
  dispatch((0, pos_1.setCashier)(tslib_1.__assign(tslib_1.__assign({}, employee), { businessDate: businessDate })));
70
73
  return [3 /*break*/, 5];
71
74
  case 4:
72
- err_1 = _h.sent();
75
+ err_1 = _e.sent();
73
76
  return [3 /*break*/, 5];
74
77
  case 5:
75
78
  revenueCenterId = store.revenue_center_id;
76
- name_1 = config.name, ipAddress = config.ip_address, hasPinpad = config.has_pinpad, hasCashDrawer = config.has_cashdrawer, prep_stations = config.prep_stations;
79
+ name_1 = null;
80
+ ipAddress = null;
81
+ hasPinpad = false;
82
+ hasCashDrawer = false;
83
+ selectOptions = null;
84
+ menuColors = null;
77
85
  dispatch((0, kds_1.setKdsItemTypes)(itemTypes));
78
- dispatch((0, kds_1.setKdsPrepStations)(prep_stations));
86
+ // dispatch(setKdsPrepStations(prep_stations))
79
87
  return [2 /*return*/, {
80
88
  api: api,
81
89
  app: app,
@@ -87,13 +95,12 @@ exports.fetchConfig = (0, toolkit_1.createAsyncThunk)(ConfigActionType.FetchConf
87
95
  hasCashDrawer: hasCashDrawer,
88
96
  selectOptions: selectOptions,
89
97
  menuColors: menuColors,
90
- levelup: levelup,
91
98
  error: null,
92
99
  loading: 'idle',
93
100
  retries: 0
94
101
  }];
95
102
  case 6:
96
- err_2 = _h.sent();
103
+ err_2 = _e.sent();
97
104
  return [2 /*return*/, rejectWithValue(err_2)];
98
105
  case 7: return [2 /*return*/];
99
106
  }
@@ -120,25 +127,24 @@ var configSlice = (0, toolkit_1.createSlice)({
120
127
  },
121
128
  extraReducers: function (builder) {
122
129
  builder
130
+ .addCase(exports.fetchConfig.pending, function (state) {
131
+ state.loading = 'pending';
132
+ })
123
133
  .addCase(exports.fetchConfig.fulfilled, function (state, action) {
124
- var _a = action.payload, api = _a.api, app = _a.app, store = _a.store, revenueCenterId = _a.revenueCenterId, name = _a.name, ipAddress = _a.ipAddress, hasPinpad = _a.hasPinpad, hasCashDrawer = _a.hasCashDrawer, selectOptions = _a.selectOptions, menuColors = _a.menuColors, levelup = _a.levelup;
134
+ var _a = action.payload, api = _a.api, app = _a.app, store = _a.store, revenueCenterId = _a.revenueCenterId, name = _a.name, ipAddress = _a.ipAddress, hasPinpad = _a.hasPinpad, hasCashDrawer = _a.hasCashDrawer, selectOptions = _a.selectOptions, menuColors = _a.menuColors;
125
135
  state.api = api;
126
136
  state.app = app;
137
+ state.store = store;
138
+ state.revenueCenterId = revenueCenterId;
127
139
  state.name = name;
128
140
  state.ipAddress = ipAddress;
129
141
  state.hasPinpad = hasPinpad;
130
142
  state.hasCashDrawer = hasCashDrawer;
131
- state.store = store;
132
- state.revenueCenterId = revenueCenterId;
133
143
  state.selectOptions = selectOptions;
134
144
  state.menuColors = menuColors;
135
- state.levelup = levelup;
136
145
  state.loading = 'idle';
137
146
  state.retries = 0;
138
147
  state.error = null;
139
- })
140
- .addCase(exports.fetchConfig.pending, function (state) {
141
- state.loading = 'pending';
142
148
  })
143
149
  .addCase(exports.fetchConfig.rejected, function (state, action) {
144
150
  state.error = action.payload;
@@ -1,4 +1,4 @@
1
- import { IpAddress, LevelUp, MenuColors, RequestError, RequestStatus, SelectOptions, Store, Timezone } from '../types';
1
+ import { IpAddress, MenuColors, RequestError, RequestStatus, SelectOptions, Store, Timezone } from '../types';
2
2
  import { AppState } from '../app';
3
3
  export interface ConfigApp {
4
4
  apiUrl: string;
@@ -15,7 +15,6 @@ export interface ConfigState {
15
15
  revenueCenterId: number | null;
16
16
  selectOptions: SelectOptions | null;
17
17
  menuColors: MenuColors | null;
18
- levelup: LevelUp | null;
19
18
  loading: RequestStatus;
20
19
  error: RequestError | null;
21
20
  retries: number;
@@ -6,7 +6,7 @@ import { ReducerType } from './types';
6
6
  import { timezoneMap, getUserTimezone, currentLocalDateStr } from '../utils';
7
7
  import { errorsApi } from '../services/errors';
8
8
  import { setCashier } from './pos';
9
- import { setKdsItemTypes, setKdsPrepStations } from './kds';
9
+ import { setKdsItemTypes } from './kds';
10
10
  var initialState = {
11
11
  api: null,
12
12
  app: null,
@@ -19,7 +19,6 @@ var initialState = {
19
19
  revenueCenterId: null,
20
20
  selectOptions: null,
21
21
  menuColors: null,
22
- levelup: null,
23
22
  loading: 'idle',
24
23
  error: null,
25
24
  retries: 0
@@ -32,47 +31,56 @@ export var fetchConfig = createAsyncThunk(ConfigActionType.FetchConfig, function
32
31
  var apiUrl = _a.apiUrl;
33
32
  var dispatch = _b.dispatch, getState = _b.getState, rejectWithValue = _b.rejectWithValue;
34
33
  return __awaiter(void 0, void 0, void 0, function () {
35
- var app, api, _c, config, store, _d, selectOptions, _e, menuColors, _f, itemTypes, _g, levelup, err, cashier, employee, tz, businessDate, err_1, revenueCenterId, name_1, ipAddress, hasPinpad, hasCashDrawer, prep_stations, err_2;
36
- return __generator(this, function (_h) {
37
- switch (_h.label) {
34
+ var app, api, _c,
35
+ // config,
36
+ store, _d,
37
+ // selectOptions = null,
38
+ // menuColors = null,
39
+ itemTypes, err, cashier, employee, tz, businessDate, err_1, revenueCenterId, name_1, ipAddress, hasPinpad, hasCashDrawer, selectOptions, menuColors, err_2;
40
+ return __generator(this, function (_e) {
41
+ switch (_e.label) {
38
42
  case 0:
39
- _h.trys.push([0, 6, , 7]);
43
+ _e.trys.push([0, 6, , 7]);
40
44
  app = { apiUrl: apiUrl };
41
45
  api = new PosAPI(app);
42
46
  return [4 /*yield*/, Promise.all([
43
- api.getConfig(),
47
+ // api.getConfig(),
44
48
  api.getStore(),
45
- api.getSelectOptions(),
46
- api.getMenuColors(),
47
- api.getItemTypes(),
48
- api.getLevelUpSettings()
49
+ // api.getSelectOptions(),
50
+ // api.getMenuColors(),
51
+ api.getItemTypes()
49
52
  ])];
50
53
  case 1:
51
- _c = _h.sent(), config = _c[0], store = _c[1], _d = _c[2], selectOptions = _d === void 0 ? null : _d, _e = _c[3], menuColors = _e === void 0 ? null : _e, _f = _c[4], itemTypes = _f === void 0 ? null : _f, _g = _c[5], levelup = _g === void 0 ? null : _g;
52
- if (!config || !store) {
54
+ _c = _e.sent(), store = _c[0], _d = _c[1], itemTypes = _d === void 0 ? null : _d;
55
+ if (!store) {
53
56
  err = errorsApi.internalServerError;
54
57
  return [2 /*return*/, rejectWithValue(err)];
55
58
  }
56
59
  cashier = getState().pos.cashier;
57
60
  if (!!cashier) return [3 /*break*/, 5];
58
- _h.label = 2;
61
+ _e.label = 2;
59
62
  case 2:
60
- _h.trys.push([2, 4, , 5]);
63
+ _e.trys.push([2, 4, , 5]);
61
64
  return [4 /*yield*/, api.getCashier()];
62
65
  case 3:
63
- employee = _h.sent();
66
+ employee = _e.sent();
64
67
  tz = timezoneMap[store.timezone];
65
68
  businessDate = currentLocalDateStr(tz);
66
69
  dispatch(setCashier(__assign(__assign({}, employee), { businessDate: businessDate })));
67
70
  return [3 /*break*/, 5];
68
71
  case 4:
69
- err_1 = _h.sent();
72
+ err_1 = _e.sent();
70
73
  return [3 /*break*/, 5];
71
74
  case 5:
72
75
  revenueCenterId = store.revenue_center_id;
73
- name_1 = config.name, ipAddress = config.ip_address, hasPinpad = config.has_pinpad, hasCashDrawer = config.has_cashdrawer, prep_stations = config.prep_stations;
76
+ name_1 = null;
77
+ ipAddress = null;
78
+ hasPinpad = false;
79
+ hasCashDrawer = false;
80
+ selectOptions = null;
81
+ menuColors = null;
74
82
  dispatch(setKdsItemTypes(itemTypes));
75
- dispatch(setKdsPrepStations(prep_stations));
83
+ // dispatch(setKdsPrepStations(prep_stations))
76
84
  return [2 /*return*/, {
77
85
  api: api,
78
86
  app: app,
@@ -84,13 +92,12 @@ export var fetchConfig = createAsyncThunk(ConfigActionType.FetchConfig, function
84
92
  hasCashDrawer: hasCashDrawer,
85
93
  selectOptions: selectOptions,
86
94
  menuColors: menuColors,
87
- levelup: levelup,
88
95
  error: null,
89
96
  loading: 'idle',
90
97
  retries: 0
91
98
  }];
92
99
  case 6:
93
- err_2 = _h.sent();
100
+ err_2 = _e.sent();
94
101
  return [2 /*return*/, rejectWithValue(err_2)];
95
102
  case 7: return [2 /*return*/];
96
103
  }
@@ -117,25 +124,24 @@ var configSlice = createSlice({
117
124
  },
118
125
  extraReducers: function (builder) {
119
126
  builder
127
+ .addCase(fetchConfig.pending, function (state) {
128
+ state.loading = 'pending';
129
+ })
120
130
  .addCase(fetchConfig.fulfilled, function (state, action) {
121
- var _a = action.payload, api = _a.api, app = _a.app, store = _a.store, revenueCenterId = _a.revenueCenterId, name = _a.name, ipAddress = _a.ipAddress, hasPinpad = _a.hasPinpad, hasCashDrawer = _a.hasCashDrawer, selectOptions = _a.selectOptions, menuColors = _a.menuColors, levelup = _a.levelup;
131
+ var _a = action.payload, api = _a.api, app = _a.app, store = _a.store, revenueCenterId = _a.revenueCenterId, name = _a.name, ipAddress = _a.ipAddress, hasPinpad = _a.hasPinpad, hasCashDrawer = _a.hasCashDrawer, selectOptions = _a.selectOptions, menuColors = _a.menuColors;
122
132
  state.api = api;
123
133
  state.app = app;
134
+ state.store = store;
135
+ state.revenueCenterId = revenueCenterId;
124
136
  state.name = name;
125
137
  state.ipAddress = ipAddress;
126
138
  state.hasPinpad = hasPinpad;
127
139
  state.hasCashDrawer = hasCashDrawer;
128
- state.store = store;
129
- state.revenueCenterId = revenueCenterId;
130
140
  state.selectOptions = selectOptions;
131
141
  state.menuColors = menuColors;
132
- state.levelup = levelup;
133
142
  state.loading = 'idle';
134
143
  state.retries = 0;
135
144
  state.error = null;
136
- })
137
- .addCase(fetchConfig.pending, function (state) {
138
- state.loading = 'pending';
139
145
  })
140
146
  .addCase(fetchConfig.rejected, function (state, action) {
141
147
  state.error = action.payload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/store",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
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",