import{$ as u,bu as k,r as n,A as L,H as F,R as G,j as t,o as r,B as s,bv as P,K as i,J as p,L as q,bp as D,bw as $,bq as j,bg as B,w as l,aJ as H,bx as b,aE as M,by as R}from"./index-e717fda1.js";const O=async(m,o)=>await u.post(`${k}`,{d:{nro:m,sid:o}}),z=48,J=8,U={PaperProps:{style:{maxHeight:z*4.5+J,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=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(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()=>{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 O(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,_]=G.useState([]);return t("div",{children:r(s,{sx:{height:600,width:"100%"},children:[t(P,{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:v,onChange:e=>y(e.target.value)}),t(q,{sx:{m:1,width:300},children:t(D,{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($,{label:"Name"}),MenuProps:U,children:K.map(e=>t(j,{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:x,density:"comfortable"}),r("form",{onSubmit:I,children:[t(l,{children:"Sid"}),t(p,{name:"sid",value:f,onChange:e=>A(e.target.value)}),t(l,{children:"Numero de telefono"}),t(p,{placeholder:"5493816296894",name:"nro",value:w,onChange:e=>N(e.target.value)}),t(s,{children:t(i,{type:"submit",children:"Enviar prueba"})})]})]})})};export{Q as default};
