@ancon/wildcat-utils 1.27.3 → 1.28.0

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.
@@ -0,0 +1,10 @@
1
+ import { ConfigureAddonGroupFormState, ConfigureIngredientFormState } from '../product/types';
2
+ import { CheckoutRequestItem } from './types';
3
+ export default function buildCheckoutRequestItem(checkoutRequestItemData: {
4
+ selectedIngredients: ConfigureIngredientFormState[];
5
+ selectedAddons: ConfigureAddonGroupFormState[];
6
+ quantity: number;
7
+ outletId: string;
8
+ selectedVariantId: string;
9
+ selectedVariantShowingPrice: number;
10
+ }): CheckoutRequestItem;
@@ -0,0 +1 @@
1
+ "use strict";const t=require("@ancon/wildcat-types");function o(d){const n=[];return d.selectedIngredients.forEach(e=>{e.selected?e.replacementId&&n.push({modification:t.ModificationType.Replace,ingredientId:e.id,replaceId:e.replacementId}):n.push({modification:t.ModificationType.Remove,ingredientId:e.id})}),d.selectedAddons.forEach(e=>{if(e.selectedIngredientId){n.push({addOnGroupId:e.addonId,modification:t.ModificationType.Add,ingredientId:e.selectedIngredientId,quantity:1,freeAmount:e.ingredients.some(i=>i.freeAmount===1)?1:0});return}e.ingredients.forEach(i=>{i.selectedCount&&n.push({addOnGroupId:e.addonId,modification:t.ModificationType.Add,ingredientId:i.id,quantity:i.selectedCount,freeAmount:i.freeAmount})})}),{modifications:n,quantity:d.quantity,variantId:d.selectedVariantId,showingPrice:d.selectedVariantShowingPrice}}module.exports=o;
@@ -0,0 +1,42 @@
1
+ import { ModificationType as t } from "@ancon/wildcat-types";
2
+ function o(i) {
3
+ const n = [];
4
+ return i.selectedIngredients.forEach((e) => {
5
+ e.selected ? e.replacementId && n.push({
6
+ modification: t.Replace,
7
+ ingredientId: e.id,
8
+ replaceId: e.replacementId
9
+ }) : n.push({
10
+ modification: t.Remove,
11
+ ingredientId: e.id
12
+ });
13
+ }), i.selectedAddons.forEach((e) => {
14
+ if (e.selectedIngredientId) {
15
+ n.push({
16
+ addOnGroupId: e.addonId,
17
+ modification: t.Add,
18
+ ingredientId: e.selectedIngredientId,
19
+ quantity: 1,
20
+ freeAmount: e.ingredients.some((d) => d.freeAmount === 1) ? 1 : 0
21
+ });
22
+ return;
23
+ }
24
+ e.ingredients.forEach((d) => {
25
+ d.selectedCount && n.push({
26
+ addOnGroupId: e.addonId,
27
+ modification: t.Add,
28
+ ingredientId: d.id,
29
+ quantity: d.selectedCount,
30
+ freeAmount: d.freeAmount
31
+ });
32
+ });
33
+ }), {
34
+ modifications: n,
35
+ quantity: i.quantity,
36
+ variantId: i.selectedVariantId,
37
+ showingPrice: i.selectedVariantShowingPrice
38
+ };
39
+ }
40
+ export {
41
+ o as default
42
+ };
@@ -0,0 +1,16 @@
1
+ import { ModificationType } from '@ancon/wildcat-types';
2
+ export declare type CheckoutRequestItemModification = {
3
+ modification: ModificationType;
4
+ ingredientId: string;
5
+ quantity?: number;
6
+ freeAmount?: number;
7
+ addOnGroupId?: string;
8
+ replaceId?: string;
9
+ };
10
+ export declare type CheckoutRequestItem = {
11
+ variantId: string;
12
+ quantity: number;
13
+ modifications: CheckoutRequestItemModification[];
14
+ upsellGroupId?: string | null;
15
+ showingPrice?: number;
16
+ };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancon/wildcat-utils",
3
- "version": "1.27.3",
3
+ "version": "1.28.0",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -36,6 +36,11 @@
36
36
  "require": "./api/isNoContentResponse.js",
37
37
  "types": "./api/isNoContentResponse.d.ts"
38
38
  },
39
+ "./checkout/buildCheckoutRequestItem": {
40
+ "import": "./checkout/buildCheckoutRequestItem.mjs",
41
+ "require": "./checkout/buildCheckoutRequestItem.js",
42
+ "types": "./checkout/buildCheckoutRequestItem.d.ts"
43
+ },
39
44
  "./checkout/getCheckoutItemModifications": {
40
45
  "import": "./checkout/getCheckoutItemModifications.mjs",
41
46
  "require": "./checkout/getCheckoutItemModifications.js",
@@ -66,6 +71,11 @@
66
71
  "require": "./checkout/isCheckoutOrderSummary.js",
67
72
  "types": "./checkout/isCheckoutOrderSummary.d.ts"
68
73
  },
74
+ "./checkout/types": {
75
+ "import": "./checkout/types.mjs",
76
+ "require": "./checkout/types.js",
77
+ "types": "./checkout/types.d.ts"
78
+ },
69
79
  "./color/brighten": {
70
80
  "import": "./color/brighten.mjs",
71
81
  "require": "./color/brighten.js",