@open-tender/store 0.6.1 → 0.6.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/.DS_Store ADDED
Binary file
@@ -17,7 +17,7 @@ declare class PosAPI {
17
17
  postCardCancel(): Promise<null | undefined>;
18
18
  getBarcodeRead(): Promise<DeviceRead | null | undefined>;
19
19
  postBarcodeCancel(): Promise<null | undefined>;
20
- getSettings(posSettingType: PosSettingType): Promise<any>;
20
+ getSettings<T>(posSettingType: PosSettingType): Promise<T | null | undefined>;
21
21
  postSettings(posSettingType: PosSettingType): Promise<Settings | null | undefined>;
22
22
  getInternalSettings(): Promise<InternalSettings | null | undefined>;
23
23
  postInternalSettings(data: InternalSettings): Promise<InternalSettings | null | undefined>;
@@ -1,4 +1,4 @@
1
- import { IpAddress, MenuColors, RequestError, RequestStatus, SelectOptions, Store, Timezone } from '../types';
1
+ import { Devices, MenuColors, RequestError, RequestStatus, SelectOptions, Store, Timezone } from '../types';
2
2
  import { AppState } from '../app';
3
3
  export interface ConfigApp {
4
4
  apiUrl: string;
@@ -7,10 +7,7 @@ export interface ConfigState {
7
7
  api: any;
8
8
  app: ConfigApp | null;
9
9
  version?: string | null;
10
- name: string | null;
11
- ipAddress: IpAddress | null;
12
- hasPinpad: boolean;
13
- hasCashDrawer: boolean;
10
+ devices: Devices | null;
14
11
  store: Store | null;
15
12
  revenueCenterId: number | null;
16
13
  selectOptions: SelectOptions | null;
@@ -32,8 +29,6 @@ export declare const resetConfig: import("@reduxjs/toolkit").ActionCreatorWithou
32
29
  export declare const selectConfig: (state: AppState) => ConfigState;
33
30
  export declare const selectApi: (state: AppState) => any;
34
31
  export declare const selectVersion: (state: AppState) => string | null | undefined;
35
- export declare const selectPinpad: (state: AppState) => boolean;
36
- export declare const selectCashDrawer: (state: AppState) => boolean;
37
32
  export declare const selectRevenueCenterId: (state: AppState) => number | null;
38
33
  export declare const selectStore: (state: AppState) => Store | null;
39
34
  export declare const selectSelectOptions: (state: AppState) => SelectOptions;
@@ -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.selectMenuColors = exports.selectSelectOptions = exports.selectStore = exports.selectRevenueCenterId = exports.selectCashDrawer = exports.selectPinpad = exports.selectVersion = exports.selectApi = exports.selectConfig = exports.setApi = exports.setVersion = exports.incrementRetries = exports.resetRetries = exports.resetConfig = exports.fetchConfig = exports.ConfigActionType = void 0;
4
+ exports.configReducer = exports.selectLoyalty = exports.selectTimezone = exports.selectMenuColors = exports.selectSelectOptions = exports.selectStore = exports.selectRevenueCenterId = exports.selectVersion = exports.selectApi = exports.selectConfig = exports.setApi = exports.setVersion = 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");
@@ -10,14 +10,13 @@ var utils_1 = require("../utils");
10
10
  var errors_1 = require("../services/errors");
11
11
  var pos_1 = require("./pos");
12
12
  var kds_1 = require("./kds");
13
+ // const defaultApiUrl = `http://${window.location.hostname}:5001/pos-api`
13
14
  var initialState = {
15
+ // api: new PosAPI({ apiUrl: defaultApiUrl }),
14
16
  api: null,
15
17
  app: null,
16
18
  version: null,
17
- name: null,
18
- ipAddress: null,
19
- hasPinpad: false,
20
- hasCashDrawer: false,
19
+ devices: null,
21
20
  store: null,
22
21
  revenueCenterId: null,
23
22
  selectOptions: null,
@@ -34,65 +33,55 @@ exports.fetchConfig = (0, toolkit_1.createAsyncThunk)(ConfigActionType.FetchConf
34
33
  var apiUrl = _a.apiUrl;
35
34
  var dispatch = _b.dispatch, getState = _b.getState, rejectWithValue = _b.rejectWithValue;
36
35
  return tslib_1.__awaiter(void 0, void 0, void 0, function () {
37
- var app, api, _c,
36
+ var app, api, _c, _d,
38
37
  // 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) {
38
+ devices, _e, store, _f, selectOptions, _g, itemTypes, err, cashier, employee, tz, businessDate, err_1, revenueCenterId, menuColors, err_2;
39
+ return tslib_1.__generator(this, function (_h) {
40
+ switch (_h.label) {
45
41
  case 0:
46
- _e.trys.push([0, 6, , 7]);
42
+ _h.trys.push([0, 6, , 7]);
47
43
  app = { apiUrl: apiUrl };
48
44
  api = new services_1.PosAPI(app);
49
45
  return [4 /*yield*/, Promise.all([
50
46
  // api.getConfig(),
51
- api.getStore(),
52
- // api.getSelectOptions(),
47
+ api.getSettings('DEVICES'),
48
+ api.getSettings('STORE'),
49
+ api.getSettings('SELECT_OPTION'),
50
+ api.getSettings('ITEM_TYPE')
53
51
  // api.getMenuColors(),
54
- api.getItemTypes()
55
52
  ])];
56
53
  case 1:
57
- _c = _e.sent(), store = _c[0], _d = _c[1], itemTypes = _d === void 0 ? null : _d;
54
+ _c = _h.sent(), _d = _c[0], devices = _d === void 0 ? null : _d, _e = _c[1], store = _e === void 0 ? null : _e, _f = _c[2], selectOptions = _f === void 0 ? null : _f, _g = _c[3], itemTypes = _g === void 0 ? null : _g;
58
55
  if (!store) {
59
56
  err = errors_1.errorsApi.internalServerError;
60
57
  return [2 /*return*/, rejectWithValue(err)];
61
58
  }
62
59
  cashier = getState().pos.cashier;
63
60
  if (!!cashier) return [3 /*break*/, 5];
64
- _e.label = 2;
61
+ _h.label = 2;
65
62
  case 2:
66
- _e.trys.push([2, 4, , 5]);
63
+ _h.trys.push([2, 4, , 5]);
67
64
  return [4 /*yield*/, api.getCashier()];
68
65
  case 3:
69
- employee = _e.sent();
66
+ employee = _h.sent();
70
67
  tz = utils_1.timezoneMap[store.timezone];
71
68
  businessDate = (0, utils_1.currentLocalDateStr)(tz);
72
69
  dispatch((0, pos_1.setCashier)(tslib_1.__assign(tslib_1.__assign({}, employee), { businessDate: businessDate })));
73
70
  return [3 /*break*/, 5];
74
71
  case 4:
75
- err_1 = _e.sent();
72
+ err_1 = _h.sent();
76
73
  return [3 /*break*/, 5];
77
74
  case 5:
78
75
  revenueCenterId = store.revenue_center_id;
79
- name_1 = null;
80
- ipAddress = null;
81
- hasPinpad = false;
82
- hasCashDrawer = false;
83
- selectOptions = null;
84
- menuColors = null;
85
76
  dispatch((0, kds_1.setKdsItemTypes)(itemTypes));
86
- // dispatch(setKdsPrepStations(prep_stations))
77
+ dispatch((0, kds_1.setKdsPrepStations)(devices === null || devices === void 0 ? void 0 : devices.prep_stations));
78
+ menuColors = [];
87
79
  return [2 /*return*/, {
88
80
  api: api,
89
81
  app: app,
82
+ devices: devices,
90
83
  store: store,
91
84
  revenueCenterId: revenueCenterId,
92
- name: name_1,
93
- ipAddress: ipAddress,
94
- hasPinpad: hasPinpad,
95
- hasCashDrawer: hasCashDrawer,
96
85
  selectOptions: selectOptions,
97
86
  menuColors: menuColors,
98
87
  error: null,
@@ -100,7 +89,7 @@ exports.fetchConfig = (0, toolkit_1.createAsyncThunk)(ConfigActionType.FetchConf
100
89
  retries: 0
101
90
  }];
102
91
  case 6:
103
- err_2 = _e.sent();
92
+ err_2 = _h.sent();
104
93
  return [2 /*return*/, rejectWithValue(err_2)];
105
94
  case 7: return [2 /*return*/];
106
95
  }
@@ -131,15 +120,12 @@ var configSlice = (0, toolkit_1.createSlice)({
131
120
  state.loading = 'pending';
132
121
  })
133
122
  .addCase(exports.fetchConfig.fulfilled, function (state, action) {
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;
123
+ var _a = action.payload, api = _a.api, app = _a.app, devices = _a.devices, store = _a.store, revenueCenterId = _a.revenueCenterId, selectOptions = _a.selectOptions, menuColors = _a.menuColors;
135
124
  state.api = api;
136
125
  state.app = app;
137
126
  state.store = store;
127
+ state.devices = devices;
138
128
  state.revenueCenterId = revenueCenterId;
139
- state.name = name;
140
- state.ipAddress = ipAddress;
141
- state.hasPinpad = hasPinpad;
142
- state.hasCashDrawer = hasCashDrawer;
143
129
  state.selectOptions = selectOptions;
144
130
  state.menuColors = menuColors;
145
131
  state.loading = 'idle';
@@ -159,10 +145,6 @@ var selectApi = function (state) { return state.config.api; };
159
145
  exports.selectApi = selectApi;
160
146
  var selectVersion = function (state) { return state.config.version; };
161
147
  exports.selectVersion = selectVersion;
162
- var selectPinpad = function (state) { return state.config.hasPinpad; };
163
- exports.selectPinpad = selectPinpad;
164
- var selectCashDrawer = function (state) { return state.config.hasCashDrawer; };
165
- exports.selectCashDrawer = selectCashDrawer;
166
148
  var selectRevenueCenterId = function (state) {
167
149
  return state.config.revenueCenterId;
168
150
  };
@@ -235,7 +235,7 @@ export declare const selectKdsItemTypes: (state: AppState) => ItemTypes | null;
235
235
  export declare const selectKdsPrepStations: (state: AppState) => PrepStations;
236
236
  export declare const selectKdsPrepStationId: (state: AppState) => number | null;
237
237
  export declare const selectKdsPrepStation: (state: AppState) => PrepStation | null;
238
- export declare const selectKdsPrepType: (state: AppState) => import("../types").KdsPrepType | null;
238
+ export declare const selectKdsPrepType: (state: AppState) => import("../types").PrepStationPrepType | null;
239
239
  export declare const selectKdsOrderType: (state: AppState) => KdsOrderType;
240
240
  export declare const selectKdsColumns: (state: AppState) => number;
241
241
  export declare const selectKdsBoxes: (state: AppState) => number;
@@ -398,7 +398,7 @@ exports.kdsSlice = (0, toolkit_1.createSlice)({
398
398
  .map(function (i) { return (tslib_1.__assign(tslib_1.__assign({}, i), { fireAt: (0, utils_1.isoToDate)(i.fire_at, tz) })); })
399
399
  .sort(function (a, b) { return a.fireAt.getTime() - b.fireAt.getTime(); });
400
400
  // const counts = makeKdsCounts(state.itemTypes, orders)
401
- var stationCounts = (0, utils_1.makeKdsStationCounts)(updatedOrders, state.prepStations);
401
+ var stationCounts = (0, utils_1.makeKdsStationCounts)(updatedOrders, state.prepStations || []);
402
402
  var order = state.order ? updated : null;
403
403
  return tslib_1.__assign(tslib_1.__assign({}, state), { orders: orders, order: order, stationCounts: stationCounts });
404
404
  }
@@ -525,7 +525,7 @@ exports.selectKdsPrepStationId = selectKdsPrepStationId;
525
525
  var selectKdsPrepStation = function (state) {
526
526
  var _a;
527
527
  var _b = state.kds, prepStations = _b.prepStations, prepStationId = _b.prepStationId;
528
- return (_a = prepStations.find(function (i) { return i.prep_station_id === prepStationId; })) !== null && _a !== void 0 ? _a : null;
528
+ return (_a = prepStations === null || prepStations === void 0 ? void 0 : prepStations.find(function (i) { return i.prep_station_id === prepStationId; })) !== null && _a !== void 0 ? _a : null;
529
529
  };
530
530
  exports.selectKdsPrepStation = selectKdsPrepStation;
531
531
  var selectKdsPrepType = function (state) {
@@ -1,5 +1,6 @@
1
1
  import { IpAddress } from '../global';
2
- import { PrepStations, PrepStatus } from './kds';
2
+ import { PrepStations } from './devices';
3
+ import { PrepStatus } from './kds';
3
4
  export interface Config {
4
5
  backup_printer_ip_address: IpAddress | null;
5
6
  backup_printer_use_beeper: boolean;
@@ -0,0 +1,88 @@
1
+ export interface PosPrinter {
2
+ backup_pos_printer_v2_id: number;
3
+ description: string;
4
+ ipv4_address: string;
5
+ name: string;
6
+ pos_printer_v2_id: number;
7
+ use_beeper: boolean;
8
+ }
9
+ export declare type PosPrinters = PosPrinter[];
10
+ export interface PosScanner {
11
+ description: string;
12
+ identifier: string;
13
+ name: string;
14
+ pos_scanner_id: number;
15
+ }
16
+ export declare type PosScanners = PosScanner[];
17
+ export declare type PosTerminalPrintReceipt = 'never' | 'always' | 'prompt';
18
+ export interface PosTerminal {
19
+ description: string;
20
+ name: string;
21
+ pos_chipdna_terminal_id: number | null;
22
+ pos_printer_v2_id: number | null;
23
+ pos_scanner: PosScanner;
24
+ pos_scanner_id: number | null;
25
+ pos_terminal_id: number;
26
+ print_kds: boolean;
27
+ print_receipt: PosTerminalPrintReceipt;
28
+ printer: PosPrinters;
29
+ }
30
+ export declare type PosTerminals = PosTerminal[];
31
+ export declare type PrepStationPrepType = 'ASSEMBLY' | 'EXPO';
32
+ export interface PrepStation {
33
+ assembly_done: boolean;
34
+ assembly_print: boolean;
35
+ expo_complete: boolean;
36
+ expo_complete_all: boolean;
37
+ expo_done_only: boolean;
38
+ expo_print: boolean;
39
+ expo_reset: boolean;
40
+ item_type_ids: number[];
41
+ name: string;
42
+ prep_station_id: number;
43
+ prep_type: PrepStationPrepType;
44
+ show_counts: boolean;
45
+ show_groups: boolean;
46
+ show_modifiers: boolean;
47
+ }
48
+ export declare type PrepStations = PrepStation[];
49
+ export interface KdsTerminal {
50
+ auto_print: boolean;
51
+ description: string;
52
+ kds_terminal_id: number;
53
+ name: string;
54
+ pos_printer_v2_id: number | null;
55
+ prep_stations: PrepStations;
56
+ printer: PosPrinters;
57
+ }
58
+ export declare type KdsTerminals = KdsTerminal[];
59
+ export interface PosServer {
60
+ ipv4_address: string;
61
+ name: string;
62
+ pos_server_id: number;
63
+ }
64
+ export declare type PosServers = PosServer[];
65
+ export interface PaymentTerminal {
66
+ api_key: string;
67
+ application_identifier: string;
68
+ description: string;
69
+ identifier: string;
70
+ is_active: boolean;
71
+ mac_address: string;
72
+ model: string;
73
+ name: string;
74
+ pos_chipdna_terminal_id: number;
75
+ revenue_center_id: number;
76
+ standby_message: string;
77
+ use_production: boolean;
78
+ }
79
+ export declare type PaymentTerminals = PaymentTerminal[];
80
+ export interface Devices {
81
+ kds_terminals: KdsTerminals;
82
+ pos_chipdna_terminals: PaymentTerminals;
83
+ pos_scanners: PosScanners;
84
+ pos_terminals: PosTerminals;
85
+ prep_stations: PrepStations;
86
+ printers: PosPrinters;
87
+ servers: PosServers;
88
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,6 +5,7 @@ export * from './checkout';
5
5
  export * from './config';
6
6
  export * from './customer';
7
7
  export * from './device';
8
+ export * from './devices';
8
9
  export * from './discounts';
9
10
  export * from './employee';
10
11
  export * from './errorAlerts';
@@ -8,6 +8,7 @@ tslib_1.__exportStar(require("./checkout"), exports);
8
8
  tslib_1.__exportStar(require("./config"), exports);
9
9
  tslib_1.__exportStar(require("./customer"), exports);
10
10
  tslib_1.__exportStar(require("./device"), exports);
11
+ tslib_1.__exportStar(require("./devices"), exports);
11
12
  tslib_1.__exportStar(require("./discounts"), exports);
12
13
  tslib_1.__exportStar(require("./employee"), exports);
13
14
  tslib_1.__exportStar(require("./errorAlerts"), exports);
@@ -2,7 +2,6 @@ import { OrdersKds } from './order';
2
2
  export declare type DeviceFontSize = 'xsmall' | 'small' | 'medium' | 'large';
3
3
  export declare type DeviceColorScheme = 'dark' | 'light';
4
4
  export declare type KdsView = 'column' | 'grid' | 'list' | 'tiles';
5
- export declare type KdsPrepType = 'ASSEMBLY' | 'EXPO';
6
5
  export declare type KdsOrderType = 'CURRENT' | 'FUTURE' | 'COMPLETED' | 'INCOMPLETE';
7
6
  export declare type KdsAssemblyOptions = 'AUTO_PRINT' | 'PRINT_DONE' | 'MARK_DONE' | 'PRINT_AND_DONE' | null;
8
7
  export declare type PrepStatus = 'TODO' | 'IN_PROGRESS' | 'DONE' | 'COMPLETED' | 'FULFILLED';
@@ -10,33 +9,6 @@ export declare type PrepStatusMap = {
10
9
  [Property in PrepStatus]: PrepStatus;
11
10
  };
12
11
  export declare type TicketStatus = 'TODO' | 'IN_PROGRESS' | 'DONE' | 'COMPLETED';
13
- export interface PrepStation {
14
- prep_station_id: number;
15
- name: string;
16
- item_type_ids: number[] | null;
17
- prep_type: KdsPrepType;
18
- assembly_options: KdsAssemblyOptions;
19
- expo_done_only: boolean;
20
- expo_print: boolean;
21
- expo_reset: boolean;
22
- expo_complete: boolean;
23
- expo_complete_all: boolean;
24
- show_modifiers: boolean;
25
- show_groups: boolean;
26
- show_counts: boolean;
27
- }
28
- export declare type PrepStations = PrepStation[];
29
- export interface KdsTerminal {
30
- name: string;
31
- ipAddress: string;
32
- prepStations: PrepStations;
33
- defaultView: KdsView;
34
- columns: number;
35
- boxes: number;
36
- cardWidth: number;
37
- fontSize: DeviceFontSize;
38
- colorScheme: DeviceColorScheme;
39
- }
40
12
  export interface KdsStationOrderTypeCount {
41
13
  orders: number;
42
14
  tickets: number;
@@ -1,4 +1,4 @@
1
- import { FetchOrdersAPIArgs, FetchOrdersArgs, HeaderColors, ItemType, ItemTypes, KdsOrderType, KdsPrepType, KdsStationCounts, KdsStationOrderTypeCount, ModifiersMetadata, Order, OrderBuckets, OrderCart, OrderItem, OrderItemCount, OrderKds, Orders, OrdersKds, OrderTickets, OrderTimes, PrepStation, PrepStations, PrepStatus, PrepStatusMap, Store, TicketGroups, Timezone } from '../types';
1
+ import { FetchOrdersAPIArgs, FetchOrdersArgs, HeaderColors, ItemType, ItemTypes, KdsOrderType, PrepStationPrepType, KdsStationCounts, KdsStationOrderTypeCount, ModifiersMetadata, Order, OrderBuckets, OrderCart, OrderItem, OrderItemCount, OrderKds, Orders, OrdersKds, OrderTickets, OrderTimes, PrepStation, PrepStations, PrepStatus, PrepStatusMap, Store, TicketGroups, Timezone } from '../types';
2
2
  export declare const prepStatus: PrepStatusMap;
3
3
  export declare const makeFetchOrdersArgs: ({ businessDate, receiptType, channelType, prepStatus, search, sortBy, sortDirection, parentOrderId }: FetchOrdersArgs) => FetchOrdersAPIArgs;
4
4
  export declare const notDone: (prep_status: PrepStatus) => boolean;
@@ -14,7 +14,7 @@ export declare const makeIncompleteOrders: (orders: OrdersKds) => OrdersKds;
14
14
  export declare const makeCompletedOrders: (orders: OrdersKds) => OrdersKds;
15
15
  export declare const makeOrdersOfType: (orders: OrdersKds, orderType: KdsOrderType) => OrdersKds;
16
16
  export declare const filterOrdersByItemType: (orders: OrdersKds, itemTypeIds: number[] | null) => OrdersKds;
17
- export declare const filterOrdersByPrepType: (orders: OrdersKds, prepType: KdsPrepType) => OrdersKds;
17
+ export declare const filterOrdersByPrepType: (orders: OrdersKds, prepType: PrepStationPrepType) => OrdersKds;
18
18
  export declare const filterOrdersToday: (orders: OrdersKds) => OrdersKds;
19
19
  export declare const makeOrdersForPrepStation: (orders: OrdersKds, prepStation: PrepStation, orderType: KdsOrderType) => OrdersKds;
20
20
  export declare const makeOrderItemSignature: (item: OrderItem, withNotes?: boolean) => string;
@@ -32,7 +32,7 @@ export declare const makeCurrentAndFutureOrders: (orders: OrdersKds) => {
32
32
  current: OrdersKds;
33
33
  future: OrdersKds;
34
34
  };
35
- export declare const makeKdsStationCount: (orders: OrdersKds, itemTypeIds: number[] | null, prepType: KdsPrepType) => KdsStationOrderTypeCount;
35
+ export declare const makeKdsStationCount: (orders: OrdersKds, itemTypeIds: number[] | null, prepType: PrepStationPrepType) => KdsStationOrderTypeCount;
36
36
  export declare const makeKdsStationCounts: (orders: OrdersKds, prepStations: PrepStations) => KdsStationCounts;
37
37
  export declare const makeOrderBuckets: (orders: OrdersKds, tz: Timezone) => OrderBuckets;
38
38
  export declare const makeOrderBucketsCounts: (itemTypes?: ItemTypes, orders?: OrdersKds) => Record<string, number>;
@@ -17,7 +17,7 @@ declare class PosAPI {
17
17
  postCardCancel(): Promise<null | undefined>;
18
18
  getBarcodeRead(): Promise<DeviceRead | null | undefined>;
19
19
  postBarcodeCancel(): Promise<null | undefined>;
20
- getSettings(posSettingType: PosSettingType): Promise<any>;
20
+ getSettings<T>(posSettingType: PosSettingType): Promise<T | null | undefined>;
21
21
  postSettings(posSettingType: PosSettingType): Promise<Settings | null | undefined>;
22
22
  getInternalSettings(): Promise<InternalSettings | null | undefined>;
23
23
  postInternalSettings(data: InternalSettings): Promise<InternalSettings | null | undefined>;
@@ -1,4 +1,4 @@
1
- import { IpAddress, MenuColors, RequestError, RequestStatus, SelectOptions, Store, Timezone } from '../types';
1
+ import { Devices, MenuColors, RequestError, RequestStatus, SelectOptions, Store, Timezone } from '../types';
2
2
  import { AppState } from '../app';
3
3
  export interface ConfigApp {
4
4
  apiUrl: string;
@@ -7,10 +7,7 @@ export interface ConfigState {
7
7
  api: any;
8
8
  app: ConfigApp | null;
9
9
  version?: string | null;
10
- name: string | null;
11
- ipAddress: IpAddress | null;
12
- hasPinpad: boolean;
13
- hasCashDrawer: boolean;
10
+ devices: Devices | null;
14
11
  store: Store | null;
15
12
  revenueCenterId: number | null;
16
13
  selectOptions: SelectOptions | null;
@@ -32,8 +29,6 @@ export declare const resetConfig: import("@reduxjs/toolkit").ActionCreatorWithou
32
29
  export declare const selectConfig: (state: AppState) => ConfigState;
33
30
  export declare const selectApi: (state: AppState) => any;
34
31
  export declare const selectVersion: (state: AppState) => string | null | undefined;
35
- export declare const selectPinpad: (state: AppState) => boolean;
36
- export declare const selectCashDrawer: (state: AppState) => boolean;
37
32
  export declare const selectRevenueCenterId: (state: AppState) => number | null;
38
33
  export declare const selectStore: (state: AppState) => Store | null;
39
34
  export declare const selectSelectOptions: (state: AppState) => SelectOptions;
@@ -6,15 +6,14 @@ 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 } from './kds';
9
+ import { setKdsItemTypes, setKdsPrepStations } from './kds';
10
+ // const defaultApiUrl = `http://${window.location.hostname}:5001/pos-api`
10
11
  var initialState = {
12
+ // api: new PosAPI({ apiUrl: defaultApiUrl }),
11
13
  api: null,
12
14
  app: null,
13
15
  version: null,
14
- name: null,
15
- ipAddress: null,
16
- hasPinpad: false,
17
- hasCashDrawer: false,
16
+ devices: null,
18
17
  store: null,
19
18
  revenueCenterId: null,
20
19
  selectOptions: null,
@@ -31,65 +30,55 @@ export var fetchConfig = createAsyncThunk(ConfigActionType.FetchConfig, function
31
30
  var apiUrl = _a.apiUrl;
32
31
  var dispatch = _b.dispatch, getState = _b.getState, rejectWithValue = _b.rejectWithValue;
33
32
  return __awaiter(void 0, void 0, void 0, function () {
34
- var app, api, _c,
33
+ var app, api, _c, _d,
35
34
  // 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) {
35
+ devices, _e, store, _f, selectOptions, _g, itemTypes, err, cashier, employee, tz, businessDate, err_1, revenueCenterId, menuColors, err_2;
36
+ return __generator(this, function (_h) {
37
+ switch (_h.label) {
42
38
  case 0:
43
- _e.trys.push([0, 6, , 7]);
39
+ _h.trys.push([0, 6, , 7]);
44
40
  app = { apiUrl: apiUrl };
45
41
  api = new PosAPI(app);
46
42
  return [4 /*yield*/, Promise.all([
47
43
  // api.getConfig(),
48
- api.getStore(),
49
- // api.getSelectOptions(),
44
+ api.getSettings('DEVICES'),
45
+ api.getSettings('STORE'),
46
+ api.getSettings('SELECT_OPTION'),
47
+ api.getSettings('ITEM_TYPE')
50
48
  // api.getMenuColors(),
51
- api.getItemTypes()
52
49
  ])];
53
50
  case 1:
54
- _c = _e.sent(), store = _c[0], _d = _c[1], itemTypes = _d === void 0 ? null : _d;
51
+ _c = _h.sent(), _d = _c[0], devices = _d === void 0 ? null : _d, _e = _c[1], store = _e === void 0 ? null : _e, _f = _c[2], selectOptions = _f === void 0 ? null : _f, _g = _c[3], itemTypes = _g === void 0 ? null : _g;
55
52
  if (!store) {
56
53
  err = errorsApi.internalServerError;
57
54
  return [2 /*return*/, rejectWithValue(err)];
58
55
  }
59
56
  cashier = getState().pos.cashier;
60
57
  if (!!cashier) return [3 /*break*/, 5];
61
- _e.label = 2;
58
+ _h.label = 2;
62
59
  case 2:
63
- _e.trys.push([2, 4, , 5]);
60
+ _h.trys.push([2, 4, , 5]);
64
61
  return [4 /*yield*/, api.getCashier()];
65
62
  case 3:
66
- employee = _e.sent();
63
+ employee = _h.sent();
67
64
  tz = timezoneMap[store.timezone];
68
65
  businessDate = currentLocalDateStr(tz);
69
66
  dispatch(setCashier(__assign(__assign({}, employee), { businessDate: businessDate })));
70
67
  return [3 /*break*/, 5];
71
68
  case 4:
72
- err_1 = _e.sent();
69
+ err_1 = _h.sent();
73
70
  return [3 /*break*/, 5];
74
71
  case 5:
75
72
  revenueCenterId = store.revenue_center_id;
76
- name_1 = null;
77
- ipAddress = null;
78
- hasPinpad = false;
79
- hasCashDrawer = false;
80
- selectOptions = null;
81
- menuColors = null;
82
73
  dispatch(setKdsItemTypes(itemTypes));
83
- // dispatch(setKdsPrepStations(prep_stations))
74
+ dispatch(setKdsPrepStations(devices === null || devices === void 0 ? void 0 : devices.prep_stations));
75
+ menuColors = [];
84
76
  return [2 /*return*/, {
85
77
  api: api,
86
78
  app: app,
79
+ devices: devices,
87
80
  store: store,
88
81
  revenueCenterId: revenueCenterId,
89
- name: name_1,
90
- ipAddress: ipAddress,
91
- hasPinpad: hasPinpad,
92
- hasCashDrawer: hasCashDrawer,
93
82
  selectOptions: selectOptions,
94
83
  menuColors: menuColors,
95
84
  error: null,
@@ -97,7 +86,7 @@ export var fetchConfig = createAsyncThunk(ConfigActionType.FetchConfig, function
97
86
  retries: 0
98
87
  }];
99
88
  case 6:
100
- err_2 = _e.sent();
89
+ err_2 = _h.sent();
101
90
  return [2 /*return*/, rejectWithValue(err_2)];
102
91
  case 7: return [2 /*return*/];
103
92
  }
@@ -128,15 +117,12 @@ var configSlice = createSlice({
128
117
  state.loading = 'pending';
129
118
  })
130
119
  .addCase(fetchConfig.fulfilled, function (state, action) {
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;
120
+ var _a = action.payload, api = _a.api, app = _a.app, devices = _a.devices, store = _a.store, revenueCenterId = _a.revenueCenterId, selectOptions = _a.selectOptions, menuColors = _a.menuColors;
132
121
  state.api = api;
133
122
  state.app = app;
134
123
  state.store = store;
124
+ state.devices = devices;
135
125
  state.revenueCenterId = revenueCenterId;
136
- state.name = name;
137
- state.ipAddress = ipAddress;
138
- state.hasPinpad = hasPinpad;
139
- state.hasCashDrawer = hasCashDrawer;
140
126
  state.selectOptions = selectOptions;
141
127
  state.menuColors = menuColors;
142
128
  state.loading = 'idle';
@@ -153,8 +139,6 @@ export var resetConfig = (_a = configSlice.actions, _a.resetConfig), resetRetrie
153
139
  export var selectConfig = function (state) { return state.config; };
154
140
  export var selectApi = function (state) { return state.config.api; };
155
141
  export var selectVersion = function (state) { return state.config.version; };
156
- export var selectPinpad = function (state) { return state.config.hasPinpad; };
157
- export var selectCashDrawer = function (state) { return state.config.hasCashDrawer; };
158
142
  export var selectRevenueCenterId = function (state) {
159
143
  return state.config.revenueCenterId;
160
144
  };
@@ -235,7 +235,7 @@ export declare const selectKdsItemTypes: (state: AppState) => ItemTypes | null;
235
235
  export declare const selectKdsPrepStations: (state: AppState) => PrepStations;
236
236
  export declare const selectKdsPrepStationId: (state: AppState) => number | null;
237
237
  export declare const selectKdsPrepStation: (state: AppState) => PrepStation | null;
238
- export declare const selectKdsPrepType: (state: AppState) => import("../types").KdsPrepType | null;
238
+ export declare const selectKdsPrepType: (state: AppState) => import("../types").PrepStationPrepType | null;
239
239
  export declare const selectKdsOrderType: (state: AppState) => KdsOrderType;
240
240
  export declare const selectKdsColumns: (state: AppState) => number;
241
241
  export declare const selectKdsBoxes: (state: AppState) => number;
@@ -394,7 +394,7 @@ export var kdsSlice = createSlice({
394
394
  .map(function (i) { return (__assign(__assign({}, i), { fireAt: isoToDate(i.fire_at, tz) })); })
395
395
  .sort(function (a, b) { return a.fireAt.getTime() - b.fireAt.getTime(); });
396
396
  // const counts = makeKdsCounts(state.itemTypes, orders)
397
- var stationCounts = makeKdsStationCounts(updatedOrders, state.prepStations);
397
+ var stationCounts = makeKdsStationCounts(updatedOrders, state.prepStations || []);
398
398
  var order = state.order ? updated : null;
399
399
  return __assign(__assign({}, state), { orders: orders, order: order, stationCounts: stationCounts });
400
400
  }
@@ -517,7 +517,7 @@ export var selectKdsPrepStationId = function (state) {
517
517
  export var selectKdsPrepStation = function (state) {
518
518
  var _a;
519
519
  var _b = state.kds, prepStations = _b.prepStations, prepStationId = _b.prepStationId;
520
- return (_a = prepStations.find(function (i) { return i.prep_station_id === prepStationId; })) !== null && _a !== void 0 ? _a : null;
520
+ return (_a = prepStations === null || prepStations === void 0 ? void 0 : prepStations.find(function (i) { return i.prep_station_id === prepStationId; })) !== null && _a !== void 0 ? _a : null;
521
521
  };
522
522
  export var selectKdsPrepType = function (state) {
523
523
  var prepStation = selectKdsPrepStation(state);
@@ -1,5 +1,6 @@
1
1
  import { IpAddress } from '../global';
2
- import { PrepStations, PrepStatus } from './kds';
2
+ import { PrepStations } from './devices';
3
+ import { PrepStatus } from './kds';
3
4
  export interface Config {
4
5
  backup_printer_ip_address: IpAddress | null;
5
6
  backup_printer_use_beeper: boolean;
@@ -0,0 +1,88 @@
1
+ export interface PosPrinter {
2
+ backup_pos_printer_v2_id: number;
3
+ description: string;
4
+ ipv4_address: string;
5
+ name: string;
6
+ pos_printer_v2_id: number;
7
+ use_beeper: boolean;
8
+ }
9
+ export declare type PosPrinters = PosPrinter[];
10
+ export interface PosScanner {
11
+ description: string;
12
+ identifier: string;
13
+ name: string;
14
+ pos_scanner_id: number;
15
+ }
16
+ export declare type PosScanners = PosScanner[];
17
+ export declare type PosTerminalPrintReceipt = 'never' | 'always' | 'prompt';
18
+ export interface PosTerminal {
19
+ description: string;
20
+ name: string;
21
+ pos_chipdna_terminal_id: number | null;
22
+ pos_printer_v2_id: number | null;
23
+ pos_scanner: PosScanner;
24
+ pos_scanner_id: number | null;
25
+ pos_terminal_id: number;
26
+ print_kds: boolean;
27
+ print_receipt: PosTerminalPrintReceipt;
28
+ printer: PosPrinters;
29
+ }
30
+ export declare type PosTerminals = PosTerminal[];
31
+ export declare type PrepStationPrepType = 'ASSEMBLY' | 'EXPO';
32
+ export interface PrepStation {
33
+ assembly_done: boolean;
34
+ assembly_print: boolean;
35
+ expo_complete: boolean;
36
+ expo_complete_all: boolean;
37
+ expo_done_only: boolean;
38
+ expo_print: boolean;
39
+ expo_reset: boolean;
40
+ item_type_ids: number[];
41
+ name: string;
42
+ prep_station_id: number;
43
+ prep_type: PrepStationPrepType;
44
+ show_counts: boolean;
45
+ show_groups: boolean;
46
+ show_modifiers: boolean;
47
+ }
48
+ export declare type PrepStations = PrepStation[];
49
+ export interface KdsTerminal {
50
+ auto_print: boolean;
51
+ description: string;
52
+ kds_terminal_id: number;
53
+ name: string;
54
+ pos_printer_v2_id: number | null;
55
+ prep_stations: PrepStations;
56
+ printer: PosPrinters;
57
+ }
58
+ export declare type KdsTerminals = KdsTerminal[];
59
+ export interface PosServer {
60
+ ipv4_address: string;
61
+ name: string;
62
+ pos_server_id: number;
63
+ }
64
+ export declare type PosServers = PosServer[];
65
+ export interface PaymentTerminal {
66
+ api_key: string;
67
+ application_identifier: string;
68
+ description: string;
69
+ identifier: string;
70
+ is_active: boolean;
71
+ mac_address: string;
72
+ model: string;
73
+ name: string;
74
+ pos_chipdna_terminal_id: number;
75
+ revenue_center_id: number;
76
+ standby_message: string;
77
+ use_production: boolean;
78
+ }
79
+ export declare type PaymentTerminals = PaymentTerminal[];
80
+ export interface Devices {
81
+ kds_terminals: KdsTerminals;
82
+ pos_chipdna_terminals: PaymentTerminals;
83
+ pos_scanners: PosScanners;
84
+ pos_terminals: PosTerminals;
85
+ prep_stations: PrepStations;
86
+ printers: PosPrinters;
87
+ servers: PosServers;
88
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -5,6 +5,7 @@ export * from './checkout';
5
5
  export * from './config';
6
6
  export * from './customer';
7
7
  export * from './device';
8
+ export * from './devices';
8
9
  export * from './discounts';
9
10
  export * from './employee';
10
11
  export * from './errorAlerts';
@@ -5,6 +5,7 @@ export * from './checkout';
5
5
  export * from './config';
6
6
  export * from './customer';
7
7
  export * from './device';
8
+ export * from './devices';
8
9
  export * from './discounts';
9
10
  export * from './employee';
10
11
  export * from './errorAlerts';
@@ -2,7 +2,6 @@ import { OrdersKds } from './order';
2
2
  export declare type DeviceFontSize = 'xsmall' | 'small' | 'medium' | 'large';
3
3
  export declare type DeviceColorScheme = 'dark' | 'light';
4
4
  export declare type KdsView = 'column' | 'grid' | 'list' | 'tiles';
5
- export declare type KdsPrepType = 'ASSEMBLY' | 'EXPO';
6
5
  export declare type KdsOrderType = 'CURRENT' | 'FUTURE' | 'COMPLETED' | 'INCOMPLETE';
7
6
  export declare type KdsAssemblyOptions = 'AUTO_PRINT' | 'PRINT_DONE' | 'MARK_DONE' | 'PRINT_AND_DONE' | null;
8
7
  export declare type PrepStatus = 'TODO' | 'IN_PROGRESS' | 'DONE' | 'COMPLETED' | 'FULFILLED';
@@ -10,33 +9,6 @@ export declare type PrepStatusMap = {
10
9
  [Property in PrepStatus]: PrepStatus;
11
10
  };
12
11
  export declare type TicketStatus = 'TODO' | 'IN_PROGRESS' | 'DONE' | 'COMPLETED';
13
- export interface PrepStation {
14
- prep_station_id: number;
15
- name: string;
16
- item_type_ids: number[] | null;
17
- prep_type: KdsPrepType;
18
- assembly_options: KdsAssemblyOptions;
19
- expo_done_only: boolean;
20
- expo_print: boolean;
21
- expo_reset: boolean;
22
- expo_complete: boolean;
23
- expo_complete_all: boolean;
24
- show_modifiers: boolean;
25
- show_groups: boolean;
26
- show_counts: boolean;
27
- }
28
- export declare type PrepStations = PrepStation[];
29
- export interface KdsTerminal {
30
- name: string;
31
- ipAddress: string;
32
- prepStations: PrepStations;
33
- defaultView: KdsView;
34
- columns: number;
35
- boxes: number;
36
- cardWidth: number;
37
- fontSize: DeviceFontSize;
38
- colorScheme: DeviceColorScheme;
39
- }
40
12
  export interface KdsStationOrderTypeCount {
41
13
  orders: number;
42
14
  tickets: number;
@@ -1,4 +1,4 @@
1
- import { FetchOrdersAPIArgs, FetchOrdersArgs, HeaderColors, ItemType, ItemTypes, KdsOrderType, KdsPrepType, KdsStationCounts, KdsStationOrderTypeCount, ModifiersMetadata, Order, OrderBuckets, OrderCart, OrderItem, OrderItemCount, OrderKds, Orders, OrdersKds, OrderTickets, OrderTimes, PrepStation, PrepStations, PrepStatus, PrepStatusMap, Store, TicketGroups, Timezone } from '../types';
1
+ import { FetchOrdersAPIArgs, FetchOrdersArgs, HeaderColors, ItemType, ItemTypes, KdsOrderType, PrepStationPrepType, KdsStationCounts, KdsStationOrderTypeCount, ModifiersMetadata, Order, OrderBuckets, OrderCart, OrderItem, OrderItemCount, OrderKds, Orders, OrdersKds, OrderTickets, OrderTimes, PrepStation, PrepStations, PrepStatus, PrepStatusMap, Store, TicketGroups, Timezone } from '../types';
2
2
  export declare const prepStatus: PrepStatusMap;
3
3
  export declare const makeFetchOrdersArgs: ({ businessDate, receiptType, channelType, prepStatus, search, sortBy, sortDirection, parentOrderId }: FetchOrdersArgs) => FetchOrdersAPIArgs;
4
4
  export declare const notDone: (prep_status: PrepStatus) => boolean;
@@ -14,7 +14,7 @@ export declare const makeIncompleteOrders: (orders: OrdersKds) => OrdersKds;
14
14
  export declare const makeCompletedOrders: (orders: OrdersKds) => OrdersKds;
15
15
  export declare const makeOrdersOfType: (orders: OrdersKds, orderType: KdsOrderType) => OrdersKds;
16
16
  export declare const filterOrdersByItemType: (orders: OrdersKds, itemTypeIds: number[] | null) => OrdersKds;
17
- export declare const filterOrdersByPrepType: (orders: OrdersKds, prepType: KdsPrepType) => OrdersKds;
17
+ export declare const filterOrdersByPrepType: (orders: OrdersKds, prepType: PrepStationPrepType) => OrdersKds;
18
18
  export declare const filterOrdersToday: (orders: OrdersKds) => OrdersKds;
19
19
  export declare const makeOrdersForPrepStation: (orders: OrdersKds, prepStation: PrepStation, orderType: KdsOrderType) => OrdersKds;
20
20
  export declare const makeOrderItemSignature: (item: OrderItem, withNotes?: boolean) => string;
@@ -32,7 +32,7 @@ export declare const makeCurrentAndFutureOrders: (orders: OrdersKds) => {
32
32
  current: OrdersKds;
33
33
  future: OrdersKds;
34
34
  };
35
- export declare const makeKdsStationCount: (orders: OrdersKds, itemTypeIds: number[] | null, prepType: KdsPrepType) => KdsStationOrderTypeCount;
35
+ export declare const makeKdsStationCount: (orders: OrdersKds, itemTypeIds: number[] | null, prepType: PrepStationPrepType) => KdsStationOrderTypeCount;
36
36
  export declare const makeKdsStationCounts: (orders: OrdersKds, prepStations: PrepStations) => KdsStationCounts;
37
37
  export declare const makeOrderBuckets: (orders: OrdersKds, tz: Timezone) => OrderBuckets;
38
38
  export declare const makeOrderBucketsCounts: (itemTypes?: ItemTypes, orders?: OrdersKds) => Record<string, number>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/store",
3
- "version": "0.6.1",
3
+ "version": "0.6.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",