import{U as p,b8 as k,r as n,A as $,x as F,R as G,j as t,l as r,B as s,b9 as L,z as i,y as u,E as O,ba as P,bb as D,bc as j,a$ as q,T as l,b3 as B,bd as b,be as M,bf as R}from"./index-cc84e56a.js";const z=async(m,o)=>await p.get(`${k}${JSON.stringify({d:{nro:m,sid:o}})}`),H=48,J=8,U={PaperProps:{style:{maxHeight:H*4.5+J,width:300}}},V=["twilio/text","twilio/media","twilio/quick-reply","twilio/list-picker"],Q=m=>{const[o,d]=n.useState([]),{empresaActual:h}=n.useContext($),C=F(),T=(e,a)=>{C(`/dashboard/template/${e}`,{state:{dataTemplate:a}})},x=[{field:"sid",headerName:"Name / Template SID",type:"string",width:350,align:"left",headerAlign:"left",renderCell:e=>r(s,{children:[t(l,{children:e.row.friendly_name}),t(l,{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(B,{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(M,{onClick:()=>T(e.row.sid,e.row),title:"Ver tamplate",children:t("span",{children:t(R,{})})},"editar-proceso")]}],g=async()=>{y("");const e=await p.get(`${b}${JSON.stringify({d:{Content:"",cuentaId:h.EmpCuentaTwilioId}})}`);d(e.data.contents.map(a=>({...a,id:a.sid})))};n.useEffect(()=>{g()},[]);const[f,A]=n.useState(""),[v,N]=n.useState(""),S=async e=>{e.preventDefault(),await z(v,f)},[w,y]=n.useState(""),I=async()=>{const e=await p.get(`${b}${JSON.stringify({d:{Content:w,cuentaId:h.EmpCuentaTwilioId}})}`);d(e.data.contents.map(a=>({...a,id:a.sid})))},[E,_]=G.useState([]);return t("div",{children:r(s,{sx:{height:600,width:"100%"},children:[t(L,{to:"/dashboard/template/create",children:t(i,{sx:{color:"#FFF",marginY:"1em"},variant:"contained",children:"Añadir nuevo template"})}),r(s,{my:1,display:"flex",alignItems:"center",gap:1,children:[t(u,{size:"small",placeholder:"Buscar...",type:"text",value:w,onChange:e=>y(e.target.value)}),t(O,{sx:{m:1,width:300},children:t(P,{labelId:"demo-multiple-name-label",id:"demo-multiple-name",multiple:!0,value:E,size:"small",onChange:e=>{const{target:{value:a}}=e;_(typeof a=="string"?a.split(","):a)},input:t(D,{label:"Name"}),MenuProps:U,children:V.map(e=>t(j,{value:e,children:e},e))})}),t(i,{onClick:I,sx:{marginLeft:"1em"},variant:"outlined",children:"Aplicar filtros"}),t(i,{onClick:g,sx:{marginLeft:"1em"},variant:"outlined",children:"Limpiar filtros"})]}),t(q,{rows:o,columns:x,density:"comfortable"}),r("form",{onSubmit:S,children:[t(l,{children:"Sid"}),t(u,{name:"sid",value:f,onChange:e=>A(e.target.value)}),t(l,{children:"Numero de telefono"}),t(u,{placeholder:"5493816296894",name:"nro",value:v,onChange:e=>N(e.target.value)}),t(s,{children:t(i,{type:"submit",children:"Enviar prueba"})})]})]})})};export{Q as default};
