@licklist/design 0.44.485-dev.35 → 0.44.485-dev.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"EmailTemplateControl.d.ts","sourceRoot":"","sources":["../../../../src/notification/email-template/control/EmailTemplateControl.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,OAAO,EACL,cAAc,EAEf,MAAM,sEAAsE,CAAC;AAG9E,OAAO,EAAE,UAAU,EAAE,MAAM,kEAAkE,CAAC;AAM9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wEAAwE,CAAC;AAM1G,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,YAAY,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE,UAAU,EAAE,CAAC;IAClC,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACvC,4BAA4B,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,IAAI,KAAK,MAAM,CAAC;CAC3E;AAED,eAAO,MAAM,oBAAoB,2FA+XhC,CAAC"}
1
+ {"version":3,"file":"EmailTemplateControl.d.ts","sourceRoot":"","sources":["../../../../src/notification/email-template/control/EmailTemplateControl.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,OAAO,EACL,cAAc,EAEf,MAAM,sEAAsE,CAAC;AAG9E,OAAO,EAAE,UAAU,EAAE,MAAM,kEAAkE,CAAC;AAM9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wEAAwE,CAAC;AAM1G,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,YAAY,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE,UAAU,EAAE,CAAC;IAClC,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACvC,4BAA4B,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,IAAI,KAAK,MAAM,CAAC;CAC3E;AAED,eAAO,MAAM,oBAAoB,2FAsZhC,CAAC"}
@@ -1 +1 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),a=require("react"),n=e(a),l=require("react-i18next"),r=require("react-bootstrap"),i=require("react-hook-form"),o=require("../../../file-upload/FileUpload.js"),s=e(require("react-email-editor")),u=require("@licklist/core/dist/DataMapper/Notification/TemplateOptionDataMapper"),c=require("@licklist/plugins/dist/hooks/Media/useAttachments"),m=require("@licklist/plugins/dist/hooks/Media/usePermanentImage"),d=require("@licklist/core/dist/DataMapper/Media/UploadPermanentImageDataMapper"),p=n.forwardRef((function(e,p){var f,g,E,v=e.setIsLoading,h=e.meta,_=e.options,b=void 0===_?[]:_,F=e.defaultAttachments,y=void 0===F?[]:F,N=e.notificationTypes,D=void 0===N?[]:N,C=e.getDefaultTemplateMetaByType,I=l.useTranslation(["Design"]).t,P=t.__read(a.useState(null),2),T=P[0],k=P[1],M=i.useFormContext(),q=M.register,R=M.setValue,x=M.formState.errors,O=M.getValues,A=M.watch,j=M.reset,w=t.__read(a.useState(!1),2),G=w[0],V=w[1],S=c.useAttachments(T),L=S.attachments,U=S.handleAttachmentRemove,Y=S.handleAttachmentUploading,B=S.isLoading,J=m.usePermanentImage(),H=J.permanentImages,z=J.handlePermanentImageRemove,K=J.handlePermanentImageUploading,Q=A("type"),W=A("id");a.useEffect((function(){var e;if(!W&&C&&Q){var a=O(),n=C(Q);j(t.__assign(t.__assign({},a),{meta:n})),null===(e=p.current)||void 0===e||e.loadDesign(JSON.parse(n))}}),[Q]),a.useEffect((function(){R("attachmentMetadata",L)}),[L,R]),a.useEffect((function(){H.length&&R("imagesMetadata",H)}),[H,R]),a.useEffect((function(){if(y&&y.length>0){var e=O("attachments");k(e)}else k([])}),[y]),a.useEffect((function(){b.length&&(b.find((function(e){return e.type===u.OPTION_TYPE.files_selector})).selectedValue&&V(!0))}),[b]);return n.createElement(n.Fragment,null,n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col,controlId:"type",xs:!0,sm:12,md:8,lg:10,xl:12},n.createElement(r.Form.Label,null,I("type")),n.createElement(r.Form.Control,t.__assign({as:"select"},q("type",{required:I("Validation:fieldRequired",{attribute:I("type")})}),{name:"type",required:!0,isInvalid:Boolean(x.type),placeholder:I("Design:type"),disabled:!!W}),n.createElement("option",{value:""},I("Design:choose")),D.map((function(e){return n.createElement("option",{key:e,value:e},I("Design:".concat(e)))}))),n.createElement(r.Form.Control.Feedback,{type:"invalid"},null===(f=x.type)||void 0===f?void 0:f.message))),n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col,controlId:"formGroupName",xs:!0,sm:12,md:8,lg:10,xl:12},n.createElement(r.Form.Label,null,I("templateName")),n.createElement(r.Form.Control,t.__assign({},q("name",{maxLength:255,required:I("Validation:fieldRequired",{attribute:I("name")})}),{name:"name",required:!0,isInvalid:Boolean(x.name),placeholder:I("Design:templateName")})),n.createElement(r.Form.Control.Feedback,{type:"invalid"},null===(g=x.name)||void 0===g?void 0:g.message))),n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col,xs:!0,sm:12,md:8,lg:10,xl:12,controlId:"formGroupSubject"},n.createElement(r.Form.Label,null,I("subject")),n.createElement(r.Form.Control,t.__assign({},q("subject",{maxLength:255,required:I("Validation:fieldRequired",{attribute:I("subject")})}),{name:"subject",required:!0,isInvalid:Boolean(x.subject),placeholder:I("Design:subject")})),n.createElement(r.Form.Control.Feedback,{type:"invalid"},null===(E=x.subject)||void 0===E?void 0:E.message))),n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col},n.createElement(r.Form.Check,t.__assign({},q("isActive"),{name:"isActive",label:I("Design:active"),id:"formGroupIsActive",custom:!0})),n.createElement(r.Form.Check,t.__assign({},q("isDefault"),{name:"isDefault",label:I("Design:defaultTemplateForTheType"),id:"formGroupIsDefault",custom:!0})))),n.createElement(r.Row,{className:"mb-4"},n.createElement(r.Form.Group,{as:r.Col},n.createElement(r.Form.Label,null,I("Design:emailBody")),n.createElement("div",{className:"email-editor"},n.createElement(s,{ref:p,onReady:function(){var e,a,n,l;v(!0),null===(e=p.current)||void 0===e||e.registerCallback("design:updated",(function(e){var t,a;null===(t=p.current)||void 0===t||t.editor.exportHtml((function(e){R("body",e.html),R("meta",JSON.stringify(e.design))})),"content:removed"===e.type&&"image"===(null===(a=e.item)||void 0===a?void 0:a.type)&&function(e){var t=e.item.values.src.url;if(!t.includes("unlayer")){var a=O("imagesMetadata");if(a){var n=a.find((function(e){return e.permanentUrl===t}));if(n)z(n.hash,d.PERMANENT_IMAGE_TYPE_TEMP);else{var l=t.split("/"),r=l[l.length-2];if(!r)return;z(r,d.PERMANENT_IMAGE_TYPE_PERMANENT)}}else{var i=t.split("/"),o=i[i.length-2];if(!o)return;z(o,d.PERMANENT_IMAGE_TYPE_PERMANENT)}}}(e)})),h&&(null===(a=p.current)||void 0===a||a.loadDesign(JSON.parse(h)),null===(n=p.current)||void 0===n||n.editor.exportHtml((function(e){R("body",e.html),R("meta",JSON.stringify(e.design))}))),v(!1),null===(l=p.current)||void 0===l||l.registerCallback("image",(function(e,a){return t.__awaiter(void 0,void 0,void 0,(function(){var n;return t.__generator(this,(function(t){switch(t.label){case 0:return[4,K(e.attachments[0])];case 1:return n=t.sent(),a({progress:100,url:n.permanentUrl}),[2]}}))}))}))},style:{height:"50rem"}})))),n.createElement(r.Row,null,n.createElement(o.FileUpload,{className:"ml-4 mr-4",allowedExtensions:["jpg","jpeg","png","txt","pdf","doc"],enablePreview:!0,allowMultiple:!0,defaultFiles:L,onFilesChange:function(e){Y(e)},title:I("Design:attachments"),onFileRemove:function(e,t){return U(String(e),t)},isLoading:B})),b.length>0&&n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col},b.map((function(e){if(e.type===u.OPTION_TYPE.checkbox)return n.createElement(r.Form.Check,t.__assign({},q("templateOptionValues.".concat(null==e?void 0:e.id,".value")),{type:"checkbox",label:I("Design:".concat(e.name)),id:e.name+e.id,defaultChecked:"true"===e.selectedValue,custom:!0}));if(e.type===u.OPTION_TYPE.files_selector){var a=JSON.parse(e.defaultValue),l=Object.values(a),i=Object.keys(a);return n.createElement(n.Fragment,null,n.createElement(r.Form.Check,{checked:G,name:"IsIncludePDF",onChange:function(){V(!G),R("templateOptionValues.".concat(e.id,".value"),"")},label:I("Design:includePDF"),id:"formGroupIsIncludePdf",custom:!0}),G&&n.createElement(n.Fragment,null,n.createElement(r.Form.Label,{className:"mt-4"},I("Design:includeFile")),n.createElement(r.Form.Control,t.__assign({as:"select"},q("templateOptionValues.".concat(e.id,".value")),{defaultValue:e.selectedValue||""}),n.createElement("option",{value:""},I("Design:choose")),i.map((function(e,t){return n.createElement("option",{value:String(e),key:String(e)},l[t])})))))}return null})))))}));p.displayName="EmailTemplateControl",exports.EmailTemplateControl=p;
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),a=require("react"),n=e(a),l=require("react-i18next"),r=require("react-bootstrap"),i=require("react-hook-form"),o=require("../../../file-upload/FileUpload.js"),s=e(require("react-email-editor")),m=require("@licklist/core/dist/DataMapper/Notification/TemplateOptionDataMapper"),c=require("@licklist/plugins/dist/hooks/Media/useAttachments"),u=require("@licklist/plugins/dist/hooks/Media/usePermanentImage"),d=require("@licklist/core/dist/DataMapper/Media/UploadPermanentImageDataMapper"),p=n.forwardRef((function(e,p){var g,f,E,v=e.setIsLoading,h=e.meta,_=e.options,F=void 0===_?[]:_,b=e.defaultAttachments,y=void 0===b?[]:b,N=e.notificationTypes,D=void 0===N?[]:N,T=e.getDefaultTemplateMetaByType,P=l.useTranslation(["Design"]).t,C=t.__read(a.useState(null),2),I=C[0],k=C[1],M=i.useFormContext(),O=M.register,q=M.setValue,R=M.formState.errors,x=M.getValues,A=M.watch,j=M.reset,w=t.__read(a.useState(!1),2),G=w[0],V=w[1],S=c.useAttachments(I),L=S.attachments,U=S.handleAttachmentRemove,Y=S.handleAttachmentUploading,B=S.isLoading,J=u.usePermanentImage(),H=J.permanentImages,z=J.handlePermanentImageRemove,K=J.handlePermanentImageUploading,Q=A("type"),W=A("id");a.useEffect((function(){var e;if(!W&&T&&Q){var a=x(),n=T(Q);j(t.__assign(t.__assign({},a),{meta:n})),null===(e=p.current)||void 0===e||e.loadDesign(JSON.parse(n))}}),[Q]),a.useEffect((function(){q("attachmentMetadata",L)}),[L,q]),a.useEffect((function(){H.length&&q("imagesMetadata",H)}),[H,q]),a.useEffect((function(){if(y&&y.length>0){var e=x("attachments");k(e)}else k([])}),[y]),a.useEffect((function(){if(null==F?void 0:F.length){var e=F.find((function(e){return e.type===m.OPTION_TYPE.files_selector}));(null==e?void 0:e.selectedValue)&&V(!0)}}),[F]);return n.createElement(n.Fragment,null,n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col,controlId:"type",xs:!0,sm:12,md:8,lg:10,xl:12},n.createElement(r.Form.Label,null,P("type")),n.createElement(r.Form.Control,t.__assign({as:"select"},O("type",{required:P("Validation:fieldRequired",{attribute:P("type")})}),{name:"type",required:!0,isInvalid:Boolean(R.type),placeholder:P("Design:type"),disabled:!!W}),n.createElement("option",{value:""},P("Design:choose")),D.map((function(e){return n.createElement("option",{key:e,value:e},P("Design:".concat(e)))}))),n.createElement(r.Form.Control.Feedback,{type:"invalid"},null===(g=R.type)||void 0===g?void 0:g.message))),n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col,controlId:"formGroupName",xs:!0,sm:12,md:8,lg:10,xl:12},n.createElement(r.Form.Label,null,P("templateName")),n.createElement(r.Form.Control,t.__assign({},O("name",{maxLength:255,required:P("Validation:fieldRequired",{attribute:P("name")})}),{name:"name",required:!0,isInvalid:Boolean(R.name),placeholder:P("Design:templateName")})),n.createElement(r.Form.Control.Feedback,{type:"invalid"},null===(f=R.name)||void 0===f?void 0:f.message))),n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col,xs:!0,sm:12,md:8,lg:10,xl:12,controlId:"formGroupSubject"},n.createElement(r.Form.Label,null,P("subject")),n.createElement(r.Form.Control,t.__assign({},O("subject",{maxLength:255,required:P("Validation:fieldRequired",{attribute:P("subject")})}),{name:"subject",required:!0,isInvalid:Boolean(R.subject),placeholder:P("Design:subject")})),n.createElement(r.Form.Control.Feedback,{type:"invalid"},null===(E=R.subject)||void 0===E?void 0:E.message))),n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col},n.createElement(r.Form.Check,t.__assign({},O("isActive"),{name:"isActive",label:P("Design:active"),id:"formGroupIsActive",custom:!0})),n.createElement(r.Form.Check,t.__assign({},O("isDefault"),{name:"isDefault",label:P("Design:defaultTemplateForTheType"),id:"formGroupIsDefault",custom:!0})))),n.createElement(r.Row,{className:"mb-4"},n.createElement(r.Form.Group,{as:r.Col},n.createElement(r.Form.Label,null,P("Design:emailBody")),n.createElement("div",{className:"email-editor"},n.createElement(s,{ref:p,onReady:function(){var e,a,n,l;v(!0),null===(e=p.current)||void 0===e||e.registerCallback("design:updated",(function(e){var t,a;null===(t=p.current)||void 0===t||t.editor.exportHtml((function(e){q("body",e.html),q("meta",JSON.stringify(e.design))})),"content:removed"===e.type&&"image"===(null===(a=e.item)||void 0===a?void 0:a.type)&&function(e){var t=e.item.values.src.url;if(!t.includes("unlayer")){var a=x("imagesMetadata");if(a){var n=a.find((function(e){return e.permanentUrl===t}));if(n)z(n.hash,d.PERMANENT_IMAGE_TYPE_TEMP);else{var l=t.split("/"),r=l[l.length-2];if(!r)return;z(r,d.PERMANENT_IMAGE_TYPE_PERMANENT)}}else{var i=t.split("/"),o=i[i.length-2];if(!o)return;z(o,d.PERMANENT_IMAGE_TYPE_PERMANENT)}}}(e)})),h&&(null===(a=p.current)||void 0===a||a.loadDesign(JSON.parse(h)),null===(n=p.current)||void 0===n||n.editor.exportHtml((function(e){q("body",e.html),q("meta",JSON.stringify(e.design))}))),v(!1),null===(l=p.current)||void 0===l||l.registerCallback("image",(function(e,a){return t.__awaiter(void 0,void 0,void 0,(function(){var n;return t.__generator(this,(function(t){switch(t.label){case 0:return[4,K(e.attachments[0])];case 1:return n=t.sent(),a({progress:100,url:n.permanentUrl}),[2]}}))}))}))},style:{height:"50rem"}})))),n.createElement(r.Row,null,n.createElement(o.FileUpload,{className:"ml-4 mr-4",allowedExtensions:["jpg","jpeg","png","txt","pdf","doc"],enablePreview:!0,allowMultiple:!0,defaultFiles:L,onFilesChange:function(e){Y(e)},title:P("Design:attachments"),onFileRemove:function(e,t){return U(String(e),t)},isLoading:B})),(null==F?void 0:F.length)>0&&n.createElement(r.Row,null,n.createElement(r.Form.Group,{as:r.Col},F.map((function(e){if(e.type===m.OPTION_TYPE.checkbox)return n.createElement(r.Form.Check,t.__assign({},O("templateOptionValues.".concat(null==e?void 0:e.id,".value")),{type:"checkbox",label:P("Design:".concat(e.name)),id:e.name+e.id,defaultChecked:"true"===e.selectedValue,custom:!0}));if(e.type===m.OPTION_TYPE.files_selector){var a=JSON.parse(e.defaultValue),l=Object.values(a),i=Object.keys(a);return n.createElement(n.Fragment,null,n.createElement(r.Form.Check,{checked:G,name:"IsIncludePDF",onChange:function(){V(!G),q("templateOptionValues.".concat(e.id,".value"),"")},label:P("Design:includePDF"),id:"formGroupIsIncludePdf",custom:!0}),G&&n.createElement(n.Fragment,null,n.createElement(r.Form.Label,{className:"mt-4"},P("Design:includeFile")),n.createElement(r.Form.Control,t.__assign({as:"select"},O("templateOptionValues.".concat(e.id,".value")),{defaultValue:e.selectedValue||""}),n.createElement("option",{value:""},P("Design:choose")),i.map((function(e,t){return n.createElement("option",{value:String(e),key:String(e)},l[t])})))))}return e.type===m.OPTION_TYPE.days_reminder?n.createElement(n.Fragment,null,n.createElement(r.Form.Label,{className:"mt-4"},P("Design:".concat(e.name))),n.createElement(r.Form.Control,t.__assign({},O("templateOptionValues.".concat(null==e?void 0:e.id,".value")),{type:"number",placeholder:P("Design:".concat(e.name)),id:e.name+e.id})),n.createElement(r.Form.Text,null,e.description)):null})))))}));p.displayName="EmailTemplateControl",exports.EmailTemplateControl=p;
@@ -34,6 +34,7 @@ export interface EmailTemplateProps extends HasPermissionProp {
34
34
  serverErrors?: ServerError;
35
35
  notificationTypes?: NotificationType[];
36
36
  getDefaultTemplateMetaByType?: (type?: NotificationType | null) => string;
37
+ onTypeChange?: (type?: NotificationType | null) => void;
37
38
  }
38
- export declare function EmailTemplateForm({ defaultValues, onSubmitSave, onSubmitSaveAndSend, hasPermission, placeholders, options, serverErrors, notificationTypes, getDefaultTemplateMetaByType, }: EmailTemplateProps): JSX.Element;
39
+ export declare const EmailTemplateForm: ({ defaultValues, onSubmitSave, onSubmitSaveAndSend, hasPermission, placeholders, options, serverErrors, notificationTypes, getDefaultTemplateMetaByType, onTypeChange, }: EmailTemplateProps) => JSX.Element;
39
40
  //# sourceMappingURL=EmailTemplateForm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EmailTemplateForm.d.ts","sourceRoot":"","sources":["../../../../src/notification/email-template/form/EmailTemplateForm.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,8DAA8D,CAAC;AAI1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,+EAA+E,CAAC;AACxH,OAAO,EAAE,cAAc,EAAE,MAAM,sEAAsE,CAAC;AACtG,OAAO,EAAE,mBAAmB,EAAE,MAAM,2EAA2E,CAAC;AAChH,OAAO,EAAE,kBAAkB,EAAE,MAAM,0EAA0E,CAAC;AAC9G,OAAO,EAAE,UAAU,EAAE,MAAM,kEAAkE,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AACxF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qEAAqE,CAAC;AAC3G,OAAO,EAAE,gBAAgB,EAAE,MAAM,wEAAwE,CAAC;AAK1G,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACrD,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,kBAAkB,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAClE,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC7C,cAAc,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACxC,IAAI,CAAC,EAAE,gBAAgB,CAAC;CACzB;AAED,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACpD,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC5D,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC,YAAY,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACzC,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACvC,4BAA4B,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,IAAI,KAAK,MAAM,CAAC;CAC3E;AAED,wBAAgB,iBAAiB,CAAC,EAChC,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,aAAoB,EACpB,YAAiB,EACjB,OAAY,EACZ,YAAY,EACZ,iBAAsB,EACtB,4BAA4B,GAC7B,EAAE,kBAAkB,eA2DpB"}
1
+ {"version":3,"file":"EmailTemplateForm.d.ts","sourceRoot":"","sources":["../../../../src/notification/email-template/form/EmailTemplateForm.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,8DAA8D,CAAC;AAI1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,+EAA+E,CAAC;AACxH,OAAO,EAAE,cAAc,EAAE,MAAM,sEAAsE,CAAC;AACtG,OAAO,EAAE,mBAAmB,EAAE,MAAM,2EAA2E,CAAC;AAChH,OAAO,EAAE,kBAAkB,EAAE,MAAM,0EAA0E,CAAC;AAC9G,OAAO,EAAE,UAAU,EAAE,MAAM,kEAAkE,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AACxF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qEAAqE,CAAC;AAC3G,OAAO,EAAE,gBAAgB,EAAE,MAAM,wEAAwE,CAAC;AAK1G,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACrD,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,kBAAkB,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAClE,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC7C,cAAc,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACxC,IAAI,CAAC,EAAE,gBAAgB,CAAC;CACzB;AAED,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACpD,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC5D,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC,YAAY,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACzC,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACvC,4BAA4B,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,IAAI,KAAK,MAAM,CAAC;IAC1E,YAAY,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,CAAC;CACzD;AAED,eAAO,MAAM,iBAAiB,6KAW3B,kBAAkB,gBAmEpB,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"),o=e(r),a=require("../../../static/loader/BlockLoader.js"),l=require("react-i18next"),n=require("react-bootstrap"),i=require("react-hook-form"),s=e(require("@licklist/plugins/dist/services/Form/FormErrorService"));require("../../../static/index.js");var m=require("../control/EmailTemplateControl.js"),u=require("../../components/NotificationPlaceholders.js");exports.EmailTemplateForm=function(e){var c=e.defaultValues,d=e.onSubmitSave,p=e.onSubmitSaveAndSend,f=e.hasPermission,v=void 0===f||f,E=e.placeholders,b=void 0===E?[]:E,h=e.options,y=void 0===h?[]:h,S=e.serverErrors,q=e.notificationTypes,T=void 0===q?[]:q,k=e.getDefaultTemplateMetaByType,g=l.useTranslation("Design").t,B=t.__read(r.useState(!1),2),j=B[0],F=B[1],_=r.useRef(null),C=i.useForm({mode:"onChange",defaultValues:c}),N=C.setError;return r.useEffect((function(){s.handleServerErrors(S,N)}),[S,N]),o.createElement(i.FormProvider,t.__assign({},C),j&&o.createElement(a.BlockLoader,null),o.createElement(n.Form,{onSubmit:C.handleSubmit(d),noValidate:!0,style:{display:j?"none":"block"}},o.createElement(m.EmailTemplateControl,{ref:_,setIsLoading:F,meta:(null==c?void 0:c.meta)||null,defaultAttachments:(null==c?void 0:c.attachments)||[],options:y,notificationTypes:T,getDefaultTemplateMetaByType:k}),o.createElement(u.NotificationPlaceholders,{placeholders:b}),v&&!p&&o.createElement(n.Button,{className:"mt-5 d-no dne d-md-block",type:"submit"},g("save")),v&&p&&o.createElement(n.Col,{as:n.Row},o.createElement(n.Button,{className:"mt-5 d-no dne d-md-block",type:"submit"},g("save")),o.createElement(n.Button,{className:"mt-5 ml-5 d-no dne d-md-block",onClick:C.handleSubmit(p)},g("saveAndSendEmail")))))};
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),r=require("react"),o=e(r),a=require("../../../static/loader/BlockLoader.js"),n=require("react-i18next"),l=require("react-bootstrap"),i=require("react-hook-form"),s=e(require("@licklist/plugins/dist/services/Form/FormErrorService"));require("../../../static/index.js");var c=require("../control/EmailTemplateControl.js"),u=require("../../components/NotificationPlaceholders.js");exports.EmailTemplateForm=function(e){var m=e.defaultValues,d=e.onSubmitSave,p=e.onSubmitSaveAndSend,f=e.hasPermission,v=void 0===f||f,E=e.placeholders,b=void 0===E?[]:E,h=e.options,y=void 0===h?[]:h,S=e.serverErrors,T=e.notificationTypes,q=void 0===T?[]:T,k=e.getDefaultTemplateMetaByType,g=e.onTypeChange,B=n.useTranslation("Design").t,j=t.__read(r.useState(!1),2),C=j[0],F=j[1],_=r.useRef(null),N=i.useForm({mode:"onChange",defaultValues:m}),P=N.setError,x=(0,N.watch)("type");return r.useEffect((function(){s.handleServerErrors(S,P)}),[S,P]),r.useEffect((function(){g&&g(x)}),[x]),o.createElement(i.FormProvider,t.__assign({},N),C&&o.createElement(a.BlockLoader,null),o.createElement(l.Form,{onSubmit:N.handleSubmit(d),noValidate:!0,style:{display:C?"none":"block"}},o.createElement(c.EmailTemplateControl,{ref:_,setIsLoading:F,meta:(null==m?void 0:m.meta)||null,defaultAttachments:(null==m?void 0:m.attachments)||[],options:y,notificationTypes:q,getDefaultTemplateMetaByType:k}),o.createElement(u.NotificationPlaceholders,{placeholders:b}),v&&!p&&o.createElement(l.Button,{className:"mt-5 d-no dne d-md-block",type:"submit"},B("save")),v&&p&&o.createElement(l.Col,{as:l.Row},o.createElement(l.Button,{className:"mt-5 d-no dne d-md-block",type:"submit"},B("save")),o.createElement(l.Button,{className:"mt-5 ml-5 d-no dne d-md-block",onClick:N.handleSubmit(p)},B("saveAndSendEmail")))))};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licklist/design",
3
- "version": "0.44.485-dev.35",
3
+ "version": "0.44.485-dev.36",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
@@ -92,6 +92,7 @@ export const EmailTemplateControl = React.forwardRef(
92
92
 
93
93
  useEffect(() => {
94
94
  if (!permanentImages.length) return;
95
+
95
96
  setValue("imagesMetadata", permanentImages);
96
97
  }, [permanentImages, setValue]);
97
98
 
@@ -107,13 +108,15 @@ export const EmailTemplateControl = React.forwardRef(
107
108
  }, [defaultAttachments]);
108
109
 
109
110
  useEffect(() => {
110
- if (!options.length) return;
111
+ if (!options?.length) return;
112
+
111
113
  const fileSelectorOptions = options.find(
112
114
  (option) => option.type === OPTION_TYPE.files_selector
113
115
  );
114
- if (fileSelectorOptions.selectedValue) {
115
- setIsIncludePDF(true);
116
- }
116
+
117
+ if (!fileSelectorOptions?.selectedValue) return;
118
+
119
+ setIsIncludePDF(true);
117
120
  }, [options]);
118
121
 
119
122
  const handleDeleteEmailImage = (content) => {
@@ -337,7 +340,7 @@ export const EmailTemplateControl = React.forwardRef(
337
340
  isLoading={isAttachmentLoading}
338
341
  />
339
342
  </Row>
340
- {options.length > 0 && (
343
+ {options?.length > 0 && (
341
344
  <Row>
342
345
  <Form.Group as={Col}>
343
346
  {options.map((option) => {
@@ -405,6 +408,26 @@ export const EmailTemplateControl = React.forwardRef(
405
408
  </>
406
409
  );
407
410
  }
411
+
412
+ if (option.type === OPTION_TYPE.days_reminder) {
413
+ return (
414
+ <>
415
+ <Form.Label className="mt-4">
416
+ {t(`Design:${option.name}`)}
417
+ </Form.Label>
418
+ <Form.Control
419
+ {...register(
420
+ `templateOptionValues.${option?.id}.value` as any
421
+ )}
422
+ type="number"
423
+ placeholder={t(`Design:${option.name}`)}
424
+ id={option.name + option.id}
425
+ />
426
+ <Form.Text>{option.description}</Form.Text>
427
+ </>
428
+ );
429
+ }
430
+
408
431
  return null;
409
432
  })}
410
433
  </Form.Group>
@@ -185,6 +185,7 @@ Default.args = {
185
185
  notificationType: "confirmation",
186
186
  type: "checkbox",
187
187
  defaultValue: "true",
188
+ descrption: "",
188
189
  },
189
190
  {
190
191
  id: 12,
@@ -192,6 +193,7 @@ Default.args = {
192
193
  notificationType: "confirmation",
193
194
  type: "checkbox",
194
195
  defaultValue: "false",
196
+ descrption: "",
195
197
  },
196
198
  {
197
199
  selectedValue: "invoice",
@@ -201,6 +203,17 @@ Default.args = {
201
203
  type: "files_selector",
202
204
  defaultValue:
203
205
  '{"confirmation":"Confirmation / Function Sheet","invoice":"Invoice"}',
206
+ descrption: "",
207
+ },
208
+ {
209
+ id: 13,
210
+ name: "days_reminder",
211
+ notificationType: "confirmation",
212
+ type: "days_reminder",
213
+ defaultValue: "",
214
+ description: `N.B. Add positive integer for days before the event, or negative for days after the event.
215
+ E.g. if you want this remainder to be send 2 days before the event, enter 2.
216
+ If you want this to be send 3 days after the event enter -3.`,
204
217
  },
205
218
  ],
206
219
  defaultValues: {
@@ -43,9 +43,10 @@ export interface EmailTemplateProps extends HasPermissionProp {
43
43
  serverErrors?: ServerError;
44
44
  notificationTypes?: NotificationType[];
45
45
  getDefaultTemplateMetaByType?: (type?: NotificationType | null) => string;
46
+ onTypeChange?: (type?: NotificationType | null) => void;
46
47
  }
47
48
 
48
- export function EmailTemplateForm({
49
+ export const EmailTemplateForm = ({
49
50
  defaultValues,
50
51
  onSubmitSave,
51
52
  onSubmitSaveAndSend,
@@ -55,7 +56,8 @@ export function EmailTemplateForm({
55
56
  serverErrors,
56
57
  notificationTypes = [],
57
58
  getDefaultTemplateMetaByType,
58
- }: EmailTemplateProps) {
59
+ onTypeChange,
60
+ }: EmailTemplateProps) => {
59
61
  const { t } = useTranslation("Design");
60
62
  const [isLoading, setIsLoading] = useState(false);
61
63
  const emailEditorRef = useRef(null);
@@ -65,12 +67,20 @@ export function EmailTemplateForm({
65
67
  defaultValues,
66
68
  });
67
69
 
68
- const { setError } = form;
70
+ const { setError, watch } = form;
71
+ const type = watch("type");
69
72
 
70
73
  useEffect(() => {
71
74
  FormErrorService.handleServerErrors(serverErrors, setError);
72
75
  }, [serverErrors, setError]);
73
76
 
77
+ useEffect(() => {
78
+ if (!onTypeChange) return;
79
+
80
+ onTypeChange(type);
81
+ // eslint-disable-next-line react-hooks/exhaustive-deps
82
+ }, [type]);
83
+
74
84
  return (
75
85
  <FormProvider {...form}>
76
86
  {isLoading && <BlockLoader />}
@@ -114,4 +124,4 @@ export function EmailTemplateForm({
114
124
  </Form>
115
125
  </FormProvider>
116
126
  );
117
- }
127
+ };