@ancon/wildcat-utils 1.27.1 → 1.27.2
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/index.js +1 -1
- package/index.mjs +16 -12
- package/package.json +16 -1
- package/product/calculateAddonGroupCost.d.ts +3 -0
- package/product/calculateAddonGroupCost.js +1 -0
- package/product/calculateAddonGroupCost.mjs +55 -0
- package/product/calculateIngredientsCost.d.ts +3 -0
- package/product/calculateIngredientsCost.js +1 -0
- package/product/calculateIngredientsCost.mjs +39 -0
- package/product/index.d.ts +3 -1
- package/product/index.js +1 -1
- package/product/index.mjs +6 -2
- package/product/types.d.ts +40 -0
- package/product/types.js +1 -0
- package/product/types.mjs +4 -0
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./shared/isWithinFlag.js"),t=require("./shared/generateId.js"),i=require("./shared/wait.js"),o=require("./outlet/getListOutletOpeningHoursTable.js"),n=require("./outlet/getOutletTagInformation.js"),u=require("./outlet/getOutletAvailabilityInfo.js"),s=require("./outlet/getOutletOfflineOrderFormats.js"),c=require("./outlet/getOutletAvailableOrderFormats.js"),a=require("./outlet/getOutletFormattedDistance.js"),l=require("./outlet/isOutletAcceptingPreOrders.js"),d=require("./outlet/getOutletDeliveryFee.js"),g=require("./outlet/getOutletTodayOpeningTimes.js"),q=require("./outlet/getOutletOrderFormats.js"),O=require("./outlet/serviceDateTimesFromOpeningHours.js"),_=require("./outlet/getPickerIntervalsForDay.js"),k=require("./outlet/getServiceIntervalRange.js"),m=require("./outlet/getServiceIntervalsForOrderFormat.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./shared/isWithinFlag.js"),t=require("./shared/generateId.js"),i=require("./shared/wait.js"),o=require("./outlet/getListOutletOpeningHoursTable.js"),n=require("./outlet/getOutletTagInformation.js"),u=require("./outlet/getOutletAvailabilityInfo.js"),s=require("./outlet/getOutletOfflineOrderFormats.js"),c=require("./outlet/getOutletAvailableOrderFormats.js"),a=require("./outlet/getOutletFormattedDistance.js"),l=require("./outlet/isOutletAcceptingPreOrders.js"),d=require("./outlet/getOutletDeliveryFee.js"),g=require("./outlet/getOutletTodayOpeningTimes.js"),q=require("./outlet/getOutletOrderFormats.js"),O=require("./outlet/serviceDateTimesFromOpeningHours.js"),_=require("./outlet/getPickerIntervalsForDay.js"),k=require("./outlet/getServiceIntervalRange.js"),m=require("./outlet/getServiceIntervalsForOrderFormat.js"),p=require("./outlet/getOutletFormattedAddress.js"),P=require("./outlet/getPartitionedOutletsList.js"),S=require("./outlet/getOutletPickerTimesForWeek.js"),f=require("./outlet/getOutletOrderPrepTime.js"),F=require("./versioning/isVersionALessThanB.js"),h=require("./versioning/cleanVersionString.js"),y=require("./api/getUrlAndParams.js"),T=require("./api/getEndpointWithVersion.js"),v=require("./api/generateBackoffWithEqualJitter.js"),C=require("./api/isAcceptedResponse.js"),I=require("./api/isNoContentResponse.js"),A=require("./string/slugify.js"),D=require("./string/truncate.js"),R=require("./color/lighten.js"),b=require("./color/brighten.js"),V=require("./color/darken.js"),E=require("./color/isDarkBackground.js"),L=require("./user/getFullName.js"),M=require("./user/getFullAddressString.js"),H=require("./user/getCustomerAddressFromGeocoderResult.js"),N=require("./logger/Logger.js"),B=require("./logger/types.js"),U=require("./logger/sanitizeAsStringDict.js"),W=require("./printing/getPrinterType.js"),w=require("./printing/isValidPrinter.js"),G=require("./printing/isValidNetworkPrinter.js"),x=require("./printing/isValidStarCloudPrinter.js"),z=require("./printing/isTerminalPrinter.js"),J=require("./printing/isCloudPrintModeEnabled.js"),K=require("./number/randomIntFromInterval.js"),Q=require("./tables/decodeTableQRPayload.js"),j=require("./checkout/getCheckoutItemModifications.js"),X=require("./checkout/getCheckoutProductName.js"),e=require("./checkout/getCheckoutOrderStatusTexts.js"),Y=require("./checkout/getCheckoutItemsMappedByTicketItemStatus.js"),Z=require("./checkout/isCheckoutOrderSummary.js"),$=require("./currency/getFormattedCurrency.js"),ee=require("./inventory/isDetailedProductOutOfStock.js"),re=require("./inventory/isDetailedProductVariantOutOfStocks.js"),te=require("./inventory/isMenuTreeProductOutOfStock.js"),ie=require("./inventory/isDetailedProductUpSellsOutOfStock.js"),oe=require("./inventory/isUpSellProductOutStock.js"),ne=require("./inventory/isDetailedProductOutletStockOutOfStock.js"),ue=require("./inventory/getDetailedProductVariantStock.js"),se=require("./signalr/createUseSignalRHook.js"),ce=require("./signalr/SignalR.js"),ae=require("./error/createCodedError.js"),le=require("./error/isCodedError.js"),de=require("./error/isNetworkError.js"),ge=require("./error/isLockedError.js"),qe=require("./hangfire/isHangfireResponse.js"),Oe=require("./hangfire/createHangfirePoller.js"),_e=require("./hangfire/createMakeHangfireRequest.js"),ke=require("./product/extractProductsFromMenuTree.js"),me=require("./product/calculateIngredientsCost.js"),pe=require("./product/calculateAddonGroupCost.js");require("moment");require("@ancon/wildcat-types");require("./outlet/constants.js");require("./outlet/getOutletCurrentActiveOperatingHour.js");require("./outlet/getMomentFromDateAndTimeString.js");require("./outlet/searchNextOpeningMoment.js");require("lodash");require("./shared/constants.js");require("./time/toMinutes.js");require("./time/getNextTenthMinute.js");require("./outlet/types.js");require("./outlet/getSettingsForOrderFormat.js");require("./outlet/getServiceIntervalStart.js");require("./outlet/getNextTenthMinute.js");require("./outlet/generatePickerTimesForDay.js");require("./outlet/getServiceIntervalEnd.js");require("./outlet/hoursAndMinutesToMinutes.js");require("compare-versions");require("tinycolor2");require("@ancon/wildcat-printing");require("./currency/getFormattedCurrencyPostfix.js");require("react");require("react-redux");require("@microsoft/signalr");require("./index-4a932b99.js");require("./axios-5f25f7ff.js");exports.isWithinFlag=r;exports.generateId=t;exports.wait=i;exports.getListOutletOpeningHoursTable=o;exports.getOutletTagInformation=n.default;exports.getOutletAvailabilityInfo=u.default;exports.getOutletOfflineOrderFormats=s;exports.getOutletAvailableOrderFormats=c;exports.getOutletFormattedDistance=a;exports.isOutletAcceptingPreOrders=l;exports.getOutletDeliveryFee=d;exports.getOutletTodayOpeningTimes=g;exports.getOutletOrderFormats=q;exports.serviceDateTimesFromOpeningHours=O;exports.getPickerIntervalsForDay=_;exports.getServiceIntervalRange=k;exports.getServiceIntervalsForOrderFormat=m;exports.getOutletFormattedAddress=p;exports.getPartitionedOutletsList=P;exports.getOutletPickerTimesForWeek=S;exports.getOutletOrderPreparationTime=f;exports.isVersionALessThanB=F;exports.cleanVersionString=h;exports.getUrlAndParams=y;exports.getEndpointWithVersion=T;exports.generateBackoffWithEqualJitter=v;exports.isAcceptedResponse=C;exports.isNoContentResponse=I;exports.slugify=A;exports.truncate=D;exports.lighten=R;exports.brighten=b;exports.darken=V;exports.isDarkBackground=E;exports.getFullName=L;exports.getFullAddressString=M;exports.getCustomerAddressFromGeocoderResult=H;exports.Logger=N;exports.LogLevel=B.LogLevel;exports.sanitizeAsStringDict=U;exports.getPrinterType=W;exports.isValidPrinter=w;exports.isValidNetworkPrinter=G;exports.isValidStarCloudPrinter=x;exports.isTerminalPrinter=z;exports.isCloudPrintModeEnabled=J;exports.randomIntFromInterval=K;exports.decodeTableQRPayload=Q;exports.getCheckoutGroupedModifications=j;exports.getCheckoutProductName=X;exports.TranslationKey=e.TranslationKey;exports.getCheckoutOrderStatusTexts=e.default;exports.getCheckoutItemsMappedByTicketItemStatus=Y;exports.isCheckoutOrderSummary=Z;exports.getFormattedCurrency=$;exports.isDetailedProductOutOfStock=ee;exports.isDetailedProductVariantOutOfStocks=re;exports.isMenuTreeProductOutOfStock=te;exports.isDetailedProductUpSellsOutOfStock=ie;exports.isUpSellProductOutOfStock=oe;exports.isDetailedProductOutletStockOutOfStock=ne;exports.getDetailedProductVariantStock=ue;exports.createUseSignalRHook=se;exports.SignalR=ce;exports.createCodedError=ae;exports.isCodedError=le;exports.isNetworkError=de;exports.isLockedError=ge;exports.isHangfireResponse=qe;exports.createHangfirePoller=Oe.default;exports.createMakeHangfireRequest=_e;exports.extractProductsFromMenuTree=ke;exports.calculateIngredientsCost=me;exports.calculateAddonGroupsCost=pe;
|
package/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { default as
|
|
1
|
+
import { default as D } from "./shared/isWithinFlag.mjs";
|
|
2
2
|
import { default as R } from "./shared/generateId.mjs";
|
|
3
3
|
import { default as E } from "./shared/wait.mjs";
|
|
4
4
|
import { default as b } from "./outlet/getListOutletOpeningHoursTable.mjs";
|
|
5
5
|
import { default as M } from "./outlet/getOutletTagInformation.mjs";
|
|
6
6
|
import { default as B } from "./outlet/getOutletAvailabilityInfo.mjs";
|
|
7
7
|
import { default as W } from "./outlet/getOutletOfflineOrderFormats.mjs";
|
|
8
|
-
import { default as
|
|
8
|
+
import { default as G } from "./outlet/getOutletAvailableOrderFormats.mjs";
|
|
9
9
|
import { default as z } from "./outlet/getOutletFormattedDistance.mjs";
|
|
10
10
|
import { default as K } from "./outlet/isOutletAcceptingPreOrders.mjs";
|
|
11
11
|
import { default as j } from "./outlet/getOutletDeliveryFee.mjs";
|
|
@@ -25,14 +25,14 @@ import { default as St } from "./api/getUrlAndParams.mjs";
|
|
|
25
25
|
import { default as Tt } from "./api/getEndpointWithVersion.mjs";
|
|
26
26
|
import { default as ht } from "./api/generateBackoffWithEqualJitter.mjs";
|
|
27
27
|
import { default as yt } from "./api/isAcceptedResponse.mjs";
|
|
28
|
-
import { default as
|
|
28
|
+
import { default as Dt } from "./api/isNoContentResponse.mjs";
|
|
29
29
|
import { default as Rt } from "./string/slugify.mjs";
|
|
30
30
|
import { default as Et } from "./string/truncate.mjs";
|
|
31
31
|
import { default as bt } from "./color/lighten.mjs";
|
|
32
32
|
import { default as Mt } from "./color/brighten.mjs";
|
|
33
33
|
import { default as Bt } from "./color/darken.mjs";
|
|
34
34
|
import { default as Wt } from "./color/isDarkBackground.mjs";
|
|
35
|
-
import { default as
|
|
35
|
+
import { default as Gt } from "./user/getFullName.mjs";
|
|
36
36
|
import { default as zt } from "./user/getFullAddressString.mjs";
|
|
37
37
|
import { default as Kt } from "./user/getCustomerAddressFromGeocoderResult.mjs";
|
|
38
38
|
import { default as jt } from "./logger/Logger.mjs";
|
|
@@ -51,7 +51,7 @@ import { default as ke } from "./checkout/getCheckoutProductName.mjs";
|
|
|
51
51
|
import { TranslationKey as Se, default as Fe } from "./checkout/getCheckoutOrderStatusTexts.mjs";
|
|
52
52
|
import { default as Ce } from "./checkout/getCheckoutItemsMappedByTicketItemStatus.mjs";
|
|
53
53
|
import { default as ve } from "./checkout/isCheckoutOrderSummary.mjs";
|
|
54
|
-
import { default as
|
|
54
|
+
import { default as Ae } from "./currency/getFormattedCurrency.mjs";
|
|
55
55
|
import { default as Ie } from "./inventory/isDetailedProductOutOfStock.mjs";
|
|
56
56
|
import { default as Ve } from "./inventory/isDetailedProductVariantOutOfStocks.mjs";
|
|
57
57
|
import { default as Le } from "./inventory/isMenuTreeProductOutOfStock.mjs";
|
|
@@ -59,7 +59,7 @@ import { default as He } from "./inventory/isDetailedProductUpSellsOutOfStock.mj
|
|
|
59
59
|
import { default as Ne } from "./inventory/isUpSellProductOutStock.mjs";
|
|
60
60
|
import { default as Ue } from "./inventory/isDetailedProductOutletStockOutOfStock.mjs";
|
|
61
61
|
import { default as we } from "./inventory/getDetailedProductVariantStock.mjs";
|
|
62
|
-
import { default as
|
|
62
|
+
import { default as qe } from "./signalr/createUseSignalRHook.mjs";
|
|
63
63
|
import { default as Je } from "./signalr/SignalR.mjs";
|
|
64
64
|
import { default as Qe } from "./error/createCodedError.mjs";
|
|
65
65
|
import { default as Xe } from "./error/isCodedError.mjs";
|
|
@@ -69,6 +69,8 @@ import { default as er } from "./hangfire/isHangfireResponse.mjs";
|
|
|
69
69
|
import { default as or } from "./hangfire/createHangfirePoller.mjs";
|
|
70
70
|
import { default as fr } from "./hangfire/createMakeHangfireRequest.mjs";
|
|
71
71
|
import { default as lr } from "./product/extractProductsFromMenuTree.mjs";
|
|
72
|
+
import { default as ur } from "./product/calculateIngredientsCost.mjs";
|
|
73
|
+
import { default as ir } from "./product/calculateAddonGroupCost.mjs";
|
|
72
74
|
import "moment";
|
|
73
75
|
import "@ancon/wildcat-types";
|
|
74
76
|
import "./outlet/constants.mjs";
|
|
@@ -101,11 +103,13 @@ export {
|
|
|
101
103
|
Je as SignalR,
|
|
102
104
|
Se as TranslationKey,
|
|
103
105
|
Mt as brighten,
|
|
106
|
+
ir as calculateAddonGroupsCost,
|
|
107
|
+
ur as calculateIngredientsCost,
|
|
104
108
|
kt as cleanVersionString,
|
|
105
109
|
Qe as createCodedError,
|
|
106
110
|
or as createHangfirePoller,
|
|
107
111
|
fr as createMakeHangfireRequest,
|
|
108
|
-
|
|
112
|
+
qe as createUseSignalRHook,
|
|
109
113
|
Bt as darken,
|
|
110
114
|
ne as decodeTableQRPayload,
|
|
111
115
|
lr as extractProductsFromMenuTree,
|
|
@@ -118,12 +122,12 @@ export {
|
|
|
118
122
|
Kt as getCustomerAddressFromGeocoderResult,
|
|
119
123
|
we as getDetailedProductVariantStock,
|
|
120
124
|
Tt as getEndpointWithVersion,
|
|
121
|
-
|
|
125
|
+
Ae as getFormattedCurrency,
|
|
122
126
|
zt as getFullAddressString,
|
|
123
|
-
|
|
127
|
+
Gt as getFullName,
|
|
124
128
|
b as getListOutletOpeningHoursTable,
|
|
125
129
|
B as getOutletAvailabilityInfo,
|
|
126
|
-
|
|
130
|
+
G as getOutletAvailableOrderFormats,
|
|
127
131
|
j as getOutletDeliveryFee,
|
|
128
132
|
dt as getOutletFormattedAddress,
|
|
129
133
|
z as getOutletFormattedDistance,
|
|
@@ -152,7 +156,7 @@ export {
|
|
|
152
156
|
$e as isLockedError,
|
|
153
157
|
Le as isMenuTreeProductOutOfStock,
|
|
154
158
|
Ze as isNetworkError,
|
|
155
|
-
|
|
159
|
+
Dt as isNoContentResponse,
|
|
156
160
|
K as isOutletAcceptingPreOrders,
|
|
157
161
|
de as isTerminalPrinter,
|
|
158
162
|
Ne as isUpSellProductOutOfStock,
|
|
@@ -160,7 +164,7 @@ export {
|
|
|
160
164
|
re as isValidPrinter,
|
|
161
165
|
se as isValidStarCloudPrinter,
|
|
162
166
|
ct as isVersionALessThanB,
|
|
163
|
-
|
|
167
|
+
D as isWithinFlag,
|
|
164
168
|
bt as lighten,
|
|
165
169
|
pe as randomIntFromInterval,
|
|
166
170
|
_t as sanitizeAsStringDict,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancon/wildcat-utils",
|
|
3
|
-
"version": "1.27.
|
|
3
|
+
"version": "1.27.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -421,6 +421,16 @@
|
|
|
421
421
|
"require": "./printing/isValidStarCloudPrinter.js",
|
|
422
422
|
"types": "./printing/isValidStarCloudPrinter.d.ts"
|
|
423
423
|
},
|
|
424
|
+
"./product/calculateAddonGroupCost": {
|
|
425
|
+
"import": "./product/calculateAddonGroupCost.mjs",
|
|
426
|
+
"require": "./product/calculateAddonGroupCost.js",
|
|
427
|
+
"types": "./product/calculateAddonGroupCost.d.ts"
|
|
428
|
+
},
|
|
429
|
+
"./product/calculateIngredientsCost": {
|
|
430
|
+
"import": "./product/calculateIngredientsCost.mjs",
|
|
431
|
+
"require": "./product/calculateIngredientsCost.js",
|
|
432
|
+
"types": "./product/calculateIngredientsCost.d.ts"
|
|
433
|
+
},
|
|
424
434
|
"./product/extractProductsFromMenuTree": {
|
|
425
435
|
"import": "./product/extractProductsFromMenuTree.mjs",
|
|
426
436
|
"require": "./product/extractProductsFromMenuTree.js",
|
|
@@ -431,6 +441,11 @@
|
|
|
431
441
|
"require": "./product/index.js",
|
|
432
442
|
"types": "./product/index.d.ts"
|
|
433
443
|
},
|
|
444
|
+
"./product/types": {
|
|
445
|
+
"import": "./product/types.mjs",
|
|
446
|
+
"require": "./product/types.js",
|
|
447
|
+
"types": "./product/types.d.ts"
|
|
448
|
+
},
|
|
434
449
|
"./shared/constants": {
|
|
435
450
|
"import": "./shared/constants.mjs",
|
|
436
451
|
"require": "./shared/constants.js",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function P(I,g){return g.reduce((o,m)=>{const{ingredients:c,addonId:F,selectedIngredientId:l,selectedCount:f}=m,a=I.find(e=>e.addOnGroupId===F);if(a){const{ingredients:e,addOnSettings:A}=a;if(l){const n=e==null?void 0:e.find(t=>t.id===l);if(n){const t=c.some(i=>i.freeAmount===1),{price:d}=n;return o+(t?0:d)}}const{afterFreePrice:p,freeAmount:s}=A,O=s!==null&&p!==null&&s>0&&f>s,D=c.reduce((n,t)=>{const{selectedCount:d,freeAmount:i}=t;if(f>0){const u=d-i;if(u===0)return n;if(O){const r=u*p.amount;return n+r}const C=e==null?void 0:e.find(r=>r.id===t.id);if(C){const{price:r}=C,G=r*u;return n+G}}return n},0);return o+D}return o},0)}module.exports=P;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
function b(I, g) {
|
|
2
|
+
return g.reduce((o, m) => {
|
|
3
|
+
const {
|
|
4
|
+
ingredients: c,
|
|
5
|
+
addonId: F,
|
|
6
|
+
selectedIngredientId: l,
|
|
7
|
+
selectedCount: a
|
|
8
|
+
} = m, f = I.find((e) => e.addOnGroupId === F);
|
|
9
|
+
if (f) {
|
|
10
|
+
const { ingredients: e, addOnSettings: A } = f;
|
|
11
|
+
if (l) {
|
|
12
|
+
const n = e == null ? void 0 : e.find(
|
|
13
|
+
(t) => t.id === l
|
|
14
|
+
);
|
|
15
|
+
if (n) {
|
|
16
|
+
const t = c.some(
|
|
17
|
+
(i) => i.freeAmount === 1
|
|
18
|
+
), { price: s } = n;
|
|
19
|
+
return o + (t ? 0 : s);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const { afterFreePrice: p, freeAmount: d } = A, O = d !== null && p !== null && d > 0 && a > d, D = c.reduce(
|
|
23
|
+
(n, t) => {
|
|
24
|
+
const {
|
|
25
|
+
selectedCount: s,
|
|
26
|
+
freeAmount: i
|
|
27
|
+
} = t;
|
|
28
|
+
if (a > 0) {
|
|
29
|
+
const u = s - i;
|
|
30
|
+
if (u === 0)
|
|
31
|
+
return n;
|
|
32
|
+
if (O) {
|
|
33
|
+
const r = u * p.amount;
|
|
34
|
+
return n + r;
|
|
35
|
+
}
|
|
36
|
+
const C = e == null ? void 0 : e.find(
|
|
37
|
+
(r) => r.id === t.id
|
|
38
|
+
);
|
|
39
|
+
if (C) {
|
|
40
|
+
const { price: r } = C, G = r * u;
|
|
41
|
+
return n + G;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return n;
|
|
45
|
+
},
|
|
46
|
+
0
|
|
47
|
+
);
|
|
48
|
+
return o + D;
|
|
49
|
+
}
|
|
50
|
+
return o;
|
|
51
|
+
}, 0);
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
b as default
|
|
55
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Ingredient } from '@ancon/wildcat-types';
|
|
2
|
+
import { ConfigureIngredientFormState } from './types';
|
|
3
|
+
export default function calculateIngredientsCost(ingredients: Ingredient[], ingredientFormState: ConfigureIngredientFormState[], allowDynamicPricing?: boolean, maximumDynamicPricingIngredients?: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function g(u,o,f,d){function c(t){return u.find(e=>e.ingredientId===t)}let l=0,p=0;if(f){const t=o.filter(e=>!e.selected).sort((e,n)=>e.position-n.position);d?l=(t.length>d?t.slice(0,d):t).reduce((i,s)=>{const r=c(s.id);return r?i-r.price:i},0):l=t.reduce((e,n)=>{const i=c(n.id);return i?e-i.price:e},0)}return p=o.reduce((t,e)=>{const n=c(e.id);if(n&&e.replacementId){const{replacementId:i}=e,s=n.replacements.find(r=>r.ingredientId===i);if(s)return t+s.price}return t},0),p+l}module.exports=g;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function g(u, o, f, s) {
|
|
2
|
+
function l(t) {
|
|
3
|
+
return u.find((e) => e.ingredientId === t);
|
|
4
|
+
}
|
|
5
|
+
let c = 0, p = 0;
|
|
6
|
+
if (f) {
|
|
7
|
+
const t = o.filter((e) => !e.selected).sort((e, n) => e.position - n.position);
|
|
8
|
+
s ? c = (t.length > s ? t.slice(0, s) : t).reduce(
|
|
9
|
+
(i, d) => {
|
|
10
|
+
const r = l(d.id);
|
|
11
|
+
return r ? i - r.price : i;
|
|
12
|
+
},
|
|
13
|
+
0
|
|
14
|
+
) : c = t.reduce(
|
|
15
|
+
(e, n) => {
|
|
16
|
+
const i = l(n.id);
|
|
17
|
+
return i ? e - i.price : e;
|
|
18
|
+
},
|
|
19
|
+
0
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
return p = o.reduce(
|
|
23
|
+
(t, e) => {
|
|
24
|
+
const n = l(e.id);
|
|
25
|
+
if (n && e.replacementId) {
|
|
26
|
+
const { replacementId: i } = e, d = n.replacements.find(
|
|
27
|
+
(r) => r.ingredientId === i
|
|
28
|
+
);
|
|
29
|
+
if (d)
|
|
30
|
+
return t + d.price;
|
|
31
|
+
}
|
|
32
|
+
return t;
|
|
33
|
+
},
|
|
34
|
+
0
|
|
35
|
+
), p + c;
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
g as default
|
|
39
|
+
};
|
package/product/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import extractProductsFromMenuTree from './extractProductsFromMenuTree';
|
|
2
|
-
|
|
2
|
+
import calculateIngredientsCost from './calculateIngredientsCost';
|
|
3
|
+
import calculateAddonGroupsCost from './calculateAddonGroupCost';
|
|
4
|
+
export { extractProductsFromMenuTree, calculateIngredientsCost, calculateAddonGroupsCost, };
|
package/product/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./extractProductsFromMenuTree.js");require("@ancon/wildcat-types");exports.extractProductsFromMenuTree=e;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./extractProductsFromMenuTree.js"),t=require("./calculateIngredientsCost.js"),r=require("./calculateAddonGroupCost.js");require("@ancon/wildcat-types");exports.extractProductsFromMenuTree=e;exports.calculateIngredientsCost=t;exports.calculateAddonGroupsCost=r;
|
package/product/index.mjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { default as
|
|
1
|
+
import { default as r } from "./extractProductsFromMenuTree.mjs";
|
|
2
|
+
import { default as s } from "./calculateIngredientsCost.mjs";
|
|
3
|
+
import { default as d } from "./calculateAddonGroupCost.mjs";
|
|
2
4
|
import "@ancon/wildcat-types";
|
|
3
5
|
export {
|
|
4
|
-
|
|
6
|
+
d as calculateAddonGroupsCost,
|
|
7
|
+
s as calculateIngredientsCost,
|
|
8
|
+
r as extractProductsFromMenuTree
|
|
5
9
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { AddonSettings } from '@ancon/wildcat-types';
|
|
2
|
+
export declare type ConfigureIngredientFormState = {
|
|
3
|
+
id: string;
|
|
4
|
+
selected: boolean;
|
|
5
|
+
position: number;
|
|
6
|
+
replacementId?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type ConfigureAddonIngredientFormState = {
|
|
9
|
+
id: string;
|
|
10
|
+
selectedCount: number;
|
|
11
|
+
freeAmount: number;
|
|
12
|
+
};
|
|
13
|
+
export declare type ConfigureAddonGroupFormState = {
|
|
14
|
+
addonId: string;
|
|
15
|
+
ingredients: ConfigureAddonIngredientFormState[];
|
|
16
|
+
selectedIngredientId?: string;
|
|
17
|
+
selectedCount: number;
|
|
18
|
+
addOnSettings: AddonSettings;
|
|
19
|
+
};
|
|
20
|
+
export declare type ConfigureUpsellGroupFormState = {
|
|
21
|
+
variantId: string;
|
|
22
|
+
selectedCount: number;
|
|
23
|
+
};
|
|
24
|
+
export declare enum ConfigureProductFormStep {
|
|
25
|
+
Product = 0,
|
|
26
|
+
UpsellGroup = 1
|
|
27
|
+
}
|
|
28
|
+
export declare type ConfigureProductFormState = {
|
|
29
|
+
activeAccordionIndex?: string;
|
|
30
|
+
selectedVariantId: string;
|
|
31
|
+
selectedVariantShowingPrice: number;
|
|
32
|
+
selectedIngredients: ConfigureIngredientFormState[];
|
|
33
|
+
selectedAddons: ConfigureAddonGroupFormState[];
|
|
34
|
+
quantity: number;
|
|
35
|
+
outletId: string;
|
|
36
|
+
};
|
|
37
|
+
export declare type ConfigureProductUpsellGroupFormState = {
|
|
38
|
+
upsellGroupId: string;
|
|
39
|
+
selectedUpsellGroups: ConfigureUpsellGroupFormState[];
|
|
40
|
+
};
|
package/product/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=(l=>(l[l.Product=0]="Product",l[l.UpsellGroup=1]="UpsellGroup",l))(e||{});exports.ConfigureProductFormStep=e;
|