@open-tender/utils 0.0.8 → 0.0.9
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 +6 -6
- package/dist/cjs/utils/cart.js +13 -18
- package/dist/esm/utils/cart.d.ts +6 -6
- package/dist/esm/utils/cart.js +13 -18
- package/package.json +1 -1
package/dist/cjs/utils/cart.d.ts
CHANGED
|
@@ -219,7 +219,7 @@ export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: Arra
|
|
|
219
219
|
}[];
|
|
220
220
|
cartCounts: any;
|
|
221
221
|
};
|
|
222
|
-
export declare const rehydrateCheckoutForm: (order: Order) => {
|
|
222
|
+
export declare const rehydrateCheckoutForm: (order: Partial<Order>) => {
|
|
223
223
|
details: {
|
|
224
224
|
cart_id: number | null | undefined;
|
|
225
225
|
eating_utensils: boolean | undefined;
|
|
@@ -232,14 +232,14 @@ export declare const rehydrateCheckoutForm: (order: Order) => {
|
|
|
232
232
|
address: Partial<Address>;
|
|
233
233
|
surcharges: {
|
|
234
234
|
id?: number | undefined;
|
|
235
|
-
}[];
|
|
235
|
+
}[] | undefined;
|
|
236
236
|
discounts: {
|
|
237
237
|
id: number;
|
|
238
238
|
ext_id?: string | null | undefined;
|
|
239
|
-
}[];
|
|
240
|
-
promoCodes: string[];
|
|
241
|
-
tenders: import("@open-tender/types").OrderTender[];
|
|
242
|
-
tip: `${number}.${number}`;
|
|
239
|
+
}[] | undefined;
|
|
240
|
+
promoCodes: string[] | undefined;
|
|
241
|
+
tenders: import("@open-tender/types").OrderTender[] | undefined;
|
|
242
|
+
tip: number | `${number}.${number}`;
|
|
243
243
|
};
|
|
244
244
|
export declare const makeGuestLookup: (cartGuests: Array<GuestItem>) => Partial<GuestItem & {
|
|
245
245
|
[key: number]: GuestData;
|
package/dist/cjs/utils/cart.js
CHANGED
|
@@ -357,23 +357,17 @@ const rehydrateAddress = (address) => {
|
|
|
357
357
|
};
|
|
358
358
|
};
|
|
359
359
|
const rehydrateSurcharges = (surcharges) => {
|
|
360
|
-
return surcharges
|
|
361
|
-
.filter(i => i.is_optional)
|
|
362
|
-
.map(i => ({ id: i.surcharge_id }));
|
|
360
|
+
return surcharges === null || surcharges === void 0 ? void 0 : surcharges.filter(i => i.is_optional).map(i => ({ id: i.surcharge_id }));
|
|
363
361
|
};
|
|
364
362
|
const rehydrateDiscounts = (discounts) => {
|
|
365
|
-
return discounts
|
|
366
|
-
.filter(i => !i.is_promo_code)
|
|
367
|
-
.map(i => ({ id: i.discount_id || i.id, ext_id: i.ext_id }));
|
|
363
|
+
return discounts === null || discounts === void 0 ? void 0 : discounts.filter(i => !i.is_promo_code).map(i => ({ id: i.discount_id || i.id, ext_id: i.ext_id }));
|
|
368
364
|
};
|
|
369
365
|
const rehydratePromoCodes = (discounts) => {
|
|
370
|
-
return discounts.filter(i => i.is_promo_code).map(i => i.name);
|
|
366
|
+
return discounts === null || discounts === void 0 ? void 0 : discounts.filter(i => i.is_promo_code).map(i => i.name);
|
|
371
367
|
};
|
|
372
368
|
const rehydrateTenders = (tenders) => {
|
|
373
369
|
// const giftCards = tenders.filter((i) => i.tender_type === 'GIFT_CARD')
|
|
374
|
-
const other = tenders
|
|
375
|
-
// .filter((i) => i.tender_type !== 'GIFT_CARD')
|
|
376
|
-
.map(i => {
|
|
370
|
+
const other = tenders === null || tenders === void 0 ? void 0 : tenders.map(i => {
|
|
377
371
|
if (i.tender_type === 'CREDIT') {
|
|
378
372
|
return Object.assign(Object.assign({}, i), i.credit_card);
|
|
379
373
|
}
|
|
@@ -387,15 +381,16 @@ const rehydrateTenders = (tenders) => {
|
|
|
387
381
|
return other;
|
|
388
382
|
};
|
|
389
383
|
const rehydrateCheckoutForm = (order) => {
|
|
384
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
390
385
|
const form = {
|
|
391
|
-
details: rehydrateDetails(order.details),
|
|
392
|
-
customer: rehydrateCustomer(order.customer),
|
|
393
|
-
address: rehydrateAddress(order.address),
|
|
394
|
-
surcharges: rehydrateSurcharges(order.surcharges),
|
|
395
|
-
discounts: rehydrateDiscounts(order.discounts),
|
|
396
|
-
promoCodes: rehydratePromoCodes(order.discounts),
|
|
397
|
-
tenders: rehydrateTenders(order.tenders),
|
|
398
|
-
tip: order.totals.tip
|
|
386
|
+
details: rehydrateDetails((_a = order.details) !== null && _a !== void 0 ? _a : null),
|
|
387
|
+
customer: rehydrateCustomer((_b = order.customer) !== null && _b !== void 0 ? _b : null),
|
|
388
|
+
address: rehydrateAddress((_c = order.address) !== null && _c !== void 0 ? _c : null),
|
|
389
|
+
surcharges: rehydrateSurcharges((_d = order.surcharges) !== null && _d !== void 0 ? _d : null),
|
|
390
|
+
discounts: rehydrateDiscounts((_e = order.discounts) !== null && _e !== void 0 ? _e : null),
|
|
391
|
+
promoCodes: rehydratePromoCodes((_f = order.discounts) !== null && _f !== void 0 ? _f : null),
|
|
392
|
+
tenders: rehydrateTenders((_g = order.tenders) !== null && _g !== void 0 ? _g : null),
|
|
393
|
+
tip: (_j = (_h = order.totals) === null || _h === void 0 ? void 0 : _h.tip) !== null && _j !== void 0 ? _j : 0
|
|
399
394
|
};
|
|
400
395
|
return form;
|
|
401
396
|
};
|
package/dist/esm/utils/cart.d.ts
CHANGED
|
@@ -219,7 +219,7 @@ export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: Arra
|
|
|
219
219
|
}[];
|
|
220
220
|
cartCounts: any;
|
|
221
221
|
};
|
|
222
|
-
export declare const rehydrateCheckoutForm: (order: Order) => {
|
|
222
|
+
export declare const rehydrateCheckoutForm: (order: Partial<Order>) => {
|
|
223
223
|
details: {
|
|
224
224
|
cart_id: number | null | undefined;
|
|
225
225
|
eating_utensils: boolean | undefined;
|
|
@@ -232,14 +232,14 @@ export declare const rehydrateCheckoutForm: (order: Order) => {
|
|
|
232
232
|
address: Partial<Address>;
|
|
233
233
|
surcharges: {
|
|
234
234
|
id?: number | undefined;
|
|
235
|
-
}[];
|
|
235
|
+
}[] | undefined;
|
|
236
236
|
discounts: {
|
|
237
237
|
id: number;
|
|
238
238
|
ext_id?: string | null | undefined;
|
|
239
|
-
}[];
|
|
240
|
-
promoCodes: string[];
|
|
241
|
-
tenders: import("@open-tender/types").OrderTender[];
|
|
242
|
-
tip: `${number}.${number}`;
|
|
239
|
+
}[] | undefined;
|
|
240
|
+
promoCodes: string[] | undefined;
|
|
241
|
+
tenders: import("@open-tender/types").OrderTender[] | undefined;
|
|
242
|
+
tip: number | `${number}.${number}`;
|
|
243
243
|
};
|
|
244
244
|
export declare const makeGuestLookup: (cartGuests: Array<GuestItem>) => Partial<GuestItem & {
|
|
245
245
|
[key: number]: GuestData;
|
package/dist/esm/utils/cart.js
CHANGED
|
@@ -337,23 +337,17 @@ const rehydrateAddress = (address) => {
|
|
|
337
337
|
};
|
|
338
338
|
};
|
|
339
339
|
const rehydrateSurcharges = (surcharges) => {
|
|
340
|
-
return surcharges
|
|
341
|
-
.filter(i => i.is_optional)
|
|
342
|
-
.map(i => ({ id: i.surcharge_id }));
|
|
340
|
+
return surcharges === null || surcharges === void 0 ? void 0 : surcharges.filter(i => i.is_optional).map(i => ({ id: i.surcharge_id }));
|
|
343
341
|
};
|
|
344
342
|
const rehydrateDiscounts = (discounts) => {
|
|
345
|
-
return discounts
|
|
346
|
-
.filter(i => !i.is_promo_code)
|
|
347
|
-
.map(i => ({ id: i.discount_id || i.id, ext_id: i.ext_id }));
|
|
343
|
+
return discounts === null || discounts === void 0 ? void 0 : discounts.filter(i => !i.is_promo_code).map(i => ({ id: i.discount_id || i.id, ext_id: i.ext_id }));
|
|
348
344
|
};
|
|
349
345
|
const rehydratePromoCodes = (discounts) => {
|
|
350
|
-
return discounts.filter(i => i.is_promo_code).map(i => i.name);
|
|
346
|
+
return discounts === null || discounts === void 0 ? void 0 : discounts.filter(i => i.is_promo_code).map(i => i.name);
|
|
351
347
|
};
|
|
352
348
|
const rehydrateTenders = (tenders) => {
|
|
353
349
|
// const giftCards = tenders.filter((i) => i.tender_type === 'GIFT_CARD')
|
|
354
|
-
const other = tenders
|
|
355
|
-
// .filter((i) => i.tender_type !== 'GIFT_CARD')
|
|
356
|
-
.map(i => {
|
|
350
|
+
const other = tenders === null || tenders === void 0 ? void 0 : tenders.map(i => {
|
|
357
351
|
if (i.tender_type === 'CREDIT') {
|
|
358
352
|
return Object.assign(Object.assign({}, i), i.credit_card);
|
|
359
353
|
}
|
|
@@ -367,15 +361,16 @@ const rehydrateTenders = (tenders) => {
|
|
|
367
361
|
return other;
|
|
368
362
|
};
|
|
369
363
|
export const rehydrateCheckoutForm = (order) => {
|
|
364
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
370
365
|
const form = {
|
|
371
|
-
details: rehydrateDetails(order.details),
|
|
372
|
-
customer: rehydrateCustomer(order.customer),
|
|
373
|
-
address: rehydrateAddress(order.address),
|
|
374
|
-
surcharges: rehydrateSurcharges(order.surcharges),
|
|
375
|
-
discounts: rehydrateDiscounts(order.discounts),
|
|
376
|
-
promoCodes: rehydratePromoCodes(order.discounts),
|
|
377
|
-
tenders: rehydrateTenders(order.tenders),
|
|
378
|
-
tip: order.totals.tip
|
|
366
|
+
details: rehydrateDetails((_a = order.details) !== null && _a !== void 0 ? _a : null),
|
|
367
|
+
customer: rehydrateCustomer((_b = order.customer) !== null && _b !== void 0 ? _b : null),
|
|
368
|
+
address: rehydrateAddress((_c = order.address) !== null && _c !== void 0 ? _c : null),
|
|
369
|
+
surcharges: rehydrateSurcharges((_d = order.surcharges) !== null && _d !== void 0 ? _d : null),
|
|
370
|
+
discounts: rehydrateDiscounts((_e = order.discounts) !== null && _e !== void 0 ? _e : null),
|
|
371
|
+
promoCodes: rehydratePromoCodes((_f = order.discounts) !== null && _f !== void 0 ? _f : null),
|
|
372
|
+
tenders: rehydrateTenders((_g = order.tenders) !== null && _g !== void 0 ? _g : null),
|
|
373
|
+
tip: (_j = (_h = order.totals) === null || _h === void 0 ? void 0 : _h.tip) !== null && _j !== void 0 ? _j : 0
|
|
379
374
|
};
|
|
380
375
|
return form;
|
|
381
376
|
};
|
package/package.json
CHANGED