@open-tender/utils 0.1.151 → 0.1.152

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.
@@ -85,9 +85,8 @@ 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 combineCarts: (cart: Cart, guestCart: SimpleCart, cartOwner: CartOwner, cartGuests: GroupOrderGuests) => ({
89
- customer_id: number;
90
- madeFor: string;
88
+ export declare const combineCarts: (cart: Cart, guestCart: Cart, cartOwner: CartOwner, cartGuests: GroupOrderGuests) => {
89
+ madeFor: string | null;
91
90
  cartGuestId: number | null;
92
91
  customerId: number | null;
93
92
  index?: number | undefined;
@@ -118,16 +117,7 @@ export declare const combineCarts: (cart: Cart, guestCart: SimpleCart, cartOwner
118
117
  totalCals: number | null;
119
118
  totalPoints: number | null;
120
119
  totalPrice: number | null;
121
- } | {
122
- madeFor: string;
123
- id: number;
124
- quantity: number;
125
- groups: SimpleCartGroups;
126
- made_for?: string | null | undefined;
127
- notes?: string | null | undefined;
128
- cart_guest_id?: number | undefined;
129
- customer_id?: number | undefined;
130
- })[];
120
+ }[];
131
121
  export declare const makeItemImageUrl: (images: Images) => any;
132
122
  export declare const makeDisplayItemGroups: (optionGroups: OrderItemGroups) => {
133
123
  options: DisplayItem[];
@@ -399,13 +399,14 @@ exports.makeGuestLookup = makeGuestLookup;
399
399
  const combineCarts = (cart, guestCart, cartOwner, cartGuests) => {
400
400
  const guestLookup = (0, exports.makeGuestLookup)(cartGuests);
401
401
  const withGuestNames = guestCart
402
- .filter(i => guestLookup[i.cart_guest_id])
402
+ .filter(i => i.cartGuestId && guestLookup[i.cartGuestId])
403
403
  .map(i => {
404
- const guest = guestLookup[i.cart_guest_id];
405
- return Object.assign(Object.assign({}, i), { madeFor: `${guest === null || guest === void 0 ? void 0 : guest.first_name} ${guest === null || guest === void 0 ? void 0 : guest.last_name}` });
404
+ const guest = i.cartGuestId ? guestLookup[i.cartGuestId] : null;
405
+ const madeFor = guest ? `${guest === null || guest === void 0 ? void 0 : guest.first_name} ${guest === null || guest === void 0 ? void 0 : guest.last_name}` : null;
406
+ return Object.assign(Object.assign({}, i), { madeFor });
406
407
  });
407
408
  const withOwnerName = cart.map(i => {
408
- return Object.assign(Object.assign({}, i), { customer_id: cartOwner.customer_id, madeFor: `${cartOwner.first_name} ${cartOwner.last_name}` });
409
+ return Object.assign(Object.assign({}, i), { customerId: cartOwner.customer_id, madeFor: `${cartOwner.first_name} ${cartOwner.last_name}` });
409
410
  });
410
411
  return [...withOwnerName, ...withGuestNames];
411
412
  };
@@ -85,9 +85,8 @@ 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 combineCarts: (cart: Cart, guestCart: SimpleCart, cartOwner: CartOwner, cartGuests: GroupOrderGuests) => ({
89
- customer_id: number;
90
- madeFor: string;
88
+ export declare const combineCarts: (cart: Cart, guestCart: Cart, cartOwner: CartOwner, cartGuests: GroupOrderGuests) => {
89
+ madeFor: string | null;
91
90
  cartGuestId: number | null;
92
91
  customerId: number | null;
93
92
  index?: number | undefined;
@@ -118,16 +117,7 @@ export declare const combineCarts: (cart: Cart, guestCart: SimpleCart, cartOwner
118
117
  totalCals: number | null;
119
118
  totalPoints: number | null;
120
119
  totalPrice: number | null;
121
- } | {
122
- madeFor: string;
123
- id: number;
124
- quantity: number;
125
- groups: SimpleCartGroups;
126
- made_for?: string | null | undefined;
127
- notes?: string | null | undefined;
128
- cart_guest_id?: number | undefined;
129
- customer_id?: number | undefined;
130
- })[];
120
+ }[];
131
121
  export declare const makeItemImageUrl: (images: Images) => any;
132
122
  export declare const makeDisplayItemGroups: (optionGroups: OrderItemGroups) => {
133
123
  options: DisplayItem[];
@@ -381,13 +381,14 @@ export const makeGuestLookup = (cartGuests) => {
381
381
  export const combineCarts = (cart, guestCart, cartOwner, cartGuests) => {
382
382
  const guestLookup = makeGuestLookup(cartGuests);
383
383
  const withGuestNames = guestCart
384
- .filter(i => guestLookup[i.cart_guest_id])
384
+ .filter(i => i.cartGuestId && guestLookup[i.cartGuestId])
385
385
  .map(i => {
386
- const guest = guestLookup[i.cart_guest_id];
387
- return Object.assign(Object.assign({}, i), { madeFor: `${guest === null || guest === void 0 ? void 0 : guest.first_name} ${guest === null || guest === void 0 ? void 0 : guest.last_name}` });
386
+ const guest = i.cartGuestId ? guestLookup[i.cartGuestId] : null;
387
+ const madeFor = guest ? `${guest === null || guest === void 0 ? void 0 : guest.first_name} ${guest === null || guest === void 0 ? void 0 : guest.last_name}` : null;
388
+ return Object.assign(Object.assign({}, i), { madeFor });
388
389
  });
389
390
  const withOwnerName = cart.map(i => {
390
- return Object.assign(Object.assign({}, i), { customer_id: cartOwner.customer_id, madeFor: `${cartOwner.first_name} ${cartOwner.last_name}` });
391
+ return Object.assign(Object.assign({}, i), { customerId: cartOwner.customer_id, madeFor: `${cartOwner.first_name} ${cartOwner.last_name}` });
391
392
  });
392
393
  return [...withOwnerName, ...withGuestNames];
393
394
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.1.151",
3
+ "version": "0.1.152",
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",