@licklist/design 0.44.486-dev.30 → 0.44.486-dev.31

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":"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;AAQ5C,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;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;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,EACZ,YAAY,GACb,EAAE,mBAAmB,CAAC,CAAC,CAAC,eA0hBxB"}
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;AAQ5C,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;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;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,EACZ,YAAY,GACb,EAAE,mBAAmB,CAAC,CAAC,CAAC,eA+hBxB"}
@@ -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"),d=e(require("@licklist/plugins/dist/services/Form/HookFormService")),m=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"),C=require("./booking-management/ProductBookingManagementControl.js"),f=require("./deposit/ProductDepositControl.js"),v=require("./quantity/ProductQuantityControl.js"),h=require("./quantity/ProductQuantityConstantControl.js"),b=require("./quantity/ProductQuantityRechargingControl.js"),I=e(require("react-bootstrap/Collapse")),F=require("@licklist/plugins/dist/hooks/Media/useImages"),P=require("@licklist/core/dist/DataMapper/Media/ImageDataMapper"),N=require("../../file-upload/FileUpload.js"),T=require("../../tiptap-editor/TipTapEditor.js"),q=require("./fixed-duration-fields/FixedDurationOptions.js"),y=require("./duration/ProductDurationControl.js"),_=require("./price/ProductPriceControl.js"),k=require("./constants.js");exports.ProductControl=function(e){var x=e.isLoading,A=void 0!==x&&x,L=e.fieldNamePrefix,S=e.allowDeposits,D=void 0!==S&&S,R=e.hasBookingManagement,G=void 0!==R&&R,j=e.zoneList,w=void 0===j?[]:j,M=e.onCopy,O=e.onProductNameChange,B=e.productName,Y=e.hasTicket,U=e.categoryType,H=e.zoneDuration,Q=s.useFormContext(),V=Q.register,X=Q.control,z=Q.formState.errors,Z=Q.setValue,W=Q.getValues,J=Q.setError,K=Q.watch,$=a.useContext(p.ProductSetLoadingContext),ee=$.setLoading,te=$.providerHasBookingManagement,ae=r.useTranslation(["Design","Validation"]).t,ne=t.__read(a.useState(!1),2),re=ne[0],oe=ne[1],le=t.__read(a.useState(null),2),ie=le[0],ce=le[1],se=Boolean(K("".concat(L,".isUnlimited"))),de=m.useId(),me=m.useId(),ue=m.useId(),Ee=m.useId(),pe=m.useId(),ge=m.useId(),Ce=m.useId(),fe=m.useId(),ve=m.useId(),he=m.useId(),be=m.useId(),Ie=[{id:1,value:ae("quantitySelector")},{id:2,value:ae("stockControl")}],Fe=a.useCallback((function(){return oe((function(e){return!e}))}),[]),Pe=s.useWatch({control:X,name:"".concat(L,".quantitySelector")}),Ne=F.useImages(ie),Te=Ne.images,qe=Ne.handleImageRemove,ye=Ne.handleImageUploading,_e=Ne.isLoading,ke=a.useCallback((function(e){ye(e,P.IMAGE_TYPE_IMAGE)}),[ye]),xe=a.useCallback((function(e,t){qe(String(e),t)}),[qe]),Ae=function(e){return e.target.select()};a.useEffect((function(){ee(_e)}),[ee,_e]),a.useEffect((function(){var e=W("".concat(L,".images"));ce(e)}),[W,ce,L]),a.useEffect((function(){Array.isArray(Te)&&Z("".concat(L,".images"),Te)}),[Te,L,Z]),a.useEffect((function(){U!==g.CATEGORY_TYPE_GAME||H||J("".concat(L,".duration"),{message:ae("Validation:categoryZoneDoesntHaveDefaultDuration")})}),[U,H,L]);var Le=null!=Pe?Pe:"1",Se=g.QUANTITY_TYPE_LIST_DTO[Le];return n.createElement(n.Fragment,null,n.createElement(o,null,n.createElement(l,{lg:8,md:8},n.createElement(i.Form.Group,{controlId:me},n.createElement(i.Form.Label,null,ae("name")),n.createElement(i.Form.Control,t.__assign({},V("".concat(L,".name")),{value:B,onChange:O,isInvalid:d.isInvalid("".concat(L,".name"),z),disabled:A,placeholder:ae("name")})),n.createElement(i.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(L,".name"),z))),n.createElement(i.Form.Group,{controlId:ue},n.createElement(i.Form.Label,null,ae("description")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange;return n.createElement(T.TipTapEditor,{withEmoji:!1,viewMode:!1,onUpdate:r,content:a,disabled:A})},rules:{maxLength:{value:k.MAX_PRODUCT_DESCRIPTION_CHARACTERS_LENGTH,message:ae("Validation:descriptionTooManyCharactersMessage",{max:k.MAX_PRODUCT_DESCRIPTION_CHARACTERS_LENGTH})}},control:X,name:"".concat(L,".description")})),n.createElement("div",{className:"invalid-feedback field-values-error d-block"},d.getErrors("".concat(L,".description"),z)),D?n.createElement(o,null,n.createElement(f.ProductDepositControl,{isLoading:A,fieldNamePrefix:L}),n.createElement(_.ProductPriceControl,{isLoading:A,fieldNamePrefix:"".concat(L,".price"),title:ae("totalPrice"),allowDeposits:D})):n.createElement(_.ProductPriceControl,{isLoading:A,fieldNamePrefix:"".concat(L,".price")}),n.createElement("div",null,n.createElement(v.ProductQuantityControl,{isLoading:A,fieldNamePrefix:L,onFocus:Ae}),Se===g.QUANTITY_TYPE_CONSTANT&&n.createElement(h.ProductQuantityConstantControl,{isLoading:A,fieldNamePrefix:L,onFocus:Ae,disabled:se}),Se===g.QUANTITY_TYPE_RECHARGING&&n.createElement(b.ProductQuantityRechargingControl,{isLoading:A,fieldNamePrefix:L,onFocus:Ae,disabled:se}),n.createElement(i.Form.Group,{controlId:he,className:"custom-checkbox"},n.createElement(i.Form.Check,t.__assign({custom:!0,type:"checkbox"},V("".concat(L,".isUnlimited")),{name:"".concat(L,".isUnlimited"),disabled:A})),n.createElement(i.Form.Check.Label,null,ae("isUnlimited")))),n.createElement(i.Form.Group,{controlId:fe},n.createElement(i.Form.Label,null,ae("quantitySelectorType")),n.createElement(i.Form.Control,t.__assign({as:"select",defaultValue:Y?Ie[0].id:void 0},V("".concat(L,".quantitySelector")),{isInvalid:d.isInvalid("".concat(L,".quantitySelector"),z),disabled:A||Y}),Ie.map((function(e){return n.createElement("option",{value:e.id,key:e.id},e.value)}))),n.createElement(i.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(L,".quantitySelector"),z))))),U===g.CATEGORY_TYPE_FIXED_DURATION&&n.createElement(o,{className:"align-items-start"},n.createElement(y.ProductDurationControl,{fieldNamePrefix:L,providerHasBookingManagement:te}),n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".capacity"),label:ae("capacity"),rules:{min:{value:1,message:ae("Validation:fieldRequired",{attribute:ae("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:ae("capacity"),onChange:function(e){Z("".concat(L,".duration"),e*H)},rules:{min:{value:1,message:ae("Validation:fieldRequired",{attribute:ae("capacity")})}}})),n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".duration"),label:ae("durationMinutes")}))),n.createElement(o,null,n.createElement(l,{lg:8,md:8},n.createElement(i.Form.Group,{controlId:Ee},n.createElement(i.Form.Label,null,ae("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:d.isInvalid("".concat(L,".termsAndConditions"),z),disabled:A,name:o})},control:X,name:"".concat(L,".termsAndConditions")}),n.createElement(i.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(L,".termsAndConditions"),z)))),n.createElement(l,{lg:4,md:4,className:"licklist-file-upload-wrapper"},n.createElement(N.FileUpload,{onFilesChange:ke,allowedExtensions:["jpeg","jpg","png"],subTitle:".jpeg .jpg .png",enablePreview:!0,onFileRemove:xe,defaultFiles:Te,isLoading:_e,withIcon:!0,title:ae("addImage")}))),n.createElement(l,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(i.Form.Group,{controlId:pe,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,ae("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:A})},control:X,name:"".concat(L,".isAvailable")})),n.createElement(i.Form.Group,{controlId:ge,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,ae("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:A})},control:X,name:"".concat(L,".isSoldOut")})),n.createElement(i.Form.Group,{controlId:de,className:"custom-checkbox"},n.createElement(i.Form.Check,{custom:!0,type:"checkbox",name:de,disabled:A},n.createElement(i.Form.Check.Input,{checked:re,onChange:Fe,type:"checkbox"}),n.createElement(i.Form.Check.Label,null,ae("showAdvancedOptions"))))),n.createElement(l,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(I,{in:re},n.createElement("div",null,n.createElement(i.Form.Group,{controlId:Ce,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,ae("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:A})},control:X,name:"".concat(L,".isRequired")})),n.createElement(i.Form.Group,{controlId:ve,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,ae("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:A})},control:X,name:"".concat(L,".hasSpecialNotes")})),[g.CATEGORY_TYPE_GAME,g.CATEGORY_TYPE_FIXED_DURATION].includes(U)&&n.createElement(q.FixedDurationOptions,{fieldNamePrefix:L}),n.createElement(i.Form.Group,{controlId:be,className:"advanced-switch-container"},n.createElement(_.ProductPriceControl,{title:ae("minSpend"),isRequired:!1,isMoreThanZero:!0,allowDeposits:!1,isLoading:A,fieldNamePrefix:"".concat(L,".minSpend")})))),n.createElement(o,null,n.createElement(l,{xs:12},G&&n.createElement(C.ProductBookingManagementControl,{isLoading:A,zoneList:w,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"})," ",ae("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"),d=e(require("@licklist/plugins/dist/services/Form/HookFormService")),u=require("@react-aria/utils"),m=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"),C=require("./booking-management/ProductBookingManagementControl.js"),f=require("./deposit/ProductDepositControl.js"),v=require("./quantity/ProductQuantityControl.js"),b=require("./quantity/ProductQuantityConstantControl.js"),h=require("./quantity/ProductQuantityRechargingControl.js"),I=e(require("react-bootstrap/Collapse")),F=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"),T=require("./duration/ProductDurationControl.js"),_=require("./price/ProductPriceControl.js"),k=require("./constants.js");exports.ProductControl=function(e){var x=e.isLoading,A=void 0!==x&&x,L=e.fieldNamePrefix,R=e.allowDeposits,S=void 0!==R&&R,j=e.hasBookingManagement,w=void 0!==j&&j,D=e.zoneList,G=void 0===D?[]:D,M=e.onCopy,O=e.onProductNameChange,B=e.productName,U=e.hasTicket,Y=e.categoryType,V=e.zoneDuration,Q=s.useFormContext(),H=Q.register,X=Q.control,z=Q.formState.errors,W=Q.setValue,Z=Q.getValues,J=Q.watch,K=a.useContext(p.ProductSetLoadingContext),$=K.setLoading,ee=K.providerHasBookingManagement,te=r.useTranslation(["Design","Validation"]).t,ae=t.__read(a.useState(!1),2),ne=ae[0],re=ae[1],oe=t.__read(a.useState(null),2),le=oe[0],ie=oe[1],ce=Boolean(J("".concat(L,".isUnlimited"))),se=u.useId(),de=u.useId(),ue=u.useId(),me=u.useId(),Ee=u.useId(),pe=u.useId(),ge=u.useId(),Ce=u.useId(),fe=u.useId(),ve=u.useId(),be=u.useId(),he=[{id:1,value:te("quantitySelector")},{id:2,value:te("stockControl")}],Ie=a.useCallback((function(){return re((function(e){return!e}))}),[]),Fe=s.useWatch({control:X,name:"".concat(L,".quantitySelector")}),Pe=F.useImages(le),Ne=Pe.images,qe=Pe.handleImageRemove,ye=Pe.handleImageUploading,Te=Pe.isLoading,_e=a.useCallback((function(e){ye(e,P.IMAGE_TYPE_IMAGE)}),[ye]),ke=a.useCallback((function(e,t){qe(String(e),t)}),[qe]),xe=function(e){return e.target.select()};a.useEffect((function(){$(Te)}),[$,Te]),a.useEffect((function(){var e=Z("".concat(L,".images"));ie(e)}),[Z,ie,L]),a.useEffect((function(){Array.isArray(Ne)&&W("".concat(L,".images"),Ne)}),[Ne,L,W]);var Ae=null!=Fe?Fe:"1",Le=g.QUANTITY_TYPE_LIST_DTO[Ae];return n.createElement(n.Fragment,null,n.createElement(o,null,n.createElement(l,{lg:8,md:8},n.createElement(i.Form.Group,{controlId:de},n.createElement(i.Form.Label,null,te("name")),n.createElement(i.Form.Control,t.__assign({},H("".concat(L,".name")),{value:B,onChange:O,isInvalid:d.isInvalid("".concat(L,".name"),z),disabled:A,placeholder:te("name")})),n.createElement(i.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(L,".name"),z))),n.createElement(i.Form.Group,{controlId:ue},n.createElement(i.Form.Label,null,te("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:A})},rules:{maxLength:{value:k.MAX_PRODUCT_DESCRIPTION_CHARACTERS_LENGTH,message:te("Validation:descriptionTooManyCharactersMessage",{max:k.MAX_PRODUCT_DESCRIPTION_CHARACTERS_LENGTH})}},control:X,name:"".concat(L,".description")})),n.createElement("div",{className:"invalid-feedback field-values-error d-block"},d.getErrors("".concat(L,".description"),z)),S?n.createElement(o,null,n.createElement(f.ProductDepositControl,{isLoading:A,fieldNamePrefix:L}),n.createElement(_.ProductPriceControl,{isLoading:A,fieldNamePrefix:"".concat(L,".price"),title:te("totalPrice"),allowDeposits:S})):n.createElement(_.ProductPriceControl,{isLoading:A,fieldNamePrefix:"".concat(L,".price")}),n.createElement("div",null,n.createElement(v.ProductQuantityControl,{isLoading:A,fieldNamePrefix:L,onFocus:xe}),Le===g.QUANTITY_TYPE_CONSTANT&&n.createElement(b.ProductQuantityConstantControl,{isLoading:A,fieldNamePrefix:L,onFocus:xe,disabled:ce}),Le===g.QUANTITY_TYPE_RECHARGING&&n.createElement(h.ProductQuantityRechargingControl,{isLoading:A,fieldNamePrefix:L,onFocus:xe,disabled:ce}),n.createElement(i.Form.Group,{controlId:ve,className:"custom-checkbox"},n.createElement(i.Form.Check,t.__assign({custom:!0,type:"checkbox"},H("".concat(L,".isUnlimited")),{name:"".concat(L,".isUnlimited"),disabled:A})),n.createElement(i.Form.Check.Label,null,te("isUnlimited")))),n.createElement(i.Form.Group,{controlId:Ce},n.createElement(i.Form.Label,null,te("quantitySelectorType")),n.createElement(i.Form.Control,t.__assign({as:"select",defaultValue:U?he[0].id:void 0},H("".concat(L,".quantitySelector")),{isInvalid:d.isInvalid("".concat(L,".quantitySelector"),z),disabled:A||U}),he.map((function(e){return n.createElement("option",{value:e.id,key:e.id},e.value)}))),n.createElement(i.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(L,".quantitySelector"),z))))),Y===g.CATEGORY_TYPE_FIXED_DURATION&&n.createElement(o,{className:"align-items-start"},n.createElement(T.ProductDurationControl,{fieldNamePrefix:L,providerHasBookingManagement:ee}),n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".capacity"),label:te("capacity"),rules:{min:{value:1,message:te("Validation:fieldRequired",{attribute:te("capacity")})}}}))),Y===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:te("capacity"),onChange:function(e){V&&W("".concat(L,".duration"),e*V)},rules:{required:te("Validation:fieldRequired",{attribute:te("capacity")}),min:{value:1,message:te("Validation:fieldRequired",{attribute:te("capacity")})}}})),n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".duration"),label:te("durationMinutes"),rules:{required:te("Validation:fieldRequired",{attribute:te("capacity")}),min:{value:1,message:te("Validation:fieldRequired",{attribute:te("capacity")})}}}))),n.createElement(o,null,n.createElement(l,{lg:8,md:8},n.createElement(i.Form.Group,{controlId:me},n.createElement(i.Form.Label,null,te("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:d.isInvalid("".concat(L,".termsAndConditions"),z),disabled:A,name:o})},control:X,name:"".concat(L,".termsAndConditions")}),n.createElement(i.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(L,".termsAndConditions"),z)))),n.createElement(l,{lg:4,md:4,className:"licklist-file-upload-wrapper"},n.createElement(N.FileUpload,{onFilesChange:_e,allowedExtensions:["jpeg","jpg","png"],subTitle:".jpeg .jpg .png",enablePreview:!0,onFileRemove:ke,defaultFiles:Ne,isLoading:Te,withIcon:!0,title:te("addImage")}))),n.createElement(l,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(i.Form.Group,{controlId:Ee,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,te("isAvailable")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(m.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:A})},control:X,name:"".concat(L,".isAvailable")})),n.createElement(i.Form.Group,{controlId:pe,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,te("isSoldOut")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(m.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:A})},control:X,name:"".concat(L,".isSoldOut")})),n.createElement(i.Form.Group,{controlId:se,className:"custom-checkbox"},n.createElement(i.Form.Check,{custom:!0,type:"checkbox",name:se,disabled:A},n.createElement(i.Form.Check.Input,{checked:ne,onChange:Ie,type:"checkbox"}),n.createElement(i.Form.Check.Label,null,te("showAdvancedOptions"))))),n.createElement(l,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(I,{in:ne},n.createElement("div",null,n.createElement(i.Form.Group,{controlId:ge,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,te("isRequired")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(m.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:A})},control:X,name:"".concat(L,".isRequired")})),n.createElement(i.Form.Group,{controlId:fe,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,te("hasSpecialNotes")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(m.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:A})},control:X,name:"".concat(L,".hasSpecialNotes")})),[g.CATEGORY_TYPE_GAME,g.CATEGORY_TYPE_FIXED_DURATION].includes(Y)&&n.createElement(y.FixedDurationOptions,{fieldNamePrefix:L}),n.createElement(i.Form.Group,{controlId:be,className:"advanced-switch-container"},n.createElement(_.ProductPriceControl,{title:te("minSpend"),isRequired:!1,isMoreThanZero:!0,allowDeposits:!1,isLoading:A,fieldNamePrefix:"".concat(L,".minSpend")})))),n.createElement(o,null,n.createElement(l,{xs:12},w&&n.createElement(C.ProductBookingManagementControl,{isLoading:A,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"})," ",te("copy"))))))};
@@ -1 +1 @@
1
- {"version":3,"file":"ProductCategoryControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/product-category/ProductCategoryControl.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,8DAA8D,CAAC;AAE1F,OAAO,EACL,YAAY,EACZ,YAAY,EAKb,MAAM,kEAAkE,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,wDAAwD,CAAC;AAG9E,OAAO,EAAE,gBAAgB,EAAmB,MAAM,UAAU,CAAC;AAI7D,MAAM,WAAW,4BAA6B,SAAQ,UAAU;IAC9D,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,IAAI,EAAE,YAAY,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,2BAA4B,SAAQ,gBAAgB;IACnE,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IAErB,oBAAoB,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAQD,wBAAgB,sBAAsB,CAAC,EACrC,SAAS,EACT,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,SAAS,GACV,EAAE,2BAA2B,eA2gB7B"}
1
+ {"version":3,"file":"ProductCategoryControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/product-category/ProductCategoryControl.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,8DAA8D,CAAC;AAE1F,OAAO,EACL,YAAY,EACZ,YAAY,EAKb,MAAM,kEAAkE,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,wDAAwD,CAAC;AAG9E,OAAO,EAAE,gBAAgB,EAAmB,MAAM,UAAU,CAAC;AAI7D,MAAM,WAAW,4BAA6B,SAAQ,UAAU;IAC9D,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,IAAI,EAAE,YAAY,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,2BAA4B,SAAQ,gBAAgB;IACnE,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IAErB,oBAAoB,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAQD,wBAAgB,sBAAsB,CAAC,EACrC,SAAS,EACT,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,SAAS,GACV,EAAE,2BAA2B,eA2f7B"}
@@ -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"),n=require("react"),a=e(n),r=require("react-i18next"),o=require("react-bootstrap"),l=require("react-hook-form"),c=e(require("@licklist/plugins/dist/services/Form/HookFormService")),m=require("@react-aria/utils"),i=require("../../static/switch/Switch.js"),u=require("../../static/switch/BooleanSwitch.js"),s=require("../../assets/dashboard/increment.svg.js");require("../../static/index.js");var d=require("../form/context.js"),E=require("@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper"),p=[E.CATEGORY_TYPE_TICKETS,E.CATEGORY_TYPE_FIXED_DURATION,E.CATEGORY_TYPE_GAME];exports.ProductCategoryControl=function(e){var v,I,C,b,f=e.isLoading,h=e.categoryName,g=e.onCategoryNameChange,F=e.productCategoryIndex,x=e.stepIndex,y=l.useFormContext(),T=y.control,G=y.formState.errors,S=y.register,k=y.clearErrors,N=y.setValue,w=y.getValues,_=y.watch,q=y.trigger,R=r.useTranslation("Design").t,A=t.__read(n.useState(!1),2),D=A[0],P=A[1],Y="steps.".concat(x,".productCategories.").concat(F),L=l.useWatch({name:Y}),O=_("".concat(Y,".maxSubItems"))||0,B=_("".concat(Y,".minSubItems"))||0,V=_("".concat(Y,".allowDeposits")),M=p.includes(L.type),j=null===(b=null===(C=null===(I=null===(v=null==G?void 0:G.steps)||void 0===v?void 0:v[x])||void 0===I?void 0:I.productCategories)||void 0===C?void 0:C[F])||void 0===b?void 0:b.products,z=m.useId(),U=m.useId(),H=m.useId(),K=m.useId(),X=m.useId(),Q=m.useId(),W=m.useId(),J=m.useId(),Z=m.useId(),$=m.useId(),ee=m.useId(),te=m.useId(),ne=n.useContext(d.ProductSetLoadingContext),ae=ne.providerHasBookingManagement,re=ne.zones,oe=void 0===re?[]:re,le=n.useCallback((function(){return P((function(e){return!e}))}),[]);n.useEffect((function(){q("".concat(Y,".maxSubItems"))}),[B,Y]),n.useEffect((function(){q("".concat(Y,".minSubItems"))}),[O,Y]);var ce=L.type===E.CATEGORY_TYPE_FIXED_DURATION||L.type===E.CATEGORY_TYPE_GAME;return a.createElement(a.Fragment,null,a.createElement(o.Col,{md:12,xl:!0,className:"p-0"},a.createElement(o.Form.Group,{controlId:U},a.createElement(o.Form.Label,null,R("nameOfTheCategory")),a.createElement(o.Form.Control,t.__assign({},S("".concat(Y,".name"),{required:R("Validation:fieldRequired",{attribute:R("name")}),validate:function(){return(null==j?void 0:j.type)===c.manualErrorType&&k("".concat(Y,".products")),!0}}),{value:h,onChange:g,isInvalid:c.isInvalid("".concat(Y,".name"),G),placeholder:R("name"),disabled:f})),a.createElement(o.Form.Control.Feedback,{type:"invalid"},c.getErrors("".concat(Y,".name"),G))),a.createElement(o.Form.Group,{controlId:X},a.createElement(l.Controller,{control:T,name:"".concat(Y,".quantityType"),render:function(e){var t=e.field;return a.createElement(o.Form.Group,{className:"d-flex flex-column flex-grow-1 align-items-start"},a.createElement(o.Form.Label,null,R("quantityType")),a.createElement(i.Switch,{name:t.name,options:E.QUANTITY_TYPES.map((function(e){return{key:e,id:e,value:R(e)}})),value:t.value,onChange:t.onChange,disabled:f}))}})),a.createElement(o.Row,null,a.createElement(o.Col,{md:6,sm:6,xs:6},a.createElement(o.Form.Group,{controlId:H},a.createElement(o.Form.Label,null,R("minItems")),a.createElement(o.InputGroup,{hasValidation:!0},a.createElement(o.InputGroup.Prepend,{className:"arrow-up-btn",onClick:function(){var e=Number(w("".concat(Y,".minSubItems"))||0);N("".concat(Y,".minSubItems"),e+1,{shouldValidate:!0})}},a.createElement(o.InputGroup.Text,{className:"py-0 px-3"},a.createElement(s.ReactComponent,null))),a.createElement(l.Controller,{render:function(e){var t=e.field,n=t.value,r=t.onChange,l=t.name,m=t.ref;return a.createElement(o.Form.Control,{ref:m,type:"number",min:0,step:1,value:null===n?"":n,onChange:r,isInvalid:c.isInvalid("".concat(Y,".minSubItems"),G),disabled:f,name:l})},control:T,name:"".concat(Y,".minSubItems"),rules:{min:{value:0,message:R("Validation:fieldMinNumber",{attribute:R("minItems"),min:0})},max:O?{value:Number(O),message:R("Validation:fieldMaxNumber",{attribute:R("minItems"),max:R("maxItems")})}:void 0}}),a.createElement(o.Form.Control.Feedback,{type:"invalid"},c.getErrors("".concat(Y,".minSubItems"),G))))),a.createElement(o.Col,{md:6,sm:6,xs:6},a.createElement(o.Form.Group,{controlId:K},a.createElement(o.Form.Label,null,R("maxItems")),a.createElement(o.InputGroup,{hasValidation:!0},a.createElement(o.InputGroup.Prepend,{className:"arrow-up-btn",onClick:function(){var e=Number(w("".concat(Y,".maxSubItems"))||0);N("".concat(Y,".maxSubItems"),e+1,{shouldValidate:!0})}},a.createElement(o.InputGroup.Text,{className:"py-0 px-3"},a.createElement(s.ReactComponent,null))),a.createElement(l.Controller,{render:function(e){var t=e.field,n=t.value,r=t.onChange,l=t.name,m=t.ref;return a.createElement(o.Form.Control,{ref:m,type:"number",step:1,name:l,value:null===n?"":n,onChange:r,isInvalid:c.isInvalid("".concat(Y,".maxSubItems"),G),disabled:f})},control:T,name:"".concat(Y,".maxSubItems"),rules:{min:{value:Number(B),message:R("Validation:fieldGreaterMinNumber",{attribute:R("maxItems"),min:R("minItems")})}}}),a.createElement(o.Form.Control.Feedback,{type:"invalid"},c.getErrors("".concat(Y,".maxSubItems"),G)))))),ce&&a.createElement(o.Row,null,a.createElement(o.Col,null,a.createElement(o.Form.Group,{controlId:$},a.createElement(o.Form.Label,null,R("Design:zone")),a.createElement(l.Controller,{control:T,name:"".concat(Y,".zoneId"),render:function(e){var n=e.field;return a.createElement(o.Form.Control,t.__assign({as:"select",isInvalid:c.isInvalid("".concat(Y,".zoneId"),G)},n),a.createElement("option",{value:null},R("Design:choose")),oe.map((function(e){return a.createElement("option",{key:e.id,value:e.id},e.name)})))},rules:{required:{value:ae,message:R("Validation:fieldRequired",{attribute:R("zone")})},validate:function(e){if(L.type!==E.CATEGORY_TYPE_GAME)return!0;var t=null==oe?void 0:oe.find((function(t){return(null==t?void 0:t.id)===Number(e)}));return!!(null==t?void 0:t.defaultDuration)||R("Validation:zoneDoesntHaveDefaultDuration")}}}),a.createElement(o.Form.Control.Feedback,{type:"invalid"},c.getErrors("".concat(Y,".zoneId"),G)))))),a.createElement(o.Col,{md:12,xl:!0,className:"p-0"},a.createElement(o.Form.Group,{controlId:z,className:"custom-checkbox"},a.createElement(o.Form.Check,{custom:!0,type:"checkbox",name:z,disabled:f,id:"check-api"},a.createElement(o.Form.Check.Input,{checked:D,onChange:le,type:"checkbox"}),a.createElement(o.Form.Check.Label,null,R("showAdvancedOptions")))),a.createElement(o.Collapse,{in:D},a.createElement("div",null,M&&a.createElement(o.Form.Group,{controlId:Z,className:"advanced-switch-container"},a.createElement(o.Form.Label,null,R("hasTicket")),a.createElement("div",null,a.createElement(l.Controller,{render:function(e){var t=e.field,n=t.name,r=t.value,o=t.onChange;return a.createElement(u.BooleanSwitch,{name:n,value:Boolean(r),onChange:o,disabled:L.type===E.CATEGORY_TYPE_TICKETS})},control:T,name:"".concat(Y,".hasTicket")}))),L.hasTicket&&a.createElement(o.Form.Group,{controlId:J,className:"advanced-switch-container"},a.createElement(o.Form.Label,null,R("collectUserInfo")),a.createElement("div",null,a.createElement(l.Controller,{render:function(e){var t=e.field,n=t.name,r=t.value,o=t.onChange;return a.createElement(u.BooleanSwitch,{name:n,value:Boolean(r),onChange:o,disabled:f})},control:T,name:"".concat(Y,".collectUserInfo")}))),a.createElement(o.Form.Group,{controlId:Q,className:"advanced-switch-container"},a.createElement(o.Form.Label,null,R("isRelyOnPeople")),a.createElement("div",null,a.createElement(l.Controller,{render:function(e){var t=e.field,n=t.name,r=t.value,o=t.onChange;return a.createElement(u.BooleanSwitch,{name:n,value:Boolean(r),onChange:o,disabled:f||L.hasTicket})},control:T,name:"".concat(Y,".isRelyOnPeople")}))),!L.hasTicket&&a.createElement(o.Form.Group,{controlId:W,className:"advanced-switch-container"},a.createElement(a.Fragment,null,a.createElement(o.Form.Label,null,R("isTimeRelated")),a.createElement("div",null,a.createElement(l.Controller,{render:function(e){var t=e.field,n=t.name,r=t.value,o=t.onChange;return a.createElement(u.BooleanSwitch,{name:n,value:Boolean(r),onChange:o,disabled:f})},control:T,name:"".concat(Y,".isTimeRelated")})))),a.createElement(o.Form.Group,{controlId:ee,className:"advanced-switch-container"},a.createElement(o.Form.Label,null,R("allowDeposits")),a.createElement("div",null,a.createElement(l.Controller,{render:function(e){var t=e.field,n=t.name,r=t.value,o=t.onChange;return a.createElement(u.BooleanSwitch,{name:n,value:Boolean(r),onChange:o,disabled:f})},control:T,name:"".concat(Y,".allowDeposits")}))),V&&a.createElement(o.Form.Group,{controlId:te,className:"deposit-days"},a.createElement(o.Form.Label,null,R("depositDays")),a.createElement(l.Controller,{render:function(e){var t=e.field,n=t.value,r=t.onChange,l=t.name,m=t.ref;return a.createElement(o.Form.Control,{ref:m,type:"number",min:0,step:1,value:n,onChange:r,isInvalid:c.isInvalid("".concat(Y,".remainderExpireAfter"),G),disabled:f,name:l})},control:T,name:"".concat(Y,".remainderExpireAfter")}),a.createElement(o.Form.Control.Feedback,{type:"invalid"},c.getErrors("".concat(Y,".remainderExpireAfter"),G)))))))};
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"),n=require("react"),a=e(n),r=require("react-i18next"),o=require("react-bootstrap"),l=require("react-hook-form"),c=e(require("@licklist/plugins/dist/services/Form/HookFormService")),m=require("@react-aria/utils"),i=require("../../static/switch/Switch.js"),u=require("../../static/switch/BooleanSwitch.js"),s=require("../../assets/dashboard/increment.svg.js");require("../../static/index.js");var d=require("../form/context.js"),E=require("@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper"),p=[E.CATEGORY_TYPE_TICKETS,E.CATEGORY_TYPE_FIXED_DURATION,E.CATEGORY_TYPE_GAME];exports.ProductCategoryControl=function(e){var v,I,C,b,f=e.isLoading,h=e.categoryName,g=e.onCategoryNameChange,F=e.productCategoryIndex,x=e.stepIndex,y=l.useFormContext(),T=y.control,S=y.formState.errors,k=y.register,G=y.clearErrors,N=y.setValue,w=y.getValues,_=y.watch,q=y.trigger,R=r.useTranslation("Design").t,P=t.__read(n.useState(!1),2),A=P[0],L=P[1],Y="steps.".concat(x,".productCategories.").concat(F),D=l.useWatch({name:Y}),O=_("".concat(Y,".maxSubItems"))||0,B=_("".concat(Y,".minSubItems"))||0,V=_("".concat(Y,".allowDeposits")),M=p.includes(D.type),j=null===(b=null===(C=null===(I=null===(v=null==S?void 0:S.steps)||void 0===v?void 0:v[x])||void 0===I?void 0:I.productCategories)||void 0===C?void 0:C[F])||void 0===b?void 0:b.products,z=m.useId(),U=m.useId(),H=m.useId(),K=m.useId(),X=m.useId(),Q=m.useId(),W=m.useId(),J=m.useId(),Z=m.useId(),$=m.useId(),ee=m.useId(),te=m.useId(),ne=n.useContext(d.ProductSetLoadingContext),ae=ne.providerHasBookingManagement,re=ne.zones,oe=void 0===re?[]:re,le=n.useCallback((function(){return L((function(e){return!e}))}),[]);n.useEffect((function(){q("".concat(Y,".maxSubItems"))}),[B,Y]),n.useEffect((function(){q("".concat(Y,".minSubItems"))}),[O,Y]);var ce=D.type===E.CATEGORY_TYPE_FIXED_DURATION||D.type===E.CATEGORY_TYPE_GAME;return a.createElement(a.Fragment,null,a.createElement(o.Col,{md:12,xl:!0,className:"p-0"},a.createElement(o.Form.Group,{controlId:U},a.createElement(o.Form.Label,null,R("nameOfTheCategory")),a.createElement(o.Form.Control,t.__assign({},k("".concat(Y,".name"),{required:R("Validation:fieldRequired",{attribute:R("name")}),validate:function(){return(null==j?void 0:j.type)===c.manualErrorType&&G("".concat(Y,".products")),!0}}),{value:h,onChange:g,isInvalid:c.isInvalid("".concat(Y,".name"),S),placeholder:R("name"),disabled:f})),a.createElement(o.Form.Control.Feedback,{type:"invalid"},c.getErrors("".concat(Y,".name"),S))),a.createElement(o.Form.Group,{controlId:X},a.createElement(l.Controller,{control:T,name:"".concat(Y,".quantityType"),render:function(e){var t=e.field;return a.createElement(o.Form.Group,{className:"d-flex flex-column flex-grow-1 align-items-start"},a.createElement(o.Form.Label,null,R("quantityType")),a.createElement(i.Switch,{name:t.name,options:E.QUANTITY_TYPES.map((function(e){return{key:e,id:e,value:R(e)}})),value:t.value,onChange:t.onChange,disabled:f}))}})),a.createElement(o.Row,null,a.createElement(o.Col,{md:6,sm:6,xs:6},a.createElement(o.Form.Group,{controlId:H},a.createElement(o.Form.Label,null,R("minItems")),a.createElement(o.InputGroup,{hasValidation:!0},a.createElement(o.InputGroup.Prepend,{className:"arrow-up-btn",onClick:function(){var e=Number(w("".concat(Y,".minSubItems"))||0);N("".concat(Y,".minSubItems"),e+1,{shouldValidate:!0})}},a.createElement(o.InputGroup.Text,{className:"py-0 px-3"},a.createElement(s.ReactComponent,null))),a.createElement(l.Controller,{render:function(e){var t=e.field,n=t.value,r=t.onChange,l=t.name,m=t.ref;return a.createElement(o.Form.Control,{ref:m,type:"number",min:0,step:1,value:null===n?"":n,onChange:r,isInvalid:c.isInvalid("".concat(Y,".minSubItems"),S),disabled:f,name:l})},control:T,name:"".concat(Y,".minSubItems"),rules:{min:{value:0,message:R("Validation:fieldMinNumber",{attribute:R("minItems"),min:0})},max:O?{value:Number(O),message:R("Validation:fieldMaxNumber",{attribute:R("minItems"),max:R("maxItems")})}:void 0}}),a.createElement(o.Form.Control.Feedback,{type:"invalid"},c.getErrors("".concat(Y,".minSubItems"),S))))),a.createElement(o.Col,{md:6,sm:6,xs:6},a.createElement(o.Form.Group,{controlId:K},a.createElement(o.Form.Label,null,R("maxItems")),a.createElement(o.InputGroup,{hasValidation:!0},a.createElement(o.InputGroup.Prepend,{className:"arrow-up-btn",onClick:function(){var e=Number(w("".concat(Y,".maxSubItems"))||0);N("".concat(Y,".maxSubItems"),e+1,{shouldValidate:!0})}},a.createElement(o.InputGroup.Text,{className:"py-0 px-3"},a.createElement(s.ReactComponent,null))),a.createElement(l.Controller,{render:function(e){var t=e.field,n=t.value,r=t.onChange,l=t.name,m=t.ref;return a.createElement(o.Form.Control,{ref:m,type:"number",step:1,name:l,value:null===n?"":n,onChange:r,isInvalid:c.isInvalid("".concat(Y,".maxSubItems"),S),disabled:f})},control:T,name:"".concat(Y,".maxSubItems"),rules:{min:{value:Number(B),message:R("Validation:fieldGreaterMinNumber",{attribute:R("maxItems"),min:R("minItems")})}}}),a.createElement(o.Form.Control.Feedback,{type:"invalid"},c.getErrors("".concat(Y,".maxSubItems"),S)))))),ce&&a.createElement(o.Row,null,a.createElement(o.Col,null,a.createElement(o.Form.Group,{controlId:$},a.createElement(o.Form.Label,null,R("Design:zone")),a.createElement(l.Controller,{control:T,name:"".concat(Y,".zoneId"),render:function(e){var n=e.field;return a.createElement(o.Form.Control,t.__assign({as:"select",isInvalid:c.isInvalid("".concat(Y,".zoneId"),S)},n),a.createElement("option",{value:null},R("Design:choose")),oe.map((function(e){return a.createElement("option",{key:e.id,value:e.id},e.name)})))},rules:{required:{value:ae,message:R("Validation:fieldRequired",{attribute:R("zone")})}}}),a.createElement(o.Form.Control.Feedback,{type:"invalid"},c.getErrors("".concat(Y,".zoneId"),S)))))),a.createElement(o.Col,{md:12,xl:!0,className:"p-0"},a.createElement(o.Form.Group,{controlId:z,className:"custom-checkbox"},a.createElement(o.Form.Check,{custom:!0,type:"checkbox",name:z,disabled:f,id:"check-api"},a.createElement(o.Form.Check.Input,{checked:A,onChange:le,type:"checkbox"}),a.createElement(o.Form.Check.Label,null,R("showAdvancedOptions")))),a.createElement(o.Collapse,{in:A},a.createElement("div",null,M&&a.createElement(o.Form.Group,{controlId:Z,className:"advanced-switch-container"},a.createElement(o.Form.Label,null,R("hasTicket")),a.createElement("div",null,a.createElement(l.Controller,{render:function(e){var t=e.field,n=t.name,r=t.value,o=t.onChange;return a.createElement(u.BooleanSwitch,{name:n,value:Boolean(r),onChange:o,disabled:D.type===E.CATEGORY_TYPE_TICKETS})},control:T,name:"".concat(Y,".hasTicket")}))),D.hasTicket&&a.createElement(o.Form.Group,{controlId:J,className:"advanced-switch-container"},a.createElement(o.Form.Label,null,R("collectUserInfo")),a.createElement("div",null,a.createElement(l.Controller,{render:function(e){var t=e.field,n=t.name,r=t.value,o=t.onChange;return a.createElement(u.BooleanSwitch,{name:n,value:Boolean(r),onChange:o,disabled:f})},control:T,name:"".concat(Y,".collectUserInfo")}))),a.createElement(o.Form.Group,{controlId:Q,className:"advanced-switch-container"},a.createElement(o.Form.Label,null,R("isRelyOnPeople")),a.createElement("div",null,a.createElement(l.Controller,{render:function(e){var t=e.field,n=t.name,r=t.value,o=t.onChange;return a.createElement(u.BooleanSwitch,{name:n,value:Boolean(r),onChange:o,disabled:f||D.hasTicket})},control:T,name:"".concat(Y,".isRelyOnPeople")}))),!D.hasTicket&&a.createElement(o.Form.Group,{controlId:W,className:"advanced-switch-container"},a.createElement(a.Fragment,null,a.createElement(o.Form.Label,null,R("isTimeRelated")),a.createElement("div",null,a.createElement(l.Controller,{render:function(e){var t=e.field,n=t.name,r=t.value,o=t.onChange;return a.createElement(u.BooleanSwitch,{name:n,value:Boolean(r),onChange:o,disabled:f})},control:T,name:"".concat(Y,".isTimeRelated")})))),a.createElement(o.Form.Group,{controlId:ee,className:"advanced-switch-container"},a.createElement(o.Form.Label,null,R("allowDeposits")),a.createElement("div",null,a.createElement(l.Controller,{render:function(e){var t=e.field,n=t.name,r=t.value,o=t.onChange;return a.createElement(u.BooleanSwitch,{name:n,value:Boolean(r),onChange:o,disabled:f})},control:T,name:"".concat(Y,".allowDeposits")}))),V&&a.createElement(o.Form.Group,{controlId:te,className:"deposit-days"},a.createElement(o.Form.Label,null,R("depositDays")),a.createElement(l.Controller,{render:function(e){var t=e.field,n=t.value,r=t.onChange,l=t.name,m=t.ref;return a.createElement(o.Form.Control,{ref:m,type:"number",min:0,step:1,value:n,onChange:r,isInvalid:c.isInvalid("".concat(Y,".remainderExpireAfter"),S),disabled:f,name:l})},control:T,name:"".concat(Y,".remainderExpireAfter")}),a.createElement(o.Form.Control.Feedback,{type:"invalid"},c.getErrors("".concat(Y,".remainderExpireAfter"),S)))))))};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licklist/design",
3
- "version": "0.44.486-dev.30",
3
+ "version": "0.44.486-dev.31",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
@@ -135,7 +135,6 @@ export function ProductControl<T extends FormValues>({
135
135
  formState: { errors },
136
136
  setValue,
137
137
  getValues,
138
- setError,
139
138
  watch,
140
139
  } = useFormContext<T>();
141
140
 
@@ -194,6 +193,9 @@ export function ProductControl<T extends FormValues>({
194
193
  );
195
194
 
196
195
  const onChangeGameCapacity = (value: number) => {
196
+ if (!zoneDuration) {
197
+ return;
198
+ }
197
199
  setValue(
198
200
  `${fieldNamePrefix}.duration` as Path<T>,
199
201
  (value * zoneDuration) as UnpackNestedValue<PathValue<T, Path<T>>>
@@ -227,17 +229,6 @@ export function ProductControl<T extends FormValues>({
227
229
  }
228
230
  }, [images, fieldNamePrefix, setValue]);
229
231
 
230
- useEffect(() => {
231
- if (categoryType !== CATEGORY_TYPE_GAME || zoneDuration) {
232
- return;
233
- }
234
-
235
- setError(`${fieldNamePrefix}.duration` as Path<T>, {
236
- message: t("Validation:categoryZoneDoesntHaveDefaultDuration"),
237
- });
238
- // eslint-disable-next-line react-hooks/exhaustive-deps
239
- }, [categoryType, zoneDuration, fieldNamePrefix]);
240
-
241
232
  const quantitySelector = quantityValue ?? "1";
242
233
  const quantity = QUANTITY_TYPE_LIST_DTO[quantitySelector as string];
243
234
  return (
@@ -414,6 +405,9 @@ export function ProductControl<T extends FormValues>({
414
405
  label={t("capacity")}
415
406
  onChange={onChangeGameCapacity}
416
407
  rules={{
408
+ required: t("Validation:fieldRequired", {
409
+ attribute: t("capacity"),
410
+ }) as string,
417
411
  min: {
418
412
  value: 1,
419
413
  message: t("Validation:fieldRequired", {
@@ -427,6 +421,17 @@ export function ProductControl<T extends FormValues>({
427
421
  <FormNumberInput
428
422
  fieldName={`${fieldNamePrefix}.duration`}
429
423
  label={t("durationMinutes")}
424
+ rules={{
425
+ required: t("Validation:fieldRequired", {
426
+ attribute: t("capacity"),
427
+ }) as string,
428
+ min: {
429
+ value: 1,
430
+ message: t("Validation:fieldRequired", {
431
+ attribute: t("capacity"),
432
+ }) as string,
433
+ },
434
+ }}
430
435
  />
431
436
  </Col>
432
437
  </Row>
@@ -360,22 +360,6 @@ export function ProductCategoryControl({
360
360
  attribute: t("zone"),
361
361
  }),
362
362
  },
363
- validate: (value) => {
364
- if (category.type !== CATEGORY_TYPE_GAME) {
365
- return true;
366
- }
367
- const selelctedZone = zones?.find(
368
- (zone) => zone?.id === Number(value)
369
- );
370
-
371
- if (!selelctedZone?.defaultDuration) {
372
- return t(
373
- "Validation:zoneDoesntHaveDefaultDuration"
374
- ) as string;
375
- }
376
-
377
- return true;
378
- },
379
363
  }}
380
364
  />
381
365
  <Form.Control.Feedback type="invalid">