@ancon/wildcat-utils 1.50.6 → 1.50.8

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.
@@ -1 +1 @@
1
- "use strict";const n=require("@ancon/wildcat-types");function s(i){const t=[],o=[];return i.selectedIngredients.forEach(e=>{e.selected?e.replacementId&&t.push({modification:n.ModificationType.Replace,ingredientId:e.id,replaceId:e.replacementId}):t.push({modification:n.ModificationType.Remove,ingredientId:e.id})}),i.selectedAddons.forEach(e=>{var c;if(e.selectedIngredientId){t.push({addOnGroupId:e.addonId,modification:n.ModificationType.Add,ingredientId:e.selectedIngredientId,quantity:1,freeAmount:e.ingredients.some(d=>d.freeAmount===1)?1:0});return}e.ingredients.forEach(d=>{d.selectedCount&&t.push({addOnGroupId:e.addonId,modification:n.ModificationType.Add,ingredientId:d.id,quantity:d.selectedCount,freeAmount:d.freeAmount})}),(c=e.products)==null||c.forEach(d=>{d.selectedCount&&o.push({variantId:d.selectedVariantId,addOnGroupId:e.addonId,quantity:d.selectedCount,freeAmount:d.freeAmount,unitQuantity:d.selectedCount})})}),{modifications:t,quantity:i.quantity,variantId:i.selectedVariantId,showingPrice:i.selectedVariantShowingPrice,addOnProducts:o}}module.exports=s;
1
+ "use strict";const n=require("@ancon/wildcat-types");function s(i){const t=[],o=[];return i.selectedIngredients.forEach(e=>{e.selected?e.replacementId&&t.push({modification:n.ModificationType.Replace,ingredientId:e.id,replaceId:e.replacementId}):t.push({modification:n.ModificationType.Remove,ingredientId:e.id})}),i.selectedAddons.forEach(e=>{var c;if(e.selectedIngredientId){t.push({addOnGroupId:e.addonId,modification:n.ModificationType.Add,ingredientId:e.selectedIngredientId,quantity:1,freeAmount:e.ingredients.some(d=>d.freeAmount===1)?1:0});return}e.ingredients.forEach(d=>{d.selectedCount&&t.push({addOnGroupId:e.addonId,modification:n.ModificationType.Add,ingredientId:d.id,quantity:d.selectedCount,freeAmount:d.freeAmount})}),(c=e.products)==null||c.forEach(d=>{d.selectedCount&&o.push({variantId:d.selectedVariantId,addOnGroupId:e.addonId,quantity:d.selectedCount,freeAmount:d.freeAmount,unitQuantity:d.selectedCount})})}),{modifications:t,quantity:i.quantity,variantId:i.selectedVariantId,showingPrice:i.selectedVariantShowingPrice,addOnProducts:o,itemType:n.CheckoutItemType.SaleProduct}}module.exports=s;
@@ -1,5 +1,5 @@
1
- import { ModificationType as n } from "@ancon/wildcat-types";
2
- function r(t) {
1
+ import { ModificationType as n, CheckoutItemType as s } from "@ancon/wildcat-types";
2
+ function f(t) {
3
3
  const i = [], o = [];
4
4
  return t.selectedIngredients.forEach((e) => {
5
5
  e.selected ? e.replacementId && i.push({
@@ -11,7 +11,7 @@ function r(t) {
11
11
  ingredientId: e.id
12
12
  });
13
13
  }), t.selectedAddons.forEach((e) => {
14
- var s;
14
+ var c;
15
15
  if (e.selectedIngredientId) {
16
16
  i.push({
17
17
  addOnGroupId: e.addonId,
@@ -30,7 +30,7 @@ function r(t) {
30
30
  quantity: d.selectedCount,
31
31
  freeAmount: d.freeAmount
32
32
  });
33
- }), (s = e.products) == null || s.forEach((d) => {
33
+ }), (c = e.products) == null || c.forEach((d) => {
34
34
  d.selectedCount && o.push({
35
35
  variantId: d.selectedVariantId,
36
36
  addOnGroupId: e.addonId,
@@ -44,9 +44,11 @@ function r(t) {
44
44
  quantity: t.quantity,
45
45
  variantId: t.selectedVariantId,
46
46
  showingPrice: t.selectedVariantShowingPrice,
47
- addOnProducts: o
47
+ addOnProducts: o,
48
+ itemType: s.SaleProduct
49
+ // default type, this only changes for upsell items
48
50
  };
49
51
  }
50
52
  export {
51
- r as default
53
+ f as default
52
54
  };
@@ -1,4 +1,4 @@
1
- import { CheckoutRequestItemUnitPrice, ModificationType, ProductType, VariantType } from '@ancon/wildcat-types';
1
+ import { CheckoutItemType, CheckoutRequestItemUnitPrice, ModificationType, ProductType, VariantType } from '@ancon/wildcat-types';
2
2
  export declare type CheckoutRequestItemModification = {
3
3
  modification: ModificationType;
4
4
  ingredientId: string;
@@ -26,5 +26,6 @@ export declare type CheckoutRequestItem = {
26
26
  showingPrice?: number;
27
27
  price?: CheckoutRequestItemUnitPrice;
28
28
  metaData?: string | null;
29
+ itemType?: CheckoutItemType;
29
30
  };
30
31
  export declare type CheckoutItemComparisonCandidate = Pick<CheckoutRequestItem, 'variantId' | 'modifications' | 'upsellGroupId'>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("@ancon/wildcat-types"),i=require("./getSettingsForOrderFormat.js");var o=(e=>(e[e.Preset1=1]="Preset1",e[e.Preset2=2]="Preset2",e[e.Preset3=3]="Preset3",e))(o||{});function a(e){if(e){const t=[];return e.percentage1Enabled&&t.push({value:e.percentage1Value,preset:1}),e.percentage2Enabled&&t.push({value:e.percentage2Value,preset:2}),e.percentage3Enabled&&t.push({value:e.percentage3Value,preset:3}),t}return[]}function d(e,t){const{orderFormatSettings:s}=e,n=i(t,s);if((r.OrderFormatOption.AOTipEnabled&n.options)===r.OrderFormatOption.AOTipEnabled){const u=(r.OrderFormatOption.AOCustomTipsEnabled&n.options)===r.OrderFormatOption.AOCustomTipsEnabled,l=a(n.aoTippingPercentages);return{aoAllowCustomTipping:u,tipPercentages:l}}return null}exports.TipPercentagePreset=o;exports.default=d;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("@ancon/wildcat-types"),i=require("./getSettingsForOrderFormat.js");var o=(e=>(e[e.Preset1=1]="Preset1",e[e.Preset2=2]="Preset2",e[e.Preset3=3]="Preset3",e))(o||{});function a(e){if(e){const t=[];return e.percentage1Enabled&&t.push({value:e.percentage1Value,preset:1}),e.percentage2Enabled&&t.push({value:e.percentage2Value,preset:2}),e.percentage3Enabled&&t.push({value:e.percentage3Value,preset:3}),t}return[]}function d(e,t){const{orderFormatSettings:s}=e,r=i(t,s);if(r!=null&&(n.OrderFormatOption.AOTipEnabled&r.options)===n.OrderFormatOption.AOTipEnabled){const u=(n.OrderFormatOption.AOCustomTipsEnabled&r.options)===n.OrderFormatOption.AOCustomTipsEnabled,l=a(r.aoTippingPercentages);return{aoAllowCustomTipping:u,tipPercentages:l}}return null}exports.TipPercentagePreset=o;exports.default=d;
@@ -1,5 +1,5 @@
1
- import { OrderFormatOption as r } from "@ancon/wildcat-types";
2
- import l from "./getSettingsForOrderFormat.mjs";
1
+ import { OrderFormatOption as n } from "@ancon/wildcat-types";
2
+ import u from "./getSettingsForOrderFormat.mjs";
3
3
  var a = /* @__PURE__ */ ((t) => (t[t.Preset1 = 1] = "Preset1", t[t.Preset2 = 2] = "Preset2", t[t.Preset3 = 3] = "Preset3", t))(a || {});
4
4
  function i(t) {
5
5
  if (t) {
@@ -21,12 +21,12 @@ function i(t) {
21
21
  return [];
22
22
  }
23
23
  function f(t, e) {
24
- const { orderFormatSettings: o } = t, n = l(e, o);
25
- if ((r.AOTipEnabled & n.options) === r.AOTipEnabled) {
26
- const s = (r.AOCustomTipsEnabled & n.options) === r.AOCustomTipsEnabled, u = i(n.aoTippingPercentages);
24
+ const { orderFormatSettings: o } = t, r = u(e, o);
25
+ if (r != null && (n.AOTipEnabled & r.options) === n.AOTipEnabled) {
26
+ const s = (n.AOCustomTipsEnabled & r.options) === n.AOCustomTipsEnabled, l = i(r.aoTippingPercentages);
27
27
  return {
28
28
  aoAllowCustomTipping: s,
29
- tipPercentages: u
29
+ tipPercentages: l
30
30
  };
31
31
  }
32
32
  return null;
@@ -1,2 +1,2 @@
1
1
  import { OrderFormatSetting, OrderFormat } from '@ancon/wildcat-types';
2
- export default function getSettingsForOrderFormat(orderFormat: OrderFormat, orderFormatSettings?: OrderFormatSetting[]): OrderFormatSetting;
2
+ export default function getSettingsForOrderFormat(orderFormat: OrderFormat, orderFormatSettings?: OrderFormatSetting[]): OrderFormatSetting | undefined;
@@ -1 +1 @@
1
- "use strict";function o(r,t=[]){return t.filter(e=>e.orderFormat===r)[0]}module.exports=o;
1
+ "use strict";function o(r,t=[]){return t.find(e=>e.orderFormat===r)}module.exports=o;
@@ -1,7 +1,7 @@
1
1
  function o(r, t = []) {
2
- return t.filter(
2
+ return t.find(
3
3
  (e) => e.orderFormat === r
4
- )[0];
4
+ );
5
5
  }
6
6
  export {
7
7
  o as default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancon/wildcat-utils",
3
- "version": "1.50.6",
3
+ "version": "1.50.8",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",