@open-tender/store 0.3.7 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/slices/kds.d.ts +8 -11
- package/dist/cjs/slices/kds.js +24 -10
- package/dist/cjs/types/api/kds.d.ts +14 -0
- package/dist/cjs/utils/orders.d.ts +10 -1
- package/dist/cjs/utils/orders.js +36 -1
- package/dist/esm/slices/kds.d.ts +8 -11
- package/dist/esm/slices/kds.js +21 -10
- package/dist/esm/types/api/kds.d.ts +14 -0
- package/dist/esm/utils/orders.d.ts +10 -1
- package/dist/esm/utils/orders.js +32 -0
- package/package.json +1 -1
package/dist/cjs/slices/kds.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AppState } from '../app';
|
|
2
|
-
import { DateString, FetchOrdersArgs, ItemTypes, KdsFontSize, KdsOrderType, KdsView, OrderCounts, OrderKds,
|
|
2
|
+
import { DateString, FetchOrdersArgs, ItemTypes, KdsFontSize, KdsOrderType, KdsStationCounts, KdsView, OrderCounts, OrderKds, OrdersAndStationCounts, OrdersKds, OrderUpdate, PrepStations, RequestError, RequestErrorAPI, RequestStatus, TicketStatus, TicketStatusUpdate } from '../types';
|
|
3
3
|
import { ReducerType } from './types';
|
|
4
4
|
export interface KdsState {
|
|
5
5
|
itemTypes: ItemTypes | null;
|
|
@@ -20,6 +20,7 @@ export interface KdsState {
|
|
|
20
20
|
error: RequestError;
|
|
21
21
|
order: OrderKds | null;
|
|
22
22
|
counts: OrderCounts;
|
|
23
|
+
stationCounts: KdsStationCounts | null;
|
|
23
24
|
}
|
|
24
25
|
export declare enum KdsActionType {
|
|
25
26
|
FetchKdsOrders = "kds/fetchKdsOrders",
|
|
@@ -30,7 +31,7 @@ export declare enum KdsActionType {
|
|
|
30
31
|
PrintTicket = "kds/printTicket",
|
|
31
32
|
UpdateTicket = "kds/updateTicket"
|
|
32
33
|
}
|
|
33
|
-
export declare const fetchKdsOrders: import("@reduxjs/toolkit").AsyncThunk<
|
|
34
|
+
export declare const fetchKdsOrders: import("@reduxjs/toolkit").AsyncThunk<OrdersAndStationCounts, FetchOrdersArgs, {
|
|
34
35
|
state: AppState;
|
|
35
36
|
rejectValue: RequestError;
|
|
36
37
|
}>;
|
|
@@ -168,15 +169,7 @@ export declare const kdsSlice: import("@reduxjs/toolkit").Slice<KdsState, {
|
|
|
168
169
|
totals: import("../types").OrderTotals;
|
|
169
170
|
}[];
|
|
170
171
|
order: OrderKds | null;
|
|
171
|
-
|
|
172
|
-
current: null;
|
|
173
|
-
future: null;
|
|
174
|
-
qa: null;
|
|
175
|
-
} | {
|
|
176
|
-
current: Record<string, number>;
|
|
177
|
-
future: Record<string, number>;
|
|
178
|
-
qa: Record<string, number>;
|
|
179
|
-
};
|
|
172
|
+
stationCounts: KdsStationCounts;
|
|
180
173
|
itemTypes: import("immer/dist/internal").WritableDraft<import("../types").ItemType>[] | null;
|
|
181
174
|
prepStations: import("immer/dist/internal").WritableDraft<import("../types").PrepStation>[];
|
|
182
175
|
prepStationId: number | null;
|
|
@@ -192,11 +185,15 @@ export declare const kdsSlice: import("@reduxjs/toolkit").Slice<KdsState, {
|
|
|
192
185
|
summary: boolean;
|
|
193
186
|
loading: RequestStatus;
|
|
194
187
|
error: import("immer/dist/internal").WritableDraft<RequestErrorAPI> | null | undefined;
|
|
188
|
+
counts: import("immer/dist/internal").WritableDraft<OrderCounts>;
|
|
195
189
|
};
|
|
196
190
|
}, ReducerType.Kds>;
|
|
197
191
|
export declare const resetkds: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setKdsItemTypes: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsPrepStations: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsPrepStationId: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsOrderType: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsColumns: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsBoxes: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsCardWidth: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsFontSize: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsPage: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsView: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsBusinessDate: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsSearch: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, toggleKdsSummary: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setKdsOrder: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, replaceKdsOrder: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>;
|
|
198
192
|
export declare const selectKds: (state: AppState) => KdsState;
|
|
199
193
|
export declare const selectKdsItemTypes: (state: AppState) => ItemTypes | null;
|
|
194
|
+
export declare const selectKdsPrepStations: (state: AppState) => PrepStations;
|
|
195
|
+
export declare const selectKdsPrepStationId: (state: AppState) => number | null;
|
|
196
|
+
export declare const selectKdsOrderType: (state: AppState) => KdsOrderType;
|
|
200
197
|
export declare const selectKdsColumns: (state: AppState) => number;
|
|
201
198
|
export declare const selectKdsBoxes: (state: AppState) => number;
|
|
202
199
|
export declare const selectKdsCardWidth: (state: AppState) => number;
|
package/dist/cjs/slices/kds.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.kdsReducer = exports.selectKdsOrdersCounts = exports.selectKdsPrepStationOrders = exports.selectKdsFutureCount = exports.selectKdsFutureOrders = exports.selectKdsCurrentCount = exports.selectKdsCurrentOrders = exports.selectKdsOrders = exports.selectKdsOrder = exports.selectKdsBusinessDate = exports.selectKdsView = exports.selectKdsPageIndex = exports.selectKdsPage = exports.selectKdsSummary = exports.selectKdsFontSize = exports.selectKdsCardWidth = exports.selectKdsBoxes = exports.selectKdsColumns = exports.selectKdsItemTypes = exports.selectKds = exports.replaceKdsOrder = exports.setKdsOrder = exports.toggleKdsSummary = exports.setKdsSearch = exports.setKdsBusinessDate = exports.setKdsView = exports.setKdsPage = exports.setKdsFontSize = exports.setKdsCardWidth = exports.setKdsBoxes = exports.setKdsColumns = exports.setKdsOrderType = exports.setKdsPrepStationId = exports.setKdsPrepStations = exports.setKdsItemTypes = exports.resetkds = exports.kdsSlice = exports.updateTicket = exports.printTicket = exports.resetTickets = exports.printTickets = exports.printKdsOrder = exports.updateKdsOrder = exports.fetchKdsOrders = exports.KdsActionType = void 0;
|
|
4
|
+
exports.kdsReducer = exports.selectKdsOrdersCounts = exports.selectKdsPrepStationOrders = exports.selectKdsFutureCount = exports.selectKdsFutureOrders = exports.selectKdsCurrentCount = exports.selectKdsCurrentOrders = exports.selectKdsOrders = exports.selectKdsOrder = exports.selectKdsBusinessDate = exports.selectKdsView = exports.selectKdsPageIndex = exports.selectKdsPage = exports.selectKdsSummary = exports.selectKdsFontSize = exports.selectKdsCardWidth = exports.selectKdsBoxes = exports.selectKdsColumns = exports.selectKdsOrderType = exports.selectKdsPrepStationId = exports.selectKdsPrepStations = exports.selectKdsItemTypes = exports.selectKds = exports.replaceKdsOrder = exports.setKdsOrder = exports.toggleKdsSummary = exports.setKdsSearch = exports.setKdsBusinessDate = exports.setKdsView = exports.setKdsPage = exports.setKdsFontSize = exports.setKdsCardWidth = exports.setKdsBoxes = exports.setKdsColumns = exports.setKdsOrderType = exports.setKdsPrepStationId = exports.setKdsPrepStations = exports.setKdsItemTypes = exports.resetkds = exports.kdsSlice = exports.updateTicket = exports.printTicket = exports.resetTickets = exports.printTickets = exports.printKdsOrder = exports.updateKdsOrder = exports.fetchKdsOrders = exports.KdsActionType = void 0;
|
|
5
5
|
var tslib_1 = require("tslib");
|
|
6
6
|
var toolkit_1 = require("@reduxjs/toolkit");
|
|
7
7
|
var types_1 = require("./types");
|
|
@@ -63,7 +63,8 @@ var initialState = {
|
|
|
63
63
|
loading: 'idle',
|
|
64
64
|
error: null,
|
|
65
65
|
order: null,
|
|
66
|
-
counts: { current: null, future: null, qa: null }
|
|
66
|
+
counts: { current: null, future: null, qa: null },
|
|
67
|
+
stationCounts: null
|
|
67
68
|
};
|
|
68
69
|
var KdsActionType;
|
|
69
70
|
(function (KdsActionType) {
|
|
@@ -78,20 +79,24 @@ var KdsActionType;
|
|
|
78
79
|
exports.fetchKdsOrders = (0, toolkit_1.createAsyncThunk)(KdsActionType.FetchKdsOrders, function (params, _a) {
|
|
79
80
|
var getState = _a.getState, rejectWithValue = _a.rejectWithValue;
|
|
80
81
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
81
|
-
var api,
|
|
82
|
+
var api, args, orders, ordersKds, prepStations_1, stationCounts, err_1;
|
|
82
83
|
return tslib_1.__generator(this, function (_b) {
|
|
83
84
|
switch (_b.label) {
|
|
84
85
|
case 0:
|
|
85
86
|
_b.trys.push([0, 2, , 3]);
|
|
86
87
|
api = getState().config.api;
|
|
87
|
-
itemTypes = getState().kds.itemTypes;
|
|
88
88
|
args = (0, utils_1.makeFetchOrdersArgs)(params);
|
|
89
89
|
return [4 /*yield*/, api.getOrders(args)];
|
|
90
90
|
case 1:
|
|
91
91
|
orders = _b.sent();
|
|
92
92
|
ordersKds = (0, utils_1.makeKdsOrders)(orders);
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
prepStations_1 = getState().kds.prepStations;
|
|
94
|
+
stationCounts = prepStations_1
|
|
95
|
+
? (0, utils_1.makeKdsStationCounts)(ordersKds, prepStations_1)
|
|
96
|
+
: null;
|
|
97
|
+
// const itemTypes = getState().kds.itemTypes
|
|
98
|
+
// const counts = makeKdsCounts(itemTypes, ordersKds)
|
|
99
|
+
return [2 /*return*/, { orders: ordersKds, stationCounts: stationCounts }];
|
|
95
100
|
case 2:
|
|
96
101
|
err_1 = _b.sent();
|
|
97
102
|
return [2 /*return*/, rejectWithValue(err_1)];
|
|
@@ -307,17 +312,18 @@ exports.kdsSlice = (0, toolkit_1.createSlice)({
|
|
|
307
312
|
var orders = updatedOrders
|
|
308
313
|
.map(function (i) { return (tslib_1.__assign(tslib_1.__assign({}, i), { fireAt: (0, utils_1.isoToDate)(i.fire_at, tz) })); })
|
|
309
314
|
.sort(function (a, b) { return a.fireAt.getTime() - b.fireAt.getTime(); });
|
|
310
|
-
|
|
315
|
+
// const counts = makeKdsCounts(state.itemTypes, orders)
|
|
316
|
+
var stationCounts = (0, utils_1.makeKdsStationCounts)(updatedOrders, state.prepStations);
|
|
311
317
|
var order = state.order ? updated : null;
|
|
312
|
-
return tslib_1.__assign(tslib_1.__assign({}, state), { orders: orders, order: order,
|
|
318
|
+
return tslib_1.__assign(tslib_1.__assign({}, state), { orders: orders, order: order, stationCounts: stationCounts });
|
|
313
319
|
}
|
|
314
320
|
},
|
|
315
321
|
extraReducers: function (builder) {
|
|
316
322
|
builder
|
|
317
323
|
.addCase(exports.fetchKdsOrders.fulfilled, function (state, action) {
|
|
318
|
-
var _a = action.payload, orders = _a.orders,
|
|
324
|
+
var _a = action.payload, orders = _a.orders, stationCounts = _a.stationCounts;
|
|
319
325
|
state.orders = orders;
|
|
320
|
-
state.
|
|
326
|
+
state.stationCounts = stationCounts;
|
|
321
327
|
state.loading = 'idle';
|
|
322
328
|
state.error = null;
|
|
323
329
|
})
|
|
@@ -395,6 +401,14 @@ var selectKds = function (state) { return state.kds; };
|
|
|
395
401
|
exports.selectKds = selectKds;
|
|
396
402
|
var selectKdsItemTypes = function (state) { return state.kds.itemTypes; };
|
|
397
403
|
exports.selectKdsItemTypes = selectKdsItemTypes;
|
|
404
|
+
var selectKdsPrepStations = function (state) { return state.kds.prepStations; };
|
|
405
|
+
exports.selectKdsPrepStations = selectKdsPrepStations;
|
|
406
|
+
var selectKdsPrepStationId = function (state) {
|
|
407
|
+
return state.kds.prepStationId;
|
|
408
|
+
};
|
|
409
|
+
exports.selectKdsPrepStationId = selectKdsPrepStationId;
|
|
410
|
+
var selectKdsOrderType = function (state) { return state.kds.orderType; };
|
|
411
|
+
exports.selectKdsOrderType = selectKdsOrderType;
|
|
398
412
|
var selectKdsColumns = function (state) { return state.kds.columns; };
|
|
399
413
|
exports.selectKdsColumns = selectKdsColumns;
|
|
400
414
|
var selectKdsBoxes = function (state) { return state.kds.boxes; };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OrdersKds } from './order';
|
|
1
2
|
export declare type PrepStatus = 'TODO' | 'IN_PROGRESS' | 'DONE' | 'COMPLETED' | 'FULFILLED';
|
|
2
3
|
export declare type PrepStatusMap = {
|
|
3
4
|
[Property in PrepStatus]: PrepStatus;
|
|
@@ -28,3 +29,16 @@ export interface KdsTerminal {
|
|
|
28
29
|
cardWidth: number;
|
|
29
30
|
fontSize: KdsFontSize;
|
|
30
31
|
}
|
|
32
|
+
export interface KdsStationOrderTypeCount {
|
|
33
|
+
orders: number;
|
|
34
|
+
ticets: number;
|
|
35
|
+
}
|
|
36
|
+
export interface KdsStationCount {
|
|
37
|
+
CURRENT: KdsStationOrderTypeCount;
|
|
38
|
+
FUTURE: KdsStationOrderTypeCount;
|
|
39
|
+
}
|
|
40
|
+
export declare type KdsStationCounts = Record<string, KdsStationCount>;
|
|
41
|
+
export interface OrdersAndStationCounts {
|
|
42
|
+
orders: OrdersKds;
|
|
43
|
+
stationCounts: KdsStationCounts | null;
|
|
44
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FetchOrdersAPIArgs, FetchOrdersArgs, ItemType, ItemTypes, KdsOrderType, ModifiersMetadata, OrderBuckets, OrderCart, OrderItem, OrderKds, Orders, OrdersKds, OrderTickets, OrderTimes, PrepStation, PrepStatus, PrepStatusMap, Store, TicketGroups, Timezone } from '../types';
|
|
1
|
+
import { FetchOrdersAPIArgs, FetchOrdersArgs, ItemType, ItemTypes, KdsOrderType, KdsStationCounts, ModifiersMetadata, OrderBuckets, OrderCart, OrderItem, 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;
|
|
@@ -21,6 +21,15 @@ export declare const makeKdsCounts: (itemTypes: ItemTypes | null, orders: Orders
|
|
|
21
21
|
future: Record<string, number>;
|
|
22
22
|
qa: Record<string, number>;
|
|
23
23
|
};
|
|
24
|
+
export declare const makeCurrentAndFutureOrders: (orders: OrdersKds) => {
|
|
25
|
+
current: OrdersKds;
|
|
26
|
+
future: OrdersKds;
|
|
27
|
+
};
|
|
28
|
+
export declare const makeKdsStationCount: (orders: OrdersKds, itemTypeIds: number[]) => {
|
|
29
|
+
orders: number;
|
|
30
|
+
tickets: number;
|
|
31
|
+
};
|
|
32
|
+
export declare const makeKdsStationCounts: (orders: OrdersKds, prepStations: PrepStations) => KdsStationCounts;
|
|
24
33
|
export declare const makeOrderBuckets: (orders: OrdersKds, tz: Timezone, prepStates?: Array<PrepStatus>) => OrderBuckets;
|
|
25
34
|
export declare const makeOrderBucketsCounts: (itemTypes?: ItemTypes, orders?: OrdersKds) => Record<string, number>;
|
|
26
35
|
export declare const makeTicketCounts: (tickets: OrderTickets) => Record<string, number>;
|
package/dist/cjs/utils/orders.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeOrderTimes = exports.makeBucketColor = exports.displayCounts = exports.makeDisplayCounts = exports.makeTicketGroups = exports.makeModifiersMetadataLookup = exports.makeCartLookup = exports.makeItemTypesMap = exports.makeItemTypeSettings = exports.makeTicketCounts = exports.makeOrderBucketsCounts = exports.makeOrderBuckets = exports.makeKdsCounts = exports.makeOrdersForPrepStation = exports.filterOrdersByItemType = exports.makeOrdersOfType = exports.makeCompletedOrders = exports.makeFutureOrders = exports.makeCurrentOrders = exports.makeKdsOrders = exports.isCompleted = exports.notCompleted = exports.isDone = exports.notDone = exports.makeFetchOrdersArgs = exports.prepStatus = void 0;
|
|
3
|
+
exports.makeOrderTimes = exports.makeBucketColor = exports.displayCounts = exports.makeDisplayCounts = exports.makeTicketGroups = exports.makeModifiersMetadataLookup = exports.makeCartLookup = exports.makeItemTypesMap = exports.makeItemTypeSettings = exports.makeTicketCounts = exports.makeOrderBucketsCounts = exports.makeOrderBuckets = exports.makeKdsStationCounts = exports.makeKdsStationCount = exports.makeCurrentAndFutureOrders = exports.makeKdsCounts = exports.makeOrdersForPrepStation = exports.filterOrdersByItemType = exports.makeOrdersOfType = exports.makeCompletedOrders = exports.makeFutureOrders = exports.makeCurrentOrders = exports.makeKdsOrders = exports.isCompleted = exports.notCompleted = exports.isDone = exports.notDone = exports.makeFetchOrdersArgs = exports.prepStatus = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var datetimes_1 = require("./datetimes");
|
|
6
6
|
exports.prepStatus = {
|
|
@@ -188,6 +188,41 @@ var makeKdsCounts = function (itemTypes, orders) {
|
|
|
188
188
|
return { current: current, future: future, qa: qa };
|
|
189
189
|
};
|
|
190
190
|
exports.makeKdsCounts = makeKdsCounts;
|
|
191
|
+
var makeCurrentAndFutureOrders = function (orders) {
|
|
192
|
+
var current = [];
|
|
193
|
+
var future = [];
|
|
194
|
+
orders.forEach(function (i) {
|
|
195
|
+
var tz = datetimes_1.timezoneMap[i.timezone];
|
|
196
|
+
var fireDate = i.fire_at ? (0, datetimes_1.isoToDate)(i.fire_at, tz) : null;
|
|
197
|
+
if ((0, exports.isCompleted)(i.prep_status) || !fireDate)
|
|
198
|
+
return;
|
|
199
|
+
var currentDate = (0, datetimes_1.currentLocalDate)(tz);
|
|
200
|
+
if (fireDate < currentDate) {
|
|
201
|
+
current.push(i);
|
|
202
|
+
}
|
|
203
|
+
else if (fireDate > currentDate) {
|
|
204
|
+
future.push(i);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
return { current: current, future: future };
|
|
208
|
+
};
|
|
209
|
+
exports.makeCurrentAndFutureOrders = makeCurrentAndFutureOrders;
|
|
210
|
+
var makeKdsStationCount = function (orders, itemTypeIds) {
|
|
211
|
+
var filtered = (0, exports.filterOrdersByItemType)(orders, itemTypeIds);
|
|
212
|
+
var tickets = filtered.reduce(function (arr, i) { return tslib_1.__spreadArray(tslib_1.__spreadArray([], arr, true), i.tickets, true); }, []);
|
|
213
|
+
return { orders: filtered.length, tickets: tickets.length };
|
|
214
|
+
};
|
|
215
|
+
exports.makeKdsStationCount = makeKdsStationCount;
|
|
216
|
+
var makeKdsStationCounts = function (orders, prepStations) {
|
|
217
|
+
var _a = (0, exports.makeCurrentAndFutureOrders)(orders), currentOrders = _a.current, futureOrders = _a.future;
|
|
218
|
+
return prepStations.reduce(function (obj, i) {
|
|
219
|
+
var _a;
|
|
220
|
+
var current = (0, exports.makeKdsStationCount)(currentOrders, i.item_type_ids);
|
|
221
|
+
var future = (0, exports.makeKdsStationCount)(futureOrders, i.item_type_ids);
|
|
222
|
+
return tslib_1.__assign(tslib_1.__assign({}, obj), (_a = {}, _a[i.prep_station_id] = { CURRENT: current, FUTURE: future }, _a));
|
|
223
|
+
}, {});
|
|
224
|
+
};
|
|
225
|
+
exports.makeKdsStationCounts = makeKdsStationCounts;
|
|
191
226
|
var makeOrderBuckets = function (orders, tz, prepStates) {
|
|
192
227
|
if (prepStates === void 0) { prepStates = []; }
|
|
193
228
|
var intervals = (0, datetimes_1.makeIntervals)(tz);
|
package/dist/esm/slices/kds.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AppState } from '../app';
|
|
2
|
-
import { DateString, FetchOrdersArgs, ItemTypes, KdsFontSize, KdsOrderType, KdsView, OrderCounts, OrderKds,
|
|
2
|
+
import { DateString, FetchOrdersArgs, ItemTypes, KdsFontSize, KdsOrderType, KdsStationCounts, KdsView, OrderCounts, OrderKds, OrdersAndStationCounts, OrdersKds, OrderUpdate, PrepStations, RequestError, RequestErrorAPI, RequestStatus, TicketStatus, TicketStatusUpdate } from '../types';
|
|
3
3
|
import { ReducerType } from './types';
|
|
4
4
|
export interface KdsState {
|
|
5
5
|
itemTypes: ItemTypes | null;
|
|
@@ -20,6 +20,7 @@ export interface KdsState {
|
|
|
20
20
|
error: RequestError;
|
|
21
21
|
order: OrderKds | null;
|
|
22
22
|
counts: OrderCounts;
|
|
23
|
+
stationCounts: KdsStationCounts | null;
|
|
23
24
|
}
|
|
24
25
|
export declare enum KdsActionType {
|
|
25
26
|
FetchKdsOrders = "kds/fetchKdsOrders",
|
|
@@ -30,7 +31,7 @@ export declare enum KdsActionType {
|
|
|
30
31
|
PrintTicket = "kds/printTicket",
|
|
31
32
|
UpdateTicket = "kds/updateTicket"
|
|
32
33
|
}
|
|
33
|
-
export declare const fetchKdsOrders: import("@reduxjs/toolkit").AsyncThunk<
|
|
34
|
+
export declare const fetchKdsOrders: import("@reduxjs/toolkit").AsyncThunk<OrdersAndStationCounts, FetchOrdersArgs, {
|
|
34
35
|
state: AppState;
|
|
35
36
|
rejectValue: RequestError;
|
|
36
37
|
}>;
|
|
@@ -168,15 +169,7 @@ export declare const kdsSlice: import("@reduxjs/toolkit").Slice<KdsState, {
|
|
|
168
169
|
totals: import("../types").OrderTotals;
|
|
169
170
|
}[];
|
|
170
171
|
order: OrderKds | null;
|
|
171
|
-
|
|
172
|
-
current: null;
|
|
173
|
-
future: null;
|
|
174
|
-
qa: null;
|
|
175
|
-
} | {
|
|
176
|
-
current: Record<string, number>;
|
|
177
|
-
future: Record<string, number>;
|
|
178
|
-
qa: Record<string, number>;
|
|
179
|
-
};
|
|
172
|
+
stationCounts: KdsStationCounts;
|
|
180
173
|
itemTypes: import("immer/dist/internal").WritableDraft<import("../types").ItemType>[] | null;
|
|
181
174
|
prepStations: import("immer/dist/internal").WritableDraft<import("../types").PrepStation>[];
|
|
182
175
|
prepStationId: number | null;
|
|
@@ -192,11 +185,15 @@ export declare const kdsSlice: import("@reduxjs/toolkit").Slice<KdsState, {
|
|
|
192
185
|
summary: boolean;
|
|
193
186
|
loading: RequestStatus;
|
|
194
187
|
error: import("immer/dist/internal").WritableDraft<RequestErrorAPI> | null | undefined;
|
|
188
|
+
counts: import("immer/dist/internal").WritableDraft<OrderCounts>;
|
|
195
189
|
};
|
|
196
190
|
}, ReducerType.Kds>;
|
|
197
191
|
export declare const resetkds: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setKdsItemTypes: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsPrepStations: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsPrepStationId: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsOrderType: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsColumns: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsBoxes: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsCardWidth: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsFontSize: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsPage: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsView: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsBusinessDate: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setKdsSearch: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, toggleKdsSummary: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setKdsOrder: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, replaceKdsOrder: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>;
|
|
198
192
|
export declare const selectKds: (state: AppState) => KdsState;
|
|
199
193
|
export declare const selectKdsItemTypes: (state: AppState) => ItemTypes | null;
|
|
194
|
+
export declare const selectKdsPrepStations: (state: AppState) => PrepStations;
|
|
195
|
+
export declare const selectKdsPrepStationId: (state: AppState) => number | null;
|
|
196
|
+
export declare const selectKdsOrderType: (state: AppState) => KdsOrderType;
|
|
200
197
|
export declare const selectKdsColumns: (state: AppState) => number;
|
|
201
198
|
export declare const selectKdsBoxes: (state: AppState) => number;
|
|
202
199
|
export declare const selectKdsCardWidth: (state: AppState) => number;
|
package/dist/esm/slices/kds.js
CHANGED
|
@@ -2,7 +2,7 @@ var _a;
|
|
|
2
2
|
import { __assign, __awaiter, __generator } from "tslib";
|
|
3
3
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
4
4
|
import { ReducerType } from './types';
|
|
5
|
-
import { currentLocalDate, isoToDate, makeFetchOrdersArgs,
|
|
5
|
+
import { currentLocalDate, isoToDate, makeFetchOrdersArgs, makeKdsOrders, makeKdsStationCounts, makeOrdersForPrepStation, notDone, timezoneMap } from '../utils';
|
|
6
6
|
import { addAlert } from './alerts';
|
|
7
7
|
var prepStations = [
|
|
8
8
|
{
|
|
@@ -60,7 +60,8 @@ var initialState = {
|
|
|
60
60
|
loading: 'idle',
|
|
61
61
|
error: null,
|
|
62
62
|
order: null,
|
|
63
|
-
counts: { current: null, future: null, qa: null }
|
|
63
|
+
counts: { current: null, future: null, qa: null },
|
|
64
|
+
stationCounts: null
|
|
64
65
|
};
|
|
65
66
|
export var KdsActionType;
|
|
66
67
|
(function (KdsActionType) {
|
|
@@ -75,20 +76,24 @@ export var KdsActionType;
|
|
|
75
76
|
export var fetchKdsOrders = createAsyncThunk(KdsActionType.FetchKdsOrders, function (params, _a) {
|
|
76
77
|
var getState = _a.getState, rejectWithValue = _a.rejectWithValue;
|
|
77
78
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
-
var api,
|
|
79
|
+
var api, args, orders, ordersKds, prepStations_1, stationCounts, err_1;
|
|
79
80
|
return __generator(this, function (_b) {
|
|
80
81
|
switch (_b.label) {
|
|
81
82
|
case 0:
|
|
82
83
|
_b.trys.push([0, 2, , 3]);
|
|
83
84
|
api = getState().config.api;
|
|
84
|
-
itemTypes = getState().kds.itemTypes;
|
|
85
85
|
args = makeFetchOrdersArgs(params);
|
|
86
86
|
return [4 /*yield*/, api.getOrders(args)];
|
|
87
87
|
case 1:
|
|
88
88
|
orders = _b.sent();
|
|
89
89
|
ordersKds = makeKdsOrders(orders);
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
prepStations_1 = getState().kds.prepStations;
|
|
91
|
+
stationCounts = prepStations_1
|
|
92
|
+
? makeKdsStationCounts(ordersKds, prepStations_1)
|
|
93
|
+
: null;
|
|
94
|
+
// const itemTypes = getState().kds.itemTypes
|
|
95
|
+
// const counts = makeKdsCounts(itemTypes, ordersKds)
|
|
96
|
+
return [2 /*return*/, { orders: ordersKds, stationCounts: stationCounts }];
|
|
92
97
|
case 2:
|
|
93
98
|
err_1 = _b.sent();
|
|
94
99
|
return [2 /*return*/, rejectWithValue(err_1)];
|
|
@@ -304,17 +309,18 @@ export var kdsSlice = createSlice({
|
|
|
304
309
|
var orders = updatedOrders
|
|
305
310
|
.map(function (i) { return (__assign(__assign({}, i), { fireAt: isoToDate(i.fire_at, tz) })); })
|
|
306
311
|
.sort(function (a, b) { return a.fireAt.getTime() - b.fireAt.getTime(); });
|
|
307
|
-
|
|
312
|
+
// const counts = makeKdsCounts(state.itemTypes, orders)
|
|
313
|
+
var stationCounts = makeKdsStationCounts(updatedOrders, state.prepStations);
|
|
308
314
|
var order = state.order ? updated : null;
|
|
309
|
-
return __assign(__assign({}, state), { orders: orders, order: order,
|
|
315
|
+
return __assign(__assign({}, state), { orders: orders, order: order, stationCounts: stationCounts });
|
|
310
316
|
}
|
|
311
317
|
},
|
|
312
318
|
extraReducers: function (builder) {
|
|
313
319
|
builder
|
|
314
320
|
.addCase(fetchKdsOrders.fulfilled, function (state, action) {
|
|
315
|
-
var _a = action.payload, orders = _a.orders,
|
|
321
|
+
var _a = action.payload, orders = _a.orders, stationCounts = _a.stationCounts;
|
|
316
322
|
state.orders = orders;
|
|
317
|
-
state.
|
|
323
|
+
state.stationCounts = stationCounts;
|
|
318
324
|
state.loading = 'idle';
|
|
319
325
|
state.error = null;
|
|
320
326
|
})
|
|
@@ -390,6 +396,11 @@ export var kdsSlice = createSlice({
|
|
|
390
396
|
export var resetkds = (_a = kdsSlice.actions, _a.resetkds), setKdsItemTypes = _a.setKdsItemTypes, setKdsPrepStations = _a.setKdsPrepStations, setKdsPrepStationId = _a.setKdsPrepStationId, setKdsOrderType = _a.setKdsOrderType, setKdsColumns = _a.setKdsColumns, setKdsBoxes = _a.setKdsBoxes, setKdsCardWidth = _a.setKdsCardWidth, setKdsFontSize = _a.setKdsFontSize, setKdsPage = _a.setKdsPage, setKdsView = _a.setKdsView, setKdsBusinessDate = _a.setKdsBusinessDate, setKdsSearch = _a.setKdsSearch, toggleKdsSummary = _a.toggleKdsSummary, setKdsOrder = _a.setKdsOrder, replaceKdsOrder = _a.replaceKdsOrder;
|
|
391
397
|
export var selectKds = function (state) { return state.kds; };
|
|
392
398
|
export var selectKdsItemTypes = function (state) { return state.kds.itemTypes; };
|
|
399
|
+
export var selectKdsPrepStations = function (state) { return state.kds.prepStations; };
|
|
400
|
+
export var selectKdsPrepStationId = function (state) {
|
|
401
|
+
return state.kds.prepStationId;
|
|
402
|
+
};
|
|
403
|
+
export var selectKdsOrderType = function (state) { return state.kds.orderType; };
|
|
393
404
|
export var selectKdsColumns = function (state) { return state.kds.columns; };
|
|
394
405
|
export var selectKdsBoxes = function (state) { return state.kds.boxes; };
|
|
395
406
|
export var selectKdsCardWidth = function (state) { return state.kds.cardWidth; };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OrdersKds } from './order';
|
|
1
2
|
export declare type PrepStatus = 'TODO' | 'IN_PROGRESS' | 'DONE' | 'COMPLETED' | 'FULFILLED';
|
|
2
3
|
export declare type PrepStatusMap = {
|
|
3
4
|
[Property in PrepStatus]: PrepStatus;
|
|
@@ -28,3 +29,16 @@ export interface KdsTerminal {
|
|
|
28
29
|
cardWidth: number;
|
|
29
30
|
fontSize: KdsFontSize;
|
|
30
31
|
}
|
|
32
|
+
export interface KdsStationOrderTypeCount {
|
|
33
|
+
orders: number;
|
|
34
|
+
ticets: number;
|
|
35
|
+
}
|
|
36
|
+
export interface KdsStationCount {
|
|
37
|
+
CURRENT: KdsStationOrderTypeCount;
|
|
38
|
+
FUTURE: KdsStationOrderTypeCount;
|
|
39
|
+
}
|
|
40
|
+
export declare type KdsStationCounts = Record<string, KdsStationCount>;
|
|
41
|
+
export interface OrdersAndStationCounts {
|
|
42
|
+
orders: OrdersKds;
|
|
43
|
+
stationCounts: KdsStationCounts | null;
|
|
44
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FetchOrdersAPIArgs, FetchOrdersArgs, ItemType, ItemTypes, KdsOrderType, ModifiersMetadata, OrderBuckets, OrderCart, OrderItem, OrderKds, Orders, OrdersKds, OrderTickets, OrderTimes, PrepStation, PrepStatus, PrepStatusMap, Store, TicketGroups, Timezone } from '../types';
|
|
1
|
+
import { FetchOrdersAPIArgs, FetchOrdersArgs, ItemType, ItemTypes, KdsOrderType, KdsStationCounts, ModifiersMetadata, OrderBuckets, OrderCart, OrderItem, 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;
|
|
@@ -21,6 +21,15 @@ export declare const makeKdsCounts: (itemTypes: ItemTypes | null, orders: Orders
|
|
|
21
21
|
future: Record<string, number>;
|
|
22
22
|
qa: Record<string, number>;
|
|
23
23
|
};
|
|
24
|
+
export declare const makeCurrentAndFutureOrders: (orders: OrdersKds) => {
|
|
25
|
+
current: OrdersKds;
|
|
26
|
+
future: OrdersKds;
|
|
27
|
+
};
|
|
28
|
+
export declare const makeKdsStationCount: (orders: OrdersKds, itemTypeIds: number[]) => {
|
|
29
|
+
orders: number;
|
|
30
|
+
tickets: number;
|
|
31
|
+
};
|
|
32
|
+
export declare const makeKdsStationCounts: (orders: OrdersKds, prepStations: PrepStations) => KdsStationCounts;
|
|
24
33
|
export declare const makeOrderBuckets: (orders: OrdersKds, tz: Timezone, prepStates?: Array<PrepStatus>) => OrderBuckets;
|
|
25
34
|
export declare const makeOrderBucketsCounts: (itemTypes?: ItemTypes, orders?: OrdersKds) => Record<string, number>;
|
|
26
35
|
export declare const makeTicketCounts: (tickets: OrderTickets) => Record<string, number>;
|
package/dist/esm/utils/orders.js
CHANGED
|
@@ -172,6 +172,38 @@ export var makeKdsCounts = function (itemTypes, orders) {
|
|
|
172
172
|
console.timeEnd('makeKdsCounts');
|
|
173
173
|
return { current: current, future: future, qa: qa };
|
|
174
174
|
};
|
|
175
|
+
export var makeCurrentAndFutureOrders = function (orders) {
|
|
176
|
+
var current = [];
|
|
177
|
+
var future = [];
|
|
178
|
+
orders.forEach(function (i) {
|
|
179
|
+
var tz = timezoneMap[i.timezone];
|
|
180
|
+
var fireDate = i.fire_at ? isoToDate(i.fire_at, tz) : null;
|
|
181
|
+
if (isCompleted(i.prep_status) || !fireDate)
|
|
182
|
+
return;
|
|
183
|
+
var currentDate = currentLocalDate(tz);
|
|
184
|
+
if (fireDate < currentDate) {
|
|
185
|
+
current.push(i);
|
|
186
|
+
}
|
|
187
|
+
else if (fireDate > currentDate) {
|
|
188
|
+
future.push(i);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
return { current: current, future: future };
|
|
192
|
+
};
|
|
193
|
+
export var makeKdsStationCount = function (orders, itemTypeIds) {
|
|
194
|
+
var filtered = filterOrdersByItemType(orders, itemTypeIds);
|
|
195
|
+
var tickets = filtered.reduce(function (arr, i) { return __spreadArray(__spreadArray([], arr, true), i.tickets, true); }, []);
|
|
196
|
+
return { orders: filtered.length, tickets: tickets.length };
|
|
197
|
+
};
|
|
198
|
+
export var makeKdsStationCounts = function (orders, prepStations) {
|
|
199
|
+
var _a = makeCurrentAndFutureOrders(orders), currentOrders = _a.current, futureOrders = _a.future;
|
|
200
|
+
return prepStations.reduce(function (obj, i) {
|
|
201
|
+
var _a;
|
|
202
|
+
var current = makeKdsStationCount(currentOrders, i.item_type_ids);
|
|
203
|
+
var future = makeKdsStationCount(futureOrders, i.item_type_ids);
|
|
204
|
+
return __assign(__assign({}, obj), (_a = {}, _a[i.prep_station_id] = { CURRENT: current, FUTURE: future }, _a));
|
|
205
|
+
}, {});
|
|
206
|
+
};
|
|
175
207
|
export var makeOrderBuckets = function (orders, tz, prepStates) {
|
|
176
208
|
if (prepStates === void 0) { prepStates = []; }
|
|
177
209
|
var intervals = makeIntervals(tz);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/store",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
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",
|