import{r as c,j as s,e0 as m,e1 as x,aH as n,e2 as S}from"./index-e79f7aad.js";import{L as v}from"./LoadingButton-2d3ef2e0.js";const y=({app_label:a,model_name:i,instance_id:l,document_status_name:p,callback:e})=>{const[u,o]=c.useState(!1);if(p!=="Draft")return null;const f=async()=>{var r;o(!0);try{const t=await x(`/users/document-save/${a}/${i}/${l}/`,{});if(t.status>=200&&t.status<300)n.fire({title:'<p style="font-size:20px">Sent to Approval Successfully</p>',icon:"success",confirmButtonText:"Close",confirmButtonColor:"#5B3959"}),e==null||e();else throw new Error(t.data)}catch(t){const d=S((r=t==null?void 0:t.response)==null?void 0:r.data).replace(/\n/g,"<br>");n.fire({title:'<p style="font-size:20px">Error</p>',html:`<div style="white-space: pre-line; text-align: left;">${d}</div>`,icon:"error",confirmButtonText:"Close",confirmButtonColor:"#5B3959"})}finally{o(!1)}};return s.jsx(v,{variant:"outlined",loading:u,startIcon:s.jsx(m,{}),onClick:f,sx:{borderRadius:2,textTransform:"none",fontWeight:600},children:"Send to Approval"})};export{y as S};
