@open-tender/store 0.6.0 → 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, LevelUp, 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,15 +7,11 @@ 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;
17
14
  menuColors: MenuColors | null;
18
- levelup: LevelUp | null;
19
15
  loading: RequestStatus;
20
16
  error: RequestError | null;
21
17
  retries: number;
@@ -33,8 +29,6 @@ export declare const resetConfig: import("@reduxjs/toolkit").ActionCreatorWithou
33
29
  export declare const selectConfig: (state: AppState) => ConfigState;
34
30
  export declare const selectApi: (state: AppState) => any;
35
31
  export declare const selectVersion: (state: AppState) => string | null | undefined;
36
- export declare const selectPinpad: (state: AppState) => boolean;
37
- export declare const selectCashDrawer: (state: AppState) => boolean;
38
32
  export declare const selectRevenueCenterId: (state: AppState) => number | null;
39
33
  export declare const selectStore: (state: AppState) => Store | null;
40
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,19 +10,17 @@ 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,
24
23
  menuColors: null,
25
- levelup: null,
26
24
  loading: 'idle',
27
25
  error: null,
28
26
  retries: 0
@@ -35,7 +33,9 @@ exports.fetchConfig = (0, toolkit_1.createAsyncThunk)(ConfigActionType.FetchConf
35
33
  var apiUrl = _a.apiUrl;
36
34
  var dispatch = _b.dispatch, getState = _b.getState, rejectWithValue = _b.rejectWithValue;
37
35
  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;
36
+ var app, api, _c, _d,
37
+ // config,
38
+ devices, _e, store, _f, selectOptions, _g, itemTypes, err, cashier, employee, tz, businessDate, err_1, revenueCenterId, menuColors, err_2;
39
39
  return tslib_1.__generator(this, function (_h) {
40
40
  switch (_h.label) {
41
41
  case 0:
@@ -43,16 +43,16 @@ exports.fetchConfig = (0, toolkit_1.createAsyncThunk)(ConfigActionType.FetchConf
43
43
  app = { apiUrl: apiUrl };
44
44
  api = new services_1.PosAPI(app);
45
45
  return [4 /*yield*/, Promise.all([
46
- api.getConfig(),
47
- api.getStore(),
48
- api.getSelectOptions(),
49
- api.getMenuColors(),
50
- api.getItemTypes(),
51
- api.getLevelUpSettings()
46
+ // api.getConfig(),
47
+ api.getSettings('DEVICES'),
48
+ api.getSettings('STORE'),
49
+ api.getSettings('SELECT_OPTION'),
50
+ api.getSettings('ITEM_TYPE')
51
+ // api.getMenuColors(),
52
52
  ])];
53
53
  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) {
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;
55
+ if (!store) {
56
56
  err = errors_1.errorsApi.internalServerError;
57
57
  return [2 /*return*/, rejectWithValue(err)];
58
58
  }
@@ -73,21 +73,17 @@ exports.fetchConfig = (0, toolkit_1.createAsyncThunk)(ConfigActionType.FetchConf
73
73
  return [3 /*break*/, 5];
74
74
  case 5:
75
75
  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;
77
76
  dispatch((0, kds_1.setKdsItemTypes)(itemTypes));
78
- dispatch((0, kds_1.setKdsPrepStations)(prep_stations));
77
+ dispatch((0, kds_1.setKdsPrepStations)(devices === null || devices === void 0 ? void 0 : devices.prep_stations));
78
+ menuColors = [];
79
79
  return [2 /*return*/, {
80
80
  api: api,
81
81
  app: app,
82
+ devices: devices,
82
83
  store: store,
83
84
  revenueCenterId: revenueCenterId,
84
- name: name_1,
85
- ipAddress: ipAddress,
86
- hasPinpad: hasPinpad,
87
- hasCashDrawer: hasCashDrawer,
88
85
  selectOptions: selectOptions,
89
86
  menuColors: menuColors,
90
- levelup: levelup,
91
87
  error: null,
92
88
  loading: 'idle',
93
89
  retries: 0
@@ -120,25 +116,21 @@ var configSlice = (0, toolkit_1.createSlice)({
120
116
  },
121
117
  extraReducers: function (builder) {
122
118
  builder
119
+ .addCase(exports.fetchConfig.pending, function (state) {
120
+ state.loading = 'pending';
121
+ })
123
122
  .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;
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;
125
124
  state.api = api;
126
125
  state.app = app;
127
- state.name = name;
128
- state.ipAddress = ipAddress;
129
- state.hasPinpad = hasPinpad;
130
- state.hasCashDrawer = hasCashDrawer;
131
126
  state.store = store;
127
+ state.devices = devices;
132
128
  state.revenueCenterId = revenueCenterId;
133
129
  state.selectOptions = selectOptions;
134
130
  state.menuColors = menuColors;
135
- state.levelup = levelup;
136
131
  state.loading = 'idle';
137
132
  state.retries = 0;
138
133
  state.error = null;
139
- })
140
- .addCase(exports.fetchConfig.pending, function (state) {
141
- state.loading = 'pending';
142
134
  })
143
135
  .addCase(exports.fetchConfig.rejected, function (state, action) {
144
136
  state.error = action.payload;
@@ -153,10 +145,6 @@ var selectApi = function (state) { return state.config.api; };
153
145
  exports.selectApi = selectApi;
154
146
  var selectVersion = function (state) { return state.config.version; };
155
147
  exports.selectVersion = selectVersion;
156
- var selectPinpad = function (state) { return state.config.hasPinpad; };
157
- exports.selectPinpad = selectPinpad;
158
- var selectCashDrawer = function (state) { return state.config.hasCashDrawer; };
159
- exports.selectCashDrawer = selectCashDrawer;
160
148
  var selectRevenueCenterId = function (state) {
161
149
  return state.config.revenueCenterId;
162
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, LevelUp, 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,15 +7,11 @@ 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;
17
14
  menuColors: MenuColors | null;
18
- levelup: LevelUp | null;
19
15
  loading: RequestStatus;
20
16
  error: RequestError | null;
21
17
  retries: number;
@@ -33,8 +29,6 @@ export declare const resetConfig: import("@reduxjs/toolkit").ActionCreatorWithou
33
29
  export declare const selectConfig: (state: AppState) => ConfigState;
34
30
  export declare const selectApi: (state: AppState) => any;
35
31
  export declare const selectVersion: (state: AppState) => string | null | undefined;
36
- export declare const selectPinpad: (state: AppState) => boolean;
37
- export declare const selectCashDrawer: (state: AppState) => boolean;
38
32
  export declare const selectRevenueCenterId: (state: AppState) => number | null;
39
33
  export declare const selectStore: (state: AppState) => Store | null;
40
34
  export declare const selectSelectOptions: (state: AppState) => SelectOptions;
@@ -7,19 +7,17 @@ import { timezoneMap, getUserTimezone, currentLocalDateStr } from '../utils';
7
7
  import { errorsApi } from '../services/errors';
8
8
  import { setCashier } from './pos';
9
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,
21
20
  menuColors: null,
22
- levelup: null,
23
21
  loading: 'idle',
24
22
  error: null,
25
23
  retries: 0
@@ -32,7 +30,9 @@ export var fetchConfig = createAsyncThunk(ConfigActionType.FetchConfig, function
32
30
  var apiUrl = _a.apiUrl;
33
31
  var dispatch = _b.dispatch, getState = _b.getState, rejectWithValue = _b.rejectWithValue;
34
32
  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;
33
+ var app, api, _c, _d,
34
+ // config,
35
+ devices, _e, store, _f, selectOptions, _g, itemTypes, err, cashier, employee, tz, businessDate, err_1, revenueCenterId, menuColors, err_2;
36
36
  return __generator(this, function (_h) {
37
37
  switch (_h.label) {
38
38
  case 0:
@@ -40,16 +40,16 @@ export var fetchConfig = createAsyncThunk(ConfigActionType.FetchConfig, function
40
40
  app = { apiUrl: apiUrl };
41
41
  api = new PosAPI(app);
42
42
  return [4 /*yield*/, Promise.all([
43
- api.getConfig(),
44
- api.getStore(),
45
- api.getSelectOptions(),
46
- api.getMenuColors(),
47
- api.getItemTypes(),
48
- api.getLevelUpSettings()
43
+ // api.getConfig(),
44
+ api.getSettings('DEVICES'),
45
+ api.getSettings('STORE'),
46
+ api.getSettings('SELECT_OPTION'),
47
+ api.getSettings('ITEM_TYPE')
48
+ // api.getMenuColors(),
49
49
  ])];
50
50
  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) {
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;
52
+ if (!store) {
53
53
  err = errorsApi.internalServerError;
54
54
  return [2 /*return*/, rejectWithValue(err)];
55
55
  }
@@ -70,21 +70,17 @@ export var fetchConfig = createAsyncThunk(ConfigActionType.FetchConfig, function
70
70
  return [3 /*break*/, 5];
71
71
  case 5:
72
72
  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;
74
73
  dispatch(setKdsItemTypes(itemTypes));
75
- dispatch(setKdsPrepStations(prep_stations));
74
+ dispatch(setKdsPrepStations(devices === null || devices === void 0 ? void 0 : devices.prep_stations));
75
+ menuColors = [];
76
76
  return [2 /*return*/, {
77
77
  api: api,
78
78
  app: app,
79
+ devices: devices,
79
80
  store: store,
80
81
  revenueCenterId: revenueCenterId,
81
- name: name_1,
82
- ipAddress: ipAddress,
83
- hasPinpad: hasPinpad,
84
- hasCashDrawer: hasCashDrawer,
85
82
  selectOptions: selectOptions,
86
83
  menuColors: menuColors,
87
- levelup: levelup,
88
84
  error: null,
89
85
  loading: 'idle',
90
86
  retries: 0
@@ -117,25 +113,21 @@ var configSlice = createSlice({
117
113
  },
118
114
  extraReducers: function (builder) {
119
115
  builder
116
+ .addCase(fetchConfig.pending, function (state) {
117
+ state.loading = 'pending';
118
+ })
120
119
  .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;
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;
122
121
  state.api = api;
123
122
  state.app = app;
124
- state.name = name;
125
- state.ipAddress = ipAddress;
126
- state.hasPinpad = hasPinpad;
127
- state.hasCashDrawer = hasCashDrawer;
128
123
  state.store = store;
124
+ state.devices = devices;
129
125
  state.revenueCenterId = revenueCenterId;
130
126
  state.selectOptions = selectOptions;
131
127
  state.menuColors = menuColors;
132
- state.levelup = levelup;
133
128
  state.loading = 'idle';
134
129
  state.retries = 0;
135
130
  state.error = null;
136
- })
137
- .addCase(fetchConfig.pending, function (state) {
138
- state.loading = 'pending';
139
131
  })
140
132
  .addCase(fetchConfig.rejected, function (state, action) {
141
133
  state.error = action.payload;
@@ -147,8 +139,6 @@ export var resetConfig = (_a = configSlice.actions, _a.resetConfig), resetRetrie
147
139
  export var selectConfig = function (state) { return state.config; };
148
140
  export var selectApi = function (state) { return state.config.api; };
149
141
  export var selectVersion = function (state) { return state.config.version; };
150
- export var selectPinpad = function (state) { return state.config.hasPinpad; };
151
- export var selectCashDrawer = function (state) { return state.config.hasCashDrawer; };
152
142
  export var selectRevenueCenterId = function (state) {
153
143
  return state.config.revenueCenterId;
154
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.0",
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",