@licklist/design 0.44.485-dev.22 → 0.44.485-dev.24

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,gBAoMtB,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"),c=require("react-i18next"),a=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,f=void 0===y||y,v=e.productsWithErrors,g=e.soldOutProducts,E=s.useIntl().formatNumber,q=c.useTranslation(["Design","Validation"]).t,_=a.useFormContext(),x=_.control,N=_.clearErrors,S=_.setError,A=t.useMemo((function(){if(v){var e=v.find((function(e){return e.product_id===m.id}));return null==e?void 0:e.message}}),[v,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(a.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,c=void 0===i?0:i,a=m.minAmount,o=void 0===a?0:a,u=m.minSub,s=m.price,d=e.quantity,l=void 0===d?0:d;return!l&&!t||(!l&&t?q("Design:pleaseSelectAtLeastFrom",{min:1,type:"item",from:"this category"}):l<o?q("Validation:fieldMinNumber",{min:m.minAmount,attribute:m.name}):u&&l*s<u?q("Design:minimumSpendSumValidation",{minSpend:E(null!=u?u:m.price,{style:"currency",currency:n.Currency.GBP})}):!(c&&l>=o&&c<l)||q("Validation:quantityMaxNumber",{max:m.maxAmount}))}},render:function(e){var t=e.field,c=t.onChange,a=t.value,s=void 0===a?{}:a,y=t.ref,v=e.fieldState,g=v.invalid,_=v.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:f})),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:c,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)))}})};
@@ -1 +1 @@
1
- {"version":3,"file":"StepsControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/form/StepsControl.tsx"],"names":[],"mappings":";AAgBA,UAAU,iBAAiB;IACzB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE,iBAAiB,eAgH5D"}
1
+ {"version":3,"file":"StepsControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/form/StepsControl.tsx"],"names":[],"mappings":";AAgBA,UAAU,iBAAiB;IACzB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE,iBAAiB,eAkI5D"}
@@ -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"),r=require("react"),a=e(r),o=require("react-i18next"),n=require("react-hook-form"),s=e(require("@licklist/plugins/dist/services/Form/HookFormService")),i=require("../../sortable-tree/SortableTreeItem.js"),l=require("../../sortable-tree/SortableTree.js"),d=e(require("react-bootstrap/Badge")),u=require("../item/CreateProductSetItem.js"),c=require("../step/StepControl.js"),p=require("./ProductCategoriesControl.js");exports.StepsControl=function(e){var m=e.isLoading,g=n.useFormContext(),v=o.useTranslation("Design").t,C=t.__read(r.useState(!1),2),b=C[0],f=C[1],S=g.control,E=g.formState,q=E.errors,I=E.isSubmitting,N=g.clearErrors,h=g.getValues,y=n.useFieldArray({name:"steps",control:S,keyName:"_id"}),j=y.fields,x=y.append,_=y.remove;r.useEffect((function(){I&&f(!I)}),[I]);var k=1===j.length;return a.createElement(a.Fragment,null,j.map((function(e,t){var r=h("steps.".concat(t));return a.createElement(n.Controller,{key:"step-".concat(e._id),name:"steps.".concat(t,".name"),control:S,rules:{required:v("Validation:fieldRequired",{attribute:v("name")})},render:function(o){var n,s,u=o.field,g=u.value,C=u.onChange;return a.createElement(l.SortableTree.Item,{id:e._id,title:g,badge:a.createElement(d,{className:"step-badge"},v("step")),isExpanded:k,isInvalid:!!(null===(n=q.steps)||void 0===n?void 0:n[t]),isIconInHeader:!1,modalLabel:v("addNewStep"),modalClass:i.ProductSetModalClasses.step,isNewAdded:b,subTitle:a.createElement("div",{className:"product-set-badges-container"},a.createElement("div",{className:"product-set-subtitle-dot product-set-subtitle-step-dot"}),a.createElement("span",null,null===(s=r.productCategories)||void 0===s?void 0:s.length," ",v("categories"))),treeLineIconColor:"#D52902",body:a.createElement(c.StepControl,{isLoading:m,stepIndex:t,stepName:g,onStepNameChange:C}),onDelete:function(){return _(t)},sortableItems:e.productCategories?e.productCategories.map((function(e){var t=e.id;return String(t)})):[]},a.createElement(p.ProductCategoriesControl,{isLoading:m,stepIndex:t}))}})})),a.createElement(u.CreateProductSetItem,{title:v("addStep"),onClick:function(){var e;x({id:null,name:"".concat(v("step")," ").concat(j.length+1),productCategories:[],weight:0,hasMap:!1,venueMapSetId:null}),f(!0),(null===(e=q.steps)||void 0===e?void 0:e.type)===s.manualErrorType&&N("steps")}}),a.createElement("div",{className:"manual-form-error"},q.steps&&q.steps.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 t=require("tslib"),r=require("react"),o=e(r),a=require("react-i18next"),n=require("react-hook-form"),s=e(require("@licklist/plugins/dist/services/Form/HookFormService")),i=require("../../sortable-tree/SortableTreeItem.js"),l=require("../../sortable-tree/SortableTree.js"),d=e(require("react-bootstrap/Badge")),u=require("../item/CreateProductSetItem.js"),c=require("../step/StepControl.js"),m=require("./ProductCategoriesControl.js");exports.StepsControl=function(e){var p=e.isLoading,v=n.useFormContext(),g=a.useTranslation("Design").t,f=t.__read(r.useState(!1),2),C=f[0],b=f[1],S=v.control,E=v.formState,q=E.errors,I=E.isSubmitting,N=v.clearErrors,h=v.getValues,y=v.setFocus,j=n.useFieldArray({name:"steps",control:S,keyName:"_id"}),x=j.fields,P=j.append,_=j.remove;r.useEffect((function(){I&&b(!I)}),[I]);var k=1===x.length;return o.createElement(o.Fragment,null,x.map((function(e,t){var r="steps.".concat(t),a=h(r);return o.createElement(n.Controller,{key:"step-".concat(e._id),name:"".concat(r,".name"),control:S,rules:{required:g("Validation:fieldRequired",{attribute:g("name")})},render:function(n){var s,u,v=n.field,f=v.value,b=v.onChange;return o.createElement(l.SortableTree.Item,{id:e._id,title:f,badge:o.createElement(d,{className:"step-badge"},g("step")),isExpanded:k,isInvalid:!!(null===(s=q.steps)||void 0===s?void 0:s[t]),isIconInHeader:!1,modalLabel:g("addNewStep"),modalClass:i.ProductSetModalClasses.step,isNewAdded:C,subTitle:o.createElement("div",{className:"product-set-badges-container"},o.createElement("div",{className:"product-set-subtitle-dot product-set-subtitle-step-dot"}),o.createElement("span",null,null===(u=a.productCategories)||void 0===u?void 0:u.length," ",g("categories"))),treeLineIconColor:"#D52902",body:o.createElement(c.StepControl,{isLoading:p,stepIndex:t,stepName:f,onStepNameChange:b}),onDelete:function(){return _(t)},sortableItems:e.productCategories?e.productCategories.map((function(e){var t=e.id;return String(t)})):[],validate:function(){var e,o,a=null===(o=null===(e=q.steps)||void 0===e?void 0:e[t])||void 0===o?void 0:o.name;return a&&y("".concat(r,".name")),Promise.resolve(!a)}},o.createElement(m.ProductCategoriesControl,{isLoading:p,stepIndex:t}))}})})),o.createElement(u.CreateProductSetItem,{title:g("addStep"),onClick:function(){var e;P({id:null,name:"".concat(g("step")," ").concat(x.length+1),productCategories:[],weight:0,hasMap:!1,venueMapSetId:null}),b(!0),(null===(e=q.steps)||void 0===e?void 0:e.type)===s.manualErrorType&&N("steps")}}),o.createElement("div",{className:"manual-form-error"},q.steps&&q.steps.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,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,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB,CAAC,CAAC,CACpC,SAAQ,gBAAgB,EACtB,mBAAmB,CAAC,CAAC,CAAC,EACtB,oCAAoC,CAAC,CAAC,CAAC;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,mBAAmB,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAChE,WAAW,EAAE,MAAM,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,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB,CAAC,CAAC,CACpC,SAAQ,gBAAgB,EACtB,mBAAmB,CAAC,CAAC,CAAC,EACtB,oCAAoC,CAAC,CAAC,CAAC;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,mBAAmB,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAChE,WAAW,EAAE,MAAM,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,eAigBxB"}
@@ -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,eA+F7B"}
@@ -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||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,6 +5,7 @@ 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;
10
11
  isSoldOut?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"iframe.d.ts","sourceRoot":"","sources":["../../src/types/iframe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0DAA0D,CAAC;AAElG,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,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,MAAM,MAAM,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,MAAM,MAAM,gBAAgB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAC"}
1
+ {"version":3,"file":"iframe.d.ts","sourceRoot":"","sources":["../../src/types/iframe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0DAA0D,CAAC;AAElG,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,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,MAAM,MAAM,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,MAAM,MAAM,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.485-dev.22",
3
+ "version": "0.44.485-dev.24",
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
  },
@@ -85,7 +85,13 @@ export const CategoryProduct = ({
85
85
  // If it will be required then required check fired firstly.
86
86
  if (!value) return true;
87
87
 
88
- const { isRequired = false, maxAmount = 0, minAmount = 0 } = product;
88
+ const {
89
+ isRequired = false,
90
+ maxAmount = 0,
91
+ minAmount = 0,
92
+ minSub,
93
+ price,
94
+ } = product;
89
95
 
90
96
  const { quantity = 0 } = value;
91
97
 
@@ -108,6 +114,15 @@ export const CategoryProduct = ({
108
114
  }) as string;
109
115
  }
110
116
 
117
+ if (minSub && quantity * price < minSub) {
118
+ return t("Design:minimumSpendSumValidation", {
119
+ minSpend: formatNumber(minSub ?? product.price, {
120
+ style: "currency",
121
+ currency: Config.Currency.GBP,
122
+ }),
123
+ }) as string;
124
+ }
125
+
111
126
  if (maxAmount && quantity >= minAmount && maxAmount < quantity) {
112
127
  return t("Validation:quantityMaxNumber", {
113
128
  max: product.maxAmount,
@@ -28,6 +28,7 @@ export function StepsControl({ isLoading }: StepsControlProps) {
28
28
  formState: { errors, isSubmitting },
29
29
  clearErrors,
30
30
  getValues,
31
+ setFocus,
31
32
  } = form;
32
33
 
33
34
  const { fields, append, remove } = useFieldArray({
@@ -57,12 +58,14 @@ export function StepsControl({ isLoading }: StepsControlProps) {
57
58
  return (
58
59
  <>
59
60
  {fields.map((step, index) => {
60
- const stepData: any = getValues(`steps.${index}` as const);
61
+ const stepFieldName = `steps.${index}` as const;
62
+
63
+ const stepData = getValues(stepFieldName);
61
64
 
62
65
  return (
63
66
  <Controller
64
67
  key={`step-${step._id}`}
65
- name={`steps.${index}.name` as const}
68
+ name={`${stepFieldName}.name` as const}
66
69
  control={control}
67
70
  rules={{
68
71
  required: t("Validation:fieldRequired", {
@@ -104,6 +107,21 @@ export function StepsControl({ isLoading }: StepsControlProps) {
104
107
  ? step.productCategories.map(({ id }) => String(id))
105
108
  : []
106
109
  }
110
+ validate={() => {
111
+ // @TODO investigate why form return true in case
112
+ // when required field not filled. Looks like
113
+ // we cann't use default hookForm trigger function
114
+ // because we have venueMap outside this form.
115
+ // So before closing we need to check directly by
116
+ // error on name field. Instead of run trugger.
117
+ const error = errors.steps?.[index]?.name;
118
+
119
+ if (error) {
120
+ setFocus(`${stepFieldName}.name` as const);
121
+ }
122
+
123
+ return Promise.resolve(!error);
124
+ }}
107
125
  >
108
126
  <ProductCategoriesControl
109
127
  isLoading={isLoading}
@@ -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,57 @@ 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 && (value === undefined || value === null)) ||
104
+ (isMoreThanZero && Number(value) > 0)
105
+ ) {
106
+ return true;
107
+ }
108
+
109
+ return t("Validation:fieldGreaterMinNumber", {
110
+ attribute: productTitle,
111
+ min: 0,
112
+ }) as string;
113
+ },
93
114
  }}
94
115
  />
95
116
 
96
117
  <Form.Control.Feedback type="invalid">
97
118
  {HookFormService.getErrors<T>(
98
- `${fieldNamePrefix}.price` as Path<T>,
119
+ `${fieldNamePrefix}` as Path<T>,
99
120
  errors
100
121
  )}
101
122
  </Form.Control.Feedback>
@@ -6,6 +6,7 @@ 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;
11
12
  isSoldOut?: boolean;