import{W as u,bh as k,r as n,A as F,x as G,R as L,j as t,l as r,B as s,bi as P,z as l,y as p,E as j,bj as B,bk as D,bl as q,b9 as M,T as i,aB as R,bm as b,aw as $,bn as z}from"./index-91e9700c.js";const H=async(m,o)=>await u.post(`${k}`,{d:{nro:m,sid:o}}),O=48,U=8,W={PaperProps:{style:{maxHeight:O*4.5+U,width:300}}},V=["twilio/text","twilio/media","twilio/quick-reply","twilio/list-picker"],Q=m=>{const[o,d]=n.useState([]),{empresaActual:h}=n.useContext(F),C=G(),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(i,{children:e.row.friendly_name}),t(i,{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(R,{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($,{onClick:()=>T(e.row.sid,e.row),title:"Ver tamplate",children:t("span",{children:t(z,{})})},"editar-proceso")]}],g=async()=>{y("");const e=await u.post(`${b}`,{d:{Content:"",cuentaId:h.EmpCuentaTwilioId}});d(e.data.contents.map(a=>({...a,id:a.sid})))};n.useEffect(()=>{g()},[]);const[f,A]=n.useState(""),[w,N]=n.useState(""),I=async e=>{e.preventDefault(),await H(w,f)},[v,y]=n.useState(""),S=async()=>{const e=await u.post(`${b}`,{d:{Content:v,cuentaId:h.EmpCuentaTwilioId}});d(e.data.contents.map(a=>({...a,id:a.sid})))},[E,_]=L.useState([]);return t("div",{children:r(s,{sx:{height:600,width:"100%"},children:[t(P,{to:"/dashboard/template/create",children:t(l,{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:v,onChange:e=>y(e.target.value)}),t(j,{sx:{m:1,width:300},children:t(B,{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:W,children:V.map(e=>t(q,{value:e,children:e},e))})}),t(l,{onClick:S,sx:{marginLeft:"1em"},variant:"outlined",children:"Aplicar filtros"}),t(l,{onClick:g,sx:{marginLeft:"1em"},variant:"outlined",children:"Limpiar filtros"})]}),t(M,{rows:o,columns:x,density:"comfortable"}),r("form",{onSubmit:I,children:[t(i,{children:"Sid"}),t(p,{name:"sid",value:f,onChange:e=>A(e.target.value)}),t(i,{children:"Numero de telefono"}),t(p,{placeholder:"5493816296894",name:"nro",value:w,onChange:e=>N(e.target.value)}),t(s,{children:t(l,{type:"submit",children:"Enviar prueba"})})]})]})})};export{Q as default};
