@licklist/design 0.44.486-dev.13 → 0.44.486-dev.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/events/event-venue-map/hooks/useImage.d.ts.map +1 -1
- package/dist/events/event-venue-map/hooks/useImage.js +1 -1
- package/dist/notification/email-template/control/EmailTemplateControl.d.ts.map +1 -1
- package/dist/notification/email-template/control/EmailTemplateControl.js +1 -1
- package/dist/product-set/form/ProductCategoriesControl.d.ts.map +1 -1
- package/dist/product-set/form/ProductCategoriesControl.js +1 -1
- package/dist/product-set/form/ProductsControl.d.ts +3 -1
- package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
- package/dist/product-set/form/ProductsControl.js +1 -1
- package/dist/product-set/product/ProductControl.d.ts +2 -1
- package/dist/product-set/product/ProductControl.d.ts.map +1 -1
- package/dist/product-set/product/ProductControl.js +1 -1
- package/dist/product-set/product/duration/ProductDurationControl.js +1 -1
- package/dist/product-set/product-category/ProductCategoryControl.d.ts.map +1 -1
- package/dist/product-set/product-category/ProductCategoryControl.js +1 -1
- package/dist/static/form-number-input/FormNumberInput.d.ts +2 -1
- package/dist/static/form-number-input/FormNumberInput.d.ts.map +1 -1
- package/dist/static/form-number-input/FormNumberInput.js +1 -1
- package/dist/styles/notification/Notification.scss +4 -0
- package/dist/zone/form/components/GameDurationControl.js +1 -1
- package/package.json +1 -1
- package/src/events/event-venue-map/hooks/useImage.tsx +17 -8
- package/src/notification/email-template/control/EmailTemplateControl.tsx +26 -1
- package/src/product-set/form/ProductCategoriesControl.tsx +2 -0
- package/src/product-set/form/ProductSetForm.stories.tsx +1 -0
- package/src/product-set/form/ProductsControl.tsx +10 -0
- package/src/product-set/product/ProductControl.tsx +23 -8
- package/src/product-set/product/duration/ProductDurationControl.tsx +1 -1
- package/src/product-set/product-category/ProductCategoryControl.tsx +15 -5
- package/src/static/form-number-input/FormNumberInput.tsx +8 -1
- package/src/styles/notification/Notification.scss +4 -0
- package/src/zone/form/components/GameDurationControl.tsx +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useImage.d.ts","sourceRoot":"","sources":["../../../../src/events/event-venue-map/hooks/useImage.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,eAAO,MAAM,QAAQ,QACd,MAAM;WACiB,MAAM;YAAU,MAAM;MACjD,CAAC,SAAS,GAAG,gBAAgB,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"useImage.d.ts","sourceRoot":"","sources":["../../../../src/events/event-venue-map/hooks/useImage.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,eAAO,MAAM,QAAQ,QACd,MAAM;WACiB,MAAM;YAAU,MAAM;MACjD,CAAC,SAAS,GAAG,gBAAgB,EAAE,mBAAmB,CAmFpD,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 t=require("tslib"),i=require("react"),
|
|
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"),i=require("react"),r=(e(i),e(require("lodash/round")));exports.useImage=function(e,a){var h=a.width,n=a.height,c=i.useRef(void 0),d=t.__read(i.useState({width:0,height:0}),2),u=d[0],l=d[1],s=function(){c.current=this,l({width:this.naturalWidth,height:this.naturalHeight})},o=i.useCallback((function(e){c.current=new window.Image,c.current.src=e,c.current.addEventListener("load",s)}),[]);i.useEffect((function(){return o(e),function(){c.current.removeEventListener("load",s),c.current=void 0}}),[e,o]);var g=i.useMemo((function(){if(!u.width||!u.height)return t.__assign({scaledWidth:1,scaledHeight:1,x:0,y:0,scale:1,widthScale:1,heightScale:1,imageScale:1,totalScaledWidth:0,totalScaledHeight:0},u);var e=h/u.width,i=n/u.height,a=Math.min(e,i),c=r(u.width*a,2),d=r(u.height*a,2),l=r(h/2-c/2,2),s=r(n/2-d/2,2),o=u.width/c,g=2*l+c,f=2*s+d;return t.__assign({scaledWidth:c,scaledHeight:d,x:l,y:s,scale:a,widthScale:e,heightScale:i,imageScale:o,totalScaledWidth:g,totalScaledHeight:f},u)}),[u,h,n]);return[c.current,g]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailTemplateControl.d.ts","sourceRoot":"","sources":["../../../../src/notification/email-template/control/EmailTemplateControl.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,OAAO,EACL,cAAc,EAEf,MAAM,sEAAsE,CAAC;AAG9E,OAAO,EAAE,UAAU,EAAE,MAAM,kEAAkE,CAAC;AAM9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wEAAwE,CAAC;AAM1G,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,YAAY,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE,UAAU,EAAE,CAAC;IAClC,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACvC,4BAA4B,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,IAAI,KAAK,MAAM,CAAC;CAC3E;AAED,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"EmailTemplateControl.d.ts","sourceRoot":"","sources":["../../../../src/notification/email-template/control/EmailTemplateControl.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,OAAO,EACL,cAAc,EAEf,MAAM,sEAAsE,CAAC;AAG9E,OAAO,EAAE,UAAU,EAAE,MAAM,kEAAkE,CAAC;AAM9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wEAAwE,CAAC;AAM1G,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,YAAY,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE,UAAU,EAAE,CAAC;IAClC,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACvC,4BAA4B,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,IAAI,KAAK,MAAM,CAAC;CAC3E;AAED,eAAO,MAAM,oBAAoB,2FAgbhC,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 t=require("tslib"),a=require("react"),n=e(a),l=require("react-i18next"),r=require("react-bootstrap"),i=require("react-hook-form"),o=require("../../../file-upload/FileUpload.js"),s=e(require("react-email-editor")),
|
|
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),l=require("react-i18next"),r=require("react-bootstrap"),i=require("react-hook-form"),o=require("../../../file-upload/FileUpload.js"),s=e(require("react-email-editor")),m=require("@licklist/core/dist/DataMapper/Notification/TemplateOptionDataMapper"),c=require("@licklist/plugins/dist/hooks/Media/useAttachments"),u=require("@licklist/plugins/dist/hooks/Media/usePermanentImage"),d=require("@licklist/core/dist/DataMapper/Media/UploadPermanentImageDataMapper"),p=n.forwardRef((function(e,p){var g,f,v,E,h=e.setIsLoading,b=e.meta,_=e.options,y=void 0===_?[]:_,F=e.defaultAttachments,N=void 0===F?[]:F,D=e.notificationTypes,T=void 0===D?[]:D,C=e.getDefaultTemplateMetaByType,P=l.useTranslation(["Design"]).t,I=t.__read(a.useState(null),2),k=I[0],x=I[1],M=i.useFormContext(),O=M.register,q=M.setValue,R=M.formState.errors,V=M.getValues,A=M.watch,j=M.reset,w=t.__read(a.useState(!1),2),G=w[0],L=w[1],S=c.useAttachments(k),U=S.attachments,Y=S.handleAttachmentRemove,B=S.handleAttachmentUploading,J=S.isLoading,H=u.usePermanentImage(),z=H.permanentImages,K=H.handlePermanentImageRemove,Q=H.handlePermanentImageUploading,W=A("type"),X=A("id");a.useEffect((function(){var e;if(!X&&C&&W){var a=V(),n=C(W);j(t.__assign(t.__assign({},a),{meta:n})),null===(e=p.current)||void 0===e||e.loadDesign(JSON.parse(n))}}),[W]),a.useEffect((function(){q("attachmentMetadata",U)}),[U,q]),a.useEffect((function(){z.length&&q("imagesMetadata",z)}),[z,q]),a.useEffect((function(){if(N&&N.length>0){var e=V("attachments");x(e)}else x([])}),[N]),a.useEffect((function(){if(null==y?void 0:y.length){var e=y.find((function(e){return e.type===m.OPTION_TYPE.files_selector}));(null==e?void 0:e.selectedValue)&&L(!0)}}),[y]);return n.createElement(n.Fragment,null,n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col,controlId:"type",xs:!0,sm:12,md:8,lg:10,xl:12},n.createElement(r.Form.Label,null,P("type")),n.createElement(r.Form.Control,t.__assign({as:"select"},O("type",{required:P("Validation:fieldRequired",{attribute:P("type")})}),{name:"type",required:!0,isInvalid:Boolean(R.type),placeholder:P("Design:type"),disabled:!!X}),n.createElement("option",{value:""},P("Design:choose")),T.map((function(e){return n.createElement("option",{key:e,value:e},P("Design:".concat(e)))}))),n.createElement(r.Form.Control.Feedback,{type:"invalid"},null===(g=R.type)||void 0===g?void 0:g.message))),n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col,controlId:"formGroupName",xs:!0,sm:12,md:8,lg:10,xl:12},n.createElement(r.Form.Label,null,P("templateName")),n.createElement(r.Form.Control,t.__assign({},O("name",{maxLength:255,required:P("Validation:fieldRequired",{attribute:P("name")})}),{name:"name",required:!0,isInvalid:Boolean(R.name),placeholder:P("Design:templateName")})),n.createElement(r.Form.Control.Feedback,{type:"invalid"},null===(f=R.name)||void 0===f?void 0:f.message))),n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col,xs:!0,sm:12,md:8,lg:10,xl:12,controlId:"formGroupSubject"},n.createElement(r.Form.Label,null,P("subject")),n.createElement(r.Form.Control,t.__assign({},O("subject",{maxLength:255,required:P("Validation:fieldRequired",{attribute:P("subject")})}),{name:"subject",required:!0,isInvalid:Boolean(R.subject),placeholder:P("Design:subject")})),n.createElement(r.Form.Control.Feedback,{type:"invalid"},null===(v=R.subject)||void 0===v?void 0:v.message))),n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col},n.createElement(r.Form.Check,t.__assign({},O("isActive"),{name:"isActive",label:P("Design:active"),id:"formGroupIsActive",custom:!0})),n.createElement(r.Form.Check,t.__assign({},O("isDefault"),{name:"isDefault",label:P("Design:defaultTemplateForTheType"),id:"formGroupIsDefault",custom:!0})))),n.createElement(r.Row,{className:"mb-4"},n.createElement(r.Form.Group,{as:r.Col},n.createElement(r.Form.Label,null,P("Design:emailBody")),n.createElement("div",{className:"alert alert-warning",role:"alert"},"Due to the mail services limitations on the length of the email body that can be sent or received - maximum length is set to 65,535 characters."),n.createElement("div",{className:"email-editor ".concat(R.body&&"is-invalid")},n.createElement(s,{ref:p,onReady:function(){var e,a,n,l;h(!0),null===(e=p.current)||void 0===e||e.registerCallback("design:updated",(function(e){var t,a;null===(t=p.current)||void 0===t||t.editor.exportHtml((function(e){q("body",e.html),q("meta",JSON.stringify(e.design))})),"content:removed"===e.type&&"image"===(null===(a=e.item)||void 0===a?void 0:a.type)&&function(e){var t=e.item.values.src.url;if(!t.includes("unlayer")){var a=V("imagesMetadata");if(a){var n=a.find((function(e){return e.permanentUrl===t}));if(n)K(n.hash,d.PERMANENT_IMAGE_TYPE_TEMP);else{var l=t.split("/"),r=l[l.length-2];if(!r)return;K(r,d.PERMANENT_IMAGE_TYPE_PERMANENT)}}else{var i=t.split("/"),o=i[i.length-2];if(!o)return;K(o,d.PERMANENT_IMAGE_TYPE_PERMANENT)}}}(e)})),b&&(null===(a=p.current)||void 0===a||a.loadDesign(JSON.parse(b)),null===(n=p.current)||void 0===n||n.editor.exportHtml((function(e){q("body",e.html),q("meta",JSON.stringify(e.design))}))),h(!1),null===(l=p.current)||void 0===l||l.registerCallback("image",(function(e,a){return t.__awaiter(void 0,void 0,void 0,(function(){var n;return t.__generator(this,(function(t){switch(t.label){case 0:return[4,Q(e.attachments[0])];case 1:return n=t.sent(),a({progress:100,url:n.permanentUrl}),[2]}}))}))}))},style:{height:"50rem"}}),n.createElement("input",t.__assign({type:"hidden",name:"body"},O("body",{maxLength:{value:65535,message:P("Validation:fieldMaxLength",{attribute:P("body"),max:65535})}})))),n.createElement(r.Form.Control.Feedback,{type:"invalid"},null===(E=R.body)||void 0===E?void 0:E.message))),n.createElement(r.Row,null,n.createElement(o.FileUpload,{className:"ml-4 mr-4",allowedExtensions:["jpg","jpeg","png","txt","pdf","doc"],enablePreview:!0,allowMultiple:!0,defaultFiles:U,onFilesChange:function(e){B(e)},title:P("Design:attachments"),onFileRemove:function(e,t){return Y(String(e),t)},isLoading:J})),(null==y?void 0:y.length)>0&&n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col},y.map((function(e){if(e.type===m.OPTION_TYPE.checkbox)return n.createElement(r.Form.Check,t.__assign({},O("templateOptionValues.".concat(null==e?void 0:e.id,".value")),{type:"checkbox",label:P("Design:".concat(e.name)),id:e.name+e.id,defaultChecked:"true"===e.selectedValue,custom:!0}));if(e.type===m.OPTION_TYPE.files_selector){var a=JSON.parse(e.defaultValue),l=Object.values(a),i=Object.keys(a);return n.createElement(n.Fragment,null,n.createElement(r.Form.Check,{checked:G,name:"IsIncludePDF",onChange:function(){L(!G),q("templateOptionValues.".concat(e.id,".value"),"")},label:P("Design:includePDF"),id:"formGroupIsIncludePdf",custom:!0}),G&&n.createElement(n.Fragment,null,n.createElement(r.Form.Label,{className:"mt-4"},P("Design:includeFile")),n.createElement(r.Form.Control,t.__assign({as:"select"},O("templateOptionValues.".concat(e.id,".value")),{defaultValue:e.selectedValue||""}),n.createElement("option",{value:""},P("Design:choose")),i.map((function(e,t){return n.createElement("option",{value:String(e),key:String(e)},l[t])})))))}return e.type===m.OPTION_TYPE.days_reminder?n.createElement(n.Fragment,null,n.createElement(r.Form.Label,{className:"mt-4"},P("Design:".concat(e.name))),n.createElement(r.Form.Control,t.__assign({},O("templateOptionValues.".concat(null==e?void 0:e.id,".value")),{type:"number",placeholder:P("Design:".concat(e.name)),id:e.name+e.id,defaultValue:e.selectedValue||""})),n.createElement(r.Form.Text,null,e.description)):null})))))}));p.displayName="EmailTemplateControl",exports.EmailTemplateControl=p;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductCategoriesControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/form/ProductCategoriesControl.tsx"],"names":[],"mappings":";AAYA,OAAO,EAKL,YAAY,EACb,MAAM,kEAAkE,CAAC;AAQ1E,OAAO,EAAwB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AASvE,UAAU,6BAA8B,SAAQ,aAAa;IAC3D,SAAS,EAAE,MAAM,CAAC;CACnB;AA4BD,wBAAgB,wBAAwB,CAAC,EACvC,SAAS,EACT,SAAS,GACV,EAAE,6BAA6B,
|
|
1
|
+
{"version":3,"file":"ProductCategoriesControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/form/ProductCategoriesControl.tsx"],"names":[],"mappings":";AAYA,OAAO,EAKL,YAAY,EACb,MAAM,kEAAkE,CAAC;AAQ1E,OAAO,EAAwB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AASvE,UAAU,6BAA8B,SAAQ,aAAa;IAC3D,SAAS,EAAE,MAAM,CAAC;CACnB;AA4BD,wBAAgB,wBAAwB,CAAC,EACvC,SAAS,EACT,SAAS,GACV,EAAE,6BAA6B,eAmS/B;AAED,eAAO,MAAM,cAAc,iBACX,YAAY,SACnB,MAAM;WACH,MAAM;eAAa,MAAM;CAcpC,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 t=require("tslib"),r=require("react"),n=e(r),
|
|
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"),n=e(r),o=require("react-i18next"),i=require("react-bootstrap"),a=require("react-hook-form"),u=e(require("@licklist/plugins/dist/services/Form/HookFormService")),d=e(require("clsx")),l=require("@dnd-kit/core"),s=require("lodash"),c=require("../../sortable-tree/SortableTreeItem.js"),m=require("../../sortable-tree/SortableTree.js"),p=require("../hooks/useSortableTreeFunctions.js"),v=require("../item/CreateProductSetItem.js"),g=require("./context.js"),f=require("@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper"),y=require("../product-category/ProductCategoryControl.js"),C=require("./ProductsControl.js"),E=require("./SelectCategoryModal.js"),b=require("./VenueMapSetModal.js"),_=require("../utils/index.js");var I=function(e,t){return e===f.CATEGORY_TYPE_GAME?{className:"game-badge",label:t}:e===f.CATEGORY_TYPE_FIXED_DURATION?{className:"fixed-duration-badge",label:t}:null};exports.ProductCategoriesControl=function(e){var S,q,T,x,P,N,h=e.isLoading,M=e.stepIndex,A=o.useTranslation("Design").t,k=r.useContext(g.ProductSetLoadingContext),j=k.providerHasMap,V=k.expandedProductCategories,D=k.setExpandedProductCategories,F=k.zones,R=a.useFormContext(),Y=t.__read(r.useState(!1),2),O=Y[0],B=Y[1],L=t.__read(r.useState(!1),2),w=L[0],G=L[1],H=t.__read(r.useState(!1),2),U=H[0],z=H[1],Q=R.control,K=R.formState.errors,W=R.clearErrors,X=R.watch,J=R.trigger,Z=R.getValues,$=R.setValue,ee=X("steps.".concat(M,".hasMap"))||!1,te="steps.".concat(M,".productCategories"),re=a.useFieldArray({name:te,control:Q,keyName:"_id"}),ne=re.fields,oe=re.append,ie=re.remove,ae=t.__read(r.useState({}),2),ue=ae[0],de=ae[1],le=p.useSortableTreeFunctions({fieldName:te,remove:ie}),se=le.edit,ce=le.saveValidField,me=le.cancelChanges,pe=a.useWatch({control:Q,name:te}),ve=null===(q=null===(S=null==K?void 0:K.steps)||void 0===S?void 0:S[M])||void 0===q?void 0:q.productCategories,ge=null===(x=null===(T=null==K?void 0:K.steps)||void 0===T?void 0:T[M])||void 0===x?void 0:x.venueMapSetId,fe=null===(N=null===(P=null==K?void 0:K.steps)||void 0===P?void 0:P[M])||void 0===N?void 0:N.pointProducts,ye=Boolean(ge||fe),Ce=l.useSensor(l.MouseSensor,{activationConstraint:{distance:10}});return r.useEffect((function(){pe&&pe.length&&pe.forEach((function(e){var r,n,o=null===(r=e.products)||void 0===r?void 0:r.reduce((function(e,t){return e+Number(t.price)*Number(t.totalQuantity)}),0),i=null===(n=e.products)||void 0===n?void 0:n.reduce((function(e,t){return e+(t.isUnlimited?0:Number(t.totalQuantity))}),0);de((function(r){var n;return t.__assign(t.__assign({},r),((n={})[(null==e?void 0:e.id)||e.uniqueId]={price:o,quantity:i},n))}))}))}),[pe]),r.useEffect((function(){1===ne.length&&D((function(e){var r,n,o;return t.__assign(t.__assign({},e),((r={})[String((null===(n=ne[0])||void 0===n?void 0:n.id)||(null===(o=ne[0])||void 0===o?void 0:o.uniqueId))]=!0,r))}))}),[ne]),n.createElement(n.Fragment,null,n.createElement(m.SortableTree,{sensors:[Ce],items:ne.map((function(e){return String(e._id)})),onDragEnd:function(e){var t=e.active,r=e.over;if(t&&r&&(null==t?void 0:t.id)&&(null==r?void 0:r.id)){var n=ne.findIndex((function(e){return e._id===t.id})),o=ne.findIndex((function(e){return e._id===r.id}));if(n!==o){var i=Z(te);if(i){var a=_.sortArrayByIndex(_.moveArrayElements(i,n,o));$(te,a)}}}}},ne.map((function(e,r){var o=(null==e?void 0:e.id)?String(e.id):e.uniqueId,u=function(){!function(e){D((function(r){var n;return t.__assign(t.__assign({},r),((n={})[e]=!r[e],n))}))}(o)};return n.createElement(a.Controller,{key:"product-category-".concat(e._id),name:"".concat(te,".").concat(r,".name"),control:Q,rules:{required:A("Validation:fieldRequired",{attribute:A("name")})},render:function(t){var a,d,l,s=t.field,p=s.value,v=s.onChange;return n.createElement(m.SortableTree.Item,{id:e._id,title:p,isExpanded:V[o],setIsExpanded:u,edit:function(){return se(r)},cancelChanges:function(){return me(r)},isInvalid:!!ve,badge:n.createElement(i.Badge,{className:"category-badge"},A("productCategory")),isIconInHeader:!1,subTitle:n.createElement("div",{className:"product-set-badges-container"},n.createElement("div",{className:"product-set-subtitle-dot product-set-subtitle-category-dot"}),n.createElement("span",null,null!==(l=null===(d=ue[null!==(a=null==e?void 0:e.id)&&void 0!==a?a:e.uniqueId])||void 0===d?void 0:d.quantity)&&void 0!==l?l:"N/A"," ",A("products"))),treeLineIconColor:"#1A93AA",modalLabel:A("addNewCategory"),secondaryBadge:I(e.type,A(e.type)),modalClass:c.ProductSetModalClasses.category,isNewAdded:U,body:n.createElement(y.ProductCategoryControl,{isLoading:h,onCategoryNameChange:v,categoryName:p,stepIndex:M,productCategoryIndex:r}),onDelete:function(){return ie(r)},validate:function(){return J("steps.".concat(M,".productCategories.").concat(r))},saveValidField:ce,sortableItems:e.products?e.products.filter((function(e){return e.id})).map((function(e){var t=e.id;return String(t)})):[]},n.createElement(C.ProductsControl,{isLoading:h,quantityType:e.quantityType,hasTicket:null==e?void 0:e.hasTicket,stepIndex:M,zones:F,productCategoryIndex:r,categoryType:e.type}))}})}))),n.createElement(v.CreateProductSetItem,{title:A("addCategory"),onClick:function(){B(!0)}}),n.createElement(E.SelectCategoryModal,{isVisible:O,onHide:function(){return B(!1)},onCategorySelect:function(e){oe(function(e,t){return{id:null,uniqueId:s.uniqueId("product-category"),name:"",minSubItems:null,maxSubItems:null,quantityType:f.QUANTITY_TYPE_STANDARD,type:e,isRelyOnPeople:e===f.CATEGORY_TYPE_TICKETS,isTimeRelated:!1,collectUserInfo:!1,hasTicket:e===f.CATEGORY_TYPE_TICKETS,allowDeposits:!1,remainderExpireAfter:void 0,hasBookingManagement:!1,weight:0,isReusable:!1,hasSubEvents:!1,products:[],zoneId:null,sort:t}}(e,ne.length)),z(!0),(null==ve?void 0:ve.type)===u.manualErrorType&&W(te)}}),j&&ee&&n.createElement(n.Fragment,null,n.createElement(v.CreateProductSetItem,{title:A("editMap"),onClick:function(){G(!0)},className:d("mt-3",ye&&"mb-3",ye&&"is-invalid")}),ye&&n.createElement("div",{className:"manual-form-error"},ge&&A("Validation:fieldRequired",{attribute:A("Design:venueMapSet")}),fe&&A("Validation:fieldMinNumber",{attribute:A("pointProduct"),min:1})),n.createElement(b.VenueMapSetModal,{isVisible:w,setIsVisible:G,stepIndex:M})),n.createElement("div",{className:"manual-form-error"},ve&&ve.message))},exports.getBadgeConfig=I;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CategoryType } from "@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper";
|
|
3
|
+
import { Zone } from "@licklist/core/dist/DataMapper/Provider/ZoneDataMapper";
|
|
3
4
|
import { ProductControlProps, ProductSetFormValues } from "..";
|
|
4
5
|
import { WithIsLoading } from "./ProductSetForm";
|
|
5
6
|
interface ProductsControlProps extends WithIsLoading {
|
|
@@ -8,7 +9,8 @@ interface ProductsControlProps extends WithIsLoading {
|
|
|
8
9
|
productCategoryIndex: number;
|
|
9
10
|
hasTicket?: boolean;
|
|
10
11
|
categoryType: CategoryType;
|
|
12
|
+
zones?: Zone[];
|
|
11
13
|
}
|
|
12
|
-
export declare function ProductsControl({ isLoading, quantityType, stepIndex, productCategoryIndex, hasTicket, categoryType, }: ProductsControlProps): JSX.Element;
|
|
14
|
+
export declare function ProductsControl({ isLoading, quantityType, stepIndex, productCategoryIndex, hasTicket, categoryType, zones, }: ProductsControlProps): JSX.Element;
|
|
13
15
|
export {};
|
|
14
16
|
//# sourceMappingURL=ProductsControl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductsControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/form/ProductsControl.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,YAAY,EAAE,MAAM,kEAAkE,CAAC;AAChG,OAAO,EAAkB,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAI/E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAQjD,UAAU,oBAAqB,SAAQ,aAAa;IAClD,YAAY,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,cAAc,CAAC,CAAC;IACxE,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"ProductsControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/form/ProductsControl.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,YAAY,EAAE,MAAM,kEAAkE,CAAC;AAChG,OAAO,EAAE,IAAI,EAAE,MAAM,wDAAwD,CAAC;AAC9E,OAAO,EAAkB,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAI/E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAQjD,UAAU,oBAAqB,SAAQ,aAAa;IAClD,YAAY,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,cAAc,CAAC,CAAC;IACxE,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,YAAY,CAAC;IAC3B,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;CAChB;AAmCD,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,SAAS,EACT,YAAY,EACZ,KAAK,GACN,EAAE,oBAAoB,eAqNtB"}
|
|
@@ -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"),o=e(r),n=require("react-i18next"),a=require("react-bootstrap"),i=require("react-hook-form"),
|
|
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),n=require("react-i18next"),a=require("react-bootstrap"),i=require("react-hook-form"),u=e(require("@licklist/plugins/dist/services/Form/HookFormService")),c=require("@dnd-kit/core"),d=require("lodash");require("../elements/DeleteFieldButton.js");var s=require("../../sortable-tree/SortableTreeItem.js"),l=require("../../sortable-tree/SortableTree.js");require("../card/ProductSetCard.js");var p=require("../hooks/useSortableTreeFunctions.js"),m=require("../item/CreateProductSetItem.js");require("../step/StepControl.js"),require("../product-category/ProductCategoryControl.js");var g=require("@licklist/core/dist/DataMapper/Product/ProductDataMapper"),v=require("@licklist/core/dist/Services");require("../product/booking-management/ProductBookingManagementControl.js"),require("../product/deposit/ProductDepositControl.js"),require("../product/quantity/ProductQuantityControl.js"),require("../product/quantity/ProductQuantityConstantControl.js"),require("../product/quantity/ProductQuantityRechargingControl.js");var q=require("../product/ProductControl.js"),f=require("./SubProductsControl.js"),y=require("./ProductCategoriesControl.js");require("../control/ProductSetControl.js"),require("../deposit-paid/ProductSetDepositPaidControl.js"),require("./ProductSetForm.js"),require("../popover/ProductSetPopover.js"),require("../tabs/ProductSetTab.js"),require("../tabs/ProductSetTabs.js");exports.ProductsControl=function(e){var C,P,b,S,_=e.isLoading,j=e.quantityType,T=e.stepIndex,h=e.productCategoryIndex,E=e.hasTicket,I=e.categoryType,k=e.zones,x=n.useTranslation("Design").t,D=i.useFormContext(),N=t.__read(r.useState(!1),2),F=N[0],A=N[1],M=D.control,Q=D.formState.errors,w=D.clearErrors,B=D.trigger,U=D.setValue,L=D.watch,R=D.getValues,V=L("steps.".concat(T,".productCategories.").concat(h,".zoneId")),z=null==k?void 0:k.find((function(e){return e.id===Number(V)})),O="steps.".concat(T,".productCategories.").concat(h,".products"),W="steps.".concat(T,".pointProducts"),H=i.useFieldArray({name:O,control:M,keyName:"_id"}),G=H.fields,Y=H.append,J=H.remove,K=H.move,X=p.useSortableTreeFunctions({fieldName:O,remove:J}),Z=X.edit,$=X.saveValidField,ee=X.cancelChanges,te=L("steps.".concat(T,".productCategories.").concat(h,".allowDeposits")),re=i.useWatch({control:M,name:t.__spreadArray([],t.__read(G.map((function(e,t){return"".concat(O,".").concat(t,".price")}))),!1)}),oe=i.useWatch({control:M,name:t.__spreadArray([],t.__read(G.map((function(e,t){return"".concat(O,".").concat(t,".totalQuantity")}))),!1)}),ne=i.useWatch({control:M,name:t.__spreadArray([],t.__read(G.map((function(e,t){return"".concat(O,".").concat(t,".isUnlimited")}))),!1)}),ae=null===(S=null===(b=null===(P=null===(C=null==Q?void 0:Q.steps)||void 0===C?void 0:C[T])||void 0===P?void 0:P.productCategories)||void 0===b?void 0:b[h])||void 0===S?void 0:S.products,ie=1===G.length,ue=c.useSensor(c.MouseSensor,{activationConstraint:{distance:10}});return o.createElement(o.Fragment,null,o.createElement(l.SortableTree,{items:G.map((function(e){return String(e._id)})),onDragEnd:function(e){var t=e.active,r=e.over;if(t&&r&&(null==t?void 0:t.id)&&(null==r?void 0:r.id)){var o=G.findIndex((function(e){return e._id===t.id})),n=G.findIndex((function(e){return e._id===r.id}));o!==n&&(K(o,n),G.forEach((function(e,t){U("".concat(O,".").concat(t,".sort"),t)})))}},sensors:[ue]},G.map((function(e,t){return o.createElement(i.Controller,{key:e._id,control:M,name:"".concat(O,".").concat(t,".name"),rules:{required:x("Validation:fieldRequired",{attribute:x("name")})},render:function(r){var n=r.field,i=n.value,u=n.onChange;return o.createElement(l.SortableTree.Item,{key:"product-".concat(e._id),id:String(e._id),isExpanded:ie,isInvalid:!!ae,title:i,badge:o.createElement(a.Badge,{className:"product-badge"},x("product")),isIconInHeader:!1,cancelChanges:function(){return ee(t)},edit:function(){return Z(t)},secondaryBadge:y.getBadgeConfig(I,x(I)),subTitle:o.createElement("div",{className:"product-set-badges-container"},o.createElement("div",{className:"product-set-subtitle-dot product-set-subtitle-product-dot"}),o.createElement("span",null,"£".concat(re[t]," ").concat(x("each")," - ").concat(x("qty"),":").concat(ne[t]?x(" unlimited"):" ".concat(oe[t])," ").concat(ne[t]?"":" - ".concat(x("possibleRevenue")," £").concat(re[t]*oe[t])," "))),modalLabel:x("addNewProduct"),modalClass:s.ProductSetModalClasses.product,isNewAdded:F,body:o.createElement(q.ProductControl,{isLoading:_,quantityType:j,allowDeposits:te,hasBookingManagement:!1,fieldNamePrefix:"".concat(O,".").concat(t),productName:i,onProductNameChange:u,hasTicket:E,categoryType:I,zoneDuration:null==z?void 0:z.defaultDuration}),onDelete:function(){return function(e){var t=R("".concat(O,".").concat(e)),r=R(W);U(W,(null==r?void 0:r.filter((function(e){return e.productUuid!==t.uuid})))||[]),J(e)}(t)},validate:function(){return B("".concat(O,".").concat(t))},saveValidField:$},o.createElement(f.SubProductsControl,{isLoading:_,quantityType:j,stepIndex:T,productCategoryIndex:h,productIndex:t}))}})}))),o.createElement(m.CreateProductSetItem,{title:x("addProduct"),onClick:function(){var e;Y((e=G.length,{id:null,name:"",termsAndConditions:"",productGroupId:null,description:"",price:0,deposit:0,minQuantity:null,maxQuantity:null,totalQuantity:0,capacity:0,duration:0,isAvailable:!0,isSoldOut:!1,isRequired:!1,isUnlimited:!1,quantitySelector:1,hasSpecialNotes:!1,weight:0,type:g.DEFAULT_PRODUCT_TYPE,tierId:Number(d.uniqueId()),zoneId:null,subProducts:[],images:[],uuid:v.generateUuid(),subSlots:null,offset:null,pause:null,serviceTime:null,sort:e})),A(!0),(null==ae?void 0:ae.type)===u.manualErrorType&&w(O)}}),o.createElement("div",{className:"manual-form-error"},ae&&ae.message))};
|
|
@@ -44,6 +44,7 @@ export interface ProductControlProps<T> extends IsDeletableEvent, FieldNamePrefi
|
|
|
44
44
|
productName: string;
|
|
45
45
|
hasTicket?: boolean;
|
|
46
46
|
categoryType?: CategoryType;
|
|
47
|
+
zoneDuration?: number;
|
|
47
48
|
}
|
|
48
|
-
export declare function ProductControl<T extends FormValues>({ isLoading, fieldNamePrefix, allowDeposits, hasBookingManagement, zoneList, onCopy, onProductNameChange, productName, hasTicket, categoryType, }: ProductControlProps<T>): JSX.Element;
|
|
49
|
+
export declare function ProductControl<T extends FormValues>({ isLoading, fieldNamePrefix, allowDeposits, hasBookingManagement, zoneList, onCopy, onProductNameChange, productName, hasTicket, categoryType, zoneDuration, }: ProductControlProps<T>): JSX.Element;
|
|
49
50
|
//# sourceMappingURL=ProductControl.d.ts.map
|
|
@@ -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;
|
|
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,eAmhBxB"}
|
|
@@ -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")),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"),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"),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,R=void 0!==S&&S,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,Q=s.useFormContext(),H=Q.register,V=Q.control,X=Q.formState.errors,z=Q.setValue,W=Q.getValues,Z=Q.watch,J=a.useContext(p.ProductSetLoadingContext),K=J.setLoading,$=J.providerHasBookingManagement,ee=r.useTranslation(["Design","Validation"]).t,te=t.__read(a.useState(!1),2),ae=te[0],ne=te[1],re=t.__read(a.useState(null),2),oe=re[0],le=re[1],ie=Boolean(Z("".concat(L,".isUnlimited"))),ce=d.useId(),se=d.useId(),me=d.useId(),de=d.useId(),ue=d.useId(),Ee=d.useId(),pe=d.useId(),ge=d.useId(),Ce=d.useId(),fe=d.useId(),ve=d.useId(),be=[{id:1,value:ee("quantitySelector")},{id:2,value:ee("stockControl")}],he=a.useCallback((function(){return ne((function(e){return!e}))}),[]),Ie=s.useWatch({control:V,name:"".concat(L,".quantitySelector")}),Fe=F.useImages(oe),Pe=Fe.images,Ne=Fe.handleImageRemove,Te=Fe.handleImageUploading,qe=Fe.isLoading,ye=a.useCallback((function(e){Te(e,P.IMAGE_TYPE_IMAGE)}),[Te]),_e=a.useCallback((function(e,t){Ne(String(e),t)}),[Ne]),ke=function(e){return e.target.select()};a.useEffect((function(){K(qe)}),[K,qe]),a.useEffect((function(){var e=W("".concat(L,".images"));le(e)}),[W,le,L]),a.useEffect((function(){Array.isArray(Pe)&&z("".concat(L,".images"),Pe)}),[Pe,L,z]);var xe=null!=Ie?Ie:"1",Ae=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:se},n.createElement(i.Form.Label,null,ee("name")),n.createElement(i.Form.Control,t.__assign({},H("".concat(L,".name")),{value:B,onChange:O,isInvalid:m.isInvalid("".concat(L,".name"),X),disabled:A,placeholder:ee("name")})),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".name"),X))),n.createElement(i.Form.Group,{controlId:me},n.createElement(i.Form.Label,null,ee("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:ee("Validation:descriptionTooManyCharactersMessage",{max:k.MAX_PRODUCT_DESCRIPTION_CHARACTERS_LENGTH})}},control:V,name:"".concat(L,".description")})),n.createElement("div",{className:"invalid-feedback field-values-error d-block"},m.getErrors("".concat(L,".description"),X)),R?n.createElement(o,null,n.createElement(f.ProductDepositControl,{isLoading:A,fieldNamePrefix:L}),n.createElement(_.ProductPriceControl,{isLoading:A,fieldNamePrefix:"".concat(L,".price"),title:ee("totalPrice"),allowDeposits:R})):n.createElement(_.ProductPriceControl,{isLoading:A,fieldNamePrefix:"".concat(L,".price")}),n.createElement("div",null,n.createElement(v.ProductQuantityControl,{isLoading:A,fieldNamePrefix:L,onFocus:ke}),Ae===g.QUANTITY_TYPE_CONSTANT&&n.createElement(b.ProductQuantityConstantControl,{isLoading:A,fieldNamePrefix:L,onFocus:ke,disabled:ie}),Ae===g.QUANTITY_TYPE_RECHARGING&&n.createElement(h.ProductQuantityRechargingControl,{isLoading:A,fieldNamePrefix:L,onFocus:ke,disabled:ie}),n.createElement(i.Form.Group,{controlId:fe,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,ee("isUnlimited")))),n.createElement(i.Form.Group,{controlId:ge},n.createElement(i.Form.Label,null,ee("quantitySelectorType")),n.createElement(i.Form.Control,t.__assign({as:"select",defaultValue:U?be[0].id:void 0},H("".concat(L,".quantitySelector")),{isInvalid:m.isInvalid("".concat(L,".quantitySelector"),X),disabled:A||U}),be.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"),X))))),Y===g.CATEGORY_TYPE_FIXED_DURATION&&n.createElement(o,{className:"align-items-start"},n.createElement(y.ProductDurationControl,{fieldNamePrefix:L,providerHasBookingManagement:$}),n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".capacity"),label:ee("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:ee("capacity"),rules:{min:{value:1,message:ee("Validation:fieldRequired",{attribute:ee("capacity")})}}})),n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".duration"),label:ee("durationMinutes"),rules:{min:{value:1,message:ee("Validation:fieldRequired",{attribute:ee("duration")})}}}))),n.createElement(o,null,n.createElement(l,{lg:8,md:8},n.createElement(i.Form.Group,{controlId:de},n.createElement(i.Form.Label,null,ee("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"),X),disabled:A,name:o})},control:V,name:"".concat(L,".termsAndConditions")}),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".termsAndConditions"),X)))),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:_e,defaultFiles:Pe,isLoading:qe,withIcon:!0,title:ee("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,ee("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:V,name:"".concat(L,".isAvailable")})),n.createElement(i.Form.Group,{controlId:Ee,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,ee("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:V,name:"".concat(L,".isSoldOut")})),n.createElement(i.Form.Group,{controlId:ce,className:"custom-checkbox"},n.createElement(i.Form.Check,{custom:!0,type:"checkbox",name:ce,disabled:A},n.createElement(i.Form.Check.Input,{checked:ae,onChange:he,type:"checkbox"}),n.createElement(i.Form.Check.Label,null,ee("showAdvancedOptions"))))),n.createElement(l,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(I,{in:ae},n.createElement("div",null,n.createElement(i.Form.Group,{controlId:pe,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,ee("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:V,name:"".concat(L,".isRequired")})),n.createElement(i.Form.Group,{controlId:Ce,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,ee("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:V,name:"".concat(L,".hasSpecialNotes")})),[g.CATEGORY_TYPE_GAME,g.CATEGORY_TYPE_FIXED_DURATION].includes(Y)&&n.createElement(q.FixedDurationOptions,{fieldNamePrefix:L}),n.createElement(i.Form.Group,{controlId:ve,className:"advanced-switch-container"},n.createElement(_.ProductPriceControl,{title:ee("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"})," ",ee("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")),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")}))),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"),disabled:!0}))),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 +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=e(require("react")),r=require("react-i18next"),n=require("react-bootstrap"),o=require("react-hook-form"),a=e(require("@licklist/plugins/dist/services/Form/HookFormService")),l=require("@react-aria/utils"),u=require("../../../assets/dashboard/increment.svg.js");exports.ProductDurationControl=function(e){var i=e.fieldNamePrefix,c=e.providerHasBookingManagement,s=r.useTranslation("Design").t,m=l.useId(),d=l.useId(),p=o.useFormContext(),f=p.control,E=p.formState.errors,v=p.setValue,
|
|
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=e(require("react")),r=require("react-i18next"),n=require("react-bootstrap"),o=require("react-hook-form"),a=e(require("@licklist/plugins/dist/services/Form/HookFormService")),l=require("@react-aria/utils"),u=require("../../../assets/dashboard/increment.svg.js");exports.ProductDurationControl=function(e){var i=e.fieldNamePrefix,c=e.providerHasBookingManagement,s=r.useTranslation("Design").t,m=l.useId(),d=l.useId(),p=o.useFormContext(),f=p.control,E=p.formState.errors,v=p.setValue,b="".concat(i,".duration"),g=function(e){return v(b,e)},F=o.useWatch({control:f,name:b}),C=Math.floor(F/60),I=F%60,N=function(e){g(60*e+I)},q=function(e){g(60*C+(e>59?59:e))},x=a.isInvalid(b,E),h=function(e){return e.target.select()};return t.createElement(o.Controller,{control:f,name:b,rules:{required:{value:Boolean(c),message:s("Validation:fieldRequired",{attribute:s("duration")})},min:{value:1,message:s("Validation:fieldMinNumber",{attribute:s("duration")})}},render:function(e){var r=e.field;return t.createElement(t.Fragment,null,t.createElement(n.Col,{lg:4,md:4,sm:6},t.createElement(n.Form.Group,{controlId:m,className:"position-relative"},t.createElement(n.Form.Label,null,s("durationHours")),t.createElement(n.InputGroup,{hasValidation:!0},t.createElement(n.InputGroup.Prepend,{className:"arrow-up-btn",onClick:function(){return N(C+1)}},t.createElement(n.InputGroup.Text,{className:"py-0 px-3"},t.createElement(u.ReactComponent,null))),t.createElement(n.Form.Control,{type:"number",min:0,step:1,value:C,isInvalid:x,onChange:function(e){return N(Number(e.target.value))},ref:r.ref,onFocus:h}),t.createElement(n.Form.Control.Feedback,{type:"invalid"},a.getErrors(b,E))))),t.createElement(n.Col,{lg:4,md:4,sm:6},t.createElement(n.Form.Group,{controlId:d,className:"position-relative"},t.createElement(n.Form.Label,null,s("durationMinutes")),t.createElement(n.InputGroup,{hasValidation:!0},t.createElement(n.InputGroup.Prepend,{className:"arrow-up-btn",onClick:function(){return q(I+1)}},t.createElement(n.InputGroup.Text,{className:"py-0 px-3"},t.createElement(u.ReactComponent,null))),t.createElement(n.Form.Control,{type:"number",min:0,step:1,value:I,isInvalid:x,onChange:function(e){return q(Number(e.target.value))},onFocus:h}),t.createElement(n.Form.Control.Feedback,{type:"invalid"},a.getErrors(b,E))))))}})};
|
|
@@ -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,
|
|
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 +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,
|
|
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)))))))};
|
|
@@ -4,9 +4,10 @@ interface FormNumberInputProps {
|
|
|
4
4
|
label: string;
|
|
5
5
|
fieldName: string;
|
|
6
6
|
step?: number;
|
|
7
|
+
onChange?: (value: number) => void;
|
|
7
8
|
disabled?: boolean;
|
|
8
9
|
rules?: Pick<RegisterOptions, "max" | "min" | "validate" | "required" | "pattern">;
|
|
9
10
|
}
|
|
10
|
-
export declare const FormNumberInput: ({ label, fieldName, step, rules, disabled, }: FormNumberInputProps) => JSX.Element;
|
|
11
|
+
export declare const FormNumberInput: ({ label, fieldName, step, rules, disabled, onChange, }: FormNumberInputProps) => JSX.Element;
|
|
11
12
|
export {};
|
|
12
13
|
//# sourceMappingURL=FormNumberInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormNumberInput.d.ts","sourceRoot":"","sources":["../../../src/static/form-number-input/FormNumberInput.tsx"],"names":[],"mappings":";AAIA,OAAO,EAEL,eAAe,EAGhB,MAAM,iBAAiB,CAAC;AAIzB,UAAU,oBAAoB;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,IAAI,CACV,eAAe,EACf,KAAK,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CACpD,CAAC;CACH;AAED,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"FormNumberInput.d.ts","sourceRoot":"","sources":["../../../src/static/form-number-input/FormNumberInput.tsx"],"names":[],"mappings":";AAIA,OAAO,EAEL,eAAe,EAGhB,MAAM,iBAAiB,CAAC;AAIzB,UAAU,oBAAoB;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,IAAI,CACV,eAAe,EACf,KAAK,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CACpD,CAAC;CACH;AAED,eAAO,MAAM,eAAe,2DAOzB,oBAAoB,gBAiEtB,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=e(require("react")),n=require("react-i18next"),a=require("react-bootstrap"),o=require("react-hook-form"),u=e(require("@licklist/plugins/dist/services/Form/HookFormService")),
|
|
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=e(require("react")),n=require("react-i18next"),a=require("react-bootstrap"),o=require("react-hook-form"),u=e(require("@licklist/plugins/dist/services/Form/HookFormService")),l=require("@react-aria/utils"),i=require("../../assets/dashboard/increment.svg.js");exports.FormNumberInput=function(e){var s=e.label,c=e.fieldName,m=e.step,d=void 0===m?1:m,p=e.rules,b=e.disabled,f=e.onChange,v=l.useId(),g=n.useTranslation("Validation").t,E=o.useFormContext(),F=E.control,C=E.setValue,q=E.formState.errors,I=o.useWatch({name:c}),N=function(e){return e.target.select()};return t.createElement(a.Form.Group,{controlId:v},t.createElement(a.Form.Label,null,s),t.createElement(a.InputGroup,{hasValidation:!0},t.createElement(a.InputGroup.Prepend,{className:"arrow-up-btn",onClick:function(){return C(c,Number(I)+1)}},t.createElement(a.InputGroup.Text,{className:"py-0 px-3"},t.createElement(i.ReactComponent,null))),t.createElement(o.Controller,{control:F,name:c,rules:r.__assign({min:{value:0,message:g("fieldMinNumber",{attribute:s,min:0})}},p),render:function(e){var n=e.field;return t.createElement(a.Form.Control,r.__assign({type:"number",step:d,disabled:b,isInvalid:u.isInvalid(c,q)},n,{onChange:function(e){f&&f(Number(e.target.value)),n.onChange(Number(e.target.value))},onFocus:N}))}}),t.createElement(a.Form.Control.Feedback,{type:"invalid"},u.getErrors(c,q))))};
|
|
@@ -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=e(require("react")),i=require("react-i18next"),a=require("react-bootstrap"),o=require("react-hook-form"),n=e(require("@licklist/plugins/dist/services/Form/HookFormService")),u=require("@react-aria/utils");exports.GameDurationControl=function(e){var l=e.isLoading,s=u.useId(),d=i.useTranslation(["Design","Validation"]).t,m=o.useFormContext(),c=m.register,f=m.formState.errors;return t.createElement(a.Form.Group,{controlId:s},t.createElement(a.Form.Label,null,d("Design:
|
|
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=e(require("react")),i=require("react-i18next"),a=require("react-bootstrap"),o=require("react-hook-form"),n=e(require("@licklist/plugins/dist/services/Form/HookFormService")),u=require("@react-aria/utils");exports.GameDurationControl=function(e){var l=e.isLoading,s=u.useId(),d=i.useTranslation(["Design","Validation"]).t,m=o.useFormContext(),c=m.register,f=m.formState.errors;return t.createElement(a.Form.Group,{controlId:s},t.createElement(a.Form.Label,null,d("Design:defaultGameDuration")),t.createElement(a.Form.Control,r.__assign({type:"number"},c("defaultDuration",{required:!1,min:1}),{placeholder:d("Design:duration"),isInvalid:Boolean(f.defaultDuration),disabled:l})),t.createElement(a.Form.Control.Feedback,{type:"invalid"},n.hasError(f.defaultDuration,"min")&&d("Validation:fieldMinNumber",{attribute:d("Design:defaultGameDuration").toLowerCase(),min:1})))};
|
package/package.json
CHANGED
|
@@ -12,21 +12,30 @@ export const useImage = (
|
|
|
12
12
|
height: 0,
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
+
const setImageEventHandler = function setImageEventHandler(
|
|
16
|
+
this: HTMLImageElement
|
|
17
|
+
) {
|
|
18
|
+
imageRef.current = this;
|
|
19
|
+
|
|
20
|
+
setImageAttributes({
|
|
21
|
+
width: this.naturalWidth,
|
|
22
|
+
height: this.naturalHeight,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
15
26
|
const loadImage = useCallback((imageUrl?: string) => {
|
|
16
27
|
imageRef.current = new window.Image();
|
|
17
28
|
imageRef.current.src = imageUrl;
|
|
18
|
-
imageRef.current.addEventListener("load",
|
|
19
|
-
imageRef.current = this;
|
|
20
|
-
|
|
21
|
-
setImageAttributes({
|
|
22
|
-
width: this.naturalWidth,
|
|
23
|
-
height: this.naturalHeight,
|
|
24
|
-
});
|
|
25
|
-
});
|
|
29
|
+
imageRef.current.addEventListener("load", setImageEventHandler);
|
|
26
30
|
}, []);
|
|
27
31
|
|
|
28
32
|
useEffect(() => {
|
|
29
33
|
loadImage(url);
|
|
34
|
+
|
|
35
|
+
return () => {
|
|
36
|
+
imageRef.current.removeEventListener("load", setImageEventHandler);
|
|
37
|
+
imageRef.current = undefined;
|
|
38
|
+
};
|
|
30
39
|
}, [url, loadImage]);
|
|
31
40
|
|
|
32
41
|
const memoizedImageAttributes = useMemo(() => {
|
|
@@ -314,13 +314,38 @@ export const EmailTemplateControl = React.forwardRef(
|
|
|
314
314
|
<Row className="mb-4">
|
|
315
315
|
<Form.Group as={Col}>
|
|
316
316
|
<Form.Label>{t("Design:emailBody")}</Form.Label>
|
|
317
|
-
|
|
317
|
+
|
|
318
|
+
<div className="alert alert-warning" role="alert">
|
|
319
|
+
Due to the mail services limitations on the length of the email
|
|
320
|
+
body that can be sent or received - maximum length is set to
|
|
321
|
+
65,535 characters.
|
|
322
|
+
</div>
|
|
323
|
+
|
|
324
|
+
<div className={`email-editor ${errors.body && "is-invalid"}`}>
|
|
318
325
|
<EmailEditor
|
|
319
326
|
ref={ref}
|
|
320
327
|
onReady={onReadyEditor}
|
|
321
328
|
style={{ height: "50rem" }}
|
|
322
329
|
/>
|
|
330
|
+
|
|
331
|
+
<input
|
|
332
|
+
type="hidden"
|
|
333
|
+
name="body"
|
|
334
|
+
{...register("body", {
|
|
335
|
+
maxLength: {
|
|
336
|
+
value: 65535,
|
|
337
|
+
message: t("Validation:fieldMaxLength", {
|
|
338
|
+
attribute: t("body"),
|
|
339
|
+
max: 65535,
|
|
340
|
+
}) as string,
|
|
341
|
+
},
|
|
342
|
+
})}
|
|
343
|
+
/>
|
|
323
344
|
</div>
|
|
345
|
+
|
|
346
|
+
<Form.Control.Feedback type="invalid">
|
|
347
|
+
{errors.body?.message}
|
|
348
|
+
</Form.Control.Feedback>
|
|
324
349
|
</Form.Group>
|
|
325
350
|
</Row>
|
|
326
351
|
<Row>
|
|
@@ -72,6 +72,7 @@ export function ProductCategoriesControl({
|
|
|
72
72
|
providerHasMap,
|
|
73
73
|
expandedProductCategories,
|
|
74
74
|
setExpandedProductCategories,
|
|
75
|
+
zones,
|
|
75
76
|
} = useContext(ProductSetLoadingContext);
|
|
76
77
|
const form = useFormContext<ProductSetFormValues>();
|
|
77
78
|
const [isSelectCategoryVisible, setIsSelectCategoryVisible] = useState(false);
|
|
@@ -287,6 +288,7 @@ export function ProductCategoriesControl({
|
|
|
287
288
|
quantityType={productCategory.quantityType}
|
|
288
289
|
hasTicket={productCategory?.hasTicket}
|
|
289
290
|
stepIndex={stepIndex}
|
|
291
|
+
zones={zones}
|
|
290
292
|
productCategoryIndex={index}
|
|
291
293
|
categoryType={productCategory.type}
|
|
292
294
|
/>
|
|
@@ -14,6 +14,7 @@ import { generateUuid } from "@licklist/core/dist/Services";
|
|
|
14
14
|
import HookFormService from "@licklist/plugins/dist/services/Form/HookFormService";
|
|
15
15
|
|
|
16
16
|
import { CategoryType } from "@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper";
|
|
17
|
+
import { Zone } from "@licklist/core/dist/DataMapper/Provider/ZoneDataMapper";
|
|
17
18
|
import { ProductControl, ProductControlProps, ProductSetFormValues } from "..";
|
|
18
19
|
import { SortableTree } from "../../sortable-tree";
|
|
19
20
|
import { CreateProductSetItem } from "../item/CreateProductSetItem";
|
|
@@ -32,6 +33,7 @@ interface ProductsControlProps extends WithIsLoading {
|
|
|
32
33
|
productCategoryIndex: number;
|
|
33
34
|
hasTicket?: boolean;
|
|
34
35
|
categoryType: CategoryType;
|
|
36
|
+
zones?: Zone[];
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
const getDefaultProductValue = (sort: number): Product => ({
|
|
@@ -74,6 +76,7 @@ export function ProductsControl({
|
|
|
74
76
|
productCategoryIndex,
|
|
75
77
|
hasTicket,
|
|
76
78
|
categoryType,
|
|
79
|
+
zones,
|
|
77
80
|
}: ProductsControlProps) {
|
|
78
81
|
const { t } = useTranslation("Design");
|
|
79
82
|
const form = useFormContext<ProductSetFormValues>();
|
|
@@ -89,6 +92,12 @@ export function ProductsControl({
|
|
|
89
92
|
getValues,
|
|
90
93
|
} = form;
|
|
91
94
|
|
|
95
|
+
const zoneId = watch(
|
|
96
|
+
`steps.${stepIndex}.productCategories.${productCategoryIndex}.zoneId`
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const catergoryZone = zones?.find((zone) => zone.id === Number(zoneId));
|
|
100
|
+
|
|
92
101
|
const productControlFieldName =
|
|
93
102
|
`steps.${stepIndex}.productCategories.${productCategoryIndex}.products` as const;
|
|
94
103
|
|
|
@@ -245,6 +254,7 @@ export function ProductsControl({
|
|
|
245
254
|
onProductNameChange={onChange}
|
|
246
255
|
hasTicket={hasTicket}
|
|
247
256
|
categoryType={categoryType}
|
|
257
|
+
zoneDuration={catergoryZone?.defaultDuration}
|
|
248
258
|
/>
|
|
249
259
|
}
|
|
250
260
|
onDelete={() => onProductRemove(index)}
|
|
@@ -113,6 +113,7 @@ export interface ProductControlProps<T>
|
|
|
113
113
|
productName: string;
|
|
114
114
|
hasTicket?: boolean;
|
|
115
115
|
categoryType?: CategoryType;
|
|
116
|
+
zoneDuration?: number;
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
export function ProductControl<T extends FormValues>({
|
|
@@ -126,6 +127,7 @@ export function ProductControl<T extends FormValues>({
|
|
|
126
127
|
productName,
|
|
127
128
|
hasTicket,
|
|
128
129
|
categoryType,
|
|
130
|
+
zoneDuration,
|
|
129
131
|
}: ProductControlProps<T>) {
|
|
130
132
|
const {
|
|
131
133
|
register,
|
|
@@ -133,6 +135,7 @@ export function ProductControl<T extends FormValues>({
|
|
|
133
135
|
formState: { errors },
|
|
134
136
|
setValue,
|
|
135
137
|
getValues,
|
|
138
|
+
setError,
|
|
136
139
|
watch,
|
|
137
140
|
} = useFormContext<T>();
|
|
138
141
|
|
|
@@ -190,6 +193,13 @@ export function ProductControl<T extends FormValues>({
|
|
|
190
193
|
[handleImageUploading]
|
|
191
194
|
);
|
|
192
195
|
|
|
196
|
+
const onChangeGameCapacity = (value: number) => {
|
|
197
|
+
setValue(
|
|
198
|
+
`${fieldNamePrefix}.duration` as Path<T>,
|
|
199
|
+
(value * zoneDuration) as UnpackNestedValue<PathValue<T, Path<T>>>
|
|
200
|
+
);
|
|
201
|
+
};
|
|
202
|
+
|
|
193
203
|
const onImageRemove = useCallback(
|
|
194
204
|
(id, path) => {
|
|
195
205
|
handleImageRemove(String(id), path);
|
|
@@ -217,6 +227,17 @@ export function ProductControl<T extends FormValues>({
|
|
|
217
227
|
}
|
|
218
228
|
}, [images, fieldNamePrefix, setValue]);
|
|
219
229
|
|
|
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
|
+
|
|
220
241
|
const quantitySelector = quantityValue ?? "1";
|
|
221
242
|
const quantity = QUANTITY_TYPE_LIST_DTO[quantitySelector as string];
|
|
222
243
|
return (
|
|
@@ -383,6 +404,7 @@ export function ProductControl<T extends FormValues>({
|
|
|
383
404
|
<FormNumberInput
|
|
384
405
|
fieldName={`${fieldNamePrefix}.capacity`}
|
|
385
406
|
label={t("capacity")}
|
|
407
|
+
onChange={onChangeGameCapacity}
|
|
386
408
|
rules={{
|
|
387
409
|
min: {
|
|
388
410
|
value: 1,
|
|
@@ -397,14 +419,7 @@ export function ProductControl<T extends FormValues>({
|
|
|
397
419
|
<FormNumberInput
|
|
398
420
|
fieldName={`${fieldNamePrefix}.duration`}
|
|
399
421
|
label={t("durationMinutes")}
|
|
400
|
-
|
|
401
|
-
min: {
|
|
402
|
-
value: 1,
|
|
403
|
-
message: t("Validation:fieldRequired", {
|
|
404
|
-
attribute: t("duration"),
|
|
405
|
-
}) as string,
|
|
406
|
-
},
|
|
407
|
-
}}
|
|
422
|
+
disabled
|
|
408
423
|
/>
|
|
409
424
|
</Col>
|
|
410
425
|
</Row>
|
|
@@ -332,7 +332,7 @@ export function ProductCategoryControl({
|
|
|
332
332
|
<Row>
|
|
333
333
|
<Col>
|
|
334
334
|
<Form.Group controlId={zoneId}>
|
|
335
|
-
<Form.Label>
|
|
335
|
+
<Form.Label>{t("Design:zone")}</Form.Label>
|
|
336
336
|
<Controller
|
|
337
337
|
control={control}
|
|
338
338
|
name={`${fieldNamePrefix}.zoneId`}
|
|
@@ -361,10 +361,20 @@ export function ProductCategoryControl({
|
|
|
361
361
|
}),
|
|
362
362
|
},
|
|
363
363
|
validate: (value) => {
|
|
364
|
-
if (
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
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;
|
|
368
378
|
},
|
|
369
379
|
}}
|
|
370
380
|
/>
|
|
@@ -15,6 +15,7 @@ interface FormNumberInputProps {
|
|
|
15
15
|
label: string;
|
|
16
16
|
fieldName: string;
|
|
17
17
|
step?: number;
|
|
18
|
+
onChange?: (value: number) => void;
|
|
18
19
|
disabled?: boolean;
|
|
19
20
|
rules?: Pick<
|
|
20
21
|
RegisterOptions,
|
|
@@ -28,6 +29,7 @@ export const FormNumberInput = ({
|
|
|
28
29
|
step = 1,
|
|
29
30
|
rules,
|
|
30
31
|
disabled,
|
|
32
|
+
onChange,
|
|
31
33
|
}: FormNumberInputProps) => {
|
|
32
34
|
const controlId = useId();
|
|
33
35
|
const { t } = useTranslation("Validation");
|
|
@@ -76,7 +78,12 @@ export const FormNumberInput = ({
|
|
|
76
78
|
disabled={disabled}
|
|
77
79
|
isInvalid={HookFormService.isInvalid(fieldName, errors)}
|
|
78
80
|
{...field}
|
|
79
|
-
onChange={(event) =>
|
|
81
|
+
onChange={(event) => {
|
|
82
|
+
if (onChange) {
|
|
83
|
+
onChange(Number(event.target.value));
|
|
84
|
+
}
|
|
85
|
+
field.onChange(Number(event.target.value));
|
|
86
|
+
}}
|
|
80
87
|
onFocus={onFocus}
|
|
81
88
|
/>
|
|
82
89
|
)}
|
|
@@ -23,7 +23,7 @@ export const GameDurationControl = ({
|
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
25
|
<Form.Group controlId={nameId}>
|
|
26
|
-
<Form.Label>{t("Design:
|
|
26
|
+
<Form.Label>{t("Design:defaultGameDuration")}</Form.Label>
|
|
27
27
|
<Form.Control
|
|
28
28
|
type="number"
|
|
29
29
|
{...register("defaultDuration", {
|
|
@@ -37,7 +37,7 @@ export const GameDurationControl = ({
|
|
|
37
37
|
<Form.Control.Feedback type="invalid">
|
|
38
38
|
{HookFormService.hasError(errors.defaultDuration, "min") &&
|
|
39
39
|
t("Validation:fieldMinNumber", {
|
|
40
|
-
attribute: t("Design:
|
|
40
|
+
attribute: t("Design:defaultGameDuration").toLowerCase(),
|
|
41
41
|
min: 1,
|
|
42
42
|
})}
|
|
43
43
|
</Form.Control.Feedback>
|