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