import{y as u,aX as E,r as n,A as $,k as D,R as F,j as t,f as r,B as s,aY as G,m as i,l as p,o as L,aZ as O,a_ as P,T as l,aV as M,a$ as C,b0 as j,b1 as q}from"./index-4e7882bc.js";import{M as B,D as R}from"./DataGrid-c017cd02.js";import"./toPropertyKey-4015efc6.js";import"./dividerClasses-9982a278.js";import"./listItemTextClasses-0d3e3a1a.js";const H=async(m,o)=>await u.get(`${E}${JSON.stringify({d:{nro:m,sid:o}})}`),J=48,z=8,U={PaperProps:{style:{maxHeight:J*4.5+z,width:300}}},V=["twilio/text","twilio/media","twilio/quick-reply","twilio/list-picker"],te=m=>{const[o,d]=n.useState([]),{empresaActual:h}=n.useContext($),b=D(),T=(e,a)=>{b(`/dashboard/template/${e}`,{state:{dataTemplate:a}})},A=[{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(M,{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(j,{onClick:()=>T(e.row.sid,e.row),title:"Ver tamplate",children:t("span",{children:t(q,{})})},"editar-proceso")]}],g=async()=>{y("");const e=await u.get(`${C}${JSON.stringify({d:{Content:"",cuentaId:h.EmpCuentaTwilioId}})}`);d(e.data.contents.map(a=>({...a,id:a.sid})))};n.useEffect(()=>{g()},[]);const[f,N]=n.useState(""),[v,x]=n.useState(""),S=async e=>{e.preventDefault(),await H(v,f)},[w,y]=n.useState(""),I=async()=>{const e=await u.get(`${C}${JSON.stringify({d:{Content:w,cuentaId:h.EmpCuentaTwilioId}})}`);d(e.data.contents.map(a=>({...a,id:a.sid})))},[_,k]=F.useState([]);return t("div",{children:r(s,{sx:{height:600,width:"100%"},children:[t(G,{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(p,{size:"small",placeholder:"Buscar...",type:"text",value:w,onChange:e=>y(e.target.value)}),t(L,{sx:{m:1,width:300},children:t(O,{labelId:"demo-multiple-name-label",id:"demo-multiple-name",multiple:!0,value:_,size:"small",onChange:e=>{const{target:{value:a}}=e;k(typeof a=="string"?a.split(","):a)},input:t(P,{label:"Name"}),MenuProps:U,children:V.map(e=>t(B,{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(R,{rows:o,columns:A,density:"comfortable"}),r("form",{onSubmit:S,children:[t(l,{children:"Sid"}),t(p,{name:"sid",value:f,onChange:e=>N(e.target.value)}),t(l,{children:"Numero de telefono"}),t(p,{placeholder:"5493816296894",name:"nro",value:v,onChange:e=>x(e.target.value)}),t(s,{children:t(i,{type:"submit",children:"Enviar prueba"})})]})]})})};export{te as default};
