@open-tender/utils 0.1.158 → 0.1.160
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/utils/cart.d.ts
CHANGED
|
@@ -85,6 +85,7 @@ export declare const rehydrateCheckoutForm: (order: Order) => {
|
|
|
85
85
|
tip: `${number}.${number}`;
|
|
86
86
|
};
|
|
87
87
|
export declare const makeGuestLookup: (cartGuests: GroupOrderGuests) => Record<string, GroupOrderGuest>;
|
|
88
|
+
export declare const compareCarts: (cart: Cart | null) => CartItem[] | null;
|
|
88
89
|
export declare const combineCarts: (cart: Cart, guestCart: Cart, cartOwner: CartOwner, cartGuests: GroupOrderGuests) => {
|
|
89
90
|
madeFor: string | null;
|
|
90
91
|
cartGuestId: number | null;
|
package/dist/cjs/utils/cart.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkAmountRemaining = exports.prepareOrder = exports.getDefaultTip = exports.validateCart = exports.makeSimpleCart = exports.decrementItem = exports.incrementItem = exports.removeItem = exports.addItem = exports.makeCartItemSignature = exports.makeItemSignature = exports.makeFavoritesLookup = exports.makeUniqueDisplayItems = exports.makeDisplayItems = exports.makeDisplayItem = exports.makeDisplayItemGroups = exports.makeItemImageUrl = exports.combineCarts = exports.makeGuestLookup = exports.rehydrateCheckoutForm = exports.rehydrateCart = exports.rehydrateOrderItem = exports.calcCartCounts = exports.makeOrderItem = exports.checkSoldOut = exports.calcPrices = exports.calcNutritionalInfo = exports.calcNutrition = exports.makeUpsellItems = exports.makeModifierGroups = exports.hasGroupsBelowMin = exports.makeModifierNames = exports.getItemOptions = void 0;
|
|
3
|
+
exports.checkAmountRemaining = exports.prepareOrder = exports.getDefaultTip = exports.validateCart = exports.makeSimpleCart = exports.decrementItem = exports.incrementItem = exports.removeItem = exports.addItem = exports.makeCartItemSignature = exports.makeItemSignature = exports.makeFavoritesLookup = exports.makeUniqueDisplayItems = exports.makeDisplayItems = exports.makeDisplayItem = exports.makeDisplayItemGroups = exports.makeItemImageUrl = exports.combineCarts = exports.compareCarts = exports.makeGuestLookup = exports.rehydrateCheckoutForm = exports.rehydrateCart = exports.rehydrateOrderItem = exports.calcCartCounts = exports.makeOrderItem = exports.checkSoldOut = exports.calcPrices = exports.calcNutritionalInfo = exports.calcNutrition = exports.makeUpsellItems = exports.makeModifierGroups = exports.hasGroupsBelowMin = exports.makeModifierNames = exports.getItemOptions = void 0;
|
|
4
4
|
const types_1 = require("@open-tender/types");
|
|
5
5
|
const helpers_1 = require("./helpers");
|
|
6
6
|
// TODO: refactor for nested mods (if needed)
|
|
@@ -396,6 +396,13 @@ const makeGuestLookup = (cartGuests) => {
|
|
|
396
396
|
return cartGuests.reduce((obj, i) => i.cart_guest_id ? Object.assign(Object.assign({}, obj), { [i.cart_guest_id]: i }) : Object.assign({}, obj), {});
|
|
397
397
|
};
|
|
398
398
|
exports.makeGuestLookup = makeGuestLookup;
|
|
399
|
+
const compareCarts = (cart) => {
|
|
400
|
+
if (!cart)
|
|
401
|
+
return null;
|
|
402
|
+
const customerCart = cart.filter(i => !i.cartGuestId);
|
|
403
|
+
return customerCart.length < cart.length ? customerCart : null;
|
|
404
|
+
};
|
|
405
|
+
exports.compareCarts = compareCarts;
|
|
399
406
|
const combineCarts = (cart, guestCart, cartOwner, cartGuests) => {
|
|
400
407
|
const guestLookup = (0, exports.makeGuestLookup)(cartGuests);
|
|
401
408
|
const withGuestNames = guestCart
|
package/dist/esm/utils/cart.d.ts
CHANGED
|
@@ -85,6 +85,7 @@ export declare const rehydrateCheckoutForm: (order: Order) => {
|
|
|
85
85
|
tip: `${number}.${number}`;
|
|
86
86
|
};
|
|
87
87
|
export declare const makeGuestLookup: (cartGuests: GroupOrderGuests) => Record<string, GroupOrderGuest>;
|
|
88
|
+
export declare const compareCarts: (cart: Cart | null) => CartItem[] | null;
|
|
88
89
|
export declare const combineCarts: (cart: Cart, guestCart: Cart, cartOwner: CartOwner, cartGuests: GroupOrderGuests) => {
|
|
89
90
|
madeFor: string | null;
|
|
90
91
|
cartGuestId: number | null;
|
package/dist/esm/utils/cart.js
CHANGED
|
@@ -378,6 +378,12 @@ export const rehydrateCheckoutForm = (order) => {
|
|
|
378
378
|
export const makeGuestLookup = (cartGuests) => {
|
|
379
379
|
return cartGuests.reduce((obj, i) => i.cart_guest_id ? Object.assign(Object.assign({}, obj), { [i.cart_guest_id]: i }) : Object.assign({}, obj), {});
|
|
380
380
|
};
|
|
381
|
+
export const compareCarts = (cart) => {
|
|
382
|
+
if (!cart)
|
|
383
|
+
return null;
|
|
384
|
+
const customerCart = cart.filter(i => !i.cartGuestId);
|
|
385
|
+
return customerCart.length < cart.length ? customerCart : null;
|
|
386
|
+
};
|
|
381
387
|
export const combineCarts = (cart, guestCart, cartOwner, cartGuests) => {
|
|
382
388
|
const guestLookup = makeGuestLookup(cartGuests);
|
|
383
389
|
const withGuestNames = guestCart
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.160",
|
|
4
4
|
"description": "A library of utils for use with Open Tender applications that utilize our cloud-based Order API.",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"react": "^18.2.0"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
+
"@open-tender/types": "^0.2.91",
|
|
62
63
|
"date-fns": "^2.29.3",
|
|
63
64
|
"date-fns-tz": "^1.3.7"
|
|
64
65
|
}
|