import{$ as u,br as k,r as n,A as L,H as D,R as F,j as t,o as r,B as s,bs as G,K as i,J as p,L as P,bn as $,bt as j,bo as q,be as B,w as l,aI as H,bu as y,aD as M,bv as R}from"./index-62412d73.js";const O=async(m,o)=>await u.post(`${k}`,{d:{nro:m,sid:o}}),z=48,U=8,J={PaperProps:{style:{maxHeight:z*4.5+U,width:300}}},K=["twilio/text","twilio/media","twilio/quick-reply","twilio/list-picker"],Q=m=>{const[o,d]=n.useState([]),{empresaActual:h}=n.useContext(L),C=D(),T=(e,a)=>{C(`/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(H,{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()=>{b("");const e=await u.post(`${y}`,{d:{Content:"",cuentaId:h.EmpCuentaTwilioId}});d(e.data.contents.map(a=>({...a,id:a.sid})))};n.useEffect(()=>{g()},[]);const[f,x]=n.useState(""),[v,N]=n.useState(""),I=async e=>{e.preventDefault(),await O(v,f)},[w,b]=n.useState(""),S=async()=>{const e=await u.post(`${y}`,{d:{Content:w,cuentaId:h.EmpCuentaTwilioId}});d(e.data.contents.map(a=>({...a,id:a.sid})))},[_,E]=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=>b(e.target.value)}),t(P,{sx:{m:1,width:300},children:t($,{labelId:"demo-multiple-name-label",id:"demo-multiple-name",multiple:!0,value:_,size:"small",onChange:e=>{const{target:{value:a}}=e;E(typeof a=="string"?a.split(","):a)},input:t(j,{label:"Name"}),MenuProps:J,children:K.map(e=>t(q,{value:e,children:e},e))})}),t(i,{onClick:S,sx:{marginLeft:"1em"},variant:"outlined",children:"Aplicar filtros"}),t(i,{onClick:g,sx:{marginLeft:"1em"},variant:"outlined",children:"Limpiar filtros"})]}),t(B,{rows:o,columns:A,density:"comfortable"}),r("form",{onSubmit:I,children:[t(l,{children:"Sid"}),t(p,{name:"sid",value:f,onChange:e=>x(e.target.value)}),t(l,{children:"Numero de telefono"}),t(p,{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};
