import{i as m}from"./emotion-use-insertion-effect-with-fallbacks.browser.esm-6809063d.js";import{a as t,j as n}from"./Tooltip-ae8d7992.js";import{i as u,$ as G,A as L,c as P,a0 as D,a1 as T,a2 as $}from"./index-dfa17bed.js";const j=async(h,o)=>await u.post(`${G}`,{d:{nro:h,sid:o}}),{Box:r,Button:i,Chip:q,FormControl:M,MenuItem:B,OutlinedInput:H,Select:O,TextField:p,Tooltip:R,Typography:s}=await m("@mui/material"),{DataGrid:z}=await m("@mui/x-data-grid"),b=await m("react"),{useContext:U,useEffect:V,useState:l}=b,W=48,Y=8,J={PaperProps:{style:{maxHeight:W*4.5+Y,width:300}}},K=["twilio/text","twilio/media","twilio/quick-reply","twilio/list-picker"],ae=h=>{const[o,d]=l([]),{empresaActual:g}=U(L),A=P(),x=(e,a)=>{A(`/dashboard/template/${e}`,{state:{dataTemplate:a}})},N=[{field:"sid",headerName:"Name / Template SID",type:"string",width:350,align:"left",headerAlign:"left",renderCell:e=>n(r,{children:[t(s,{children:e.row.friendly_name}),t(s,{children:e.row.sid})]})},{field:"language",headerName:"Language",type:"string",width:200,align:"left",headerAlign:"left",valueGetter:e=>e.value==="es_AR"?"Español (ARG)":e.value},{field:"Nombre",headerName:"Content type",type:"string",width:200,align:"left",headerAlign:"left",valueGetter:e=>Object.keys(e.row.types)[0]},{field:"approval_requests",headerName:"WhatsApp eligibility",type:"string",width:200,align:"left",headerAlign:"left",renderCell:e=>{const a=c=>{switch(c){case"unsubmitted":return"No presentado";case"approved":return"Aprobado";case"pending":return"pendiente";case"received":return"recibido";default:return""}};return t(q,{variant:"filled",color:(c=>{switch(c){case"unsubmitted":return"info";case"approved":return"success";case"pending":return"warning";case"received":return"error";default:return"info"}})(e.row.approval_requests.status),label:a(e.row.approval_requests.status)})}},{field:"date_updated",headerName:"Last updated",type:"string",width:200,align:"left",headerAlign:"left"},{field:"actions",type:"actions",headerName:"Acciones",width:170,getActions:e=>[t(R,{onClick:()=>x(e.row.sid,e.row),title:"Ver tamplate",children:t("span",{children:t($,{})})},"editar-proceso")]}],f=async()=>{C("");const e=await u.post(`${T}`,{d:{Content:"",cuentaId:g.EmpCuentaTwilioId}});d(e.data.contents.map(a=>({...a,id:a.sid})))};V(()=>{f()},[]);const[w,I]=l(""),[v,S]=l(""),_=async e=>{e.preventDefault(),await j(v,w)},[y,C]=l(""),k=async()=>{const e=await u.post(`${T}`,{d:{Content:y,cuentaId:g.EmpCuentaTwilioId}});d(e.data.contents.map(a=>({...a,id:a.sid})))},[E,F]=b.useState([]);return t("div",{children:n(r,{sx:{height:600,width:"100%"},children:[t(D,{to:"/dashboard/template/create",children:t(i,{sx:{color:"#FFF",marginY:"1em"},variant:"contained",children:"Añadir nuevo template"})}),n(r,{my:1,display:"flex",alignItems:"center",gap:1,children:[t(p,{size:"small",placeholder:"Buscar...",type:"text",value:y,onChange:e=>C(e.target.value)}),t(M,{sx:{m:1,width:300},children:t(O,{labelId:"demo-multiple-name-label",id:"demo-multiple-name",multiple:!0,value:E,size:"small",onChange:e=>{const{target:{value:a}}=e;F(typeof a=="string"?a.split(","):a)},input:t(H,{label:"Name"}),MenuProps:J,children:K.map(e=>t(B,{value:e,children:e},e))})}),t(i,{onClick:k,sx:{marginLeft:"1em"},variant:"outlined",children:"Aplicar filtros"}),t(i,{onClick:f,sx:{marginLeft:"1em"},variant:"outlined",children:"Limpiar filtros"})]}),t(z,{rows:o,columns:N,density:"comfortable"}),n("form",{onSubmit:_,children:[t(s,{children:"Sid"}),t(p,{name:"sid",value:w,onChange:e=>I(e.target.value)}),t(s,{children:"Numero de telefono"}),t(p,{placeholder:"5493816296894",name:"nro",value:v,onChange:e=>S(e.target.value)}),t(r,{children:t(i,{type:"submit",children:"Enviar prueba"})})]})]})})};export{ae as default};
