@open-tender/store 0.5.20 → 0.5.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.DS_Store +0 -0
- package/dist/cjs/types/api/cart.d.ts +0 -6
- package/dist/cjs/types/api/checkout.d.ts +8 -0
- package/dist/cjs/utils/order.d.ts +67 -2
- package/dist/cjs/utils/order.js +32 -1
- package/dist/esm/types/api/cart.d.ts +0 -6
- package/dist/esm/types/api/checkout.d.ts +8 -0
- package/dist/esm/utils/order.d.ts +67 -2
- package/dist/esm/utils/order.js +30 -0
- package/package.json +1 -1
package/dist/.DS_Store
CHANGED
|
Binary file
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { NutritionalInfo } from './menu';
|
|
2
|
-
export interface GuestItem {
|
|
3
|
-
cart_guest_id?: number | null;
|
|
4
|
-
customer_id?: number | null;
|
|
5
|
-
made_for: string | null;
|
|
6
|
-
notes: string | null;
|
|
7
|
-
}
|
|
8
2
|
export interface CartItemOption {
|
|
9
3
|
allergens: string[];
|
|
10
4
|
cals: number | null;
|
|
@@ -45,12 +45,20 @@ export interface SimpleCartGroup {
|
|
|
45
45
|
id: number;
|
|
46
46
|
options: Array<SimpleCartOption>;
|
|
47
47
|
}
|
|
48
|
+
export declare type SimpleOptionLookup = Record<number, SimpleCartOption>;
|
|
49
|
+
export interface SimpleCartGroupLookup {
|
|
50
|
+
id: number;
|
|
51
|
+
options: SimpleOptionLookup;
|
|
52
|
+
}
|
|
53
|
+
export declare type SimpleCartGroupsLookup = Record<number, SimpleCartGroupLookup>;
|
|
48
54
|
export interface SimpleCartItem {
|
|
49
55
|
id: number;
|
|
50
56
|
quantity: number;
|
|
51
57
|
groups?: Array<SimpleCartGroup>;
|
|
52
58
|
made_for?: string;
|
|
53
59
|
notes?: string;
|
|
60
|
+
cart_guest_id?: number | null;
|
|
61
|
+
customer_id?: number | null;
|
|
54
62
|
}
|
|
55
63
|
export declare type SimpleCart = Array<SimpleCartItem>;
|
|
56
64
|
export interface OrderCreateDetails {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cart, CartItem, CartItemOption, FullOrderType,
|
|
1
|
+
import { Cart, CartItem, CartItemOption, FullOrderType, MenuItem, NutritionalInfo, OrderChannel, OrderTenders, OrderType, OrderTypeMap, ServiceTypeMap, SimpleCart, SimpleCartItem, SoldOut, TenderType, TenderTypeMap } from '../types';
|
|
2
2
|
export declare const orderTypeNamesMap: OrderTypeMap;
|
|
3
3
|
export declare const normalizeOrderType: (orderType: FullOrderType) => OrderType;
|
|
4
4
|
export declare const serviceTypeNamesMap: ServiceTypeMap;
|
|
@@ -73,7 +73,7 @@ export declare const calcPrices: (item: CartItem) => {
|
|
|
73
73
|
similarItems: number[];
|
|
74
74
|
};
|
|
75
75
|
export declare const calcNutrition: (item: CartItem) => NutritionalInfo | null;
|
|
76
|
-
export declare const makeCartItem: (item: MenuItem, isEdit?: boolean, soldOut?:
|
|
76
|
+
export declare const makeCartItem: (item: MenuItem, isEdit?: boolean, soldOut?: SoldOut, simpleItem?: SimpleCartItem, hasPoints?: boolean) => {
|
|
77
77
|
groups: {
|
|
78
78
|
quantity: number;
|
|
79
79
|
options: {
|
|
@@ -139,6 +139,71 @@ export declare const makeCartItem: (item: MenuItem, isEdit?: boolean, soldOut?:
|
|
|
139
139
|
similarItems: number[];
|
|
140
140
|
};
|
|
141
141
|
export declare const makeCartItemSignature: (item: CartItem, withNotes?: boolean) => string;
|
|
142
|
+
export declare const rehydrateCartItem: (menuItem: MenuItem, simpleCartItem: SimpleCartItem) => {
|
|
143
|
+
groups: {
|
|
144
|
+
quantity: number;
|
|
145
|
+
options: {
|
|
146
|
+
totalPrice: number;
|
|
147
|
+
totalPoints: number;
|
|
148
|
+
totalCals: number;
|
|
149
|
+
allergens: string[];
|
|
150
|
+
cals: number | null;
|
|
151
|
+
color?: string | null | undefined;
|
|
152
|
+
description: string | null;
|
|
153
|
+
id: number;
|
|
154
|
+
imageUrl: string | null;
|
|
155
|
+
increment: number;
|
|
156
|
+
ingredients: string | null;
|
|
157
|
+
isDefault: boolean;
|
|
158
|
+
isSoldOut: boolean;
|
|
159
|
+
max: number;
|
|
160
|
+
min: number;
|
|
161
|
+
name: string;
|
|
162
|
+
nutritionalInfo: NutritionalInfo | null;
|
|
163
|
+
points: number;
|
|
164
|
+
price: number;
|
|
165
|
+
quantity: number;
|
|
166
|
+
shortName: string;
|
|
167
|
+
tags: string[];
|
|
168
|
+
}[];
|
|
169
|
+
id: number;
|
|
170
|
+
name: string;
|
|
171
|
+
description: string | null;
|
|
172
|
+
imageUrl: string | null;
|
|
173
|
+
included: number;
|
|
174
|
+
max: number;
|
|
175
|
+
min: number;
|
|
176
|
+
isSize: boolean;
|
|
177
|
+
}[];
|
|
178
|
+
totalPrice: number;
|
|
179
|
+
totalPoints: number | null;
|
|
180
|
+
totalCals: number | null;
|
|
181
|
+
index?: number | undefined;
|
|
182
|
+
id: number;
|
|
183
|
+
name: string;
|
|
184
|
+
shortName: string;
|
|
185
|
+
cart_guest_id?: number | null | undefined;
|
|
186
|
+
category: string;
|
|
187
|
+
customer_id?: number | null | undefined;
|
|
188
|
+
description: string | null;
|
|
189
|
+
imageUrl: string | null;
|
|
190
|
+
slug: string;
|
|
191
|
+
allergens: string[];
|
|
192
|
+
tags: string[];
|
|
193
|
+
ingredients: string | null;
|
|
194
|
+
madeFor?: string | null | undefined;
|
|
195
|
+
notes?: string | null | undefined;
|
|
196
|
+
nutritionalInfo: NutritionalInfo | null;
|
|
197
|
+
cals: number | null;
|
|
198
|
+
quantity: number;
|
|
199
|
+
price: number;
|
|
200
|
+
increment: number;
|
|
201
|
+
max: number;
|
|
202
|
+
min: number;
|
|
203
|
+
points: number | null;
|
|
204
|
+
upsellItems: number[];
|
|
205
|
+
similarItems: number[];
|
|
206
|
+
};
|
|
142
207
|
export declare const addItem: (cart: Cart, item: CartItem) => {
|
|
143
208
|
cart: Cart;
|
|
144
209
|
cartCounts: {};
|
package/dist/cjs/utils/order.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getItemOptions = exports.calcCartCounts = exports.makeSimpleCart = exports.decrementItem = exports.incrementItem = exports.removeItem = exports.addItem = exports.makeCartItemSignature = exports.makeCartItem = exports.calcNutrition = exports.calcPrices = exports.findCreditCardToken = exports.calcCashBack = exports.makeChannelName = exports.makeTenderTypeName = exports.tenderTypeNamesMap = exports.serviceTypeNamesMap = exports.normalizeOrderType = exports.orderTypeNamesMap = void 0;
|
|
3
|
+
exports.getItemOptions = exports.calcCartCounts = exports.makeSimpleCart = exports.decrementItem = exports.incrementItem = exports.removeItem = exports.addItem = exports.rehydrateCartItem = exports.makeCartItemSignature = exports.makeCartItem = exports.calcNutrition = exports.calcPrices = exports.findCreditCardToken = exports.calcCashBack = exports.makeChannelName = exports.makeTenderTypeName = exports.tenderTypeNamesMap = exports.serviceTypeNamesMap = exports.normalizeOrderType = exports.orderTypeNamesMap = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var helpers_1 = require("./helpers");
|
|
6
6
|
exports.orderTypeNamesMap = {
|
|
@@ -263,6 +263,37 @@ var makeCartItemSignature = function (item, withNotes) {
|
|
|
263
263
|
return withNotes ? "".concat(itemIds, ".").concat(item.madeFor, ".").concat(item.notes) : itemIds;
|
|
264
264
|
};
|
|
265
265
|
exports.makeCartItemSignature = makeCartItemSignature;
|
|
266
|
+
var makeGroupsLookup = function (item) {
|
|
267
|
+
if (!item.groups)
|
|
268
|
+
return {};
|
|
269
|
+
return item.groups.reduce(function (grpObj, i) {
|
|
270
|
+
var options = i.options.reduce(function (optObj, o) {
|
|
271
|
+
optObj[o.id] = o;
|
|
272
|
+
return optObj;
|
|
273
|
+
}, {});
|
|
274
|
+
grpObj[i.id] = tslib_1.__assign(tslib_1.__assign({}, i), { options: options });
|
|
275
|
+
return grpObj;
|
|
276
|
+
}, {});
|
|
277
|
+
};
|
|
278
|
+
var rehydrateCartItem = function (menuItem, simpleCartItem) {
|
|
279
|
+
var orderItem = (0, exports.makeCartItem)(menuItem, true, [], simpleCartItem);
|
|
280
|
+
orderItem.quantity = simpleCartItem.quantity || 1;
|
|
281
|
+
if (simpleCartItem.groups && simpleCartItem.groups.length) {
|
|
282
|
+
var groupsLookup_1 = makeGroupsLookup(simpleCartItem);
|
|
283
|
+
orderItem.groups.forEach(function (group) {
|
|
284
|
+
var simpleGroup = groupsLookup_1[group.id];
|
|
285
|
+
if (simpleGroup) {
|
|
286
|
+
group.options.forEach(function (option) {
|
|
287
|
+
var simpleOption = simpleGroup.options[option.id];
|
|
288
|
+
option.quantity = simpleOption ? simpleOption.quantity : 0;
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
var pricedItem = (0, exports.calcPrices)(orderItem);
|
|
294
|
+
return pricedItem;
|
|
295
|
+
};
|
|
296
|
+
exports.rehydrateCartItem = rehydrateCartItem;
|
|
266
297
|
var addItem = function (cart, item) {
|
|
267
298
|
if (typeof item.index === 'undefined') {
|
|
268
299
|
var itemSignature_1 = (0, exports.makeCartItemSignature)(item);
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { NutritionalInfo } from './menu';
|
|
2
|
-
export interface GuestItem {
|
|
3
|
-
cart_guest_id?: number | null;
|
|
4
|
-
customer_id?: number | null;
|
|
5
|
-
made_for: string | null;
|
|
6
|
-
notes: string | null;
|
|
7
|
-
}
|
|
8
2
|
export interface CartItemOption {
|
|
9
3
|
allergens: string[];
|
|
10
4
|
cals: number | null;
|
|
@@ -45,12 +45,20 @@ export interface SimpleCartGroup {
|
|
|
45
45
|
id: number;
|
|
46
46
|
options: Array<SimpleCartOption>;
|
|
47
47
|
}
|
|
48
|
+
export declare type SimpleOptionLookup = Record<number, SimpleCartOption>;
|
|
49
|
+
export interface SimpleCartGroupLookup {
|
|
50
|
+
id: number;
|
|
51
|
+
options: SimpleOptionLookup;
|
|
52
|
+
}
|
|
53
|
+
export declare type SimpleCartGroupsLookup = Record<number, SimpleCartGroupLookup>;
|
|
48
54
|
export interface SimpleCartItem {
|
|
49
55
|
id: number;
|
|
50
56
|
quantity: number;
|
|
51
57
|
groups?: Array<SimpleCartGroup>;
|
|
52
58
|
made_for?: string;
|
|
53
59
|
notes?: string;
|
|
60
|
+
cart_guest_id?: number | null;
|
|
61
|
+
customer_id?: number | null;
|
|
54
62
|
}
|
|
55
63
|
export declare type SimpleCart = Array<SimpleCartItem>;
|
|
56
64
|
export interface OrderCreateDetails {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cart, CartItem, CartItemOption, FullOrderType,
|
|
1
|
+
import { Cart, CartItem, CartItemOption, FullOrderType, MenuItem, NutritionalInfo, OrderChannel, OrderTenders, OrderType, OrderTypeMap, ServiceTypeMap, SimpleCart, SimpleCartItem, SoldOut, TenderType, TenderTypeMap } from '../types';
|
|
2
2
|
export declare const orderTypeNamesMap: OrderTypeMap;
|
|
3
3
|
export declare const normalizeOrderType: (orderType: FullOrderType) => OrderType;
|
|
4
4
|
export declare const serviceTypeNamesMap: ServiceTypeMap;
|
|
@@ -73,7 +73,7 @@ export declare const calcPrices: (item: CartItem) => {
|
|
|
73
73
|
similarItems: number[];
|
|
74
74
|
};
|
|
75
75
|
export declare const calcNutrition: (item: CartItem) => NutritionalInfo | null;
|
|
76
|
-
export declare const makeCartItem: (item: MenuItem, isEdit?: boolean, soldOut?:
|
|
76
|
+
export declare const makeCartItem: (item: MenuItem, isEdit?: boolean, soldOut?: SoldOut, simpleItem?: SimpleCartItem, hasPoints?: boolean) => {
|
|
77
77
|
groups: {
|
|
78
78
|
quantity: number;
|
|
79
79
|
options: {
|
|
@@ -139,6 +139,71 @@ export declare const makeCartItem: (item: MenuItem, isEdit?: boolean, soldOut?:
|
|
|
139
139
|
similarItems: number[];
|
|
140
140
|
};
|
|
141
141
|
export declare const makeCartItemSignature: (item: CartItem, withNotes?: boolean) => string;
|
|
142
|
+
export declare const rehydrateCartItem: (menuItem: MenuItem, simpleCartItem: SimpleCartItem) => {
|
|
143
|
+
groups: {
|
|
144
|
+
quantity: number;
|
|
145
|
+
options: {
|
|
146
|
+
totalPrice: number;
|
|
147
|
+
totalPoints: number;
|
|
148
|
+
totalCals: number;
|
|
149
|
+
allergens: string[];
|
|
150
|
+
cals: number | null;
|
|
151
|
+
color?: string | null | undefined;
|
|
152
|
+
description: string | null;
|
|
153
|
+
id: number;
|
|
154
|
+
imageUrl: string | null;
|
|
155
|
+
increment: number;
|
|
156
|
+
ingredients: string | null;
|
|
157
|
+
isDefault: boolean;
|
|
158
|
+
isSoldOut: boolean;
|
|
159
|
+
max: number;
|
|
160
|
+
min: number;
|
|
161
|
+
name: string;
|
|
162
|
+
nutritionalInfo: NutritionalInfo | null;
|
|
163
|
+
points: number;
|
|
164
|
+
price: number;
|
|
165
|
+
quantity: number;
|
|
166
|
+
shortName: string;
|
|
167
|
+
tags: string[];
|
|
168
|
+
}[];
|
|
169
|
+
id: number;
|
|
170
|
+
name: string;
|
|
171
|
+
description: string | null;
|
|
172
|
+
imageUrl: string | null;
|
|
173
|
+
included: number;
|
|
174
|
+
max: number;
|
|
175
|
+
min: number;
|
|
176
|
+
isSize: boolean;
|
|
177
|
+
}[];
|
|
178
|
+
totalPrice: number;
|
|
179
|
+
totalPoints: number | null;
|
|
180
|
+
totalCals: number | null;
|
|
181
|
+
index?: number | undefined;
|
|
182
|
+
id: number;
|
|
183
|
+
name: string;
|
|
184
|
+
shortName: string;
|
|
185
|
+
cart_guest_id?: number | null | undefined;
|
|
186
|
+
category: string;
|
|
187
|
+
customer_id?: number | null | undefined;
|
|
188
|
+
description: string | null;
|
|
189
|
+
imageUrl: string | null;
|
|
190
|
+
slug: string;
|
|
191
|
+
allergens: string[];
|
|
192
|
+
tags: string[];
|
|
193
|
+
ingredients: string | null;
|
|
194
|
+
madeFor?: string | null | undefined;
|
|
195
|
+
notes?: string | null | undefined;
|
|
196
|
+
nutritionalInfo: NutritionalInfo | null;
|
|
197
|
+
cals: number | null;
|
|
198
|
+
quantity: number;
|
|
199
|
+
price: number;
|
|
200
|
+
increment: number;
|
|
201
|
+
max: number;
|
|
202
|
+
min: number;
|
|
203
|
+
points: number | null;
|
|
204
|
+
upsellItems: number[];
|
|
205
|
+
similarItems: number[];
|
|
206
|
+
};
|
|
142
207
|
export declare const addItem: (cart: Cart, item: CartItem) => {
|
|
143
208
|
cart: Cart;
|
|
144
209
|
cartCounts: {};
|
package/dist/esm/utils/order.js
CHANGED
|
@@ -251,6 +251,36 @@ export var makeCartItemSignature = function (item, withNotes) {
|
|
|
251
251
|
var itemIds = __spreadArray([item.id], optionIds, true).join('.');
|
|
252
252
|
return withNotes ? "".concat(itemIds, ".").concat(item.madeFor, ".").concat(item.notes) : itemIds;
|
|
253
253
|
};
|
|
254
|
+
var makeGroupsLookup = function (item) {
|
|
255
|
+
if (!item.groups)
|
|
256
|
+
return {};
|
|
257
|
+
return item.groups.reduce(function (grpObj, i) {
|
|
258
|
+
var options = i.options.reduce(function (optObj, o) {
|
|
259
|
+
optObj[o.id] = o;
|
|
260
|
+
return optObj;
|
|
261
|
+
}, {});
|
|
262
|
+
grpObj[i.id] = __assign(__assign({}, i), { options: options });
|
|
263
|
+
return grpObj;
|
|
264
|
+
}, {});
|
|
265
|
+
};
|
|
266
|
+
export var rehydrateCartItem = function (menuItem, simpleCartItem) {
|
|
267
|
+
var orderItem = makeCartItem(menuItem, true, [], simpleCartItem);
|
|
268
|
+
orderItem.quantity = simpleCartItem.quantity || 1;
|
|
269
|
+
if (simpleCartItem.groups && simpleCartItem.groups.length) {
|
|
270
|
+
var groupsLookup_1 = makeGroupsLookup(simpleCartItem);
|
|
271
|
+
orderItem.groups.forEach(function (group) {
|
|
272
|
+
var simpleGroup = groupsLookup_1[group.id];
|
|
273
|
+
if (simpleGroup) {
|
|
274
|
+
group.options.forEach(function (option) {
|
|
275
|
+
var simpleOption = simpleGroup.options[option.id];
|
|
276
|
+
option.quantity = simpleOption ? simpleOption.quantity : 0;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
var pricedItem = calcPrices(orderItem);
|
|
282
|
+
return pricedItem;
|
|
283
|
+
};
|
|
254
284
|
export var addItem = function (cart, item) {
|
|
255
285
|
if (typeof item.index === 'undefined') {
|
|
256
286
|
var itemSignature_1 = makeCartItemSignature(item);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/store",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.22",
|
|
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",
|