whoami7 - Manager
:
/
home
/
qbizpnmr
/
arif.umairtax.com
/
public
/
Upload File:
files >> /home/qbizpnmr/arif.umairtax.com/public/Mailer-CZBmNGmG.js
import{a9 as R,bf as b,r as T,e as C,$ as P,cp as M,cK as N,p as l,j as s,u as O,t as V,w as D,cJ as G,C as v,by as p,E as U,cB as F,cC as H,cx as E,cL as K,cM as $,cA as k,cN as q,be as A}from"./bundle.OlIVtvc7.js";import{I as z}from"./InvoiceViewer-Dp83-peG.js";/** * Invoice Ninja (https://invoiceninja.com). * * @link https://github.com/invoiceninja/invoiceninja source repository * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license */function B({setErrors:e}){const h=R();return(u,t,d,j,n,a,m)=>{b.processing(),e(void 0),T("POST",C("/api/v1/emails"),{body:u,entity:t,entity_id:d,subject:j,template:n,cc_email:m}).then(()=>{P([`${t}s`]),b.success("email_queued"),h(a)}).catch(i=>{var g;((g=i.response)==null?void 0:g.status)===422&&(e(i.response.data),b.dismiss())})}}function J(e){const h=M(),u=N(),[t,d]=l.useState(),[j,n]=l.useState("client_contact_id");return l.useEffect(()=>{e.resourceType==="purchase_order"&&e.resource.vendor_id.length>=1&&u.find(e.resource.vendor_id).then(a=>d(a)).then(()=>n("vendor_contact_id")),e.resourceType!=="purchase_order"&&e.resource.client_id.length>=1&&h.find(e.resource.client_id).then(a=>d(a)).then(()=>n("client_contact_id"))},[]),s.jsx(s.Fragment,{children:t&&s.jsx("div",{children:t.contacts.filter(a=>e.resource.invitations.find(m=>m[j]===a.id)).map((a,m)=>s.jsxs("p",{children:[a.first_name," ",a.last_name," ยท",s.jsxs("span",{className:"font-semibold",children:[" ",a.email]})]},m))})})}const W=l.forwardRef((e,h)=>{var y;const[u]=O(),t=V(),d=D(),j=G({resourceType:e.resourceType}),n=l.useRef(null),[a,m]=l.useState(),[i,g]=l.useState(),[x,f]=l.useState(!0),w=B({setErrors:m}),[r,_]=l.useState({body:"",ccEmail:"",subject:"",templateId:e.defaultEmail}),S=c=>{_(A.cloneDeep({body:"",ccEmail:"",subject:"",templateId:c})),f(!0)};return l.useEffect(()=>{var c;x&&(f(!1),b.processing(),n.current&&n.current.abort(),n.current=new AbortController,T("POST",C("/api/v1/templates"),{body:r.body,entity:e.resourceType,entity_id:((c=e.resource)==null?void 0:c.id)||"",subject:r.subject,template:r.templateId,cc_email:r.ccEmail},{signal:n.current?n.current.signal:void 0}).then(o=>{b.dismiss(),g(o.data)}))},[x,e.resourceType,(y=e.resource)==null?void 0:y.id]),l.useEffect(()=>{i&&_(c=>({...c,subject:i.raw_subject,body:i.raw_body,ccEmail:i.cc_email}))},[i]),l.useImperativeHandle(h,()=>({sendEmail(){var c;w(r.body,e.resourceType,((c=e.resource)==null?void 0:c.id)||"",r.subject,r.templateId,e.redirectUrl,r.ccEmail)}}),[r]),s.jsxs("div",{className:"grid grid-cols-12 lg:gap-4 my-4",children:[s.jsxs("div",{className:"col-span-12 lg:col-span-5 space-y-4",children:[s.jsxs(v,{children:[s.jsx(p,{leftSide:u("to"),children:s.jsx(J,{resource:e.resource,resourceType:e.resourceType})}),s.jsx(p,{leftSide:u("template"),children:s.jsxs(U,{defaultValue:r.templateId,onValueChange:c=>S(c),errorMessage:a==null?void 0:a.errors.template,children:[Object.entries(e.list).map(([c,o],I)=>s.jsx("option",{value:c,children:u(o)},I)),(t==null?void 0:t.settings.email_subject_custom1)&&s.jsx("option",{value:"email_template_custom1",children:t==null?void 0:t.settings.email_subject_custom1}),(t==null?void 0:t.settings.email_subject_custom2)&&s.jsx("option",{value:"email_template_custom2",children:t==null?void 0:t.settings.email_subject_custom2}),(t==null?void 0:t.settings.email_subject_custom3)&&s.jsx("option",{value:"email_template_custom3",children:t==null?void 0:t.settings.email_subject_custom3})]})})]}),s.jsxs(v,{withContainer:!0,children:[s.jsx(E,{label:u("cc_email"),value:r.ccEmail,onValueChange:c=>_(o=>({...o,ccEmail:c})),errorMessage:a==null?void 0:a.errors.cc_email}),s.jsx(E,{label:u("subject"),value:r.subject,onValueChange:c=>{_(o=>({...o,subject:c})),f(!0)},disabled:K()&&$(),changeOverride:!0,errorMessage:a==null?void 0:a.errors.subject}),(F()||H())&&s.jsx(k,{value:r.body,onChange:c=>{_(o=>({...o,body:c})),f(!0)},handleChangeOnlyOnUserInput:!0})]}),i&&s.jsx(v,{className:"scale-y-100",title:i.subject,children:s.jsx("iframe",{srcDoc:q(i.body,i.wrapper),width:"100%",height:800,tabIndex:-1,loading:"lazy"})})]}),s.jsx("div",{className:"my-4 lg:my-0 col-span-12 lg:col-span-7 h-max",children:e.resource&&(d==null?void 0:d.show_pdf_preview)&&s.jsx(z,{method:"GET",link:j(e.resource)})})]})});export{W as M};
Copyright ©2021 || Defacer Indonesia