@open-tender/store 0.5.19 → 0.5.21

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 CHANGED
Binary file
@@ -29,8 +29,8 @@ var KioskActionType;
29
29
  var enhanceTheme = function (theme) {
30
30
  var icons = tslib_1.__assign(tslib_1.__assign({}, theme.icons), { strokeLinejoin: 'miter', strokeLinecap: 'square' });
31
31
  var kiosk = {
32
- padding: '10px',
33
- gutter: '5px'
32
+ padding: '1rem',
33
+ gutter: '0.5rem'
34
34
  };
35
35
  return tslib_1.__assign(tslib_1.__assign({}, theme), { icons: icons, kiosk: kiosk });
36
36
  };
@@ -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, GuestItem, MenuItem, NutritionalInfo, OrderChannel, OrderTenders, OrderType, OrderTypeMap, ServiceTypeMap, SimpleCart, TenderType, TenderTypeMap } from '../types';
1
+ import { Cart, CartItem, CartItemOption, FullOrderType, MenuItem, NutritionalInfo, OrderChannel, OrderTenders, OrderType, OrderTypeMap, ServiceTypeMap, SimpleCart, SimpleCartItem, 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?: never[], simpleItem?: GuestItem, hasPoints?: boolean) => {
76
+ export declare const makeCartItem: (item: MenuItem, isEdit?: boolean, soldOut?: never[], 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: {};
@@ -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);
@@ -53,6 +53,13 @@ var layoutToPixels = function (object, ratio) {
53
53
  return tslib_1.__assign(tslib_1.__assign({}, obj), (_b = {}, _b[key] = (0, exports.remsToPixels)(value, ratio), _b));
54
54
  }, {});
55
55
  };
56
+ var kioskToPixels = function (object, ratio) {
57
+ return Object.entries(object).reduce(function (obj, _a) {
58
+ var _b;
59
+ var key = _a[0], value = _a[1];
60
+ return tslib_1.__assign(tslib_1.__assign({}, obj), (_b = {}, _b[key] = (0, exports.remsToPixels)(value, ratio), _b));
61
+ }, {});
62
+ };
56
63
  var paddingToPixels = function (padding, ratio) {
57
64
  var _a = padding.split(' '), top = _a[0], horizontal = _a[1], bottom = _a[2];
58
65
  var topPx = (0, exports.remsToPixels)(top, ratio);
@@ -200,10 +207,11 @@ var decorateTheme = function (theme, ratio) {
200
207
  var fonts = makeFonts(theme.fonts, theme.lineHeight, ratio);
201
208
  var inputs = makeInputs(theme.inputs, ratio);
202
209
  var item = makeItems(theme.item, ratio);
210
+ var kiosk = kioskToPixels(theme.kiosk, ratio);
203
211
  var layout = layoutToPixels(theme.layout, ratio);
204
212
  var lineHeight = makeLineHeight(theme.lineHeight, fonts.sizes.main);
205
213
  var welcome = makeWelcomes(theme.welcome, ratio);
206
214
  var icons = makeIcons(theme.icons, ratio);
207
- return tslib_1.__assign(tslib_1.__assign({}, theme), { border: border, buttons: buttons, cards: cards, counts: counts, fonts: fonts, inputs: inputs, item: item, lineHeight: lineHeight, layout: layout, welcome: welcome, icons: icons });
215
+ return tslib_1.__assign(tslib_1.__assign({}, theme), { border: border, buttons: buttons, cards: cards, counts: counts, fonts: fonts, inputs: inputs, item: item, lineHeight: lineHeight, kiosk: kiosk, layout: layout, welcome: welcome, icons: icons });
208
216
  };
209
217
  exports.decorateTheme = decorateTheme;
@@ -26,8 +26,8 @@ export var KioskActionType;
26
26
  var enhanceTheme = function (theme) {
27
27
  var icons = __assign(__assign({}, theme.icons), { strokeLinejoin: 'miter', strokeLinecap: 'square' });
28
28
  var kiosk = {
29
- padding: '10px',
30
- gutter: '5px'
29
+ padding: '1rem',
30
+ gutter: '0.5rem'
31
31
  };
32
32
  return __assign(__assign({}, theme), { icons: icons, kiosk: kiosk });
33
33
  };
@@ -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, GuestItem, MenuItem, NutritionalInfo, OrderChannel, OrderTenders, OrderType, OrderTypeMap, ServiceTypeMap, SimpleCart, TenderType, TenderTypeMap } from '../types';
1
+ import { Cart, CartItem, CartItemOption, FullOrderType, MenuItem, NutritionalInfo, OrderChannel, OrderTenders, OrderType, OrderTypeMap, ServiceTypeMap, SimpleCart, SimpleCartItem, 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?: never[], simpleItem?: GuestItem, hasPoints?: boolean) => {
76
+ export declare const makeCartItem: (item: MenuItem, isEdit?: boolean, soldOut?: never[], 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: {};
@@ -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);
@@ -47,6 +47,13 @@ var layoutToPixels = function (object, ratio) {
47
47
  return __assign(__assign({}, obj), (_b = {}, _b[key] = remsToPixels(value, ratio), _b));
48
48
  }, {});
49
49
  };
50
+ var kioskToPixels = function (object, ratio) {
51
+ return Object.entries(object).reduce(function (obj, _a) {
52
+ var _b;
53
+ var key = _a[0], value = _a[1];
54
+ return __assign(__assign({}, obj), (_b = {}, _b[key] = remsToPixels(value, ratio), _b));
55
+ }, {});
56
+ };
50
57
  var paddingToPixels = function (padding, ratio) {
51
58
  var _a = padding.split(' '), top = _a[0], horizontal = _a[1], bottom = _a[2];
52
59
  var topPx = remsToPixels(top, ratio);
@@ -191,9 +198,10 @@ export var decorateTheme = function (theme, ratio) {
191
198
  var fonts = makeFonts(theme.fonts, theme.lineHeight, ratio);
192
199
  var inputs = makeInputs(theme.inputs, ratio);
193
200
  var item = makeItems(theme.item, ratio);
201
+ var kiosk = kioskToPixels(theme.kiosk, ratio);
194
202
  var layout = layoutToPixels(theme.layout, ratio);
195
203
  var lineHeight = makeLineHeight(theme.lineHeight, fonts.sizes.main);
196
204
  var welcome = makeWelcomes(theme.welcome, ratio);
197
205
  var icons = makeIcons(theme.icons, ratio);
198
- return __assign(__assign({}, theme), { border: border, buttons: buttons, cards: cards, counts: counts, fonts: fonts, inputs: inputs, item: item, lineHeight: lineHeight, layout: layout, welcome: welcome, icons: icons });
206
+ return __assign(__assign({}, theme), { border: border, buttons: buttons, cards: cards, counts: counts, fonts: fonts, inputs: inputs, item: item, lineHeight: lineHeight, kiosk: kiosk, layout: layout, welcome: welcome, icons: icons });
199
207
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/store",
3
- "version": "0.5.19",
3
+ "version": "0.5.21",
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",