@licklist/design 0.59.0-dev.7 → 0.59.0-dev.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/product-set/product/ProductControl.d.ts.map +1 -1
- package/dist/product-set/product/ProductControl.js +1 -1
- package/dist/sales/coupon/control/CouponFormControl.d.ts +2 -1
- package/dist/sales/coupon/control/CouponFormControl.d.ts.map +1 -1
- package/dist/sales/coupon/control/CouponFormControl.js +1 -1
- package/dist/sales/coupon/form/CouponFrom.d.ts +2 -2
- package/dist/sales/coupon/form/CouponFrom.d.ts.map +1 -1
- package/dist/sales/coupon/utils/index.d.ts +7 -0
- package/dist/sales/coupon/utils/index.d.ts.map +1 -0
- package/dist/sales/coupon/utils/index.js +1 -0
- package/dist/typeahead/Typeahead.d.ts +2 -1
- package/dist/typeahead/Typeahead.d.ts.map +1 -1
- package/dist/typeahead/Typeahead.js +1 -1
- package/package.json +1 -1
- package/src/product-set/product/ProductControl.tsx +32 -35
- package/src/sales/coupon/control/CouponFormControl.tsx +29 -50
- package/src/sales/coupon/form/CouponFrom.tsx +5 -15
- package/src/sales/coupon/utils/index.ts +13 -0
- package/src/typeahead/Typeahead.tsx +16 -3
|
@@ -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,EACL,WAAW,EAEZ,MAAM,0DAA0D,CAAC;AAGlE,OAAO,EACL,mBAAmB,EACnB,UAAU,EACX,MAAM,8DAA8D,CAAC;AAEtE,OAAc,EACZ,WAAW,EAKZ,MAAM,OAAO,CAAC;AAgBf,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;AAQzC,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;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;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,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,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,EACZ,WAAmB,GACpB,EAAE,mBAAmB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"ProductControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/product/ProductControl.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,YAAY,EAMb,MAAM,kEAAkE,CAAC;AAC1E,OAAO,EACL,WAAW,EAEZ,MAAM,0DAA0D,CAAC;AAGlE,OAAO,EACL,mBAAmB,EACnB,UAAU,EACX,MAAM,8DAA8D,CAAC;AAEtE,OAAc,EACZ,WAAW,EAKZ,MAAM,OAAO,CAAC;AAgBf,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;AAQzC,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;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;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,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,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,EACZ,WAAmB,GACpB,EAAE,mBAAmB,CAAC,CAAC,CAAC,eAqlBxB"}
|
|
@@ -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")),i=e(require("react-bootstrap/Col")),l=require("react-bootstrap"),c=require("../../static/Icon.js"),s=require("react-hook-form"),d=e(require("@licklist/plugins/dist/services/Form/HookFormService")),u=require("@react-aria/utils"),m=e(require("clsx")),p=require("../../static/switch/BooleanSwitch.js"),E=require("../../static/form-number-input/FormNumberInput.js");require("../../static/index.js");var g=require("../form/context.js"),f=require("@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper"),C=require("@licklist/core/dist/DataMapper/Product/ProductDataMapper"),v=require("./booking-management/ProductBookingManagementControl.js"),b=require("./deposit/ProductDepositControl.js"),h=require("./quantity/ProductQuantityControl.js"),P=require("./quantity/ProductQuantityConstantControl.js"),I=require("./quantity/ProductQuantityRechargingControl.js"),N=e(require("react-bootstrap/Collapse")),F=require("@licklist/plugins/dist/hooks/Media/useImages"),q=require("@licklist/core/dist/DataMapper/Media/ImageDataMapper"),T=require("../../file-upload/FileUpload.js");require("../../snippet/snippet-template/context/snippetTemplate.js"),require("../../snippet/snippet-template/context/snippetTemplateLoading.js"),require("../../snippet/snippet-template/context/snippetTemplateView.js");var y=require("../../snippet/snippet-template/control/PropertyControl.js");require("../../snippet/snippet-template/form/SnippetTemplateForm.js");var x=require("../../tiptap-editor/TipTapEditor.js");require("../../snippet/snippet-template/settings/SettingButton.js"),require("../../snippet/snippet-template/preview/Preview.js"),require("../../snippet/snippet-template/SnippetTemplate.js");var _=require("./fixed-duration-fields/FixedDurationOptions.js"),k=require("./duration/ProductDurationControl.js"),S=require("./price/ProductPriceControl.js"),D=require("./constants.js");exports.ProductControl=function(e){var j=e.isLoading,L=void 0!==j&&j,A=e.fieldNamePrefix,R=e.allowDeposits,w=void 0!==R&&R,M=e.hasBookingManagement,O=void 0!==M&&M,G=e.zoneList,U=void 0===G?[]:G,B=e.onCopy,Y=e.onProductNameChange,V=e.productName,Q=e.hasTicket,H=e.categoryType,X=e.zoneDuration,z=e.isOverrides,W=void 0!==z&&z,Z=s.useFormContext(),J=Z.register,K=Z.control,$=Z.formState.errors,ee=Z.setValue,te=Z.getValues,ae=Z.watch,ne=Z.trigger,re=Z.clearErrors,oe=a.useContext(g.ProductSetLoadingContext).setLoading,ie=r.useTranslation(["Design","Validation","ProductSet"]).t,le=t.__read(a.useState(!1),2),ce=le[0],se=le[1],de=t.__read(a.useState(null),2),ue=de[0],me=de[1],pe=Boolean(ae("".concat(A,".isUnlimited"))),Ee=ae("".concat(A,".capacity")),ge="0"===Ee||!Ee,fe=u.useId(),Ce=u.useId(),ve=u.useId(),be=u.useId(),he=u.useId(),Pe=u.useId(),Ie=u.useId(),Ne=u.useId(),Fe=u.useId(),qe=u.useId(),Te=u.useId(),ye=[{id:1,value:ie("quantitySelector")},{id:2,value:ie("stockControl")}],xe=a.useCallback((function(){return se((function(e){return!e}))}),[]),_e=s.useWatch({control:K,name:"".concat(A,".quantitySelector")}),ke=F.useImages(ue),Se=ke.images,De=ke.handleImageRemove,je=ke.handleImageUploading,Le=ke.isLoading,Ae=a.useCallback((function(e){je(e,q.IMAGE_TYPE_IMAGE)}),[je]),Re=a.useCallback((function(e,t){De(String(e),t)}),[De]),we=function(e){return e.target.select()};a.useEffect((function(){oe(Le)}),[oe,Le]),a.useEffect((function(){var e=te("".concat(A,".images"));me(e)}),[te,me,A]),a.useEffect((function(){Array.isArray(Se)&&ee("".concat(A,".images"),Se)}),[Se,A,ee]),a.useEffect((function(){ge?(ee("".concat(A,".duration"),0),re("".concat(A,".duration"))):ne("".concat(A,".duration"))}),[ge]);var Me=null!=_e?_e:"1",Oe=f.QUANTITY_TYPE_LIST_DTO[Me];return n.createElement(n.Fragment,null,n.createElement(o,null,n.createElement(i,{lg:8,md:8},n.createElement(l.Form.Group,{controlId:Ce},n.createElement(l.Form.Label,null,ie("name")),n.createElement(l.Form.Control,t.__assign({},J("".concat(A,".name")),{value:V,onChange:Y,isInvalid:d.isInvalid("".concat(A,".name"),$),disabled:L||W,placeholder:ie("name")})),n.createElement(l.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(A,".name"),$))),n.createElement(l.Form.Group,{controlId:ve},n.createElement(l.Form.Label,null,ie("description")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange;return n.createElement(x.TipTapEditor,{withEmoji:!1,viewMode:!1,onUpdate:r,content:a,disabled:L||W})},rules:{maxLength:{value:D.MAX_PRODUCT_DESCRIPTION_CHARACTERS_LENGTH,message:ie("Validation:descriptionTooManyCharactersMessage",{max:D.MAX_PRODUCT_DESCRIPTION_CHARACTERS_LENGTH})}},control:K,name:"".concat(A,".description")})),n.createElement("div",{className:"invalid-feedback field-values-error d-block"},d.getErrors("".concat(A,".description"),$)),w?n.createElement(o,null,n.createElement(b.ProductDepositControl,{isLoading:L,fieldNamePrefix:A}),n.createElement(S.ProductPriceControl,{isLoading:L,fieldNamePrefix:"".concat(A,".price"),title:ie("totalPrice"),allowDeposits:w})):n.createElement(S.ProductPriceControl,{isLoading:L,fieldNamePrefix:"".concat(A,".price")}),n.createElement("div",null,n.createElement(h.ProductQuantityControl,{isLoading:L,fieldNamePrefix:A,isOverrides:W,onFocus:we}),Oe===f.QUANTITY_TYPE_CONSTANT&&n.createElement(P.ProductQuantityConstantControl,{isLoading:L,fieldNamePrefix:A,onFocus:we,disabled:pe}),Oe===f.QUANTITY_TYPE_RECHARGING&&n.createElement(I.ProductQuantityRechargingControl,{isLoading:L,fieldNamePrefix:A,onFocus:we,disabled:pe}),n.createElement(l.Form.Group,{controlId:qe,className:"custom-checkbox"},n.createElement(l.Form.Check,t.__assign({custom:!0,type:"checkbox"},J("".concat(A,".isUnlimited")),{name:"".concat(A,".isUnlimited"),disabled:L})),n.createElement(l.Form.Check.Label,null,ie("isUnlimited")))),n.createElement(l.Form.Group,{controlId:Ne},n.createElement(l.Form.Label,null,ie("quantitySelectorType")),n.createElement(l.Form.Control,t.__assign({as:"select",defaultValue:Q?ye[0].id:void 0},J("".concat(A,".quantitySelector")),{isInvalid:d.isInvalid("".concat(A,".quantitySelector"),$),disabled:L||Q||W}),ye.map((function(e){return n.createElement("option",{value:e.id,key:e.id},e.value)}))),n.createElement(l.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(A,".quantitySelector"),$))),n.createElement(y.PropertyControl,{item:"".concat(A,".color"),label:ie("ProductSet:selectColor"),isDisabled:W,isRequired:!1,defaultColors:C.PRODUCT_DEfAULT_COLORS}))),H===f.CATEGORY_TYPE_FIXED_DURATION&&n.createElement(o,{className:"align-items-start duration-capacity-container"},n.createElement(k.ProductDurationControl,{fieldNamePrefix:A,disabled:ge||W}),n.createElement(i,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(A,".capacity"),label:ie("capacity"),disabled:W,rules:{min:{value:0,message:ie("Validation:fieldMinNumber",{attribute:ie("capacity"),min:0})}}})),ge&&n.createElement("div",{className:"duration-hint duration-capacity-container"},ie("Design:forDurationEditing"))),H===f.CATEGORY_TYPE_GAME&&n.createElement(n.Fragment,null,n.createElement(o,{className:"align-items-start duration-capacity-container"},n.createElement(i,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(A,".capacity"),label:ie("capacity"),onChange:function(e){X&&ee("".concat(A,".duration"),e*X)},disabled:W,rules:{min:{value:0,message:ie("Validation:fieldMinNumber",{attribute:ie("capacity"),min:1})}}})),n.createElement(i,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(A,".duration"),label:ie("durationMinutes"),disabled:ge||W,rules:{min:{value:0,message:ie("Validation:fieldMinNumber",{attribute:ie("duration"),min:0})},validate:function(e){return!(!ge&&(!e||e<1))||ie("Validation:fieldRequired",{attribute:ie("duration")})}}}))),ge&&n.createElement("div",{className:"duration-hint pl-0"},ie("Design:forDurationEditing"))),n.createElement(o,{className:"mt-4"},n.createElement(i,{lg:8,md:8},n.createElement(l.Form.Group,{controlId:be},n.createElement(l.Form.Label,null,ie("productTermsConditions")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name,i=t.ref;return n.createElement(l.Form.Control,{ref:i,as:"textarea",rows:3,value:a,onChange:r,isInvalid:d.isInvalid("".concat(A,".termsAndConditions"),$),disabled:L||W,name:o})},control:K,name:"".concat(A,".termsAndConditions")}),n.createElement(l.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(A,".termsAndConditions"),$)))),n.createElement(i,{lg:4,md:4,className:m("licklist-file-upload-wrapper",W&&"opacity-50")},n.createElement(T.FileUpload,{onFilesChange:Ae,allowedExtensions:["jpeg","jpg","png"],subTitle:".jpeg .jpg .png",enablePreview:!0,onFileRemove:Re,defaultFiles:Se,isLoading:Le,disabled:W,withIcon:!0,title:ie("addImage")}))),n.createElement(i,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(l.Form.Group,{controlId:he,className:"advanced-switch-container"},n.createElement(l.Form.Label,null,ie("isAvailable")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(p.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:L||W})},control:K,name:"".concat(A,".isAvailable")})),n.createElement(l.Form.Group,{controlId:Pe,className:"advanced-switch-container"},n.createElement(l.Form.Label,null,ie("isSoldOut")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(p.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:L})},control:K,name:"".concat(A,".isSoldOut")})),n.createElement(l.Form.Group,{controlId:fe,className:"custom-checkbox"},n.createElement(l.Form.Check,{custom:!0,type:"checkbox",name:fe,disabled:L||W},n.createElement(l.Form.Check.Input,{checked:ce,onChange:xe,type:"checkbox"}),n.createElement(l.Form.Check.Label,null,ie("showAdvancedOptions"))))),n.createElement(i,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(N,{in:ce},n.createElement("div",null,n.createElement(l.Form.Group,{controlId:Ie,className:"advanced-switch-container"},n.createElement(l.Form.Label,null,ie("isRequired")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(p.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:L||W})},control:K,name:"".concat(A,".isRequired")})),n.createElement(l.Form.Group,{controlId:Fe,className:"advanced-switch-container"},n.createElement(l.Form.Label,null,ie("hasSpecialNotes")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(p.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:L||W})},control:K,name:"".concat(A,".hasSpecialNotes")})),[f.CATEGORY_TYPE_GAME,f.CATEGORY_TYPE_FIXED_DURATION].includes(H)&&n.createElement(_.FixedDurationOptions,{fieldNamePrefix:A,isOverrides:W}),n.createElement(l.Form.Group,{controlId:Te,className:"advanced-switch-container"},n.createElement(S.ProductPriceControl,{title:ie("minSpend"),isRequired:!1,isMoreThanZero:!0,allowDeposits:!1,isLoading:L||W,fieldNamePrefix:"".concat(A,".minSpend")})))),n.createElement(o,null,n.createElement(i,{xs:12},O&&n.createElement(v.ProductBookingManagementControl,{isLoading:L,zoneList:U,fieldNamePrefix:A})))),n.createElement(o,null,n.createElement(i,{xs:!0},n.createElement("div",{className:"d-flex justify-content-end mt-4"},Boolean(B)&&n.createElement(l.Button,{onClick:B,variant:"link",className:"d-flex align-items-center"},n.createElement(c.default,{type:"clipboard",height:"1rem",className:"mr-2"})," ",ie("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")),i=e(require("react-bootstrap/Col")),l=require("react-bootstrap"),c=require("../../static/Icon.js"),s=require("react-hook-form"),d=e(require("@licklist/plugins/dist/services/Form/HookFormService")),u=require("@react-aria/utils"),m=e(require("clsx")),p=require("../../static/switch/BooleanSwitch.js"),E=require("../../static/form-number-input/FormNumberInput.js");require("../../static/index.js");var g=require("../form/context.js"),f=require("@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper"),C=require("@licklist/core/dist/DataMapper/Product/ProductDataMapper"),v=require("./booking-management/ProductBookingManagementControl.js"),b=require("./deposit/ProductDepositControl.js"),I=require("./quantity/ProductQuantityControl.js"),h=require("./quantity/ProductQuantityConstantControl.js"),F=require("./quantity/ProductQuantityRechargingControl.js"),P=e(require("react-bootstrap/Collapse")),N=require("@licklist/plugins/dist/hooks/Media/useImages"),q=require("@licklist/core/dist/DataMapper/Media/ImageDataMapper"),T=require("../../file-upload/FileUpload.js");require("../../snippet/snippet-template/context/snippetTemplate.js"),require("../../snippet/snippet-template/context/snippetTemplateLoading.js"),require("../../snippet/snippet-template/context/snippetTemplateView.js");var y=require("../../snippet/snippet-template/control/PropertyControl.js");require("../../snippet/snippet-template/form/SnippetTemplateForm.js");var _=require("../../tiptap-editor/TipTapEditor.js");require("../../snippet/snippet-template/settings/SettingButton.js"),require("../../snippet/snippet-template/preview/Preview.js"),require("../../snippet/snippet-template/SnippetTemplate.js");var x=require("./fixed-duration-fields/FixedDurationOptions.js"),k=require("./duration/ProductDurationControl.js"),S=require("./price/ProductPriceControl.js"),D=require("./constants.js");exports.ProductControl=function(e){var L=e.isLoading,j=void 0!==L&&L,A=e.fieldNamePrefix,G=e.allowDeposits,R=void 0!==G&&G,w=e.hasBookingManagement,M=void 0!==w&&w,O=e.zoneList,U=void 0===O?[]:O,B=e.onCopy,Y=e.onProductNameChange,V=e.productName,Q=e.hasTicket,H=e.categoryType,X=e.zoneDuration,z=e.isOverrides,W=void 0!==z&&z,Z=s.useFormContext(),J=Z.register,K=Z.control,$=Z.formState.errors,ee=Z.setValue,te=Z.getValues,ae=Z.watch,ne=Z.trigger,re=Z.clearErrors,oe=a.useContext(g.ProductSetLoadingContext),ie=oe.setLoading,le=oe.productGroupList,ce=r.useTranslation(["Design","Validation","ProductSet"]).t,se=t.__read(a.useState(!1),2),de=se[0],ue=se[1],me=t.__read(a.useState(null),2),pe=me[0],Ee=me[1],ge=Boolean(ae("".concat(A,".isUnlimited"))),fe=ae("".concat(A,".capacity")),Ce="0"===fe||!fe,ve=u.useId(),be=u.useId(),Ie=u.useId(),he=u.useId(),Fe=u.useId(),Pe=u.useId(),Ne=u.useId(),qe=u.useId(),Te=u.useId(),ye=u.useId(),_e=u.useId(),xe=u.useId(),ke=[{id:1,value:ce("quantitySelector")},{id:2,value:ce("stockControl")}],Se=a.useCallback((function(){return ue((function(e){return!e}))}),[]),De=s.useWatch({control:K,name:"".concat(A,".quantitySelector")}),Le=N.useImages(pe),je=Le.images,Ae=Le.handleImageRemove,Ge=Le.handleImageUploading,Re=Le.isLoading,we=a.useCallback((function(e){Ge(e,q.IMAGE_TYPE_IMAGE)}),[Ge]),Me=a.useCallback((function(e,t){Ae(String(e),t)}),[Ae]),Oe=function(e){return e.target.select()};a.useEffect((function(){ie(Re)}),[ie,Re]),a.useEffect((function(){var e=te("".concat(A,".images"));Ee(e)}),[te,Ee,A]),a.useEffect((function(){Array.isArray(je)&&ee("".concat(A,".images"),je)}),[je,A,ee]),a.useEffect((function(){Ce?(ee("".concat(A,".duration"),0),re("".concat(A,".duration"))):ne("".concat(A,".duration"))}),[Ce]);var Ue=null!=De?De:"1",Be=f.QUANTITY_TYPE_LIST_DTO[Ue];return n.createElement(n.Fragment,null,n.createElement(o,null,n.createElement(i,{lg:8,md:8},n.createElement(l.Form.Group,{controlId:be},n.createElement(l.Form.Label,null,ce("name")),n.createElement(l.Form.Control,t.__assign({},J("".concat(A,".name")),{value:V,onChange:Y,isInvalid:d.isInvalid("".concat(A,".name"),$),disabled:j||W,placeholder:ce("name")})),n.createElement(l.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(A,".name"),$))),n.createElement(l.Form.Group,{controlId:he},n.createElement(l.Form.Label,null,ce("description")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange;return n.createElement(_.TipTapEditor,{withEmoji:!1,viewMode:!1,onUpdate:r,content:a,disabled:j||W})},rules:{maxLength:{value:D.MAX_PRODUCT_DESCRIPTION_CHARACTERS_LENGTH,message:ce("Validation:descriptionTooManyCharactersMessage",{max:D.MAX_PRODUCT_DESCRIPTION_CHARACTERS_LENGTH})}},control:K,name:"".concat(A,".description")})),n.createElement("div",{className:"invalid-feedback field-values-error d-block"},d.getErrors("".concat(A,".description"),$)),R?n.createElement(o,null,n.createElement(b.ProductDepositControl,{isLoading:j,fieldNamePrefix:A}),n.createElement(S.ProductPriceControl,{isLoading:j,fieldNamePrefix:"".concat(A,".price"),title:ce("totalPrice"),allowDeposits:R})):n.createElement(S.ProductPriceControl,{isLoading:j,fieldNamePrefix:"".concat(A,".price")}),n.createElement("div",null,n.createElement(I.ProductQuantityControl,{isLoading:j,fieldNamePrefix:A,isOverrides:W,onFocus:Oe}),Be===f.QUANTITY_TYPE_CONSTANT&&n.createElement(h.ProductQuantityConstantControl,{isLoading:j,fieldNamePrefix:A,onFocus:Oe,disabled:ge}),Be===f.QUANTITY_TYPE_RECHARGING&&n.createElement(F.ProductQuantityRechargingControl,{isLoading:j,fieldNamePrefix:A,onFocus:Oe,disabled:ge}),n.createElement(l.Form.Group,{controlId:_e,className:"custom-checkbox"},n.createElement(l.Form.Check,t.__assign({custom:!0,type:"checkbox"},J("".concat(A,".isUnlimited")),{name:"".concat(A,".isUnlimited"),disabled:j})),n.createElement(l.Form.Check.Label,null,ce("isUnlimited")))),n.createElement(l.Form.Group,{controlId:Te},n.createElement(l.Form.Label,null,ce("quantitySelectorType")),n.createElement(l.Form.Control,t.__assign({as:"select",defaultValue:Q?ke[0].id:void 0},J("".concat(A,".quantitySelector")),{isInvalid:d.isInvalid("".concat(A,".quantitySelector"),$),disabled:j||Q||W}),ke.map((function(e){return n.createElement("option",{value:e.id,key:e.id},e.value)}))),n.createElement(l.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(A,".quantitySelector"),$))),n.createElement(y.PropertyControl,{item:"".concat(A,".color"),label:ce("ProductSet:selectColor"),isDisabled:W,isRequired:!1,defaultColors:C.PRODUCT_DEfAULT_COLORS}),n.createElement(l.Form.Group,{controlId:Ie},n.createElement(l.Form.Label,null,ce("productGroup")),n.createElement(l.Form.Control,t.__assign({as:"select"},J("".concat(A,".productGroupId")),{isInvalid:d.isInvalid("".concat(A,".productGroupId"),$),disabled:j,defaultValue:""}),n.createElement("option",{value:""},ce("Design:selectProductGroup")),le.map((function(e){return n.createElement("option",{value:e.id,key:e.id},e.value)}))),n.createElement(l.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(A,".productGroupId"),$))))),H===f.CATEGORY_TYPE_FIXED_DURATION&&n.createElement(o,{className:"align-items-start duration-capacity-container"},n.createElement(k.ProductDurationControl,{fieldNamePrefix:A,disabled:Ce||W}),n.createElement(i,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(A,".capacity"),label:ce("capacity"),disabled:W,rules:{min:{value:0,message:ce("Validation:fieldMinNumber",{attribute:ce("capacity"),min:0})}}})),Ce&&n.createElement("div",{className:"duration-hint duration-capacity-container"},ce("Design:forDurationEditing"))),H===f.CATEGORY_TYPE_GAME&&n.createElement(n.Fragment,null,n.createElement(o,{className:"align-items-start duration-capacity-container"},n.createElement(i,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(A,".capacity"),label:ce("capacity"),onChange:function(e){X&&ee("".concat(A,".duration"),e*X)},disabled:W,rules:{min:{value:0,message:ce("Validation:fieldMinNumber",{attribute:ce("capacity"),min:1})}}})),n.createElement(i,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(A,".duration"),label:ce("durationMinutes"),disabled:Ce||W,rules:{min:{value:0,message:ce("Validation:fieldMinNumber",{attribute:ce("duration"),min:0})},validate:function(e){return!(!Ce&&(!e||e<1))||ce("Validation:fieldRequired",{attribute:ce("duration")})}}}))),Ce&&n.createElement("div",{className:"duration-hint pl-0"},ce("Design:forDurationEditing"))),n.createElement(o,{className:"mt-4"},n.createElement(i,{lg:8,md:8},n.createElement(l.Form.Group,{controlId:Fe},n.createElement(l.Form.Label,null,ce("productTermsConditions")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name,i=t.ref;return n.createElement(l.Form.Control,{ref:i,as:"textarea",rows:3,value:a,onChange:r,isInvalid:d.isInvalid("".concat(A,".termsAndConditions"),$),disabled:j||W,name:o})},control:K,name:"".concat(A,".termsAndConditions")}),n.createElement(l.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(A,".termsAndConditions"),$)))),n.createElement(i,{lg:4,md:4,className:m("licklist-file-upload-wrapper",W&&"opacity-50")},n.createElement(T.FileUpload,{onFilesChange:we,allowedExtensions:["jpeg","jpg","png"],subTitle:".jpeg .jpg .png",enablePreview:!0,onFileRemove:Me,defaultFiles:je,isLoading:Re,disabled:W,withIcon:!0,title:ce("addImage")}))),n.createElement(i,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(l.Form.Group,{controlId:Pe,className:"advanced-switch-container"},n.createElement(l.Form.Label,null,ce("isAvailable")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(p.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:j||W})},control:K,name:"".concat(A,".isAvailable")})),n.createElement(l.Form.Group,{controlId:Ne,className:"advanced-switch-container"},n.createElement(l.Form.Label,null,ce("isSoldOut")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(p.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:j})},control:K,name:"".concat(A,".isSoldOut")})),n.createElement(l.Form.Group,{controlId:ve,className:"custom-checkbox"},n.createElement(l.Form.Check,{custom:!0,type:"checkbox",name:ve,disabled:j||W},n.createElement(l.Form.Check.Input,{checked:de,onChange:Se,type:"checkbox"}),n.createElement(l.Form.Check.Label,null,ce("showAdvancedOptions"))))),n.createElement(i,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(P,{in:de},n.createElement("div",null,n.createElement(l.Form.Group,{controlId:qe,className:"advanced-switch-container"},n.createElement(l.Form.Label,null,ce("isRequired")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(p.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:j||W})},control:K,name:"".concat(A,".isRequired")})),n.createElement(l.Form.Group,{controlId:ye,className:"advanced-switch-container"},n.createElement(l.Form.Label,null,ce("hasSpecialNotes")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(p.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:j||W})},control:K,name:"".concat(A,".hasSpecialNotes")})),[f.CATEGORY_TYPE_GAME,f.CATEGORY_TYPE_FIXED_DURATION].includes(H)&&n.createElement(x.FixedDurationOptions,{fieldNamePrefix:A,isOverrides:W}),n.createElement(l.Form.Group,{controlId:xe,className:"advanced-switch-container"},n.createElement(S.ProductPriceControl,{title:ce("minSpend"),isRequired:!1,isMoreThanZero:!0,allowDeposits:!1,isLoading:j||W,fieldNamePrefix:"".concat(A,".minSpend")})))),n.createElement(o,null,n.createElement(i,{xs:12},M&&n.createElement(v.ProductBookingManagementControl,{isLoading:j,zoneList:U,fieldNamePrefix:A})))),n.createElement(o,null,n.createElement(i,{xs:!0},n.createElement("div",{className:"d-flex justify-content-end mt-4"},Boolean(B)&&n.createElement(l.Button,{onClick:B,variant:"link",className:"d-flex align-items-center"},n.createElement(c.default,{type:"clipboard",height:"1rem",className:"mr-2"})," ",ce("copy"))))))};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ProductGroup } from "@licklist/core/dist/DataMapper/Product/ProductGroupDataMapper";
|
|
3
3
|
import { CouponTotalType, CouponType } from "@licklist/core/dist/DataMapper/Product/CouponDataMapper";
|
|
4
|
+
import { TypeaheadOptions } from "../../../typeahead";
|
|
4
5
|
export interface CouponFormValues {
|
|
5
6
|
name?: string;
|
|
6
7
|
code: string;
|
|
7
8
|
discountType: CouponType;
|
|
8
|
-
productGroupIds:
|
|
9
|
+
productGroupIds: Array<TypeaheadOptions | ProductGroup>;
|
|
9
10
|
discount: number;
|
|
10
11
|
totalType: CouponTotalType;
|
|
11
12
|
startFrom: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CouponFormControl.d.ts","sourceRoot":"","sources":["../../../../src/sales/coupon/control/CouponFormControl.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,+DAA+D,CAAC;AAC7F,OAAO,EAOL,eAAe,EACf,UAAU,EACX,MAAM,yDAAyD,CAAC;
|
|
1
|
+
{"version":3,"file":"CouponFormControl.d.ts","sourceRoot":"","sources":["../../../../src/sales/coupon/control/CouponFormControl.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,+DAA+D,CAAC;AAC7F,OAAO,EAOL,eAAe,EACf,UAAU,EACX,MAAM,yDAAyD,CAAC;AAYjE,OAAO,EAAa,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGjE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,UAAU,CAAC;IACzB,eAAe,EAAE,KAAK,CAAC,gBAAgB,GAAG,YAAY,CAAC,CAAC;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,eAAe,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,iBAAiB,kCAG3B,eAAe,gBAyVjB,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"),l=require("react"),n=e(l),r=require("react-i18next"),o=require("react-bootstrap"),a=require("react-hook-form"),i=require("luxon"),m=require("@licklist/core/dist/DataMapper/Product/CouponDataMapper"),u=e(require("@licklist/plugins/dist/validation/Rules/couponCodeRules"));exports.CouponFormControl=function(e){var
|
|
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"),l=require("react"),n=e(l),r=require("react-i18next"),o=require("react-bootstrap"),a=require("react-hook-form"),i=require("luxon"),m=require("../../../typeahead/Typeahead.js"),s=require("@licklist/core/dist/DataMapper/Product/CouponDataMapper"),u=e(require("@licklist/plugins/dist/validation/Rules/couponCodeRules")),c=require("../utils/index.js");exports.CouponFormControl=function(e){var d,E,p,g,F,v,C,b,_,D=e.isLoading,T=void 0!==D&&D,f=e.productGroups,y=a.useFormContext(),P=y.register,O=y.setValue,x=y.getValues,R=y.formState.errors,G=y.watch,L=r.useTranslation(["Design","Notification","App"]).t,N=t.__read(l.useState([]),2),h=N[0],q=N[1],k=G("startFrom"),A=G("validTill"),w=l.useRef(null),I=l.useRef(null),U=((d={})[s.COUPON_TYPE_FIXED]=L("Design:fixed"),d[s.COUPON_TYPE_FIXED_PER_PERSON]=L("Design:fixedPerPerson"),d[s.COUPON_TYPE_PERCENTAGE]=L("Design:percentage"),d[s.COUPON_TYPE_PERCENTAGE_PER_PERSON]=L("Design:percentagePerPerson"),d),S=((E={})[s.COUPON_TOTAL_TYPE_GROSS]=L("Design:grossTotal"),E[s.COUPON_TOTAL_TYPE_TOTAL]=L("Design:depositTotal"),E);l.useEffect((function(){var e=x("productGroupIds");q(c.convertToTypeaheadOptions(e))}),[x]),l.useEffect((function(){O("productGroupIds",h)}),[x,O,h]);var V=c.convertToTypeaheadOptions(f);return n.createElement(o.Row,null,n.createElement(o.Col,{md:5},n.createElement("h2",{className:"mb-5"},L("Design:coupon")),n.createElement(o.Row,null,n.createElement(o.Col,{md:6},n.createElement(o.Form.Group,null,n.createElement(o.Form.Label,null,L("Design:name")),n.createElement(o.Form.Control,t.__assign({isInvalid:void 0!==R.name},P("name",{required:L("Validation:fieldRequired",{attribute:L("Design:name")})}),{disabled:T})),n.createElement(o.Form.Control.Feedback,{type:"invalid"},null===(p=null==R?void 0:R.name)||void 0===p?void 0:p.message))),n.createElement(o.Col,{md:6},n.createElement(o.Form.Group,null,n.createElement(o.Form.Label,null,L("Design:couponCode")),n.createElement(o.Form.Control,t.__assign({isInvalid:void 0!==R.code},P("code",{required:L("Validation:fieldRequired",{attribute:L("Design:code")}),pattern:{message:"".concat(L("Validation:fieldCouponCode")),value:u}}),{disabled:T})),n.createElement(o.Form.Control.Feedback,{type:"invalid"},null===(g=null==R?void 0:R.code)||void 0===g?void 0:g.message)))),n.createElement(o.Row,null,n.createElement(o.Col,{md:6},n.createElement(o.Form.Group,null,n.createElement(o.Form.Label,null,L("Design:discountType")),n.createElement(o.Form.Control,t.__assign({},P("discountType",{required:!0}),{as:"select",defaultValue:null!==(F=x("discountType"))&&void 0!==F?F:1,disabled:T}),Object.keys(U).map((function(e){return n.createElement("option",{value:e,key:e},U[e])}))))),n.createElement(o.Col,{md:6},n.createElement(o.Form.Group,null,n.createElement(o.Form.Label,null,L("Design:discount")),n.createElement(o.Form.Control,t.__assign({type:"number",isInvalid:void 0!==R.discount},P("discount",{required:L("Validation:fieldRequired",{attribute:L("Design:discount")})}),{disabled:T})),n.createElement(o.Form.Control.Feedback,{type:"invalid"},null===(v=null==R?void 0:R.discount)||void 0===v?void 0:v.message)))),n.createElement(o.Row,null,n.createElement(o.Col,{md:6},n.createElement(o.Form.Group,null,n.createElement(o.Form.Label,null,L("Design:applyOn")),n.createElement(o.Form.Control,t.__assign({},P("totalType",{required:!0}),{as:"select",defaultValue:null!==(C=x("totalType"))&&void 0!==C?C:1,disabled:T}),Object.keys(S).map((function(e){return n.createElement("option",{value:e,key:e},S[e])}))))))),n.createElement(o.Col,{md:{span:5,offset:1}},n.createElement("h2",{className:"mb-5"},L("Design:limitations")),n.createElement(o.Row,null,n.createElement(o.Col,{md:6},n.createElement(o.Form.Group,null,n.createElement(o.Form.Label,null,L("Design:startFrom")),n.createElement(o.Form.Control,t.__assign({type:"date"},P("startFrom"),{value:k,isInvalid:void 0!==R.startFrom,onChange:function(e){var t=i.DateTime.fromSQL(e.target.value).toISODate();O("startFrom",t)},className:k&&"date-input-with-value",ref:w,onClick:function(){var e;return null===(e=null==w?void 0:w.current)||void 0===e?void 0:e.showPicker()},disabled:T})),n.createElement(o.Form.Control.Feedback,{type:"invalid"},null===(b=null==R?void 0:R.startFrom)||void 0===b?void 0:b.message))),n.createElement(o.Col,{md:6},n.createElement(o.Form.Group,null,n.createElement(o.Form.Label,null,L("Design:validTill")),n.createElement(o.Form.Control,t.__assign({type:"date"},P("validTill"),{value:A,onChange:function(e){var t=i.DateTime.fromSQL(e.target.value).toISODate();O("validTill",t)},ref:I,className:A&&"date-input-with-value",onClick:function(){var e;return null===(e=null==I?void 0:I.current)||void 0===e?void 0:e.showPicker()},disabled:T}))))),n.createElement(o.Row,null,n.createElement(o.Col,null,n.createElement(o.Form.Group,{className:"mb-3"},n.createElement(o.Form.Label,null,L("Design:productGroups")),n.createElement(m.Typeahead,{name:"productGroupIds",options:V,isMultipleChoise:!0,isCouponForm:!0,placeholder:L("Design:choose"),noOptionsMessage:L("Design:noActiveTemplates",{notification:L("Design:email")})})))),n.createElement(o.Row,null,n.createElement(o.Col,{md:6},n.createElement(o.Form.Group,null,n.createElement(o.Form.Label,null,L("Design:totalCoupons")),n.createElement(o.Form.Control,t.__assign({},P("totalCoupons"),{type:"number",isInvalid:void 0!==R.totalCoupons,disabled:T})),n.createElement(o.Form.Control.Feedback,{type:"invalid"},null===(_=null==R?void 0:R.totalCoupons)||void 0===_?void 0:_.message))),n.createElement(o.Col,{md:6},n.createElement(o.Form.Group,null,n.createElement(o.Form.Label,null,L("Design:usesPerUser")),n.createElement(o.Form.Control,t.__assign({type:"number"},P("usesPerUser"),{disabled:T}))))),n.createElement(o.Row,null,n.createElement(o.Col,{md:6},n.createElement(o.Form.Group,null,n.createElement(o.Form.Label,null,L("Design:useAgain")),n.createElement(o.Form.Control,t.__assign({type:"number"},P("useAgain"),{disabled:T})),n.createElement(o.Form.Text,{className:"text-muted"},L("Design:useAgainExplanation")))),n.createElement(o.Col,{md:6},n.createElement(o.Form.Group,null,n.createElement(o.Form.Label,null,L("Design:usesPerUserDay")),n.createElement(o.Form.Control,t.__assign({type:"number"},P("usesPerUserDay"),{disabled:T})),n.createElement(o.Form.Text,{className:"text-muted"},L("Design:usesPerUserDayExplanation"))))),n.createElement(o.Row,null,n.createElement(o.Col,{md:6},n.createElement(o.Form.Group,null,n.createElement(o.Form.Label,null,L("Design:minAmount")),n.createElement(o.Form.Control,t.__assign({type:"number"},P("minAmount"),{disabled:T})),n.createElement(o.Form.Text,{className:"text-muted"},L("Design:minAmountExplanation")))),n.createElement(o.Col,{md:6},n.createElement(o.Form.Group,null,n.createElement(o.Form.Label,null,L("Design:maxAmount")),n.createElement(o.Form.Control,t.__assign({type:"number"},P("maxAmount"),{disabled:T})),n.createElement(o.Form.Text,{className:"text-muted"},L("Design:maxAmountExplanation")))))))};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ProductGroup } from "@licklist/core/dist/DataMapper/Product/ProductGroupDataMapper";
|
|
2
|
+
import { ProductGroup, ProductGroupDTO } from "@licklist/core/dist/DataMapper/Product/ProductGroupDataMapper";
|
|
3
3
|
import { CouponTotalType, CouponType } from "@licklist/core/dist/DataMapper/Product/CouponDataMapper";
|
|
4
4
|
import { ServerError } from "@licklist/plugins/dist/hooks/Api/useHttpQuery";
|
|
5
5
|
export interface CouponFormValues {
|
|
6
6
|
name?: string;
|
|
7
7
|
code: string;
|
|
8
8
|
discountType: CouponType;
|
|
9
|
-
productGroupIds:
|
|
9
|
+
productGroupIds: ProductGroupDTO[];
|
|
10
10
|
discount: number;
|
|
11
11
|
totalType: CouponTotalType;
|
|
12
12
|
startFrom: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CouponFrom.d.ts","sourceRoot":"","sources":["../../../../src/sales/coupon/form/CouponFrom.tsx"],"names":[],"mappings":";AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"CouponFrom.d.ts","sourceRoot":"","sources":["../../../../src/sales/coupon/form/CouponFrom.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,YAAY,EACZ,eAAe,EAChB,MAAM,+DAA+D,CAAC;AACvE,OAAO,EACL,eAAe,EACf,UAAU,EACX,MAAM,yDAAyD,CAAC;AAIjE,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAK5E,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,UAAU,CAAC;IACzB,eAAe,EAAE,eAAe,EAAE,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,eAAe,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;IAC/B,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC,QAAQ,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC7C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,WAAW,CAAC;CAC5B;AAED,eAAO,MAAM,UAAU,wFAOpB,eAAe,gBAkCjB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProductGroup } from "@licklist/core/dist/DataMapper/Product/ProductGroupDataMapper";
|
|
2
|
+
export declare const convertToTypeaheadOptions: (productGroups?: ProductGroup[]) => {
|
|
3
|
+
id: number;
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
}[];
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sales/coupon/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,+DAA+D,CAAC;AAE7F,eAAO,MAAM,yBAAyB,mBAAoB,YAAY,EAAE;;;;GAUvE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.convertToTypeaheadOptions=function(e){return e&&e.length?e.map((function(e){var t=e.id,r=e.name;return{id:Number(t),value:r,label:r}})):[]};
|
|
@@ -12,7 +12,8 @@ export interface TypeaheadProps {
|
|
|
12
12
|
isMultipleChoise?: boolean;
|
|
13
13
|
noOptionsMessage: string;
|
|
14
14
|
isInvalid?: boolean;
|
|
15
|
+
isCouponForm?: boolean;
|
|
15
16
|
}
|
|
16
|
-
declare function Typeahead({ options, placeholder, isRequired, isMultipleChoise, name, noOptionsMessage, isInvalid, }: TypeaheadProps): JSX.Element;
|
|
17
|
+
declare function Typeahead({ options, placeholder, isRequired, isMultipleChoise, name, isCouponForm, noOptionsMessage, isInvalid, }: TypeaheadProps): JSX.Element;
|
|
17
18
|
export { Typeahead };
|
|
18
19
|
//# sourceMappingURL=Typeahead.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typeahead.d.ts","sourceRoot":"","sources":["../../src/typeahead/Typeahead.tsx"],"names":[],"mappings":";AAIA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Typeahead.d.ts","sourceRoot":"","sources":["../../src/typeahead/Typeahead.tsx"],"names":[],"mappings":";AAIA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,iBAAS,SAAS,CAAC,EACjB,OAAO,EACP,WAAW,EACX,UAAkB,EAClB,gBAAgB,EAChB,IAAS,EACT,YAAoB,EACpB,gBAAqB,EACrB,SAAS,GACV,EAAE,cAAc,eA4ChB;AAED,OAAO,EAAE,SAAS,EAAE,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"),n=e(require("react")),
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("tslib"),n=e(require("react")),o=require("react-hook-form"),t=e(require("react-select"));exports.Typeahead=function(e){var i=e.options,s=e.placeholder,a=e.isRequired,l=void 0!==a&&a,u=e.isMultipleChoise,c=e.name,d=void 0===c?"":c,p=e.isCouponForm,m=void 0!==p&&p,f=e.noOptionsMessage,v=void 0===f?"":f,g=e.isInvalid,_=o.useFormContext().control;return n.createElement(n.Fragment,null,n.createElement(o.Controller,{name:d,control:_,rules:{required:l},render:function(e){var o=e.field;return n.createElement(t,{placeholder:s,value:o.value,isMulti:u,styles:{control:function(e){return r.__assign(r.__assign({},e),(n=m?{borderRadius:"1rem",minHeight:"3rem"}:{},g?r.__assign({borderColor:"red"},n):r.__assign({},n)));var n}},onChange:function(e){o.onChange(e)},options:i,noOptionsMessage:function(){return n.createElement("span",null,v)}})}}))};
|
package/package.json
CHANGED
|
@@ -149,7 +149,7 @@ export function ProductControl<T extends FormValues>({
|
|
|
149
149
|
clearErrors,
|
|
150
150
|
} = useFormContext<T>();
|
|
151
151
|
|
|
152
|
-
const { setLoading } = useContext(ProductSetLoadingContext);
|
|
152
|
+
const { setLoading, productGroupList } = useContext(ProductSetLoadingContext);
|
|
153
153
|
const { t } = useTranslation(["Design", "Validation", "ProductSet"]);
|
|
154
154
|
const [expanded, setExpanded] = useState(false);
|
|
155
155
|
const [initialImages, setInitialImages] = useState<Image[] | null>(null);
|
|
@@ -162,8 +162,8 @@ export function ProductControl<T extends FormValues>({
|
|
|
162
162
|
|
|
163
163
|
const advancedId = useId();
|
|
164
164
|
const nameId = useId();
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
|
|
166
|
+
const productGroupId = useId();
|
|
167
167
|
const descriptionId = useId();
|
|
168
168
|
const termsAndConditionsId = useId();
|
|
169
169
|
const isAvailableId = useId();
|
|
@@ -403,6 +403,35 @@ export function ProductControl<T extends FormValues>({
|
|
|
403
403
|
isRequired={false}
|
|
404
404
|
defaultColors={PRODUCT_DEfAULT_COLORS}
|
|
405
405
|
/>
|
|
406
|
+
|
|
407
|
+
<Form.Group controlId={productGroupId}>
|
|
408
|
+
<Form.Label>{t("productGroup")}</Form.Label>
|
|
409
|
+
<Form.Control
|
|
410
|
+
as="select"
|
|
411
|
+
{...register(`${fieldNamePrefix}.productGroupId` as Path<T>)}
|
|
412
|
+
isInvalid={HookFormService.isInvalid<T>(
|
|
413
|
+
`${fieldNamePrefix}.productGroupId` as Path<T>,
|
|
414
|
+
errors
|
|
415
|
+
)}
|
|
416
|
+
disabled={isLoading}
|
|
417
|
+
defaultValue=""
|
|
418
|
+
>
|
|
419
|
+
<option value="">{t("Design:selectProductGroup")}</option>
|
|
420
|
+
{productGroupList.map((productGroup) => {
|
|
421
|
+
return (
|
|
422
|
+
<option value={productGroup.id} key={productGroup.id}>
|
|
423
|
+
{productGroup.value}
|
|
424
|
+
</option>
|
|
425
|
+
);
|
|
426
|
+
})}
|
|
427
|
+
</Form.Control>
|
|
428
|
+
<Form.Control.Feedback type="invalid">
|
|
429
|
+
{HookFormService.getErrors<T>(
|
|
430
|
+
`${fieldNamePrefix}.productGroupId` as Path<T>,
|
|
431
|
+
errors
|
|
432
|
+
)}
|
|
433
|
+
</Form.Control.Feedback>
|
|
434
|
+
</Form.Group>
|
|
406
435
|
</Col>
|
|
407
436
|
</Row>
|
|
408
437
|
|
|
@@ -675,38 +704,6 @@ export function ProductControl<T extends FormValues>({
|
|
|
675
704
|
</Collapse>
|
|
676
705
|
|
|
677
706
|
<Row>
|
|
678
|
-
{/* @TODO: no need for v1 release
|
|
679
|
-
<Col xs={12} sm={6}>
|
|
680
|
-
<Form.Group controlId={productGroupId}>
|
|
681
|
-
<Form.Label>{t("productGroup")}</Form.Label>
|
|
682
|
-
<Form.Control
|
|
683
|
-
as="select"
|
|
684
|
-
{...register(`${fieldNamePrefix}.productGroupId` as Path<T>)}
|
|
685
|
-
isInvalid={HookFormService.isInvalid<T>(
|
|
686
|
-
`${fieldNamePrefix}.productGroupId` as Path<T>,
|
|
687
|
-
errors
|
|
688
|
-
)}
|
|
689
|
-
disabled={isLoading}
|
|
690
|
-
defaultValue=""
|
|
691
|
-
>
|
|
692
|
-
<option value="">{t("Design:selectProductGroup")}</option>
|
|
693
|
-
{productGroupList.map((productGroup) => {
|
|
694
|
-
return (
|
|
695
|
-
<option value={productGroup.id} key={productGroup.id}>
|
|
696
|
-
{productGroup.value}
|
|
697
|
-
</option>
|
|
698
|
-
);
|
|
699
|
-
})}
|
|
700
|
-
</Form.Control>
|
|
701
|
-
<Form.Control.Feedback type="invalid">
|
|
702
|
-
{HookFormService.getErrors<T>(
|
|
703
|
-
`${fieldNamePrefix}.productGroupId` as Path<T>,
|
|
704
|
-
errors
|
|
705
|
-
)}
|
|
706
|
-
</Form.Control.Feedback>
|
|
707
|
-
</Form.Group>
|
|
708
|
-
</Col> */}
|
|
709
|
-
|
|
710
707
|
<Col xs={12}>
|
|
711
708
|
{hasBookingManagement && (
|
|
712
709
|
<ProductBookingManagementControl<T>
|
|
@@ -21,12 +21,14 @@ import couponCodeRules from "@licklist/plugins/dist/validation/Rules/couponCodeR
|
|
|
21
21
|
// import { useId } from "@react-aria/utils";
|
|
22
22
|
|
|
23
23
|
import HTMLInputDateElement from "../../../types/static/HTMLInputDateElement";
|
|
24
|
+
import { Typeahead, TypeaheadOptions } from "../../../typeahead";
|
|
25
|
+
import { convertToTypeaheadOptions } from "../utils";
|
|
24
26
|
|
|
25
27
|
export interface CouponFormValues {
|
|
26
28
|
name?: string;
|
|
27
29
|
code: string;
|
|
28
30
|
discountType: CouponType;
|
|
29
|
-
productGroupIds:
|
|
31
|
+
productGroupIds: Array<TypeaheadOptions | ProductGroup>;
|
|
30
32
|
discount: number;
|
|
31
33
|
totalType: CouponTotalType;
|
|
32
34
|
startFrom: string;
|
|
@@ -58,9 +60,9 @@ export const CouponFormControl = ({
|
|
|
58
60
|
watch,
|
|
59
61
|
} = useFormContext<CouponFormValues>();
|
|
60
62
|
const { t } = useTranslation(["Design", "Notification", "App"]);
|
|
61
|
-
const [selectedProductGroups, setSelectedProductGroups] = useState<
|
|
62
|
-
[]
|
|
63
|
-
);
|
|
63
|
+
const [selectedProductGroups, setSelectedProductGroups] = useState<
|
|
64
|
+
TypeaheadOptions[]
|
|
65
|
+
>([]);
|
|
64
66
|
/* TODO: Show Recurrent date, when reccurent date bugs are fixed */
|
|
65
67
|
// const rrule = watch("rrule");
|
|
66
68
|
// const [recurrent, setRecurrent] = useState(Boolean(rrule));
|
|
@@ -85,15 +87,20 @@ export const CouponFormControl = ({
|
|
|
85
87
|
[COUPON_TOTAL_TYPE_TOTAL]: t("Design:depositTotal"),
|
|
86
88
|
};
|
|
87
89
|
|
|
88
|
-
// Set pre-selected Product Groups
|
|
89
90
|
useEffect(() => {
|
|
90
|
-
|
|
91
|
+
const defaultProductGroup = getValues("productGroupIds");
|
|
92
|
+
|
|
93
|
+
setSelectedProductGroups(
|
|
94
|
+
convertToTypeaheadOptions(defaultProductGroup as ProductGroup[])
|
|
95
|
+
);
|
|
91
96
|
}, [getValues]);
|
|
92
97
|
|
|
93
98
|
useEffect(() => {
|
|
94
99
|
setValue("productGroupIds", selectedProductGroups);
|
|
95
100
|
}, [getValues, setValue, selectedProductGroups]);
|
|
96
101
|
|
|
102
|
+
const productGroupList = convertToTypeaheadOptions(productGroups);
|
|
103
|
+
|
|
97
104
|
/* TODO: Show Recurrent date, when reccurent date bugs are fixed */
|
|
98
105
|
// useEffect(() => {
|
|
99
106
|
// if (!recurrent && rrule) {
|
|
@@ -251,51 +258,23 @@ export const CouponFormControl = ({
|
|
|
251
258
|
</Form.Group>
|
|
252
259
|
</Col>
|
|
253
260
|
</Row>
|
|
254
|
-
|
|
255
|
-
<
|
|
256
|
-
<
|
|
257
|
-
<
|
|
258
|
-
<
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
<Form.Check
|
|
267
|
-
key={productGroup.id}
|
|
268
|
-
label={productGroup.name}
|
|
269
|
-
defaultChecked={isGroupSelected}
|
|
270
|
-
disabled={isLoading}
|
|
271
|
-
onChange={(e) => {
|
|
272
|
-
if (e.target.checked) {
|
|
273
|
-
setSelectedProductGroups((prevGroups) =>
|
|
274
|
-
Array.from(
|
|
275
|
-
new Set([...prevGroups, String(productGroup.id)])
|
|
276
|
-
)
|
|
277
|
-
);
|
|
278
|
-
} else {
|
|
279
|
-
setSelectedProductGroups((prevGroups) => {
|
|
280
|
-
return prevGroups.filter(
|
|
281
|
-
(id) => String(productGroup.id) !== id
|
|
282
|
-
);
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
}}
|
|
286
|
-
/>
|
|
287
|
-
);
|
|
261
|
+
<Row>
|
|
262
|
+
<Col>
|
|
263
|
+
<Form.Group className="mb-3">
|
|
264
|
+
<Form.Label>{t("Design:productGroups")}</Form.Label>
|
|
265
|
+
<Typeahead
|
|
266
|
+
name="productGroupIds"
|
|
267
|
+
options={productGroupList}
|
|
268
|
+
isMultipleChoise
|
|
269
|
+
isCouponForm
|
|
270
|
+
placeholder={t("Design:choose")}
|
|
271
|
+
noOptionsMessage={t("Design:noActiveTemplates", {
|
|
272
|
+
notification: t("Design:email"),
|
|
288
273
|
})}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
disabled={isLoading}
|
|
294
|
-
/>
|
|
295
|
-
</Form.Group>
|
|
296
|
-
</Col>
|
|
297
|
-
</Row>
|
|
298
|
-
)}
|
|
274
|
+
/>
|
|
275
|
+
</Form.Group>
|
|
276
|
+
</Col>
|
|
277
|
+
</Row>
|
|
299
278
|
|
|
300
279
|
{/* TODO: Show Recurrent date, when reccurent date bugs are fixed */}
|
|
301
280
|
{/* {startFromValue && (
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ProductGroup,
|
|
4
|
+
ProductGroupDTO,
|
|
5
|
+
} from "@licklist/core/dist/DataMapper/Product/ProductGroupDataMapper";
|
|
3
6
|
import {
|
|
4
7
|
CouponTotalType,
|
|
5
8
|
CouponType,
|
|
@@ -16,7 +19,7 @@ export interface CouponFormValues {
|
|
|
16
19
|
name?: string;
|
|
17
20
|
code: string;
|
|
18
21
|
discountType: CouponType;
|
|
19
|
-
productGroupIds:
|
|
22
|
+
productGroupIds: ProductGroupDTO[];
|
|
20
23
|
discount: number;
|
|
21
24
|
totalType: CouponTotalType;
|
|
22
25
|
startFrom: string;
|
|
@@ -54,19 +57,6 @@ export const CouponForm = ({
|
|
|
54
57
|
const { setError } = form;
|
|
55
58
|
const { t } = useTranslation(["Design", "Notification", "App"]);
|
|
56
59
|
|
|
57
|
-
// @TODO: dont need for v1 release
|
|
58
|
-
// const [selectedProductGroups, setSelectedProductGroups] = useState<string[]>(
|
|
59
|
-
// []
|
|
60
|
-
// );
|
|
61
|
-
// Set pre-selected Product Groups
|
|
62
|
-
// useEffect(() => {
|
|
63
|
-
// setSelectedProductGroups(getValues("productGroupIds"));
|
|
64
|
-
// }, [getValues]);
|
|
65
|
-
|
|
66
|
-
// useEffect(() => {
|
|
67
|
-
// setValue("productGroupIds", selectedProductGroups);
|
|
68
|
-
// }, [getValues, setValue, selectedProductGroups]);
|
|
69
|
-
|
|
70
60
|
useEffect(() => {
|
|
71
61
|
FormErrorService.handleServerErrors(serverErrors, setError);
|
|
72
62
|
}, [serverErrors, setError]);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ProductGroup } from "@licklist/core/dist/DataMapper/Product/ProductGroupDataMapper";
|
|
2
|
+
|
|
3
|
+
export const convertToTypeaheadOptions = (productGroups?: ProductGroup[]) => {
|
|
4
|
+
if (!productGroups || !productGroups.length) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return productGroups.map(({ id, name }: ProductGroup) => ({
|
|
9
|
+
id: Number(id),
|
|
10
|
+
value: name,
|
|
11
|
+
label: name,
|
|
12
|
+
}));
|
|
13
|
+
};
|
|
@@ -16,6 +16,7 @@ export interface TypeaheadProps {
|
|
|
16
16
|
isMultipleChoise?: boolean;
|
|
17
17
|
noOptionsMessage: string;
|
|
18
18
|
isInvalid?: boolean;
|
|
19
|
+
isCouponForm?: boolean;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
function Typeahead({
|
|
@@ -24,13 +25,25 @@ function Typeahead({
|
|
|
24
25
|
isRequired = false,
|
|
25
26
|
isMultipleChoise,
|
|
26
27
|
name = "",
|
|
28
|
+
isCouponForm = false,
|
|
27
29
|
noOptionsMessage = "",
|
|
28
30
|
isInvalid,
|
|
29
31
|
}: TypeaheadProps) {
|
|
30
32
|
const { control } = useFormContext();
|
|
31
33
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
+
const getStyle = (): CSSObjectWithLabel => {
|
|
35
|
+
const couponFormStyle = isCouponForm
|
|
36
|
+
? {
|
|
37
|
+
borderRadius: "1rem",
|
|
38
|
+
minHeight: "3rem",
|
|
39
|
+
}
|
|
40
|
+
: {};
|
|
41
|
+
return isInvalid
|
|
42
|
+
? { borderColor: "red", ...couponFormStyle }
|
|
43
|
+
: {
|
|
44
|
+
...couponFormStyle,
|
|
45
|
+
};
|
|
46
|
+
};
|
|
34
47
|
|
|
35
48
|
return (
|
|
36
49
|
<>
|
|
@@ -46,7 +59,7 @@ function Typeahead({
|
|
|
46
59
|
styles={{
|
|
47
60
|
control: (base) => ({
|
|
48
61
|
...base,
|
|
49
|
-
...
|
|
62
|
+
...getStyle(),
|
|
50
63
|
}),
|
|
51
64
|
}}
|
|
52
65
|
onChange={(value) => {
|