@open-tender/store 0.7.2 → 0.7.4
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/services/api.d.ts +66 -66
- package/dist/cjs/services/api.js +1 -1
- package/dist/cjs/slices/arrivals.js +0 -4
- package/dist/cjs/slices/checkout.d.ts +7 -7
- package/dist/cjs/slices/checkout.js +39 -39
- package/dist/cjs/slices/config.d.ts +4 -5
- package/dist/cjs/slices/config.js +17 -21
- package/dist/cjs/slices/discounts.js +9 -8
- package/dist/cjs/slices/errorAlerts.js +3 -1
- package/dist/cjs/slices/kds.js +3 -3
- package/dist/cjs/slices/order.d.ts +8 -23
- package/dist/cjs/slices/order.js +18 -76
- package/dist/cjs/slices/pos.js +1 -1
- package/dist/cjs/slices/settings.d.ts +1 -1
- package/dist/cjs/slices/surcharges.js +4 -3
- package/dist/cjs/slices/taxes.js +9 -8
- package/dist/cjs/types/api/checkout.d.ts +5 -2
- package/dist/cjs/types/api/store.d.ts +9 -16
- package/dist/cjs/types/global.d.ts +2 -0
- package/dist/cjs/utils/datetimes.d.ts +1 -1
- package/dist/esm/services/api.d.ts +66 -66
- package/dist/esm/services/api.js +1 -1
- package/dist/esm/slices/arrivals.js +0 -4
- package/dist/esm/slices/checkout.d.ts +7 -7
- package/dist/esm/slices/checkout.js +39 -39
- package/dist/esm/slices/config.d.ts +4 -5
- package/dist/esm/slices/config.js +17 -20
- package/dist/esm/slices/discounts.js +9 -8
- package/dist/esm/slices/errorAlerts.js +3 -1
- package/dist/esm/slices/kds.js +3 -3
- package/dist/esm/slices/order.d.ts +8 -23
- package/dist/esm/slices/order.js +18 -74
- package/dist/esm/slices/pos.js +1 -1
- package/dist/esm/slices/settings.d.ts +1 -1
- package/dist/esm/slices/surcharges.js +4 -3
- package/dist/esm/slices/taxes.js +9 -8
- package/dist/esm/types/api/checkout.d.ts +5 -2
- package/dist/esm/types/api/store.d.ts +9 -16
- package/dist/esm/types/global.d.ts +2 -0
- package/dist/esm/utils/datetimes.d.ts +1 -1
- package/package.json +1 -1
|
@@ -5,72 +5,72 @@ interface ConfigAPI {
|
|
|
5
5
|
declare class PosAPI {
|
|
6
6
|
apiUrl: string;
|
|
7
7
|
constructor(config: ConfigAPI);
|
|
8
|
-
request: <T>(endpoint: string, method?: string, data?: any) => Promise<T
|
|
9
|
-
post(endpoint: string, data: Record<string, unknown>): Promise<Record<string, unknown
|
|
10
|
-
getConfig(): Promise<Config
|
|
11
|
-
getKioskConfig(): Promise<KioskConfig
|
|
12
|
-
getStore(): Promise<Store
|
|
13
|
-
getSelectOptions(): Promise<SelectOptions
|
|
14
|
-
getItemTypes(): Promise<ItemTypes
|
|
15
|
-
getLevelUpSettings(): Promise<LevelUp
|
|
16
|
-
getCardRead(): Promise<DeviceRead
|
|
17
|
-
postCardCancel(): Promise<null
|
|
18
|
-
getBarcodeRead(): Promise<DeviceRead
|
|
19
|
-
postBarcodeCancel(): Promise<null
|
|
20
|
-
getSettings<T>(posSettingType: PosSettingType): Promise<T
|
|
21
|
-
postSettings(posSettingType
|
|
22
|
-
getInternalSettings(): Promise<InternalSettings
|
|
23
|
-
postInternalSettings(data: InternalSettings): Promise<InternalSettings
|
|
24
|
-
postGiftCardCredit(data: GiftCardCredit, checkOnly
|
|
25
|
-
getGiftCardBalance(code: string | null, cardNumber?: string): Promise<GiftCardBalance
|
|
26
|
-
getEmployee(identifier: string | number): Promise<Employee
|
|
27
|
-
getCashier(): Promise<Employee
|
|
28
|
-
postCardAssign(employeeId: number, code: string): Promise<null
|
|
29
|
-
postCardUnassign(code: string): Promise<null
|
|
30
|
-
postTimePunch(data: Punch): Promise<null
|
|
31
|
-
getTimePunchesReport(businessDate
|
|
32
|
-
postPrintShiftSummary(employeeId: number): Promise<null
|
|
33
|
-
postCashEvent(data: CashEvent): Promise<null
|
|
34
|
-
getCashSummary(employeeId: number): Promise<CashSummary
|
|
35
|
-
postPrintCashSummary(employeeId: number): Promise<null
|
|
36
|
-
getAlerts(): Promise<ErrorAlerts
|
|
37
|
-
getAlert(alertId: number): Promise<ErrorAlert
|
|
38
|
-
putAlert(alertId: number, data: ErrorAlert): Promise<ErrorAlert
|
|
39
|
-
deleteAlert(alertId: number): Promise<null
|
|
40
|
-
getOfflineAuths(): Promise<OfflineAuths
|
|
41
|
-
postOfflineAuths(): Promise<OfflineAuthsResult
|
|
42
|
-
getMenu(revenueCenterId: number, serviceType: ServiceType, requestedAt: RequestedAt): Promise<Menu
|
|
43
|
-
getMenuColors(): Promise<MenuColors
|
|
44
|
-
getMenuPages(): Promise<MenuPages
|
|
45
|
-
getSurcharges(serviceType: ServiceType): Promise<Surcharges
|
|
46
|
-
getDiscounts(serviceType: ServiceType, orderType: OrderType): Promise<Discounts
|
|
47
|
-
getDiscount(name: string): Promise<Discount
|
|
48
|
-
getDiscountViaQRCode(code: string): Promise<Discount
|
|
49
|
-
getTaxes(serviceType: ServiceType, orderType: OrderType): Promise<Taxes
|
|
50
|
-
getRevenueCenter(revenueCenterId: number): Promise<RevenueCenter
|
|
51
|
-
postOpenCashDrawer(): Promise<null
|
|
52
|
-
postTender(orderId: string, data: Tender): Promise<OrderTender
|
|
53
|
-
patchTender(orderId: string, index: number, data: Tender): Promise<OrderTender
|
|
54
|
-
postTenderVoid(orderId: string, index: number): Promise<OrderTender
|
|
8
|
+
request: <T>(endpoint: string, method?: string, data?: any) => Promise<T>;
|
|
9
|
+
post(endpoint: string, data: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
10
|
+
getConfig(): Promise<Config>;
|
|
11
|
+
getKioskConfig(): Promise<KioskConfig>;
|
|
12
|
+
getStore(): Promise<Store>;
|
|
13
|
+
getSelectOptions(): Promise<SelectOptions>;
|
|
14
|
+
getItemTypes(): Promise<ItemTypes>;
|
|
15
|
+
getLevelUpSettings(): Promise<LevelUp>;
|
|
16
|
+
getCardRead(): Promise<DeviceRead>;
|
|
17
|
+
postCardCancel(): Promise<null>;
|
|
18
|
+
getBarcodeRead(): Promise<DeviceRead>;
|
|
19
|
+
postBarcodeCancel(): Promise<null>;
|
|
20
|
+
getSettings<T>(posSettingType: PosSettingType): Promise<T>;
|
|
21
|
+
postSettings(posSettingType?: PosSettingType): Promise<Settings>;
|
|
22
|
+
getInternalSettings(): Promise<InternalSettings>;
|
|
23
|
+
postInternalSettings(data: InternalSettings): Promise<InternalSettings>;
|
|
24
|
+
postGiftCardCredit(data: GiftCardCredit, checkOnly?: boolean): Promise<GiftCardCredit>;
|
|
25
|
+
getGiftCardBalance(code: string | null, cardNumber?: string): Promise<GiftCardBalance>;
|
|
26
|
+
getEmployee(identifier: string | number): Promise<Employee>;
|
|
27
|
+
getCashier(): Promise<Employee>;
|
|
28
|
+
postCardAssign(employeeId: number, code: string): Promise<null>;
|
|
29
|
+
postCardUnassign(code: string): Promise<null>;
|
|
30
|
+
postTimePunch(data: Punch): Promise<null>;
|
|
31
|
+
getTimePunchesReport(businessDate?: string, employeeId?: number): Promise<Employees>;
|
|
32
|
+
postPrintShiftSummary(employeeId: number): Promise<null>;
|
|
33
|
+
postCashEvent(data: CashEvent): Promise<null>;
|
|
34
|
+
getCashSummary(employeeId: number): Promise<CashSummary>;
|
|
35
|
+
postPrintCashSummary(employeeId: number): Promise<null>;
|
|
36
|
+
getAlerts(): Promise<ErrorAlerts>;
|
|
37
|
+
getAlert(alertId: number): Promise<ErrorAlert>;
|
|
38
|
+
putAlert(alertId: number, data: ErrorAlert): Promise<ErrorAlert>;
|
|
39
|
+
deleteAlert(alertId: number): Promise<null>;
|
|
40
|
+
getOfflineAuths(): Promise<OfflineAuths>;
|
|
41
|
+
postOfflineAuths(): Promise<OfflineAuthsResult>;
|
|
42
|
+
getMenu(revenueCenterId: number, serviceType: ServiceType, requestedAt: RequestedAt): Promise<Menu>;
|
|
43
|
+
getMenuColors(): Promise<MenuColors>;
|
|
44
|
+
getMenuPages(): Promise<MenuPages>;
|
|
45
|
+
getSurcharges(serviceType: ServiceType): Promise<Surcharges>;
|
|
46
|
+
getDiscounts(serviceType: ServiceType, orderType: OrderType): Promise<Discounts>;
|
|
47
|
+
getDiscount(name: string): Promise<Discount>;
|
|
48
|
+
getDiscountViaQRCode(code: string): Promise<Discount>;
|
|
49
|
+
getTaxes(serviceType: ServiceType, orderType: OrderType): Promise<Taxes>;
|
|
50
|
+
getRevenueCenter(revenueCenterId: number): Promise<RevenueCenter>;
|
|
51
|
+
postOpenCashDrawer(): Promise<null>;
|
|
52
|
+
postTender(orderId: string, data: Tender): Promise<OrderTender>;
|
|
53
|
+
patchTender(orderId: string, index: number, data: Tender): Promise<OrderTender>;
|
|
54
|
+
postTenderVoid(orderId: string, index: number): Promise<OrderTender>;
|
|
55
55
|
postChipDNATender(orderId: string, data: Tender): Promise<unknown>;
|
|
56
|
-
postChipDNACancel(): Promise<null
|
|
57
|
-
postChipDNATmsUpdate(): Promise<null
|
|
58
|
-
postIdentifyCustomer(data: CustomerIdentifier): Promise<CustomerCheckout
|
|
59
|
-
postOrderValidate(order: OrderCreate): Promise<Order
|
|
60
|
-
postOrder(order: OrderCreate): Promise<Order
|
|
61
|
-
deleteOrder(order: OrderCreate): Promise<Order
|
|
62
|
-
getOrders(args: FetchOrdersAPIArgs): Promise<Orders
|
|
63
|
-
patchOrder(orderId: string, data: OrderUpdate): Promise<Order
|
|
64
|
-
postReceipt(orderId: string): Promise<Order
|
|
65
|
-
putTicketsStatus(orderId: string, data: TicketsUpdate): Promise<Order
|
|
66
|
-
postTicketsPrint(orderId: string, data?: TicketsUpdate): Promise<Order
|
|
67
|
-
postTicketsReset(orderId: string): Promise<Order
|
|
68
|
-
putTicketStatus(orderId: string, ticketNo: number, data
|
|
69
|
-
postTicketPrint(orderId: string, ticketNo: number, data?: TicketUpdate): Promise<Order
|
|
70
|
-
postTicketStatus(orderId: string, ticketNo: number, status: TicketStatusUpdate): Promise<Order
|
|
71
|
-
getArrivals(): Promise<Arrivals
|
|
72
|
-
postAcknowledgeArrival(orderId: string): Promise<Order
|
|
73
|
-
postRefundValidate(orderId: string, refund: Refund): Promise<Order
|
|
74
|
-
postRefund(orderId: string, refund: Refund): Promise<Order
|
|
56
|
+
postChipDNACancel(): Promise<null>;
|
|
57
|
+
postChipDNATmsUpdate(): Promise<null>;
|
|
58
|
+
postIdentifyCustomer(data: CustomerIdentifier): Promise<CustomerCheckout>;
|
|
59
|
+
postOrderValidate(order: OrderCreate): Promise<Order>;
|
|
60
|
+
postOrder(order: OrderCreate): Promise<Order>;
|
|
61
|
+
deleteOrder(order: OrderCreate): Promise<Order>;
|
|
62
|
+
getOrders(args: FetchOrdersAPIArgs): Promise<Orders>;
|
|
63
|
+
patchOrder(orderId: string, data: OrderUpdate): Promise<Order>;
|
|
64
|
+
postReceipt(orderId: string): Promise<Order>;
|
|
65
|
+
putTicketsStatus(orderId: string, data: TicketsUpdate): Promise<Order>;
|
|
66
|
+
postTicketsPrint(orderId: string, data?: TicketsUpdate): Promise<Order>;
|
|
67
|
+
postTicketsReset(orderId: string): Promise<Order>;
|
|
68
|
+
putTicketStatus(orderId: string, ticketNo: number, data?: TicketUpdate): Promise<Order>;
|
|
69
|
+
postTicketPrint(orderId: string, ticketNo: number, data?: TicketUpdate): Promise<Order>;
|
|
70
|
+
postTicketStatus(orderId: string, ticketNo: number, status: TicketStatusUpdate): Promise<Order>;
|
|
71
|
+
getArrivals(): Promise<Arrivals>;
|
|
72
|
+
postAcknowledgeArrival(orderId: string): Promise<Order>;
|
|
73
|
+
postRefundValidate(orderId: string, refund: Refund): Promise<Order>;
|
|
74
|
+
postRefund(orderId: string, refund: Refund): Promise<Order>;
|
|
75
75
|
}
|
|
76
76
|
export default PosAPI;
|
package/dist/cjs/services/api.js
CHANGED
|
@@ -61,7 +61,7 @@ var PosAPI = /** @class */ (function () {
|
|
|
61
61
|
case 1:
|
|
62
62
|
res = _b.sent();
|
|
63
63
|
if (res.status === 204) {
|
|
64
|
-
return [2 /*return
|
|
64
|
+
return [2 /*return*/];
|
|
65
65
|
}
|
|
66
66
|
contentType = (_a = res.headers.get('Content-Type')) === null || _a === void 0 ? void 0 : _a.split(';')[0];
|
|
67
67
|
if (!contentType) {
|
|
@@ -23,8 +23,6 @@ exports.fetchArrivals = (0, toolkit_1.createAsyncThunk)(ArrivalsActionType.Fetch
|
|
|
23
23
|
case 0:
|
|
24
24
|
_b.trys.push([0, 2, , 3]);
|
|
25
25
|
api = getState().config.api;
|
|
26
|
-
if (!api)
|
|
27
|
-
return [2 /*return*/, null];
|
|
28
26
|
return [4 /*yield*/, api.getArrivals()];
|
|
29
27
|
case 1: return [2 /*return*/, _b.sent()];
|
|
30
28
|
case 2:
|
|
@@ -44,8 +42,6 @@ exports.acknowledgeArrival = (0, toolkit_1.createAsyncThunk)(ArrivalsActionType.
|
|
|
44
42
|
case 0:
|
|
45
43
|
_b.trys.push([0, 2, , 3]);
|
|
46
44
|
api = getState().config.api;
|
|
47
|
-
if (!api)
|
|
48
|
-
return [2 /*return*/, null];
|
|
49
45
|
return [4 /*yield*/, api.postAcknowledgeArrival(orderUuid)];
|
|
50
46
|
case 1: return [2 /*return*/, _b.sent()];
|
|
51
47
|
case 2:
|
|
@@ -32,7 +32,7 @@ export declare enum CheckoutActionType {
|
|
|
32
32
|
VoidPosOrder = "checkout/voidPosOrder",
|
|
33
33
|
ActivateGiftCards = "checkout/activateGiftCards"
|
|
34
34
|
}
|
|
35
|
-
export declare const addTender: import("@reduxjs/toolkit").AsyncThunk<OrderTender, Tender, {
|
|
35
|
+
export declare const addTender: import("@reduxjs/toolkit").AsyncThunk<void | OrderTender, Tender, {
|
|
36
36
|
state: AppState;
|
|
37
37
|
rejectValue: RequestError;
|
|
38
38
|
dispatch?: import("redux").Dispatch<import("redux").UnknownAction> | undefined;
|
|
@@ -42,7 +42,7 @@ export declare const addTender: import("@reduxjs/toolkit").AsyncThunk<OrderTende
|
|
|
42
42
|
fulfilledMeta?: unknown;
|
|
43
43
|
rejectedMeta?: unknown;
|
|
44
44
|
}>;
|
|
45
|
-
export declare const removeTender: import("@reduxjs/toolkit").AsyncThunk<OrderTender, number, {
|
|
45
|
+
export declare const removeTender: import("@reduxjs/toolkit").AsyncThunk<void | OrderTender, number, {
|
|
46
46
|
state: AppState;
|
|
47
47
|
rejectValue: RequestError;
|
|
48
48
|
dispatch?: import("redux").Dispatch<import("redux").UnknownAction> | undefined;
|
|
@@ -52,7 +52,7 @@ export declare const removeTender: import("@reduxjs/toolkit").AsyncThunk<OrderTe
|
|
|
52
52
|
fulfilledMeta?: unknown;
|
|
53
53
|
rejectedMeta?: unknown;
|
|
54
54
|
}>;
|
|
55
|
-
export declare const updateTender: import("@reduxjs/toolkit").AsyncThunk<OrderTender, void, {
|
|
55
|
+
export declare const updateTender: import("@reduxjs/toolkit").AsyncThunk<void | OrderTender, void, {
|
|
56
56
|
state: AppState;
|
|
57
57
|
rejectValue: RequestError;
|
|
58
58
|
dispatch?: import("redux").Dispatch<import("redux").UnknownAction> | undefined;
|
|
@@ -72,7 +72,7 @@ export declare const updateCart: import("@reduxjs/toolkit").AsyncThunk<void, any
|
|
|
72
72
|
fulfilledMeta?: unknown;
|
|
73
73
|
rejectedMeta?: unknown;
|
|
74
74
|
}>;
|
|
75
|
-
export declare const identifyCustomer: import("@reduxjs/toolkit").AsyncThunk<CustomerCheckout, IdentifyCustomer, {
|
|
75
|
+
export declare const identifyCustomer: import("@reduxjs/toolkit").AsyncThunk<void | CustomerCheckout, IdentifyCustomer, {
|
|
76
76
|
state: AppState;
|
|
77
77
|
rejectValue: RequestError;
|
|
78
78
|
dispatch?: import("redux").Dispatch<import("redux").UnknownAction> | undefined;
|
|
@@ -92,7 +92,7 @@ export declare const completeChipDNA: import("@reduxjs/toolkit").AsyncThunk<any,
|
|
|
92
92
|
fulfilledMeta?: unknown;
|
|
93
93
|
rejectedMeta?: unknown;
|
|
94
94
|
}>;
|
|
95
|
-
export declare const validatePosOrder: import("@reduxjs/toolkit").AsyncThunk<Order, void, {
|
|
95
|
+
export declare const validatePosOrder: import("@reduxjs/toolkit").AsyncThunk<void | Order, void, {
|
|
96
96
|
state: AppState;
|
|
97
97
|
rejectValue: RequestError;
|
|
98
98
|
dispatch?: import("redux").Dispatch<import("redux").UnknownAction> | undefined;
|
|
@@ -102,7 +102,7 @@ export declare const validatePosOrder: import("@reduxjs/toolkit").AsyncThunk<Ord
|
|
|
102
102
|
fulfilledMeta?: unknown;
|
|
103
103
|
rejectedMeta?: unknown;
|
|
104
104
|
}>;
|
|
105
|
-
export declare const submitPosOrder: import("@reduxjs/toolkit").AsyncThunk<Order, void, {
|
|
105
|
+
export declare const submitPosOrder: import("@reduxjs/toolkit").AsyncThunk<void | Order, void, {
|
|
106
106
|
state: AppState;
|
|
107
107
|
rejectValue: RequestError;
|
|
108
108
|
dispatch?: import("redux").Dispatch<import("redux").UnknownAction> | undefined;
|
|
@@ -112,7 +112,7 @@ export declare const submitPosOrder: import("@reduxjs/toolkit").AsyncThunk<Order
|
|
|
112
112
|
fulfilledMeta?: unknown;
|
|
113
113
|
rejectedMeta?: unknown;
|
|
114
114
|
}>;
|
|
115
|
-
export declare const voidPosOrder: import("@reduxjs/toolkit").AsyncThunk<Order, void, {
|
|
115
|
+
export declare const voidPosOrder: import("@reduxjs/toolkit").AsyncThunk<void | Order, void, {
|
|
116
116
|
state: AppState;
|
|
117
117
|
rejectValue: RequestError;
|
|
118
118
|
dispatch?: import("redux").Dispatch<import("redux").UnknownAction> | undefined;
|
|
@@ -36,12 +36,14 @@ var getAmountDue = function (check) {
|
|
|
36
36
|
return check && check.totals ? check.totals.amount_due : null;
|
|
37
37
|
};
|
|
38
38
|
var prepareOrder = function (order, checkout) {
|
|
39
|
-
var order_uuid = order.orderId, requested_at = order.requestedAt, service_type = order.serviceType, order_type = order.orderType,
|
|
39
|
+
var order_uuid = order.orderId, requested_at = order.requestedAt, service_type = order.serviceType, order_type = order.orderType, revenue_center_id = order.revenueCenterId;
|
|
40
40
|
if (!order_uuid)
|
|
41
41
|
return null;
|
|
42
42
|
var simpleCart = (0, order_1.makeSimpleCart)(order.cart);
|
|
43
43
|
var cart = simpleCart.filter(function (item) { return item; });
|
|
44
|
-
|
|
44
|
+
if (!revenue_center_id || !order_type || !service_type) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
45
47
|
var customer = checkout.customer, gift_cards = checkout.giftCards, surcharges = checkout.surcharges, discounts = checkout.discounts, taxes = checkout.taxes, tip = checkout.tip, isTaxExempt = checkout.isTaxExempt, points = checkout.points;
|
|
46
48
|
var is_tax_exempt = isTaxExempt ? true : false;
|
|
47
49
|
return {
|
|
@@ -142,7 +144,7 @@ exports.removeTender = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Remove
|
|
|
142
144
|
exports.updateTender = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.UpdateTender, function (_, _a) {
|
|
143
145
|
var dispatch = _a.dispatch, getState = _a.getState, rejectWithValue = _a.rejectWithValue;
|
|
144
146
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
145
|
-
var api, orderId, check, tenders, totals, tender, index, amountTender, amountDue, amount,
|
|
147
|
+
var api, orderId, check, tenders, totals, tender, index, amountTender, amountDue, amount, updatedTender, response, err_3;
|
|
146
148
|
return tslib_1.__generator(this, function (_b) {
|
|
147
149
|
switch (_b.label) {
|
|
148
150
|
case 0:
|
|
@@ -161,8 +163,8 @@ exports.updateTender = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Update
|
|
|
161
163
|
amountDue = parseFloat(totals.amount_due || '0.00');
|
|
162
164
|
amount = amountTender + amountDue;
|
|
163
165
|
if (!(amount > 0)) return [3 /*break*/, 2];
|
|
164
|
-
|
|
165
|
-
return [4 /*yield*/, api.patchTender(orderId, index,
|
|
166
|
+
updatedTender = { tender_type: tender.tender_type, amount: amount.toFixed(2) };
|
|
167
|
+
return [4 /*yield*/, api.patchTender(orderId, index, updatedTender)];
|
|
166
168
|
case 1:
|
|
167
169
|
response = _b.sent();
|
|
168
170
|
dispatch((0, exports.validatePosOrder)());
|
|
@@ -172,7 +174,7 @@ exports.updateTender = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Update
|
|
|
172
174
|
var msg = 'Order fully discounted. Tender removed.';
|
|
173
175
|
dispatch((0, notifications_1.showNotification)(msg));
|
|
174
176
|
});
|
|
175
|
-
|
|
177
|
+
return [2 /*return*/];
|
|
176
178
|
case 3: return [3 /*break*/, 5];
|
|
177
179
|
case 4:
|
|
178
180
|
err_3 = _b.sent();
|
|
@@ -222,11 +224,8 @@ exports.identifyCustomer = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Id
|
|
|
222
224
|
return tslib_1.__generator(this, function (_c) {
|
|
223
225
|
switch (_c.label) {
|
|
224
226
|
case 0:
|
|
225
|
-
_c.trys.push([0,
|
|
227
|
+
_c.trys.push([0, 7, , 8]);
|
|
226
228
|
api = getState().config.api;
|
|
227
|
-
if (!api) {
|
|
228
|
-
return [2 /*return*/];
|
|
229
|
-
}
|
|
230
229
|
return [4 /*yield*/, api.postIdentifyCustomer(data)];
|
|
231
230
|
case 1:
|
|
232
231
|
response = _c.sent();
|
|
@@ -244,22 +243,21 @@ exports.identifyCustomer = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Id
|
|
|
244
243
|
return [4 /*yield*/, dispatch((0, exports.validatePosOrder)())];
|
|
245
244
|
case 2:
|
|
246
245
|
_c.sent();
|
|
247
|
-
return [3 /*break*/,
|
|
246
|
+
return [3 /*break*/, 6];
|
|
248
247
|
case 3:
|
|
249
248
|
if (!discounts.length) return [3 /*break*/, 5];
|
|
250
249
|
dispatch((0, exports.setPendingDiscounts)(autoDiscounts.length === 0));
|
|
251
250
|
return [4 /*yield*/, dispatch((0, exports.validatePosOrder)())];
|
|
252
251
|
case 4:
|
|
253
252
|
_c.sent();
|
|
254
|
-
return [3 /*break*/,
|
|
253
|
+
return [3 /*break*/, 6];
|
|
255
254
|
case 5:
|
|
256
|
-
if (
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
_c.
|
|
260
|
-
|
|
261
|
-
case 7:
|
|
262
|
-
case 8:
|
|
255
|
+
if (callback) {
|
|
256
|
+
callback();
|
|
257
|
+
}
|
|
258
|
+
_c.label = 6;
|
|
259
|
+
case 6: return [2 /*return*/, response];
|
|
260
|
+
case 7:
|
|
263
261
|
err_4 = _c.sent();
|
|
264
262
|
if (showError) {
|
|
265
263
|
errMsg = err_4.status === 404
|
|
@@ -267,14 +265,15 @@ exports.identifyCustomer = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Id
|
|
|
267
265
|
: err_4.detail || err_4.message;
|
|
268
266
|
dispatch((0, alerts_1.addAlert)(errMsg));
|
|
269
267
|
}
|
|
270
|
-
if (
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
268
|
+
if (callback) {
|
|
269
|
+
callback();
|
|
270
|
+
return [2 /*return*/];
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
return [2 /*return*/, rejectWithValue(err_4)];
|
|
274
|
+
}
|
|
275
|
+
return [3 /*break*/, 8];
|
|
276
|
+
case 8: return [2 /*return*/];
|
|
278
277
|
}
|
|
279
278
|
});
|
|
280
279
|
});
|
|
@@ -309,10 +308,11 @@ exports.validatePosOrder = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Va
|
|
|
309
308
|
var dispatch = _a.dispatch, getState = _a.getState, rejectWithValue = _a.rejectWithValue;
|
|
310
309
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
311
310
|
var _b, config, order, checkout, preparedOrder, check, orderDiscountIds, checkDiscountIds_1, toRemove, err_6, errors, fields;
|
|
312
|
-
|
|
313
|
-
|
|
311
|
+
var _c;
|
|
312
|
+
return tslib_1.__generator(this, function (_d) {
|
|
313
|
+
switch (_d.label) {
|
|
314
314
|
case 0:
|
|
315
|
-
|
|
315
|
+
_d.trys.push([0, 2, , 3]);
|
|
316
316
|
_b = getState(), config = _b.config, order = _b.order, checkout = _b.checkout;
|
|
317
317
|
preparedOrder = prepareOrder(order, checkout);
|
|
318
318
|
if (!preparedOrder)
|
|
@@ -321,16 +321,16 @@ exports.validatePosOrder = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Va
|
|
|
321
321
|
// remove any submitted discounts that aren't applied
|
|
322
322
|
];
|
|
323
323
|
case 1:
|
|
324
|
-
check =
|
|
325
|
-
orderDiscountIds = preparedOrder.discounts.map(function (i) { return i.id; });
|
|
324
|
+
check = _d.sent();
|
|
325
|
+
orderDiscountIds = (_c = preparedOrder.discounts) === null || _c === void 0 ? void 0 : _c.map(function (i) { return i.id; });
|
|
326
326
|
checkDiscountIds_1 = check.discounts.map(function (i) { return i.id; });
|
|
327
|
-
toRemove = orderDiscountIds.filter(function (id) { return !checkDiscountIds_1.includes(id); });
|
|
328
|
-
toRemove.forEach(function (discountId) {
|
|
327
|
+
toRemove = orderDiscountIds === null || orderDiscountIds === void 0 ? void 0 : orderDiscountIds.filter(function (id) { return !checkDiscountIds_1.includes(id); });
|
|
328
|
+
toRemove === null || toRemove === void 0 ? void 0 : toRemove.forEach(function (discountId) {
|
|
329
329
|
return dispatch((0, exports.removeDiscount)(discountId));
|
|
330
330
|
});
|
|
331
331
|
return [2 /*return*/, check];
|
|
332
332
|
case 2:
|
|
333
|
-
err_6 =
|
|
333
|
+
err_6 = _d.sent();
|
|
334
334
|
errors = (0, utils_1.handleRespError)(err_6).errors;
|
|
335
335
|
fields = errors ? Object.keys(errors) : [];
|
|
336
336
|
if (fields.includes('order_uuid')) {
|
|
@@ -592,7 +592,7 @@ var checkoutSlice = (0, toolkit_1.createSlice)({
|
|
|
592
592
|
state.error = action.payload;
|
|
593
593
|
})
|
|
594
594
|
.addCase(exports.validatePosOrder.fulfilled, function (state, action) {
|
|
595
|
-
state.check = action.payload;
|
|
595
|
+
state.check = action.payload || null;
|
|
596
596
|
state.loading = 'idle';
|
|
597
597
|
state.validating = 'idle';
|
|
598
598
|
state.error = null;
|
|
@@ -607,7 +607,7 @@ var checkoutSlice = (0, toolkit_1.createSlice)({
|
|
|
607
607
|
state.error = action.payload;
|
|
608
608
|
})
|
|
609
609
|
.addCase(exports.submitPosOrder.fulfilled, function (state, action) {
|
|
610
|
-
state.check = action.payload;
|
|
610
|
+
state.check = action.payload || null;
|
|
611
611
|
state.loading = 'idle';
|
|
612
612
|
state.submitting = 'idle';
|
|
613
613
|
state.error = null;
|
|
@@ -654,14 +654,14 @@ exports.selectPosCustomer = selectPosCustomer;
|
|
|
654
654
|
var selectPosCustomerName = function (state) {
|
|
655
655
|
if (!state.checkout.customer)
|
|
656
656
|
return null;
|
|
657
|
-
var _a = state.checkout.customer, first_name = _a.first_name, last_name = _a.last_name;
|
|
657
|
+
var _a = state.checkout.customer.customer, first_name = _a.first_name, last_name = _a.last_name;
|
|
658
658
|
return "".concat(first_name, " ").concat(last_name);
|
|
659
659
|
};
|
|
660
660
|
exports.selectPosCustomerName = selectPosCustomerName;
|
|
661
661
|
var selectPosCustomerNameShort = function (state) {
|
|
662
662
|
if (!state.checkout.customer)
|
|
663
663
|
return null;
|
|
664
|
-
var _a = state.checkout.customer, first_name = _a.first_name, last_name = _a.last_name;
|
|
664
|
+
var _a = state.checkout.customer.customer, first_name = _a.first_name, last_name = _a.last_name;
|
|
665
665
|
var lastName = (last_name === null || last_name === void 0 ? void 0 : last_name.charAt(0)) || '';
|
|
666
666
|
return "".concat(first_name, " ").concat(lastName);
|
|
667
667
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { PosAPI } from '../services';
|
|
1
2
|
import { Devices, MenuColors, RequestError, RequestStatus, SelectOptions, Store, Timezone } from '../types';
|
|
2
3
|
import { AppState } from '../app';
|
|
3
4
|
export interface ConfigApp {
|
|
4
5
|
apiUrl: string;
|
|
5
6
|
}
|
|
6
7
|
export interface ConfigState {
|
|
7
|
-
api:
|
|
8
|
+
api: PosAPI;
|
|
8
9
|
app: ConfigApp | null;
|
|
9
10
|
version?: string | null;
|
|
10
11
|
devices: Devices | null;
|
|
11
12
|
store: Store | null;
|
|
12
|
-
revenueCenterId: number | null;
|
|
13
13
|
selectOptions: SelectOptions | null;
|
|
14
14
|
menuColors: MenuColors | null;
|
|
15
15
|
name: string | null;
|
|
@@ -37,14 +37,13 @@ export declare const fetchConfig: import("@reduxjs/toolkit").AsyncThunk<ConfigSt
|
|
|
37
37
|
}>;
|
|
38
38
|
export declare const resetConfig: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"config/resetConfig">, resetRetries: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"config/resetRetries">, incrementRetries: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"config/incrementRetries">, setVersion: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "config/setVersion">, setApi: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "config/setApi">;
|
|
39
39
|
export declare const selectConfig: (state: AppState) => ConfigState;
|
|
40
|
-
export declare const selectApi: (state: AppState) =>
|
|
40
|
+
export declare const selectApi: (state: AppState) => PosAPI;
|
|
41
41
|
export declare const selectVersion: (state: AppState) => string | null | undefined;
|
|
42
42
|
export declare const selectDevices: (state: AppState) => Devices | null;
|
|
43
43
|
export declare const selectStore: (state: AppState) => Store | null;
|
|
44
|
-
export declare const selectRevenueCenterId: (state: AppState) => number | null;
|
|
45
44
|
export declare const selectSelectOptions: (state: AppState) => SelectOptions;
|
|
46
45
|
export declare const selectMenuColors: (state: AppState) => MenuColors;
|
|
47
|
-
export declare const selectTimezone: (
|
|
46
|
+
export declare const selectTimezone: () => Timezone;
|
|
48
47
|
export declare const selectLoyalty: (state: AppState) => boolean;
|
|
49
48
|
export declare const selectPinpad: (state: AppState) => boolean;
|
|
50
49
|
export declare const selectCashDrawer: (state: AppState) => boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.configReducer = exports.selectCashDrawer = exports.selectPinpad = exports.selectLoyalty = exports.selectTimezone = exports.selectMenuColors = exports.selectSelectOptions = exports.
|
|
4
|
+
exports.configReducer = exports.selectCashDrawer = exports.selectPinpad = exports.selectLoyalty = exports.selectTimezone = exports.selectMenuColors = exports.selectSelectOptions = exports.selectStore = exports.selectDevices = 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,15 +10,14 @@ 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
|
-
|
|
13
|
+
var order_1 = require("./order");
|
|
14
|
+
var defaultApiUrl = "http://".concat(window.location.hostname, ":5001/pos-api");
|
|
14
15
|
var initialState = {
|
|
15
|
-
|
|
16
|
-
api: null,
|
|
16
|
+
api: new services_1.PosAPI({ apiUrl: defaultApiUrl }),
|
|
17
17
|
app: null,
|
|
18
18
|
version: null,
|
|
19
19
|
devices: null,
|
|
20
20
|
store: null,
|
|
21
|
-
revenueCenterId: null,
|
|
22
21
|
selectOptions: null,
|
|
23
22
|
menuColors: null,
|
|
24
23
|
name: null,
|
|
@@ -39,7 +38,7 @@ exports.fetchConfig = (0, toolkit_1.createAsyncThunk)(ConfigActionType.FetchConf
|
|
|
39
38
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
40
39
|
var app, api, _c, _d,
|
|
41
40
|
// config,
|
|
42
|
-
devicesList, _e, stores, _f, selectOptions, _g, itemTypes, store, devices, err, cashier, employee, tz, businessDate, err_1,
|
|
41
|
+
devicesList, _e, stores, _f, selectOptions, _g, itemTypes, store, devices, err, cashier, employee, tz, businessDate, err_1, menuColors, err_2;
|
|
43
42
|
return tslib_1.__generator(this, function (_h) {
|
|
44
43
|
switch (_h.label) {
|
|
45
44
|
case 0:
|
|
@@ -67,10 +66,13 @@ exports.fetchConfig = (0, toolkit_1.createAsyncThunk)(ConfigActionType.FetchConf
|
|
|
67
66
|
_h.label = 2;
|
|
68
67
|
case 2:
|
|
69
68
|
_h.trys.push([2, 4, , 5]);
|
|
70
|
-
return [4 /*yield*/, api.getCashier()
|
|
69
|
+
return [4 /*yield*/, api.getCashier()
|
|
70
|
+
// TODO: figure out how to get the timezone from BE
|
|
71
|
+
// const tz = timezoneMap[store.timezone]
|
|
72
|
+
];
|
|
71
73
|
case 3:
|
|
72
74
|
employee = _h.sent();
|
|
73
|
-
tz = utils_1.
|
|
75
|
+
tz = (0, utils_1.getUserTimezone)();
|
|
74
76
|
businessDate = (0, utils_1.currentLocalDateStr)(tz);
|
|
75
77
|
dispatch((0, pos_1.setCashier)(tslib_1.__assign(tslib_1.__assign({}, employee), { businessDate: businessDate })));
|
|
76
78
|
return [3 /*break*/, 5];
|
|
@@ -78,7 +80,7 @@ exports.fetchConfig = (0, toolkit_1.createAsyncThunk)(ConfigActionType.FetchConf
|
|
|
78
80
|
err_1 = _h.sent();
|
|
79
81
|
return [3 /*break*/, 5];
|
|
80
82
|
case 5:
|
|
81
|
-
|
|
83
|
+
dispatch((0, order_1.setRevenueCenterId)(store.revenue_center_id));
|
|
82
84
|
dispatch((0, kds_1.setKdsItemTypes)(itemTypes));
|
|
83
85
|
dispatch((0, kds_1.setKdsPrepStations)(devices.prep_stations));
|
|
84
86
|
menuColors = [];
|
|
@@ -87,7 +89,6 @@ exports.fetchConfig = (0, toolkit_1.createAsyncThunk)(ConfigActionType.FetchConf
|
|
|
87
89
|
app: app,
|
|
88
90
|
devices: devices,
|
|
89
91
|
store: store,
|
|
90
|
-
revenueCenterId: revenueCenterId,
|
|
91
92
|
selectOptions: selectOptions,
|
|
92
93
|
menuColors: menuColors,
|
|
93
94
|
name: 'Name',
|
|
@@ -130,12 +131,11 @@ var configSlice = (0, toolkit_1.createSlice)({
|
|
|
130
131
|
state.loading = 'pending';
|
|
131
132
|
})
|
|
132
133
|
.addCase(exports.fetchConfig.fulfilled, function (state, action) {
|
|
133
|
-
var _a = action.payload, api = _a.api, app = _a.app, devices = _a.devices, store = _a.store,
|
|
134
|
+
var _a = action.payload, api = _a.api, app = _a.app, devices = _a.devices, store = _a.store, selectOptions = _a.selectOptions, menuColors = _a.menuColors;
|
|
134
135
|
state.api = api;
|
|
135
136
|
state.app = app;
|
|
136
137
|
state.store = store;
|
|
137
138
|
state.devices = devices;
|
|
138
|
-
state.revenueCenterId = revenueCenterId;
|
|
139
139
|
state.selectOptions = selectOptions;
|
|
140
140
|
state.menuColors = menuColors;
|
|
141
141
|
state.loading = 'idle';
|
|
@@ -159,10 +159,6 @@ var selectDevices = function (state) { return state.config.devices; };
|
|
|
159
159
|
exports.selectDevices = selectDevices;
|
|
160
160
|
var selectStore = function (state) { return state.config.store; };
|
|
161
161
|
exports.selectStore = selectStore;
|
|
162
|
-
var selectRevenueCenterId = function (state) {
|
|
163
|
-
return state.config.revenueCenterId;
|
|
164
|
-
};
|
|
165
|
-
exports.selectRevenueCenterId = selectRevenueCenterId;
|
|
166
162
|
var selectSelectOptions = function (state) {
|
|
167
163
|
return state.config.selectOptions || [];
|
|
168
164
|
};
|
|
@@ -171,11 +167,11 @@ var selectMenuColors = function (state) {
|
|
|
171
167
|
return state.config.menuColors || [];
|
|
172
168
|
};
|
|
173
169
|
exports.selectMenuColors = selectMenuColors;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
};
|
|
170
|
+
// export const selectTimezone = (state: AppState): Timezone =>
|
|
171
|
+
// state.config.store
|
|
172
|
+
// ? timezoneMap[state.config.store.timezone as TimezonePython]
|
|
173
|
+
// : (getUserTimezone() as Timezone)
|
|
174
|
+
var selectTimezone = function () { return (0, utils_1.getUserTimezone)(); };
|
|
179
175
|
exports.selectTimezone = selectTimezone;
|
|
180
176
|
var selectLoyalty = function (state) {
|
|
181
177
|
return state.config.store ? state.config.store.has_loyalty : false;
|
|
@@ -17,18 +17,19 @@ var DiscountsActionType;
|
|
|
17
17
|
exports.fetchDiscounts = (0, toolkit_1.createAsyncThunk)(DiscountsActionType.GetDiscounts, function (_, _a) {
|
|
18
18
|
var getState = _a.getState, rejectWithValue = _a.rejectWithValue;
|
|
19
19
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
20
|
-
var api,
|
|
21
|
-
return tslib_1.__generator(this, function (
|
|
22
|
-
switch (
|
|
20
|
+
var api, _b, serviceType, orderType, err_1;
|
|
21
|
+
return tslib_1.__generator(this, function (_c) {
|
|
22
|
+
switch (_c.label) {
|
|
23
23
|
case 0:
|
|
24
|
-
|
|
24
|
+
_c.trys.push([0, 2, , 3]);
|
|
25
25
|
api = getState().config.api;
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
_b = getState().order, serviceType = _b.serviceType, orderType = _b.orderType;
|
|
27
|
+
if (!serviceType || !orderType)
|
|
28
|
+
return [2 /*return*/, []];
|
|
28
29
|
return [4 /*yield*/, api.getDiscounts(serviceType, orderType)];
|
|
29
|
-
case 1: return [2 /*return*/,
|
|
30
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
30
31
|
case 2:
|
|
31
|
-
err_1 =
|
|
32
|
+
err_1 = _c.sent();
|
|
32
33
|
return [2 /*return*/, rejectWithValue(err_1)];
|
|
33
34
|
case 3: return [2 /*return*/];
|
|
34
35
|
}
|
|
@@ -43,7 +43,9 @@ exports.dismissErrorAlert = (0, toolkit_1.createAsyncThunk)(ErrorAlertsActionTyp
|
|
|
43
43
|
_b.trys.push([0, 2, , 3]);
|
|
44
44
|
api = getState().config.api;
|
|
45
45
|
return [4 /*yield*/, api.deleteAlert(alertId)];
|
|
46
|
-
case 1:
|
|
46
|
+
case 1:
|
|
47
|
+
_b.sent();
|
|
48
|
+
return [2 /*return*/];
|
|
47
49
|
case 2:
|
|
48
50
|
err_2 = _b.sent();
|
|
49
51
|
return [2 /*return*/, rejectWithValue(err_2)];
|
package/dist/cjs/slices/kds.js
CHANGED
|
@@ -213,7 +213,7 @@ exports.printTicket = (0, toolkit_1.createAsyncThunk)(KdsActionType.PrintTicket,
|
|
|
213
213
|
case 0:
|
|
214
214
|
_c.trys.push([0, 2, , 3]);
|
|
215
215
|
api = getState().config.api;
|
|
216
|
-
data = status ? { ticket_status: status } :
|
|
216
|
+
data = status ? { ticket_status: status } : undefined;
|
|
217
217
|
return [4 /*yield*/, api.postTicketPrint(orderId, ticketNo, data)];
|
|
218
218
|
case 1:
|
|
219
219
|
order = _c.sent();
|
|
@@ -239,7 +239,7 @@ exports.updateTicket = (0, toolkit_1.createAsyncThunk)(KdsActionType.UpdateTicke
|
|
|
239
239
|
case 0:
|
|
240
240
|
_c.trys.push([0, 2, , 3]);
|
|
241
241
|
api = getState().config.api;
|
|
242
|
-
data = status ? { ticket_status: status } :
|
|
242
|
+
data = status ? { ticket_status: status } : undefined;
|
|
243
243
|
return [4 /*yield*/, api.putTicketStatus(orderId, ticketNo, data)];
|
|
244
244
|
case 1:
|
|
245
245
|
order = _c.sent();
|
|
@@ -315,7 +315,7 @@ exports.completeTicket = (0, toolkit_1.createAsyncThunk)(KdsActionType.CompleteT
|
|
|
315
315
|
case 0:
|
|
316
316
|
_c.trys.push([0, 2, , 3]);
|
|
317
317
|
api = getState().config.api;
|
|
318
|
-
return [4 /*yield*/, api.postTicketStatus(orderId, ticketNo, '
|
|
318
|
+
return [4 /*yield*/, api.postTicketStatus(orderId, ticketNo, 'completed')];
|
|
319
319
|
case 1:
|
|
320
320
|
order = _c.sent();
|
|
321
321
|
dispatch((0, exports.replaceKdsOrder)((0, utils_1.makeKdsOrder)(order)));
|