import{u as N,a as C,p as t,aB as S,gR as E,h8 as v,j as e,dy as F,C as B,c2 as f,Q as h,F as l,E as T,r as b,gT as A,ak as I}from"./bundle.CHKSNOJF.js";function R(){const[n]=N(),i=C(),[a,m]=t.useState(!1),[c,g]=t.useState(null),[d,u]=t.useState(""),[p,x]=t.useState(""),[y]=S(E),s=y?.companies?.[0],j=s?.id;return t.useEffect(()=>{s?.settings&&(u(s.settings.email_from_name??""),x(s.settings.reply_to_email??""))},[s?.settings]),v({onClick:()=>{if(!a){m(!0),l.processing();const o=T.cloneDeep(s);o&&(o.settings.email_from_name=d||null,o.settings.reply_to_email=p||null),b("PUT",A("/api/companies/:id",{id:j}),o,{headers:{Authorization:`Bearer ${localStorage.getItem("X-DOCU-NINJA-TOKEN")}`}}).then(()=>{l.success("updated_company"),I(["docuninja_login"])}).catch(r=>{if(r.response?.status===422){g(r.response.data);const _=r.response.data.message||"validation_errors";l.error(_)}else l.error("error_title")}).finally(()=>m(!1))}},disableSaveButton:a},[a]),e.jsxs(e.Fragment,{children:[c&&e.jsx(F,{errors:c}),e.jsxs(B,{title:n("email_settings"),className:"shadow-sm",style:{borderColor:i.$24},headerStyle:{borderColor:i.$20},children:[e.jsx(f,{leftSide:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-medium",children:n("from_name")}),e.jsx("span",{className:"text-xs text-gray-500",children:"Custom sender name for outgoing document emails."})]}),children:e.jsx(h,{value:d,onValueChange:u,disabled:a,placeholder:"Your Company Name"})}),e.jsx(f,{leftSide:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-medium",children:n("reply_to_email")}),e.jsx("span",{className:"text-xs text-gray-500",children:"Custom reply-to email address for outgoing document emails."})]}),children:e.jsx(h,{value:p,onValueChange:x,disabled:a,placeholder:"reply@yourdomain.com"})})]})]})}export{R as default};
