@open-tender/store 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OrderState } from './order';
|
|
2
2
|
import { AppState } from '../app';
|
|
3
|
-
import { CustomerIdentifier, CustomerIdentify, Money, Order, OrderCreate, OrderCreateDiscounts, OrderCreateGiftCards, OrderCreatePoints, OrderCreateSurcharges, OrderTender, RequestError, RequestStatus, Taxes } from '@open-tender/types';
|
|
3
|
+
import { CustomerIdentifier, CustomerIdentify, Money, Order, OrderCreate, OrderCreateDiscount, OrderCreateDiscounts, OrderCreateGiftCards, OrderCreatePoints, OrderCreateSurcharge, OrderCreateSurcharges, OrderTender, RequestError, RequestStatus, Taxes } from '@open-tender/types';
|
|
4
4
|
import { Tender } from '../types';
|
|
5
5
|
export interface CheckoutState {
|
|
6
6
|
activating: RequestStatus;
|
|
@@ -143,7 +143,7 @@ export declare const activateGiftCards: import("@reduxjs/toolkit").AsyncThunk<an
|
|
|
143
143
|
fulfilledMeta?: unknown;
|
|
144
144
|
rejectedMeta?: unknown;
|
|
145
145
|
}>;
|
|
146
|
-
export declare const resetPosCheckout: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheckout">, resetPosCheck: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheck">, handleCheckoutError: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/handleCheckoutError">, addGiftCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addGiftCard">, removeGiftCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeGiftCard">, addSurcharge: import("@reduxjs/toolkit").ActionCreatorWithPayload<
|
|
146
|
+
export declare const resetPosCheckout: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheckout">, resetPosCheck: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheck">, handleCheckoutError: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/handleCheckoutError">, addGiftCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addGiftCard">, removeGiftCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeGiftCard">, addSurcharge: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateSurcharge, "checkout/addSurcharge">, removeSurcharge: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateSurcharge, "checkout/removeSurcharge">, addDiscount: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateDiscount, "checkout/addDiscount">, removeDiscount: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateDiscount, "checkout/removeDiscount">, addTax: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addTax">, removeTax: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeTax">, addTip: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addTip">, removeTip: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/removeTip">, setTaxExempt: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setTaxExempt">, addCustomer: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addCustomer">, removeCustomer: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/removeCustomer">, setPendingDiscounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPendingDiscounts">, setPoints: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPoints">, setMadeFor: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setMadeFor">, setPhone: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPhone">;
|
|
147
147
|
export declare const selectPosCheckout: (state: AppState) => CheckoutState;
|
|
148
148
|
export declare const selectPosCheck: (state: AppState) => Order | null;
|
|
149
149
|
export declare const selectPosCustomer: (state: AppState) => CustomerIdentify | null;
|
|
@@ -255,7 +255,7 @@ exports.identifyCustomer = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Id
|
|
|
255
255
|
var msg = "".concat(i.name, " discount applied!");
|
|
256
256
|
dispatch((0, notifications_1.showNotification)(msg));
|
|
257
257
|
});
|
|
258
|
-
if (!(points && points > 0)) return [3 /*break*/, 3];
|
|
258
|
+
if (!(points && parseInt(points) > 0)) return [3 /*break*/, 3];
|
|
259
259
|
dispatch((0, exports.setPendingDiscounts)(true));
|
|
260
260
|
return [4 /*yield*/, dispatch((0, exports.validatePosOrder)())];
|
|
261
261
|
case 2:
|
|
@@ -324,7 +324,7 @@ exports.completeChipDNA = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Com
|
|
|
324
324
|
exports.validatePosOrder = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.ValidatePosOrder, function (_, _a) {
|
|
325
325
|
var dispatch = _a.dispatch, getState = _a.getState, rejectWithValue = _a.rejectWithValue;
|
|
326
326
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
327
|
-
var _b, config, order, checkout, preparedOrder, check,
|
|
327
|
+
var _b, config, order, checkout, preparedOrder, check, submitted, validated_1, toRemove, err_6, errors, fields;
|
|
328
328
|
var _c;
|
|
329
329
|
return tslib_1.__generator(this, function (_d) {
|
|
330
330
|
switch (_d.label) {
|
|
@@ -339,12 +339,10 @@ exports.validatePosOrder = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Va
|
|
|
339
339
|
];
|
|
340
340
|
case 1:
|
|
341
341
|
check = _d.sent();
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
toRemove =
|
|
345
|
-
toRemove === null || toRemove === void 0 ? void 0 : toRemove.forEach(function (
|
|
346
|
-
return dispatch((0, exports.removeDiscount)(discountId));
|
|
347
|
-
});
|
|
342
|
+
submitted = (_c = preparedOrder.discounts) === null || _c === void 0 ? void 0 : _c.map(function (i) { return i.id; });
|
|
343
|
+
validated_1 = check.discounts.map(function (i) { return i.id; });
|
|
344
|
+
toRemove = submitted === null || submitted === void 0 ? void 0 : submitted.filter(function (id) { return !validated_1.includes(id); });
|
|
345
|
+
toRemove === null || toRemove === void 0 ? void 0 : toRemove.forEach(function (id) { return dispatch((0, exports.removeDiscount)({ id: id })); });
|
|
348
346
|
return [2 /*return*/, check];
|
|
349
347
|
case 2:
|
|
350
348
|
err_6 = _d.sent();
|
|
@@ -482,20 +480,22 @@ var checkoutSlice = (0, toolkit_1.createSlice)({
|
|
|
482
480
|
state.surcharges.push(action.payload);
|
|
483
481
|
},
|
|
484
482
|
removeSurcharge: function (state, action) {
|
|
485
|
-
|
|
483
|
+
var id = action.payload.id;
|
|
484
|
+
state.surcharges = state.surcharges.filter(function (i) { return i.id !== id; });
|
|
486
485
|
},
|
|
487
486
|
addDiscount: function (state, action) {
|
|
488
487
|
state.discounts.push(action.payload);
|
|
489
488
|
},
|
|
490
489
|
removeDiscount: function (state, action) {
|
|
490
|
+
var id = action.payload.id;
|
|
491
491
|
var discount = state.check
|
|
492
|
-
? state.check.discounts.find(function (i) { return i.id ===
|
|
492
|
+
? state.check.discounts.find(function (i) { return i.id === id; })
|
|
493
493
|
: null;
|
|
494
494
|
if (discount && discount.discount_type === 'LOYALTY') {
|
|
495
495
|
state.points = [];
|
|
496
496
|
}
|
|
497
497
|
else {
|
|
498
|
-
state.discounts = state.discounts.filter(function (i) { return i.id !==
|
|
498
|
+
state.discounts = state.discounts.filter(function (i) { return i.id !== id; });
|
|
499
499
|
}
|
|
500
500
|
},
|
|
501
501
|
addTax: function (state, action) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OrderState } from './order';
|
|
2
2
|
import { AppState } from '../app';
|
|
3
|
-
import { CustomerIdentifier, CustomerIdentify, Money, Order, OrderCreate, OrderCreateDiscounts, OrderCreateGiftCards, OrderCreatePoints, OrderCreateSurcharges, OrderTender, RequestError, RequestStatus, Taxes } from '@open-tender/types';
|
|
3
|
+
import { CustomerIdentifier, CustomerIdentify, Money, Order, OrderCreate, OrderCreateDiscount, OrderCreateDiscounts, OrderCreateGiftCards, OrderCreatePoints, OrderCreateSurcharge, OrderCreateSurcharges, OrderTender, RequestError, RequestStatus, Taxes } from '@open-tender/types';
|
|
4
4
|
import { Tender } from '../types';
|
|
5
5
|
export interface CheckoutState {
|
|
6
6
|
activating: RequestStatus;
|
|
@@ -143,7 +143,7 @@ export declare const activateGiftCards: import("@reduxjs/toolkit").AsyncThunk<an
|
|
|
143
143
|
fulfilledMeta?: unknown;
|
|
144
144
|
rejectedMeta?: unknown;
|
|
145
145
|
}>;
|
|
146
|
-
export declare const resetPosCheckout: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheckout">, resetPosCheck: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheck">, handleCheckoutError: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/handleCheckoutError">, addGiftCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addGiftCard">, removeGiftCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeGiftCard">, addSurcharge: import("@reduxjs/toolkit").ActionCreatorWithPayload<
|
|
146
|
+
export declare const resetPosCheckout: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheckout">, resetPosCheck: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheck">, handleCheckoutError: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/handleCheckoutError">, addGiftCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addGiftCard">, removeGiftCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeGiftCard">, addSurcharge: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateSurcharge, "checkout/addSurcharge">, removeSurcharge: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateSurcharge, "checkout/removeSurcharge">, addDiscount: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateDiscount, "checkout/addDiscount">, removeDiscount: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateDiscount, "checkout/removeDiscount">, addTax: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addTax">, removeTax: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeTax">, addTip: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addTip">, removeTip: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/removeTip">, setTaxExempt: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setTaxExempt">, addCustomer: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addCustomer">, removeCustomer: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/removeCustomer">, setPendingDiscounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPendingDiscounts">, setPoints: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPoints">, setMadeFor: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setMadeFor">, setPhone: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPhone">;
|
|
147
147
|
export declare const selectPosCheckout: (state: AppState) => CheckoutState;
|
|
148
148
|
export declare const selectPosCheck: (state: AppState) => Order | null;
|
|
149
149
|
export declare const selectPosCustomer: (state: AppState) => CustomerIdentify | null;
|
|
@@ -251,7 +251,7 @@ export var identifyCustomer = createAsyncThunk(CheckoutActionType.IdentifyCustom
|
|
|
251
251
|
var msg = "".concat(i.name, " discount applied!");
|
|
252
252
|
dispatch(showNotification(msg));
|
|
253
253
|
});
|
|
254
|
-
if (!(points && points > 0)) return [3 /*break*/, 3];
|
|
254
|
+
if (!(points && parseInt(points) > 0)) return [3 /*break*/, 3];
|
|
255
255
|
dispatch(setPendingDiscounts(true));
|
|
256
256
|
return [4 /*yield*/, dispatch(validatePosOrder())];
|
|
257
257
|
case 2:
|
|
@@ -320,7 +320,7 @@ export var completeChipDNA = createAsyncThunk(CheckoutActionType.CompleteChipDNA
|
|
|
320
320
|
export var validatePosOrder = createAsyncThunk(CheckoutActionType.ValidatePosOrder, function (_, _a) {
|
|
321
321
|
var dispatch = _a.dispatch, getState = _a.getState, rejectWithValue = _a.rejectWithValue;
|
|
322
322
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
323
|
-
var _b, config, order, checkout, preparedOrder, check,
|
|
323
|
+
var _b, config, order, checkout, preparedOrder, check, submitted, validated_1, toRemove, err_6, errors, fields;
|
|
324
324
|
var _c;
|
|
325
325
|
return __generator(this, function (_d) {
|
|
326
326
|
switch (_d.label) {
|
|
@@ -335,12 +335,10 @@ export var validatePosOrder = createAsyncThunk(CheckoutActionType.ValidatePosOrd
|
|
|
335
335
|
];
|
|
336
336
|
case 1:
|
|
337
337
|
check = _d.sent();
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
toRemove =
|
|
341
|
-
toRemove === null || toRemove === void 0 ? void 0 : toRemove.forEach(function (
|
|
342
|
-
return dispatch(removeDiscount(discountId));
|
|
343
|
-
});
|
|
338
|
+
submitted = (_c = preparedOrder.discounts) === null || _c === void 0 ? void 0 : _c.map(function (i) { return i.id; });
|
|
339
|
+
validated_1 = check.discounts.map(function (i) { return i.id; });
|
|
340
|
+
toRemove = submitted === null || submitted === void 0 ? void 0 : submitted.filter(function (id) { return !validated_1.includes(id); });
|
|
341
|
+
toRemove === null || toRemove === void 0 ? void 0 : toRemove.forEach(function (id) { return dispatch(removeDiscount({ id: id })); });
|
|
344
342
|
return [2 /*return*/, check];
|
|
345
343
|
case 2:
|
|
346
344
|
err_6 = _d.sent();
|
|
@@ -478,20 +476,22 @@ var checkoutSlice = createSlice({
|
|
|
478
476
|
state.surcharges.push(action.payload);
|
|
479
477
|
},
|
|
480
478
|
removeSurcharge: function (state, action) {
|
|
481
|
-
|
|
479
|
+
var id = action.payload.id;
|
|
480
|
+
state.surcharges = state.surcharges.filter(function (i) { return i.id !== id; });
|
|
482
481
|
},
|
|
483
482
|
addDiscount: function (state, action) {
|
|
484
483
|
state.discounts.push(action.payload);
|
|
485
484
|
},
|
|
486
485
|
removeDiscount: function (state, action) {
|
|
486
|
+
var id = action.payload.id;
|
|
487
487
|
var discount = state.check
|
|
488
|
-
? state.check.discounts.find(function (i) { return i.id ===
|
|
488
|
+
? state.check.discounts.find(function (i) { return i.id === id; })
|
|
489
489
|
: null;
|
|
490
490
|
if (discount && discount.discount_type === 'LOYALTY') {
|
|
491
491
|
state.points = [];
|
|
492
492
|
}
|
|
493
493
|
else {
|
|
494
|
-
state.discounts = state.discounts.filter(function (i) { return i.id !==
|
|
494
|
+
state.discounts = state.discounts.filter(function (i) { return i.id !== id; });
|
|
495
495
|
}
|
|
496
496
|
},
|
|
497
497
|
addTax: function (state, action) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/store",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
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",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@emotion/react": "^11.11.1",
|
|
61
|
-
"@open-tender/types": "^0.4.
|
|
61
|
+
"@open-tender/types": "^0.4.27",
|
|
62
62
|
"@open-tender/ui": "^0.1.21",
|
|
63
63
|
"@open-tender/utils": "^0.4.9",
|
|
64
64
|
"@reduxjs/toolkit": "^2.0.1",
|