PageSourceSearch

https://jfa-infq.web.app/assets/system-email-templates-editor.component-0rQ1NoJj.js

js jfa-infq.web.app collected 2026-10-03 12:28:03 UTC 11,059 bytes, 1 lines download raw bytes

1import{e,F as me}from"./ui-vendor-CaFOqX7E.js";import{u as ce,r as l,k as ue}from"./react-vendor-Diu8YNKx.js";import{gS as ge,gR as pe,gV as he,b_ as ae,gW as fe,a5 as je,R as L,dP as ne,o as xe,gT as Te,e as F,gX as be,eZ as ie,gY as oe,y as ve,z as Se,T as Ce,L as Ee,K as we}from"./index-MMViGgmL.js";import{e as Ne,u as W}from"./redux-vendor-kFPYml90.js";import{E as ke}from"./index-DZRs3xs5.js";import{h as ye,i as Ae}from"./emailCmsFunctions-DvP8g-dj.js";import{S as Pe}from"./check-icon-PCvO9M95.js";import{E as Me}from"./email-preview-modal.component-ouz20gxa.js";import{a as ze}from"./useEmailPreview-DiRKufYv.js";import{r as le}from"./replaceWithDynamicContent-oNJ1RlI4.js";import{g as te}from"./email-template-display-names-BZvRfkvA.js";import"./firebase-vendor-DpNCE-dN.js";import"./form-vendor-D7Pc5Nza.js";import"./chart-vendor-DSC_euA_.js";import"./useIdToGetEventType-XqsVbM7I.js";const De=x=>{ce();const p=Ne(),d=l.useRef(null),[N,H]=l.useState(!0),[C,$]=l.useState(ye),[k,I]=l.useState(!1),[a,v]=l.useState({}),[h,G]=l.useState({code:"en",name:"English"}),[c,f]=l.useState({code:"en",name:"English"}),[y,j]=l.useState(""),{basicBrandInfo:re}=W(t=>t.InfauqeInstance),{featuresPermv2:P}=W(t=>t.InfauqeInstance),Y=P["email-template-localization"],{translationLoading:E,templateJsonMap:o,specificTemplateLoading:M,specificTemplateInfo:T}=W(t=>t.emailCMS);l.useEffect(()=>{M.loading!==!0&&p(ge(x))},[]),l.useEffect(()=>{var n,r;const t=((n=o.en)==null?void 0:n.subject)||"",s=((r=o.en)==null?void 0:r.design)||"";d.current&&d.current.editor&&M.success===!0&&(d.current.editor.loadDesign(s),j(t)),$([...Ae(x)])},[x,M,N,p]),l.useEffect(()=>{I((T==null?void 0:T.localization)||!1)},[T.localization]);const K=t=>{G(t)},B=()=>new Promise((t,s)=>{d.current.editor.exportHtml(function(n){n.html?t(n.html):s("Error exporting HTML")})}),z=()=>new Promise((t,s)=>{d.current.editor.exportHtml(function(n){n.design?t(n.design):s("Error exporting HTML")})}),U=async t=>{if(c!=null&&c.code){const n=await z();p({type:"SET_TEMPLATE_JSON_MAP",payload:{...o,[c.code]:{code:c==null?void 0:c.code,design:n,subject:y}}})}f(t);const s=o[t.code];j((s==null?void 0:s.subject)||""),b(s==null?void 0:s.design)},V=t=>{f({}),j(t==null?void 0:t.subject),b(t.design)},X=t=>{var n,r;let s={...o};delete s[t.code],p({type:"SET_TEMPLATE_JSON_MAP",payload:s}),f({code:"en",name:"English"}),b((n=o.en)==null?void 0:n.design),v({}),j((r=o.en)==null?void 0:r.subject)},Z=async()=>{var r,S,A;let t=((r=o.en)==null?void 0:r.subject)||"",s=((S=o.en)==null?void 0:S.design)||"";if((c==null?void 0:c.code)==="en"){t=y||((A=o.en)==null?void 0:A.subject),s=await z();const w=ae.cloneDeep(o);delete w.en,p({type:"SET_TEMPLATE_JSON_MAP",payload:{en:{code:"en",design:s,subject:t},...w}})}v({...h});const n=ae.cloneDeep(s);p(fe(t,n,h==null?void 0:h.name,h==null?void 0:h.code,Q))},Q=(t,s,n)=>{if(o[n]){const r={...o};r[n]={code:n,design:s,subject:t},f({code:n}),p({type:"SET_TEMPLATE_JSON_MAP",payload:r}),v({})}else v(r=>({...r,subject:t,design:s})),f({});j(t),b(s)},b=t=>{d.current&&d.current.editor&&d.current.editor.loadDesign(t)},g=()=>{const t={...o,[a==null?void 0:a.code]:{code:(a==null?void 0:a.code)||"",design:a==null?void 0:a.design,subject:(a==null?void 0:a.subject)||""}};p({type:"SET_TEMPLATE_JSON_MAP",payload:t});const s={code:a==null?void 0:a.code,name:a==null?void 0:a.name};f(s),b(a==null?void 0:a.design),j(a==null?void 0:a.subject),v({})},D=()=>{var t,s;f({code:"en",name:"English"}),b((t=o.en)==null?void 0:t.design),j((s=o.en)==null?void 0:s.subject),v({})},_=async()=>{var w,O,i,m,u;const t=Object.keys(o),s={},n=(c==null?void 0:c.code)||"en",r=await z(),S={...o,[n]:{code:n,design:r,subject:y}};for(const J of t){const R=(w=S[J])==null?void 0:w.design,ee=((O=S[J])==null?void 0:O.subject)||"";if(R){b(R);const de=await B();s[J]={design:R,html:de,subject:ee}}}const A={type:x,subject:(i=s==null?void 0:s.en)==null?void 0:i.subject,localization:k,html:(m=s==null?void 0:s.en)==null?void 0:m.html,design:(u=s==null?void 0:s.en)==null?void 0:u.design,languages:t,...s};p(he(A,q))},q=t=>{t?je.success("Template saved successfully!"):console.error("Error saving template:",t)};return{emailEditorRef:d,tags:C,loading:N,setLoading:H,langDropdown:h,selectedLang:c,templateSubject:y,setTemplateSubject:j,handleLanguageChange:K,handleChipClick:U,handleTempChipClick:V,handleChipDelete:X,handleTranslation:Z,handleAddTempLanguage:g,temporaryLang:a,translationLoading:E,clearTemporaryLang:D,templateJsonMap:o,handleSaveTemplate:_,localization:k,updateLocalization:()=>{p(pe({template:x,switchCase:"localization",toggleState:!k})),I(s=>!s)},localizationEnabled:Y}},Ve=()=>{const x=ce(),d=ue().id||"",[N,H]=l.useState(null),C=l.useRef(null),[$,k]=l.useState(!1),[I,a]=l.useState(""),[v,h]=l.useState(""),[G,c]=l.useState(!1),f=ze(),y=i=>{navigator.clipboard.writeText(i)},{specificTemplateLoading:j,specificTemplateInfo:re,emailDesignLoading:P,toggleLoading:Y}=W(i=>
1i.emailCMS),{emailEditorRef:E,tags:o,setLoading:M,langDropdown:T,selectedLang:K,templateSubject:B,setTemplateSubject:z,handleLanguageChange:U,handleChipClick:V,handleTempChipClick:X,handleChipDelete:Z,handleTranslation:Q,handleAddTempLanguage:b,temporaryLang:g,translationLoading:D,clearTemporaryLang:_,templateJsonMap:q,handleSaveTemplate:se,localization:t,updateLocalization:s,localizationEnabled:n}=De(d),r=()=>{t&&(g!=null&&g.design)?c(!0):x("/system-generated-email-templates")},S=()=>{c(!1)},A=()=>{c(!1),_(),x("/system-generated-email-templates")},w=async()=>{var i,m;(m=(i=E==null?void 0:E.current)==null?void 0:i.editor)!=null&&m.exportHtml&&E.current.editor.exportHtml(u=>{const J=(u==null?void 0:u.html)||"",R=le(J,f),ee=le(B||"",f);a(R),h(ee),k(!0)})};l.useEffect(()=>{L.rebuild()},[o]),l.useEffect(()=>()=>{C.current&&clearTimeout(C.current)},[]);const O=i=>{console.log("Go back clicked",i),(i===0||i===1)&&x("/system-generated-email-templates")};return e.jsxs("div",{className:"system-temp-editor-wrapper",children:[j.loading?e.jsx("div",{className:"loading-container",children:e.jsx(ne,{size:22})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"header-container",children:[e.jsx(me,{direction:"row",justifyContent:"space-between",alignItems:"center",children:e.jsx(xe,{crumbs:["Correspondence","System Email Templates",te(d)],onCrumbClick:O})}),e.jsxs("div",{className:"header-stack",children:[e.jsx("h1",{className:"template-name",children:te(d)}),e.jsxs("div",{className:"header-actions",children:[n?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"enable-localization-text",children:"Enable localization"}),e.jsx("div",{className:"switch-container",children:Y.loading?e.jsx(ne,{size:22,color:"grey"}):e.jsx(Te,{sx:{m:1},checked:t,onClick:i=>i.stopPropagation(),onChange:()=>s()})})]}):"",e.jsx(F,{weight:"700",size:"large",variant:"outlined",onClick:r,children:"Cancel"}),e.jsx(F,{weight:"700",size:"large",variant:"outlined",onClick:w,children:"Preview"}),e.jsx(F,{weight:"700",size:"large",variant:"contained",disabled:P.loading||D.loading||(g==null?void 0:g.design),onClick:()=>se(),sx:{width:"160px"},children:"Save Template"})]})]})]}),e.jsxs("div",{className:"system-temp-editor-content",children:[n?e.jsxs("div",{className:"select-lang-container",children:[e.jsx("span",{className:"select-lang-text",children:"Select languages"}),e.jsx("span",{className:"select-lang-subtitle",children:"Choose a configured language and click 'Translate' to convert the form content into your preferred language."}),e.jsxs("div",{className:"select-container",children:[e.jsx(be,{value:T.code,options:ie,onChange:U,disabled:!t,sx:{backgroundColor:"#fff"}}),(T==null?void 0:T.code)!=="en"&&e.jsx(F,{weight:"700",size:"large",variant:"contained",onClick:()=>Q(),disabled:D.loading||!t,children:"Translate"})]}),t&&e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:"translation-text",children:"Review and customize translation"}),e.jsx("span",{className:"translation-subtitle",children:"Review the translated content and make edits as needed to ensure the language matches your preferences before publishing."})]}),e.jsxs("div",{className:"translation-chips-container",children:[t&&Object.keys(q).map(i=>{const m=ie.find(u=>u.code===i);return e.jsx(oe,{lang:m,selected:K.code===m.code,onClick:V,onDelete:Z},m.code)}),(g==null?void 0:g.design)&&e.jsxs(e.Fragment,{children:[e.jsx(oe,{lang:g,error:!0,onClick:X,onDelete:()=>_()},g.code),e.jsx("span",{className:"satisfied-language-text",children:"Are you satisfied with this translation?"}),e.jsx("div",{className:"cross-icon",onClick:()=>_(),children:e.jsx(ve,{stroke:"#98A2B3"})}),e.jsx("div",{className:"tick-icon",onClick:()=>b(),children:e.jsx(Pe,{stroke:"var(--primary-color)"})})]})]})]}):e.jsx("div",{className:"select-lang-substitube",children:" "}),e.jsxs("div",{className:"tags-container",children:[e.jsx("span",{className:"content-text",children:"Content tags"}),e.jsx(L,{id:"system-email-template-copy",place:"top",effect:"solid",className:"custom-tooltip",backgroundColor:"#101828"}),e.jsx("div",{className:"tags-list",children:o.filter(i=>i!=="Transaction Date"||["eventConfirmation","campaignContribution"].includes(d)).map((i,m)=>e.jsx(Se,{variant:"outlined",className:`tag-button${N===m?" highlighted":""}`,sx:{padding:"10px  !important",fontWeight:400,backgroundColor:"white !important",border:"1.65px solid",borderColor:N===m?"var(--primary-color) !important":"#d0d5dd","&.Mu
1iButton-outlined":{backgroundColor:"white !important",height:"42px !important",border:"1.65px solid",borderColor:N===m?"var(--primary-color) !important":"#D0D5DD",color:"#231f20 !important",fontSize:"14px !important"}},onClick:u=>{y(`[${i}]`),H(m),C.current&&clearTimeout(C.current),u.currentTarget.setAttribute("data-for","system-email-template-copy"),u.currentTarget.setAttribute("data-tip","Copied!"),L.show(u.currentTarget),C.current=setTimeout(()=>{L.hide(),H(null),u.currentTarget.removeAttribute("data-for"),u.currentTarget.removeAttribute("data-tip")},1e3)},children:`[${i}]`},m))})]}),e.jsxs("div",{className:"email-editor-container",children:[e.jsx("span",{className:"email-subject-text",children:"Email subject"}),e.jsx("div",{className:"email-subject-textfield",children:e.jsx(Ce,{placeholder:"subject",value:B||"",onChange:i=>z(i.target.value),sx:{backgroundColor:"#fff"}})}),e.jsx("span",{className:"email-content-text",children:"Email content"}),e.jsx("div",{className:"email-editor",children:e.jsx(ke,{ref:E,onLoad:()=>M(!1),options:{features:{preview:!1},customCSS:".toolbar-right [data-key='preview'], .toolbar [data-key='preview'], button[aria-label*='preview' i], button[aria-label*='Preview' i] { display: none !important; }"}})})]})]})]}),e.jsx(Me,{open:$,onClose:()=>k(!1),previewHtml:I,subject:v,displayName:te(d)}),(P.loading||D.loading)&&e.jsx(Ee,{title:P.loading?"Saving template ...":"Translating ...",width:"64px"}),G&&e.jsx(we,{title:"Unsaved changes",subText:"There are some unsaved changes. Do you want to discard this changes?",confirmText:"Yes",cancelText:"No",onConfirm:A,onCancel:S})]})};export{Ve as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.