@licklist/design 0.44.486-dev.13 → 0.44.486-dev.14

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.
Files changed (24) hide show
  1. package/dist/product-set/form/ProductCategoriesControl.d.ts.map +1 -1
  2. package/dist/product-set/form/ProductCategoriesControl.js +1 -1
  3. package/dist/product-set/form/ProductsControl.d.ts +3 -1
  4. package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
  5. package/dist/product-set/form/ProductsControl.js +1 -1
  6. package/dist/product-set/product/ProductControl.d.ts +2 -1
  7. package/dist/product-set/product/ProductControl.d.ts.map +1 -1
  8. package/dist/product-set/product/ProductControl.js +1 -1
  9. package/dist/product-set/product/duration/ProductDurationControl.js +1 -1
  10. package/dist/product-set/product-category/ProductCategoryControl.d.ts.map +1 -1
  11. package/dist/product-set/product-category/ProductCategoryControl.js +1 -1
  12. package/dist/static/form-number-input/FormNumberInput.d.ts +2 -1
  13. package/dist/static/form-number-input/FormNumberInput.d.ts.map +1 -1
  14. package/dist/static/form-number-input/FormNumberInput.js +1 -1
  15. package/dist/zone/form/components/GameDurationControl.js +1 -1
  16. package/package.json +1 -1
  17. package/src/product-set/form/ProductCategoriesControl.tsx +2 -0
  18. package/src/product-set/form/ProductSetForm.stories.tsx +1 -0
  19. package/src/product-set/form/ProductsControl.tsx +10 -0
  20. package/src/product-set/product/ProductControl.tsx +23 -8
  21. package/src/product-set/product/duration/ProductDurationControl.tsx +1 -1
  22. package/src/product-set/product-category/ProductCategoryControl.tsx +15 -5
  23. package/src/static/form-number-input/FormNumberInput.tsx +8 -1
  24. package/src/zone/form/components/GameDurationControl.tsx +2 -2
@@ -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,eAiS/B;AAED,eAAO,MAAM,cAAc,iBACX,YAAY,SACnB,MAAM;WACH,MAAM;eAAa,MAAM;CAcpC,CAAC"}
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),i=require("react-i18next"),o=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=i.useTranslation("Design").t,k=r.useContext(g.ProductSetLoadingContext),j=k.providerHasMap,V=k.expandedProductCategories,D=k.setExpandedProductCategories,F=a.useFormContext(),R=t.__read(r.useState(!1),2),Y=R[0],O=R[1],B=t.__read(r.useState(!1),2),L=B[0],w=B[1],G=t.__read(r.useState(!1),2),H=G[0],U=G[1],Q=F.control,K=F.formState.errors,z=F.clearErrors,W=F.watch,X=F.trigger,J=F.getValues,Z=F.setValue,$=W("steps.".concat(M,".hasMap"))||!1,ee="steps.".concat(M,".productCategories"),te=a.useFieldArray({name:ee,control:Q,keyName:"_id"}),re=te.fields,ne=te.append,ie=te.remove,oe=t.__read(r.useState({}),2),ae=oe[0],ue=oe[1],de=p.useSortableTreeFunctions({fieldName:ee,remove:ie}),le=de.edit,se=de.saveValidField,ce=de.cancelChanges,me=a.useWatch({control:Q,name:ee}),pe=null===(q=null===(S=null==K?void 0:K.steps)||void 0===S?void 0:S[M])||void 0===q?void 0:q.productCategories,ve=null===(x=null===(T=null==K?void 0:K.steps)||void 0===T?void 0:T[M])||void 0===x?void 0:x.venueMapSetId,ge=null===(N=null===(P=null==K?void 0:K.steps)||void 0===P?void 0:P[M])||void 0===N?void 0:N.pointProducts,fe=Boolean(ve||ge),ye=l.useSensor(l.MouseSensor,{activationConstraint:{distance:10}});return r.useEffect((function(){me&&me.length&&me.forEach((function(e){var r,n,i=null===(r=e.products)||void 0===r?void 0:r.reduce((function(e,t){return e+Number(t.price)*Number(t.totalQuantity)}),0),o=null===(n=e.products)||void 0===n?void 0:n.reduce((function(e,t){return e+(t.isUnlimited?0:Number(t.totalQuantity))}),0);ue((function(r){var n;return t.__assign(t.__assign({},r),((n={})[(null==e?void 0:e.id)||e.uniqueId]={price:i,quantity:o},n))}))}))}),[me]),r.useEffect((function(){1===re.length&&D((function(e){var r,n,i;return t.__assign(t.__assign({},e),((r={})[String((null===(n=re[0])||void 0===n?void 0:n.id)||(null===(i=re[0])||void 0===i?void 0:i.uniqueId))]=!0,r))}))}),[re]),n.createElement(n.Fragment,null,n.createElement(m.SortableTree,{sensors:[ye],items:re.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=re.findIndex((function(e){return e._id===t.id})),i=re.findIndex((function(e){return e._id===r.id}));if(n!==i){var o=J(ee);if(o){var a=_.sortArrayByIndex(_.moveArrayElements(o,n,i));Z(ee,a)}}}}},re.map((function(e,r){var i=(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))}))}(i)};return n.createElement(a.Controller,{key:"product-category-".concat(e._id),name:"".concat(ee,".").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[i],setIsExpanded:u,edit:function(){return le(r)},cancelChanges:function(){return ce(r)},isInvalid:!!pe,badge:n.createElement(o.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=ae[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:H,body:n.createElement(y.ProductCategoryControl,{isLoading:h,onCategoryNameChange:v,categoryName:p,stepIndex:M,productCategoryIndex:r}),onDelete:function(){return ie(r)},validate:function(){return X("steps.".concat(M,".productCategories.").concat(r))},saveValidField:se,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,productCategoryIndex:r,categoryType:e.type}))}})}))),n.createElement(v.CreateProductSetItem,{title:A("addCategory"),onClick:function(){O(!0)}}),n.createElement(E.SelectCategoryModal,{isVisible:Y,onHide:function(){return O(!1)},onCategorySelect:function(e){ne(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,re.length)),U(!0),(null==pe?void 0:pe.type)===u.manualErrorType&&z(ee)}}),j&&$&&n.createElement(n.Fragment,null,n.createElement(v.CreateProductSetItem,{title:A("editMap"),onClick:function(){w(!0)},className:d("mt-3",fe&&"mb-3",fe&&"is-invalid")}),fe&&n.createElement("div",{className:"manual-form-error"},ve&&A("Validation:fieldRequired",{attribute:A("Design:venueMapSet")}),ge&&A("Validation:fieldMinNumber",{attribute:A("pointProduct"),min:1})),n.createElement(b.VenueMapSetModal,{isVisible:L,setIsVisible:w,stepIndex:M})),n.createElement("div",{className:"manual-form-error"},pe&&pe.message))},exports.getBadgeConfig=I;
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;CAC5B;AAmCD,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,SAAS,EACT,YAAY,GACb,EAAE,oBAAoB,eA8MtB"}
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"),c=e(require("@licklist/plugins/dist/services/Form/HookFormService")),u=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"),y=require("./SubProductsControl.js"),f=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=n.useTranslation("Design").t,x=i.useFormContext(),N=t.__read(r.useState(!1),2),D=N[0],F=N[1],A=x.control,M=x.formState.errors,Q=x.clearErrors,w=x.trigger,B=x.setValue,U=x.watch,L=x.getValues,R="steps.".concat(T,".productCategories.").concat(h,".products"),V="steps.".concat(T,".pointProducts"),O=i.useFieldArray({name:R,control:A,keyName:"_id"}),W=O.fields,H=O.append,z=O.remove,G=O.move,Y=p.useSortableTreeFunctions({fieldName:R,remove:z}),J=Y.edit,K=Y.saveValidField,X=Y.cancelChanges,Z=U("steps.".concat(T,".productCategories.").concat(h,".allowDeposits")),$=i.useWatch({control:A,name:t.__spreadArray([],t.__read(W.map((function(e,t){return"".concat(R,".").concat(t,".price")}))),!1)}),ee=i.useWatch({control:A,name:t.__spreadArray([],t.__read(W.map((function(e,t){return"".concat(R,".").concat(t,".totalQuantity")}))),!1)}),te=i.useWatch({control:A,name:t.__spreadArray([],t.__read(W.map((function(e,t){return"".concat(R,".").concat(t,".isUnlimited")}))),!1)}),re=null===(S=null===(b=null===(P=null===(C=null==M?void 0:M.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,oe=1===W.length,ne=u.useSensor(u.MouseSensor,{activationConstraint:{distance:10}});return o.createElement(o.Fragment,null,o.createElement(l.SortableTree,{items:W.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=W.findIndex((function(e){return e._id===t.id})),n=W.findIndex((function(e){return e._id===r.id}));o!==n&&(G(o,n),W.forEach((function(e,t){B("".concat(R,".").concat(t,".sort"),t)})))}},sensors:[ne]},W.map((function(e,t){return o.createElement(i.Controller,{key:e._id,control:A,name:"".concat(R,".").concat(t,".name"),rules:{required:k("Validation:fieldRequired",{attribute:k("name")})},render:function(r){var n=r.field,i=n.value,c=n.onChange;return o.createElement(l.SortableTree.Item,{key:"product-".concat(e._id),id:String(e._id),isExpanded:oe,isInvalid:!!re,title:i,badge:o.createElement(a.Badge,{className:"product-badge"},k("product")),isIconInHeader:!1,cancelChanges:function(){return X(t)},edit:function(){return J(t)},secondaryBadge:f.getBadgeConfig(I,k(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($[t]," ").concat(k("each")," - ").concat(k("qty"),":").concat(te[t]?k(" unlimited"):" ".concat(ee[t])," ").concat(te[t]?"":" - ".concat(k("possibleRevenue")," £").concat($[t]*ee[t])," "))),modalLabel:k("addNewProduct"),modalClass:s.ProductSetModalClasses.product,isNewAdded:D,body:o.createElement(q.ProductControl,{isLoading:_,quantityType:j,allowDeposits:Z,hasBookingManagement:!1,fieldNamePrefix:"".concat(R,".").concat(t),productName:i,onProductNameChange:c,hasTicket:E,categoryType:I}),onDelete:function(){return function(e){var t=L("".concat(R,".").concat(e)),r=L(V);B(V,(null==r?void 0:r.filter((function(e){return e.productUuid!==t.uuid})))||[]),z(e)}(t)},validate:function(){return w("".concat(R,".").concat(t))},saveValidField:K},o.createElement(y.SubProductsControl,{isLoading:_,quantityType:j,stepIndex:T,productCategoryIndex:h,productIndex:t}))}})}))),o.createElement(m.CreateProductSetItem,{title:k("addProduct"),onClick:function(){var e;H((e=W.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})),F(!0),(null==re?void 0:re.type)===c.manualErrorType&&Q(R)}}),o.createElement("div",{className:"manual-form-error"},re&&re.message))};
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),r=require("react"),o=e(r),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;CAC7B;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,UAAU,EAAE,EACnD,SAAiB,EACjB,eAAe,EACf,aAAqB,EACrB,oBAA4B,EAC5B,QAAa,EACb,MAAM,EACN,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,YAAY,GACb,EAAE,mBAAmB,CAAC,CAAC,CAAC,eAsgBxB"}
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,g="".concat(i,".duration"),b=function(e){return v(g,e)},F=o.useWatch({control:f,name:g}),C=Math.floor(F/60),I=F%60,q=function(e){b(60*e+I)},x=function(e){b(60*C+(e>59?59:e))},N=a.isInvalid(g,E),h=function(e){return e.target.select()};return t.createElement(o.Controller,{control:f,name:g,rules:{required:{value:Boolean(c),message:s("Validation:fieldRequired",{attribute:s("duration")})},min:{value:1,message:s("Validation:fieldMin",{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 q(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:N,onChange:function(e){return q(Number(e.target.value))},ref:r.ref,onFocus:h}),t.createElement(n.Form.Control.Feedback,{type:"invalid"},a.getErrors(g,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 x(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:N,onChange:function(e){return x(Number(e.target.value))},onFocus:h}),t.createElement(n.Form.Control.Feedback,{type:"invalid"},a.getErrors(g,E))))))}})};
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,eAigB7B"}
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,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),O=l.useWatch({name:Y}),B=_("".concat(Y,".maxSubItems"))||0,D=_("".concat(Y,".minSubItems"))||0,V=_("".concat(Y,".allowDeposits")),M=p.includes(O.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(),Z=m.useId(),J=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"))}),[D,Y]),n.useEffect((function(){q("".concat(Y,".minSubItems"))}),[B,Y]);var ce=O.type===E.CATEGORY_TYPE_FIXED_DURATION||O.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:B?{value:Number(B),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(D),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,"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")})},validate:function(e){return!!e||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:J,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:O.type===E.CATEGORY_TYPE_TICKETS})},control:T,name:"".concat(Y,".hasTicket")}))),O.hasTicket&&a.createElement(o.Form.Group,{controlId:Z,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||O.hasTicket})},control:T,name:"".concat(Y,".isRelyOnPeople")}))),!O.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)))))))};
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,iDAMzB,oBAAoB,gBA4DtB,CAAC"}
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")),i=require("@react-aria/utils"),l=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=i.useId(),v=n.useTranslation("Validation").t,g=o.useFormContext(),E=g.control,F=g.setValue,q=g.formState.errors,C=o.useWatch({name:c}),I=function(e){return e.target.select()};return t.createElement(a.Form.Group,{controlId:f},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 F(c,Number(C)+1)}},t.createElement(a.InputGroup.Text,{className:"py-0 px-3"},t.createElement(l.ReactComponent,null))),t.createElement(o.Controller,{control:E,name:c,rules:r.__assign({min:{value:0,message:v("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){return n.onChange(Number(e.target.value))},onFocus:I}))}}),t.createElement(a.Form.Control.Feedback,{type:"invalid"},u.getErrors(c,q))))};
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=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:gameDefaultDuration")),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:gameDefaultDuration"),min: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: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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licklist/design",
3
- "version": "0.44.486-dev.13",
3
+ "version": "0.44.486-dev.14",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
@@ -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
  />
@@ -74,6 +74,7 @@ Default.args = {
74
74
  {
75
75
  createdAt: "2023-05-08T15:55:28.000+03:00",
76
76
  deletedAt: null,
77
+ defaultDuration: 30,
77
78
  description: "Zone description 2",
78
79
  id: 2,
79
80
  image: null,
@@ -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
- rules={{
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>
@@ -66,7 +66,7 @@ export const ProductDurationControl = <T,>({
66
66
  },
67
67
  min: {
68
68
  value: 1,
69
- message: t("Validation:fieldMin", {
69
+ message: t("Validation:fieldMinNumber", {
70
70
  attribute: t("duration"),
71
71
  }),
72
72
  },
@@ -332,7 +332,7 @@ export function ProductCategoryControl({
332
332
  <Row>
333
333
  <Col>
334
334
  <Form.Group controlId={zoneId}>
335
- <Form.Label>Zone</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 (value) return true;
365
- return t("Validation:fieldRequired", {
366
- attribute: t("zone"),
367
- }) as string;
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) => field.onChange(Number(event.target.value))}
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:gameDefaultDuration")}</Form.Label>
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:gameDefaultDuration"),
40
+ attribute: t("Design:defaultGameDuration").toLowerCase(),
41
41
  min: 1,
42
42
  })}
43
43
  </Form.Control.Feedback>