@licklist/design 0.44.500 → 0.44.501

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
- {"version":3,"file":"CategoryProduct.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,UAAU,oBAAoB;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,kBAAkB,CAAC,EAAE,cAAc,CAAC,oBAAoB,CAAC,CAAC;IAC1D,eAAe,CAAC,EAAE,cAAc,CAAC,oBAAoB,CAAC,CAAC;CACxD;AAED,eAAO,MAAM,eAAe,sFAMzB,oBAAoB,gBAqLtB,CAAC"}
1
+ {"version":3,"file":"CategoryProduct.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,UAAU,oBAAoB;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,kBAAkB,CAAC,EAAE,cAAc,CAAC,oBAAoB,CAAC,CAAC;IAC1D,eAAe,CAAC,EAAE,cAAc,CAAC,oBAAoB,CAAC,CAAC;CACxD;AAED,eAAO,MAAM,eAAe,sFAMzB,oBAAoB,gBAwMtB,CAAC"}
@@ -1 +1 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("tslib"),t=require("react"),i=e(t),n=require("@licklist/core/dist/Config"),a=require("react-i18next"),o=require("react-hook-form"),c=e(require("@licklist/plugins/dist/services/Form/HookFormService")),u=e(require("clsx")),s=require("react-intl"),d=require("../../../event/ticket-description/TicketDescription.js"),l=require("./components/ProductQuantityInput/ProductQuantityInput.js");exports.CategoryProduct=function(e){var m=e.product,p=e.category,f=e.canExpandDescription,v=void 0===f||f,y=e.productsWithErrors,g=e.soldOutProducts,E=s.useIntl().formatNumber,q=a.useTranslation(["Design","Validation"]).t,_=o.useFormContext(),x=_.control,N=_.clearErrors,A=_.setError,C=t.useMemo((function(){if(y){var e=y.find((function(e){return e.product_id===m.id}));return null==e?void 0:e.message}}),[y,m.id]),P=t.useMemo((function(){if(p.allowDeposits&&m.deposit&&!(null==m?void 0:m.isSoldOut)&&!(m.deposit>=m.price))return m.deposit}),[p,m]),D=function(){if(g&&!(null==m?void 0:m.isSoldOut)){var e=g.find((function(e){return e.product_id===m.id}));return!!(null==e?void 0:e.message)}};return t.useEffect((function(){C&&A("".concat(m.id),{message:C,type:"validate"})}),[C,m.id]),i.createElement(o.Controller,{control:x,name:"".concat(m.id),rules:{required:m.isRequired,validate:function(e){if(!e)return!0;var r=m.isRequired,t=void 0!==r&&r,i=m.maxAmount,n=void 0===i?0:i,a=m.minAmount,o=void 0===a?0:a,c=e.quantity,u=void 0===c?0:c;return!u&&!t||(!u&&t?q("Design:pleaseSelectAtLeastFrom",{min:1,type:"item",from:"this category"}):u<o?q("Validation:fieldMinNumber",{min:m.minAmount,attribute:m.name}):!(n&&u>=o&&n<u)||q("Validation:quantityMaxNumber",{max:m.maxAmount}))}},render:function(e){var t=e.field,a=t.onChange,o=t.value,s=void 0===o?{}:o,f=t.ref,y=e.fieldState,g=y.invalid,_=y.error;return i.createElement("div",{id:String(m.id),className:"iframe-event__category-product"},i.createElement("div",{className:u("iframe-event__product",g&&"error")},i.createElement(d.TicketDescription,{title:m.name,description:m.description,className:u("iframe-event__product-description"),images:m.images,isRequired:m.isRequired,canExpand:v})),i.createElement("div",{className:"iframe-event__product-price-wrapper"},i.createElement("span",{className:"product-price"},E(null!=P?P:m.price,{style:"currency",currency:n.Currency.GBP})),i.createElement(l.ProductQuantityInput,{onChange:a,productInfo:s,ref:f,clearErrors:N,product:r.__assign(r.__assign({},m),{isSoldOut:(null==m?void 0:m.isSoldOut)||D()}),category:p,invalid:g,deposit:P})),P&&!(null==p?void 0:p.remainderExpireAfter)&&i.createElement("div",{className:"mt-4"},q("Design:payNowAndUponArrival",{deposit:E(P,{style:"currency",currency:n.Currency.GBP}),remainder:E(m.price-P,{style:"currency",currency:n.Currency.GBP})})),P&&(null==p?void 0:p.remainderExpireAfter)>0&&i.createElement("div",{className:"mt-4"},q("Design:payNowAndReminderDays",{deposit:E(P,{style:"currency",currency:n.Currency.GBP}),remainder:E(m.price-P,{style:"currency",currency:n.Currency.GBP}),days:null==p?void 0:p.remainderExpireAfter})),g&&i.createElement("div",{className:"d-flex mt-3 w-100"},i.createElement("p",{className:"iframe-event__message-error"},c.hasError(_,"required")&&q("Design:pleaseSelectAtLeastFrom",{min:1,type:"item",from:"this category"}),c.hasError(_,"validate")&&_.message)))}})};
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("tslib"),t=require("react"),i=e(t),n=require("@licklist/core/dist/Config"),a=require("react-i18next"),c=require("react-hook-form"),o=e(require("@licklist/plugins/dist/services/Form/HookFormService")),u=e(require("clsx")),s=require("react-intl"),d=require("../../../event/ticket-description/TicketDescription.js"),l=require("./components/ProductQuantityInput/ProductQuantityInput.js");exports.CategoryProduct=function(e){var m=e.product,p=e.category,y=e.canExpandDescription,v=void 0===y||y,f=e.productsWithErrors,g=e.soldOutProducts,E=s.useIntl().formatNumber,q=a.useTranslation(["Design","Validation"]).t,_=c.useFormContext(),x=_.control,N=_.clearErrors,S=_.setError,A=t.useMemo((function(){if(f){var e=f.find((function(e){return e.product_id===m.id}));return null==e?void 0:e.message}}),[f,m.id]),C=t.useMemo((function(){if(p.allowDeposits&&m.deposit&&!(null==m?void 0:m.isSoldOut)&&!(m.deposit>=m.price))return m.deposit}),[p,m]),P=function(){if(g&&!(null==m?void 0:m.isSoldOut)){var e=g.find((function(e){return e.product_id===m.id}));return!!(null==e?void 0:e.message)}};return t.useEffect((function(){A&&S("".concat(m.id),{message:A,type:"validate"})}),[A,m.id]),i.createElement(c.Controller,{control:x,name:"".concat(m.id),rules:{required:m.isRequired,validate:function(e){var r,t=m.isRequired,i=void 0!==t&&t,a=m.maxAmount,c=void 0===a?0:a,o=m.minAmount,u=void 0===o?0:o,s=m.minSpend,d=m.price,l=null!==(r=null==e?void 0:e.quantity)&&void 0!==r?r:0;return s&&l*d<s?q("Design:minimumSpendSumValidation",{minSpend:E(s,{style:"currency",currency:n.Currency.GBP})}):!e||(!l&&!i||(!l&&i?q("Design:pleaseSelectAtLeastFrom",{min:1,type:"item",from:"this category"}):l<u?q("Validation:fieldMinNumber",{min:m.minAmount,attribute:m.name}):!(c&&l>=u&&c<l)||q("Validation:quantityMaxNumber",{max:m.maxAmount})))}},render:function(e){var t=e.field,a=t.onChange,c=t.value,s=void 0===c?{}:c,y=t.ref,f=e.fieldState,g=f.invalid,_=f.error;return i.createElement("div",{id:String(m.id),className:"iframe-event__category-product"},i.createElement("div",{className:u("iframe-event__product",g&&"error")},i.createElement(d.TicketDescription,{title:m.name,description:m.description,className:u("iframe-event__product-description"),images:m.images,isRequired:m.isRequired,canExpand:v})),i.createElement("div",{className:"iframe-event__product-price-wrapper"},i.createElement("span",{className:"product-price"},E(null!=C?C:m.price,{style:"currency",currency:n.Currency.GBP})),i.createElement(l.ProductQuantityInput,{onChange:a,productInfo:s,ref:y,clearErrors:N,product:r.__assign(r.__assign({},m),{isSoldOut:(null==m?void 0:m.isSoldOut)||P()}),category:p,invalid:g,deposit:C})),C&&!(null==p?void 0:p.remainderExpireAfter)&&i.createElement("div",{className:"mt-4"},q("Design:payNowAndUponArrival",{deposit:E(C,{style:"currency",currency:n.Currency.GBP}),remainder:E(m.price-C,{style:"currency",currency:n.Currency.GBP})})),C&&(null==p?void 0:p.remainderExpireAfter)>0&&i.createElement("div",{className:"mt-4"},q("Design:payNowAndReminderDays",{deposit:E(C,{style:"currency",currency:n.Currency.GBP}),remainder:E(m.price-C,{style:"currency",currency:n.Currency.GBP}),days:null==p?void 0:p.remainderExpireAfter})),g&&i.createElement("div",{className:"d-flex mt-3 w-100"},i.createElement("p",{className:"iframe-event__message-error"},o.hasError(_,"required")&&q("Design:pleaseSelectAtLeastFrom",{min:1,type:"item",from:"this category"}),o.hasError(_,"validate")&&_.message)))}})};
@@ -22,6 +22,7 @@ export interface ProductControlValues extends FormValues, ProductDepositControlV
22
22
  isRequired: boolean;
23
23
  quantitySelector: number;
24
24
  hasSpecialNotes: boolean;
25
+ minSpend?: number | null;
25
26
  type?: ProductType;
26
27
  weight?: number;
27
28
  tierId?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"ProductControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/product/ProductControl.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,YAAY,EAMb,MAAM,kEAAkE,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,0DAA0D,CAAC;AAEvF,OAAO,EACL,mBAAmB,EACnB,UAAU,EACX,MAAM,8DAA8D,CAAC;AAEtE,OAAc,EACZ,WAAW,EAKZ,MAAM,OAAO,CAAC;AAef,OAAO,EACL,KAAK,EAEN,MAAM,sDAAsD,CAAC;AAO9D,OAAO,EAEL,oCAAoC,EACpC,qCAAqC,EACtC,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,iCAAiC,CAAC;AAOzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAO5C,MAAM,WAAW,oBACf,SAAQ,UAAU,EACh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CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,UAAU,EAAE,EACnD,SAAiB,EACjB,eAAe,EACf,aAAqB,EACrB,oBAA4B,EAC5B,QAAa,EACb,MAAM,EACN,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,YAAY,GACb,EAAE,mBAAmB,CAAC,CAAC,CAAC,eAmfxB"}
1
+ {"version":3,"file":"ProductControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/product/ProductControl.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,YAAY,EAMb,MAAM,kEAAkE,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,0DAA0D,CAAC;AAEvF,OAAO,EACL,mBAAmB,EACnB,UAAU,EACX,MAAM,8DAA8D,CAAC;AAEtE,OAAc,EACZ,WAAW,EAKZ,MAAM,OAAO,CAAC;AAef,OAAO,EACL,KAAK,EAEN,MAAM,sDAAsD,CAAC;AAO9D,OAAO,EAEL,oCAAoC,EACpC,qCAAqC,EACtC,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,iCAAiC,CAAC;AAOzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAO5C,MAAM,WAAW,oBACf,SAAQ,UAAU,EAChB,2BAA2B,EAC3B,qCAAqC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,O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BxB"}
@@ -1 +1 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),a=require("react"),n=e(a),r=require("react-i18next"),o=e(require("react-bootstrap/Row")),l=e(require("react-bootstrap/Col")),i=require("react-bootstrap"),c=require("../../static/Icon.js"),s=require("react-hook-form"),m=e(require("@licklist/plugins/dist/services/Form/HookFormService")),u=require("@react-aria/utils"),d=require("../../static/switch/BooleanSwitch.js"),E=require("../../static/form-number-input/FormNumberInput.js");require("../../static/index.js");var p=require("../form/context.js"),g=require("@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper"),f=require("./booking-management/ProductBookingManagementControl.js"),C=require("./deposit/ProductDepositControl.js"),v=require("./quantity/ProductQuantityControl.js"),b=require("./quantity/ProductQuantityConstantControl.js"),h=require("./quantity/ProductQuantityRechargingControl.js"),F=e(require("react-bootstrap/Collapse")),I=require("@licklist/plugins/dist/hooks/Media/useImages"),N=require("@licklist/core/dist/DataMapper/Media/ImageDataMapper"),P=require("../../file-upload/FileUpload.js"),q=require("../../tiptap-editor/TipTapEditor.js"),y=require("./fixed-duration-fields/FixedDurationOptions.js"),k=require("./duration/ProductDurationControl.js"),x=require("./price/ProductPriceControl.js");exports.ProductControl=function(e){var T=e.isLoading,_=void 0!==T&&T,L=e.fieldNamePrefix,j=e.allowDeposits,S=void 0!==j&&j,w=e.hasBookingManagement,A=void 0!==w&&w,D=e.zoneList,G=void 0===D?[]:D,B=e.onCopy,M=e.onProductNameChange,R=e.productName,O=e.hasTicket,U=e.categoryType,Y=s.useFormContext(),Q=Y.register,V=Y.control,H=Y.formState.errors,z=Y.setValue,X=Y.getValues,W=Y.watch,J=a.useContext(p.ProductSetLoadingContext),K=J.setLoading,Z=J.providerHasBookingManagement,$=r.useTranslation("Design").t,ee=t.__read(a.useState(!1),2),te=ee[0],ae=ee[1],ne=t.__read(a.useState(null),2),re=ne[0],oe=ne[1],le=Boolean(W("".concat(L,".isUnlimited"))),ie=u.useId(),ce=u.useId(),se=u.useId(),me=u.useId(),ue=u.useId(),de=u.useId(),Ee=u.useId(),pe=u.useId(),ge=u.useId(),fe=u.useId(),Ce=[{id:1,value:$("quantitySelector")},{id:2,value:$("stockControl")}],ve=a.useCallback((function(){return ae((function(e){return!e}))}),[]),be=s.useWatch({control:V,name:"".concat(L,".quantitySelector")}),he=I.useImages(re),Fe=he.images,Ie=he.handleImageRemove,Ne=he.handleImageUploading,Pe=he.isLoading,qe=a.useCallback((function(e){Ne(e,N.IMAGE_TYPE_IMAGE)}),[Ne]),ye=a.useCallback((function(e,t){Ie(String(e),t)}),[Ie]),ke=function(e){return e.target.select()};a.useEffect((function(){K(Pe)}),[K,Pe]),a.useEffect((function(){var e=X("".concat(L,".images"));oe(e)}),[X,oe,L]),a.useEffect((function(){Array.isArray(Fe)&&z("".concat(L,".images"),Fe)}),[Fe,L,z]);var xe=null!=be?be:"1",Te=g.QUANTITY_TYPE_LIST_DTO[xe];return n.createElement(n.Fragment,null,n.createElement(o,null,n.createElement(l,{lg:8,md:8},n.createElement(i.Form.Group,{controlId:ce},n.createElement(i.Form.Label,null,$("name")),n.createElement(i.Form.Control,t.__assign({},Q("".concat(L,".name")),{value:R,onChange:M,isInvalid:m.isInvalid("".concat(L,".name"),H),disabled:_,placeholder:$("name")})),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".name"),H))),n.createElement(i.Form.Group,{controlId:se},n.createElement(i.Form.Label,null,$("description")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange;return n.createElement(q.TipTapEditor,{withEmoji:!1,viewMode:!1,onUpdate:r,content:a,disabled:_})},control:V,name:"".concat(L,".description")}),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".description"),H))),S?n.createElement(o,null,n.createElement(C.ProductDepositControl,{isLoading:_,fieldNamePrefix:L}),n.createElement(x.ProductPriceControl,{isLoading:_,fieldNamePrefix:L,title:$("totalPrice"),allowDeposits:S})):n.createElement(x.ProductPriceControl,{isLoading:_,fieldNamePrefix:L}),n.createElement("div",null,n.createElement(v.ProductQuantityControl,{isLoading:_,fieldNamePrefix:L,onFocus:ke}),Te===g.QUANTITY_TYPE_CONSTANT&&n.createElement(b.ProductQuantityConstantControl,{isLoading:_,fieldNamePrefix:L,onFocus:ke,disabled:le}),Te===g.QUANTITY_TYPE_RECHARGING&&n.createElement(h.ProductQuantityRechargingControl,{isLoading:_,fieldNamePrefix:L,onFocus:ke,disabled:le}),n.createElement(i.Form.Group,{controlId:fe,className:"custom-checkbox"},n.createElement(i.Form.Check,t.__assign({custom:!0,type:"checkbox"},Q("".concat(L,".isUnlimited")),{name:"".concat(L,".isUnlimited"),disabled:_})),n.createElement(i.Form.Check.Label,null,$("isUnlimited")))),n.createElement(i.Form.Group,{controlId:pe},n.createElement(i.Form.Label,null,$("quantitySelectorType")),n.createElement(i.Form.Control,t.__assign({as:"select",defaultValue:O?Ce[0].id:void 0},Q("".concat(L,".quantitySelector")),{isInvalid:m.isInvalid("".concat(L,".quantitySelector"),H),disabled:_||O}),Ce.map((function(e){return n.createElement("option",{value:e.id,key:e.id},e.value)}))),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".quantitySelector"),H))))),U===g.CATEGORY_TYPE_FIXED_DURATION&&n.createElement(o,{className:"align-items-start"},n.createElement(k.ProductDurationControl,{fieldNamePrefix:L,providerHasBookingManagement:Z}),n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".capacity"),label:$("capacity")}))),U===g.CATEGORY_TYPE_GAME&&n.createElement(o,{className:"align-items-start"},n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".capacity"),label:$("capacity"),rules:{min:{value:1,message:$("Validation:fieldRequired",{attribute:$("capacity")})}}})),n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".duration"),label:$("durationMinutes"),rules:{min:{value:1,message:$("Validation:fieldRequired",{attribute:$("duration")})}}}))),n.createElement(o,null,n.createElement(l,{lg:8,md:8},n.createElement(i.Form.Group,{controlId:me},n.createElement(i.Form.Label,null,$("productTermsConditions")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name,l=t.ref;return n.createElement(i.Form.Control,{ref:l,as:"textarea",rows:3,value:a,onChange:r,isInvalid:m.isInvalid("".concat(L,".termsAndConditions"),H),disabled:_,name:o})},control:V,name:"".concat(L,".termsAndConditions")}),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".termsAndConditions"),H)))),n.createElement(l,{lg:4,md:4,className:"licklist-file-upload-wrapper"},n.createElement(P.FileUpload,{onFilesChange:qe,allowedExtensions:["jpeg","jpg","png"],subTitle:".jpeg .jpg .png",enablePreview:!0,onFileRemove:ye,defaultFiles:Fe,isLoading:Pe,withIcon:!0,title:$("addImage")}))),n.createElement(l,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(i.Form.Group,{controlId:ue,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,$("isAvailable")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(d.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:_})},control:V,name:"".concat(L,".isAvailable")})),n.createElement(i.Form.Group,{controlId:de,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,$("isSoldOut")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(d.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:_})},control:V,name:"".concat(L,".isSoldOut")})),n.createElement(i.Form.Group,{controlId:ie,className:"custom-checkbox"},n.createElement(i.Form.Check,{custom:!0,type:"checkbox",name:ie,disabled:_},n.createElement(i.Form.Check.Input,{checked:te,onChange:ve,type:"checkbox"}),n.createElement(i.Form.Check.Label,null,$("showAdvancedOptions"))))),n.createElement(l,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(F,{in:te},n.createElement("div",null,n.createElement(i.Form.Group,{controlId:Ee,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,$("isRequired")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(d.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:_})},control:V,name:"".concat(L,".isRequired")})),n.createElement(i.Form.Group,{controlId:ge,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,$("hasSpecialNotes")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(d.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:_})},control:V,name:"".concat(L,".hasSpecialNotes")})),U===g.CATEGORY_TYPE_FIXED_DURATION&&n.createElement(y.FixedDurationOptions,{fieldNamePrefix:L}))),n.createElement(o,null,n.createElement(l,{xs:12},A&&n.createElement(f.ProductBookingManagementControl,{isLoading:_,zoneList:G,fieldNamePrefix:L})))),n.createElement(o,null,n.createElement(l,{xs:!0},n.createElement("div",{className:"d-flex justify-content-end mt-4"},Boolean(B)&&n.createElement(i.Button,{onClick:B,variant:"link",className:"d-flex align-items-center"},n.createElement(c.default,{type:"clipboard",height:"1rem",className:"mr-2"})," ",$("copy"))))))};
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),a=require("react"),n=e(a),r=require("react-i18next"),o=e(require("react-bootstrap/Row")),l=e(require("react-bootstrap/Col")),i=require("react-bootstrap"),c=require("../../static/Icon.js"),s=require("react-hook-form"),m=e(require("@licklist/plugins/dist/services/Form/HookFormService")),d=require("@react-aria/utils"),u=require("../../static/switch/BooleanSwitch.js"),E=require("../../static/form-number-input/FormNumberInput.js");require("../../static/index.js");var p=require("../form/context.js"),g=require("@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper"),f=require("./booking-management/ProductBookingManagementControl.js"),C=require("./deposit/ProductDepositControl.js"),v=require("./quantity/ProductQuantityControl.js"),b=require("./quantity/ProductQuantityConstantControl.js"),h=require("./quantity/ProductQuantityRechargingControl.js"),F=e(require("react-bootstrap/Collapse")),I=require("@licklist/plugins/dist/hooks/Media/useImages"),P=require("@licklist/core/dist/DataMapper/Media/ImageDataMapper"),N=require("../../file-upload/FileUpload.js"),q=require("../../tiptap-editor/TipTapEditor.js"),y=require("./fixed-duration-fields/FixedDurationOptions.js"),k=require("./duration/ProductDurationControl.js"),x=require("./price/ProductPriceControl.js");exports.ProductControl=function(e){var T=e.isLoading,_=void 0!==T&&T,L=e.fieldNamePrefix,S=e.allowDeposits,w=void 0!==S&&S,j=e.hasBookingManagement,A=void 0!==j&&j,D=e.zoneList,G=void 0===D?[]:D,M=e.onCopy,B=e.onProductNameChange,R=e.productName,O=e.hasTicket,U=e.categoryType,Y=s.useFormContext(),Q=Y.register,V=Y.control,H=Y.formState.errors,z=Y.setValue,X=Y.getValues,W=Y.watch,Z=a.useContext(p.ProductSetLoadingContext),J=Z.setLoading,K=Z.providerHasBookingManagement,$=r.useTranslation("Design").t,ee=t.__read(a.useState(!1),2),te=ee[0],ae=ee[1],ne=t.__read(a.useState(null),2),re=ne[0],oe=ne[1],le=Boolean(W("".concat(L,".isUnlimited"))),ie=d.useId(),ce=d.useId(),se=d.useId(),me=d.useId(),de=d.useId(),ue=d.useId(),Ee=d.useId(),pe=d.useId(),ge=d.useId(),fe=d.useId(),Ce=d.useId(),ve=[{id:1,value:$("quantitySelector")},{id:2,value:$("stockControl")}],be=a.useCallback((function(){return ae((function(e){return!e}))}),[]),he=s.useWatch({control:V,name:"".concat(L,".quantitySelector")}),Fe=I.useImages(re),Ie=Fe.images,Pe=Fe.handleImageRemove,Ne=Fe.handleImageUploading,qe=Fe.isLoading,ye=a.useCallback((function(e){Ne(e,P.IMAGE_TYPE_IMAGE)}),[Ne]),ke=a.useCallback((function(e,t){Pe(String(e),t)}),[Pe]),xe=function(e){return e.target.select()};a.useEffect((function(){J(qe)}),[J,qe]),a.useEffect((function(){var e=X("".concat(L,".images"));oe(e)}),[X,oe,L]),a.useEffect((function(){Array.isArray(Ie)&&z("".concat(L,".images"),Ie)}),[Ie,L,z]);var Te=null!=he?he:"1",_e=g.QUANTITY_TYPE_LIST_DTO[Te];return n.createElement(n.Fragment,null,n.createElement(o,null,n.createElement(l,{lg:8,md:8},n.createElement(i.Form.Group,{controlId:ce},n.createElement(i.Form.Label,null,$("name")),n.createElement(i.Form.Control,t.__assign({},Q("".concat(L,".name")),{value:R,onChange:B,isInvalid:m.isInvalid("".concat(L,".name"),H),disabled:_,placeholder:$("name")})),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".name"),H))),n.createElement(i.Form.Group,{controlId:se},n.createElement(i.Form.Label,null,$("description")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange;return n.createElement(q.TipTapEditor,{withEmoji:!1,viewMode:!1,onUpdate:r,content:a,disabled:_})},control:V,name:"".concat(L,".description")}),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".description"),H))),w?n.createElement(o,null,n.createElement(C.ProductDepositControl,{isLoading:_,fieldNamePrefix:L}),n.createElement(x.ProductPriceControl,{isLoading:_,fieldNamePrefix:"".concat(L,".price"),title:$("totalPrice"),allowDeposits:w})):n.createElement(x.ProductPriceControl,{isLoading:_,fieldNamePrefix:"".concat(L,".price")}),n.createElement("div",null,n.createElement(v.ProductQuantityControl,{isLoading:_,fieldNamePrefix:L,onFocus:xe}),_e===g.QUANTITY_TYPE_CONSTANT&&n.createElement(b.ProductQuantityConstantControl,{isLoading:_,fieldNamePrefix:L,onFocus:xe,disabled:le}),_e===g.QUANTITY_TYPE_RECHARGING&&n.createElement(h.ProductQuantityRechargingControl,{isLoading:_,fieldNamePrefix:L,onFocus:xe,disabled:le}),n.createElement(i.Form.Group,{controlId:fe,className:"custom-checkbox"},n.createElement(i.Form.Check,t.__assign({custom:!0,type:"checkbox"},Q("".concat(L,".isUnlimited")),{name:"".concat(L,".isUnlimited"),disabled:_})),n.createElement(i.Form.Check.Label,null,$("isUnlimited")))),n.createElement(i.Form.Group,{controlId:pe},n.createElement(i.Form.Label,null,$("quantitySelectorType")),n.createElement(i.Form.Control,t.__assign({as:"select",defaultValue:O?ve[0].id:void 0},Q("".concat(L,".quantitySelector")),{isInvalid:m.isInvalid("".concat(L,".quantitySelector"),H),disabled:_||O}),ve.map((function(e){return n.createElement("option",{value:e.id,key:e.id},e.value)}))),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".quantitySelector"),H))))),U===g.CATEGORY_TYPE_FIXED_DURATION&&n.createElement(o,{className:"align-items-start"},n.createElement(k.ProductDurationControl,{fieldNamePrefix:L,providerHasBookingManagement:K}),n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".capacity"),label:$("capacity")}))),U===g.CATEGORY_TYPE_GAME&&n.createElement(o,{className:"align-items-start"},n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".capacity"),label:$("capacity"),rules:{min:{value:1,message:$("Validation:fieldRequired",{attribute:$("capacity")})}}})),n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".duration"),label:$("durationMinutes"),rules:{min:{value:1,message:$("Validation:fieldRequired",{attribute:$("duration")})}}}))),n.createElement(o,null,n.createElement(l,{lg:8,md:8},n.createElement(i.Form.Group,{controlId:me},n.createElement(i.Form.Label,null,$("productTermsConditions")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name,l=t.ref;return n.createElement(i.Form.Control,{ref:l,as:"textarea",rows:3,value:a,onChange:r,isInvalid:m.isInvalid("".concat(L,".termsAndConditions"),H),disabled:_,name:o})},control:V,name:"".concat(L,".termsAndConditions")}),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".termsAndConditions"),H)))),n.createElement(l,{lg:4,md:4,className:"licklist-file-upload-wrapper"},n.createElement(N.FileUpload,{onFilesChange:ye,allowedExtensions:["jpeg","jpg","png"],subTitle:".jpeg .jpg .png",enablePreview:!0,onFileRemove:ke,defaultFiles:Ie,isLoading:qe,withIcon:!0,title:$("addImage")}))),n.createElement(l,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(i.Form.Group,{controlId:de,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,$("isAvailable")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(u.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:_})},control:V,name:"".concat(L,".isAvailable")})),n.createElement(i.Form.Group,{controlId:ue,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,$("isSoldOut")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(u.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:_})},control:V,name:"".concat(L,".isSoldOut")})),n.createElement(i.Form.Group,{controlId:ie,className:"custom-checkbox"},n.createElement(i.Form.Check,{custom:!0,type:"checkbox",name:ie,disabled:_},n.createElement(i.Form.Check.Input,{checked:te,onChange:be,type:"checkbox"}),n.createElement(i.Form.Check.Label,null,$("showAdvancedOptions"))))),n.createElement(l,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(F,{in:te},n.createElement("div",null,n.createElement(i.Form.Group,{controlId:Ee,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,$("isRequired")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(u.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:_})},control:V,name:"".concat(L,".isRequired")})),n.createElement(i.Form.Group,{controlId:ge,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,$("hasSpecialNotes")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(u.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:_})},control:V,name:"".concat(L,".hasSpecialNotes")})),U===g.CATEGORY_TYPE_FIXED_DURATION&&n.createElement(y.FixedDurationOptions,{fieldNamePrefix:L}),n.createElement(i.Form.Group,{controlId:Ce,className:"advanced-switch-container"},n.createElement(x.ProductPriceControl,{title:$("minSpend"),isRequired:!1,isMoreThanZero:!0,allowDeposits:!1,isLoading:_,fieldNamePrefix:"".concat(L,".minSpend")})))),n.createElement(o,null,n.createElement(l,{xs:12},A&&n.createElement(f.ProductBookingManagementControl,{isLoading:_,zoneList:G,fieldNamePrefix:L})))),n.createElement(o,null,n.createElement(l,{xs:!0},n.createElement("div",{className:"d-flex justify-content-end mt-4"},Boolean(M)&&n.createElement(i.Button,{onClick:M,variant:"link",className:"d-flex align-items-center"},n.createElement(c.default,{type:"clipboard",height:"1rem",className:"mr-2"})," ",$("copy"))))))};
@@ -1,12 +1,16 @@
1
1
  /// <reference types="react" />
2
- import { FieldNamePrefixPath, FormValues } from "@licklist/plugins/dist/types/services/Form/hook-form-service";
2
+ import { FormValues } from "@licklist/plugins/dist/types/services/Form/hook-form-service";
3
+ import { Path } from "react-hook-form";
3
4
  export interface ProductPriceControlValues extends FormValues {
4
5
  price: number;
5
6
  }
6
- export interface ProductPriceControlProps<T> extends FieldNamePrefixPath<T> {
7
+ export interface ProductPriceControlProps<T> {
7
8
  isLoading: boolean;
8
9
  title?: string;
9
10
  allowDeposits?: boolean;
11
+ fieldNamePrefix: Path<T>;
12
+ isRequired?: boolean;
13
+ isMoreThanZero?: boolean;
10
14
  }
11
- export declare function ProductPriceControl<T extends FormValues>({ isLoading, fieldNamePrefix, title, allowDeposits, }: ProductPriceControlProps<T>): JSX.Element;
15
+ export declare function ProductPriceControl<T extends FormValues>({ isLoading, fieldNamePrefix, title, allowDeposits, isRequired, isMoreThanZero, }: ProductPriceControlProps<T>): JSX.Element;
12
16
  //# sourceMappingURL=ProductPriceControl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProductPriceControl.d.ts","sourceRoot":"","sources":["../../../../src/product-set/product/price/ProductPriceControl.tsx"],"names":[],"mappings":";AAEA,OAAO,EACL,mBAAmB,EACnB,UAAU,EACX,MAAM,8DAA8D,CAAC;AAStE,MAAM,WAAW,yBAA0B,SAAQ,UAAU;IAC3D,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,wBAAwB,CAAC,CAAC,CAAE,SAAQ,mBAAmB,CAAC,CAAC,CAAC;IACzE,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAAE,EACxD,SAAiB,EACjB,eAAe,EACf,KAAK,EACL,aAAa,GACd,EAAE,wBAAwB,CAAC,CAAC,CAAC,eA4E7B"}
1
+ {"version":3,"file":"ProductPriceControl.d.ts","sourceRoot":"","sources":["../../../../src/product-set/product/price/ProductPriceControl.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,8DAA8D,CAAC;AAK1F,OAAO,EAAc,IAAI,EAAkB,MAAM,iBAAiB,CAAC;AAInE,MAAM,WAAW,yBAA0B,SAAQ,UAAU;IAC3D,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,wBAAwB,CAAC,CAAC;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAAE,EACxD,SAAiB,EACjB,eAAe,EACf,KAAK,EACL,aAAa,EACb,UAAiB,EACjB,cAAc,GACf,EAAE,wBAAwB,CAAC,CAAC,CAAC,eAgG7B"}
@@ -1 +1 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=e(require("react")),t=require("react-i18next"),a=e(require("react-bootstrap/Col")),i=require("react-bootstrap"),n=require("../../../static/Icon.js"),o=require("react-hook-form"),l=e(require("@licklist/plugins/dist/services/Form/HookFormService")),c=require("@react-aria/utils"),u=e(require("react-bootstrap/InputGroup"));exports.ProductPriceControl=function(e){var s=e.isLoading,m=void 0!==s&&s,d=e.fieldNamePrefix,p=e.title,f=e.allowDeposits,v=o.useFormContext(),b=v.control,q=v.formState.errors,x=t.useTranslation("Design").t,E=c.useId();return r.createElement(a,{xs:f?12:void 0,sm:f?6:void 0,className:!f&&"p-0"},r.createElement(i.Form.Group,{controlId:E},r.createElement(i.Form.Label,null,null!=p?p:x("price")),r.createElement(u,{hasValidation:!0},r.createElement(u.Prepend,null,r.createElement(u.Text,null,r.createElement(n.default,{type:"pound-sign",width:".6rem",className:"p-0"}))),r.createElement(o.Controller,{render:function(e){var t=e.field,a=t.value,n=t.onChange,o=t.name,c=t.ref;return r.createElement(i.Form.Control,{ref:c,type:"number",min:0,max:999999.99,step:"0.01",value:a,name:o,onChange:n,isInvalid:l.isInvalid("".concat(d,".price"),q),disabled:m})},control:b,name:"".concat(d,".price"),rules:{required:x("Validation:fieldRequired",{attribute:x("price")}),min:{value:0,message:x("Validation:fieldMinNumber",{attribute:x("price"),min:0})},max:{value:999999.99,message:x("Validation:fieldMaxNumber",{attribute:x("price"),max:999999.99})}}}),r.createElement(i.Form.Control.Feedback,{type:"invalid"},l.getErrors("".concat(d,".price"),q)))))};
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=e(require("react")),t=require("react-i18next"),a=e(require("react-bootstrap/Col")),i=require("react-bootstrap"),n=require("../../../static/Icon.js"),o=require("react-hook-form"),l=e(require("@licklist/plugins/dist/services/Form/HookFormService")),u=require("@react-aria/utils"),s=e(require("react-bootstrap/InputGroup"));exports.ProductPriceControl=function(e){var c=e.isLoading,m=void 0!==c&&c,d=e.fieldNamePrefix,p=e.title,f=e.allowDeposits,v=e.isRequired,b=void 0===v||v,q=e.isMoreThanZero,x=o.useFormContext(),E=x.control,g=x.formState.errors,C=t.useTranslation("Design").t,F=null!=p?p:C("price"),N=u.useId();return r.createElement(a,{xs:f?12:void 0,sm:f?6:void 0,className:!f&&"p-0"},r.createElement(i.Form.Group,{controlId:N},r.createElement(i.Form.Label,null,F),r.createElement(s,{hasValidation:!0},r.createElement(s.Prepend,null,r.createElement(s.Text,null,r.createElement(n.default,{type:"pound-sign",width:".6rem",className:"p-0"}))),r.createElement(o.Controller,{render:function(e){var t=e.field,a=t.value,n=t.onChange,o=t.name,u=t.ref;return r.createElement(i.Form.Control,{ref:u,type:"number",min:0,max:999999.99,step:"0.01",value:a,name:o,onChange:n,isInvalid:l.isInvalid("".concat(d),g),disabled:m})},control:E,name:"".concat(d),rules:{required:!!b&&C("Validation:fieldRequired",{attribute:F}),min:q?void 0:{value:0,message:C("Validation:fieldMinNumber",{attribute:F,min:0})},max:{value:999999.99,message:C("Validation:fieldMaxNumber",{attribute:F,max:999999.99})},validate:function(e){return!!(!q||q&&(null==e||""===e)||q&&Number(e)>0)||C("Validation:fieldGreaterMinNumber",{attribute:F,min:0})}}}),r.createElement(i.Form.Control.Feedback,{type:"invalid"},l.getErrors("".concat(d),g)))))};
@@ -5,8 +5,10 @@ export interface Product {
5
5
  description: string;
6
6
  deposit: number;
7
7
  price: number;
8
+ minSub?: number;
8
9
  minAmount?: number;
9
10
  maxAmount?: number;
11
+ minSpend?: number;
10
12
  isSoldOut?: boolean;
11
13
  isRequired?: boolean;
12
14
  isUnlimited?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"iframe.d.ts","s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AAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,eAAe,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,oBAAY,UAAU,GAAG,CACvB,GAAG,EACC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACrB,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,KAC5D,IAAI,CAAC;AAEV,oBAAY,gBAAgB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licklist/design",
3
- "version": "0.44.500",
3
+ "version": "0.44.501",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
@@ -49,6 +49,7 @@ const productCategories = [
49
49
 
50
50
  price: 5,
51
51
  deposit: 3,
52
+ minSub: 10,
52
53
  isRequired: true,
53
54
  images: IMAGES,
54
55
  },
@@ -83,17 +83,32 @@ export const CategoryProduct = ({
83
83
  // One case when no value is that we have product,
84
84
  // but didn't click on number input.
85
85
  // If it will be required then required check fired firstly.
86
- if (!value) return true;
87
86
 
88
- const { isRequired = false, maxAmount = 0, minAmount = 0 } = product;
87
+ const {
88
+ isRequired = false,
89
+ maxAmount = 0,
90
+ minAmount = 0,
91
+ minSpend,
92
+ price,
93
+ } = product;
94
+
95
+ const currentQuantity = value?.quantity ?? 0;
96
+ if (minSpend && currentQuantity * price < minSpend) {
97
+ return t("Design:minimumSpendSumValidation", {
98
+ minSpend: formatNumber(minSpend, {
99
+ style: "currency",
100
+ currency: Config.Currency.GBP,
101
+ }),
102
+ }) as string;
103
+ }
89
104
 
90
- const { quantity = 0 } = value;
105
+ if (!value) return true;
91
106
 
92
- if (!quantity && !isRequired) {
107
+ if (!currentQuantity && !isRequired) {
93
108
  return true;
94
109
  }
95
110
 
96
- if (!quantity && isRequired) {
111
+ if (!currentQuantity && isRequired) {
97
112
  return t("Design:pleaseSelectAtLeastFrom", {
98
113
  min: 1,
99
114
  type: "item",
@@ -101,14 +116,18 @@ export const CategoryProduct = ({
101
116
  }) as string;
102
117
  }
103
118
 
104
- if (quantity < minAmount) {
119
+ if (currentQuantity < minAmount) {
105
120
  return t("Validation:fieldMinNumber", {
106
121
  min: product.minAmount,
107
122
  attribute: product.name,
108
123
  }) as string;
109
124
  }
110
125
 
111
- if (maxAmount && quantity >= minAmount && maxAmount < quantity) {
126
+ if (
127
+ maxAmount &&
128
+ currentQuantity >= minAmount &&
129
+ maxAmount < currentQuantity
130
+ ) {
112
131
  return t("Validation:quantityMaxNumber", {
113
132
  max: product.maxAmount,
114
133
  }) as string;
@@ -86,6 +86,7 @@ export interface ProductControlValues
86
86
  isRequired: boolean;
87
87
  quantitySelector: number;
88
88
  hasSpecialNotes: boolean;
89
+ minSpend?: number | null;
89
90
  type?: ProductType;
90
91
  weight?: number;
91
92
  tierId?: number;
@@ -157,6 +158,7 @@ export function ProductControl<T extends FormValues>({
157
158
  const quantitySelectorId = useId();
158
159
  const hasSpecialNotesId = useId();
159
160
  const unlimitedQuantityId = useId();
161
+ const minSpendId = useId();
160
162
 
161
163
  const quantitySelectorList: SelectItem[] = [
162
164
  { id: 1, value: t("quantitySelector") },
@@ -274,7 +276,7 @@ export function ProductControl<T extends FormValues>({
274
276
  />
275
277
  <ProductPriceControl<T>
276
278
  isLoading={isLoading}
277
- fieldNamePrefix={fieldNamePrefix}
279
+ fieldNamePrefix={`${fieldNamePrefix}.price` as Path<T>}
278
280
  title={t("totalPrice")}
279
281
  allowDeposits={allowDeposits}
280
282
  />
@@ -282,7 +284,7 @@ export function ProductControl<T extends FormValues>({
282
284
  ) : (
283
285
  <ProductPriceControl<T>
284
286
  isLoading={isLoading}
285
- fieldNamePrefix={fieldNamePrefix}
287
+ fieldNamePrefix={`${fieldNamePrefix}.price` as Path<T>}
286
288
  />
287
289
  )}
288
290
 
@@ -557,6 +559,19 @@ export function ProductControl<T extends FormValues>({
557
559
  {categoryType === CATEGORY_TYPE_FIXED_DURATION && (
558
560
  <FixedDurationOptions fieldNamePrefix={fieldNamePrefix} />
559
561
  )}
562
+ <Form.Group
563
+ controlId={minSpendId}
564
+ className="advanced-switch-container"
565
+ >
566
+ <ProductPriceControl
567
+ title={t("minSpend")}
568
+ isRequired={false}
569
+ isMoreThanZero
570
+ allowDeposits={false}
571
+ isLoading={isLoading}
572
+ fieldNamePrefix={`${fieldNamePrefix}.minSpend` as Path<T>}
573
+ />
574
+ </Form.Group>
560
575
  </div>
561
576
  </Collapse>
562
577
 
@@ -1,9 +1,6 @@
1
1
  import React from "react";
2
2
  import HookFormService from "@licklist/plugins/dist/services/Form/HookFormService";
3
- import {
4
- FieldNamePrefixPath,
5
- FormValues,
6
- } from "@licklist/plugins/dist/types/services/Form/hook-form-service";
3
+ import { FormValues } from "@licklist/plugins/dist/types/services/Form/hook-form-service";
7
4
  import { useId } from "@react-aria/utils";
8
5
  import { Form } from "react-bootstrap";
9
6
  import Col from "react-bootstrap/Col";
@@ -16,10 +13,13 @@ export interface ProductPriceControlValues extends FormValues {
16
13
  price: number;
17
14
  }
18
15
 
19
- export interface ProductPriceControlProps<T> extends FieldNamePrefixPath<T> {
16
+ export interface ProductPriceControlProps<T> {
20
17
  isLoading: boolean;
21
18
  title?: string;
22
19
  allowDeposits?: boolean;
20
+ fieldNamePrefix: Path<T>;
21
+ isRequired?: boolean;
22
+ isMoreThanZero?: boolean;
23
23
  }
24
24
 
25
25
  export function ProductPriceControl<T extends FormValues>({
@@ -27,13 +27,15 @@ export function ProductPriceControl<T extends FormValues>({
27
27
  fieldNamePrefix,
28
28
  title,
29
29
  allowDeposits,
30
+ isRequired = true,
31
+ isMoreThanZero,
30
32
  }: ProductPriceControlProps<T>) {
31
33
  const {
32
34
  control,
33
35
  formState: { errors },
34
36
  } = useFormContext<T>();
35
37
  const { t } = useTranslation("Design");
36
-
38
+ const productTitle = title ?? t("price");
37
39
  const priceId = useId();
38
40
 
39
41
  return (
@@ -43,7 +45,7 @@ export function ProductPriceControl<T extends FormValues>({
43
45
  className={!allowDeposits && "p-0"}
44
46
  >
45
47
  <Form.Group controlId={priceId}>
46
- <Form.Label>{title ?? t("price")}</Form.Label>
48
+ <Form.Label>{productTitle}</Form.Label>
47
49
 
48
50
  <InputGroup hasValidation>
49
51
  <InputGroup.Prepend>
@@ -64,38 +66,58 @@ export function ProductPriceControl<T extends FormValues>({
64
66
  name={name}
65
67
  onChange={onChange}
66
68
  isInvalid={HookFormService.isInvalid<T>(
67
- `${fieldNamePrefix}.price` as Path<T>,
69
+ `${fieldNamePrefix}` as Path<T>,
68
70
  errors
69
71
  )}
70
72
  disabled={isLoading}
71
73
  />
72
74
  )}
73
75
  control={control}
74
- name={`${fieldNamePrefix}.price` as Path<T>}
76
+ name={`${fieldNamePrefix}` as Path<T>}
75
77
  rules={{
76
- required: t("Validation:fieldRequired", {
77
- attribute: t("price"),
78
- }) as string,
79
- min: {
80
- value: 0,
81
- message: t("Validation:fieldMinNumber", {
82
- attribute: t("price"),
83
- min: 0,
84
- }) as string,
85
- },
78
+ required: isRequired
79
+ ? (t("Validation:fieldRequired", {
80
+ attribute: productTitle,
81
+ }) as string)
82
+ : false,
83
+ min: !isMoreThanZero
84
+ ? {
85
+ value: 0,
86
+ message: t("Validation:fieldMinNumber", {
87
+ attribute: productTitle,
88
+ min: 0,
89
+ }) as string,
90
+ }
91
+ : undefined,
86
92
  max: {
87
93
  value: 999999.99,
88
94
  message: t("Validation:fieldMaxNumber", {
89
- attribute: t("price"),
95
+ attribute: productTitle,
90
96
  max: 999999.99,
91
97
  }) as string,
92
98
  },
99
+
100
+ validate: (value) => {
101
+ if (
102
+ !isMoreThanZero ||
103
+ (isMoreThanZero &&
104
+ (value === undefined || value === null || value === "")) ||
105
+ (isMoreThanZero && Number(value) > 0)
106
+ ) {
107
+ return true;
108
+ }
109
+
110
+ return t("Validation:fieldGreaterMinNumber", {
111
+ attribute: productTitle,
112
+ min: 0,
113
+ }) as string;
114
+ },
93
115
  }}
94
116
  />
95
117
 
96
118
  <Form.Control.Feedback type="invalid">
97
119
  {HookFormService.getErrors<T>(
98
- `${fieldNamePrefix}.price` as Path<T>,
120
+ `${fieldNamePrefix}` as Path<T>,
99
121
  errors
100
122
  )}
101
123
  </Form.Control.Feedback>
@@ -6,8 +6,10 @@ export interface Product {
6
6
  description: string;
7
7
  deposit: number;
8
8
  price: number;
9
+ minSub?: number;
9
10
  minAmount?: number;
10
11
  maxAmount?: number;
12
+ minSpend?: number;
11
13
  isSoldOut?: boolean;
12
14
  isRequired?: boolean;
13
15
  isUnlimited?: boolean;