import{y,eO as C,r as a,A,k as D,j as l,m as N,aV as S,f as x,B as T,l as v}from"./index-ca24af84.js";import{F as P}from"./Tabla-a272f202.js";import{I as q}from"./ImageViewerModal-515fd301.js";import"./NoRowsComponent-10f615cd.js";import"./DataGrid-e816acb7.js";import"./toPropertyKey-4015efc6.js";import"./dividerClasses-fa4eeeba.js";import"./listItemTextClasses-9e4a600e.js";import"./ListItemIcon-2dd9a578.js";import"./cjs-8bb62be0.js";import"./env-198ff0f3.js";const F=async n=>await y.get(`${C}${JSON.stringify({url:n})}`),$=n=>{const{empresaActual:i}=a.useContext(A),[s,d]=a.useState(!1),[m,p]=a.useState(""),c=D(),[u,g]=a.useState(""),[j,f]=a.useState(""),b=()=>{d(!s)},h=()=>{c("/dashboard/template/create")},[e,I]=a.useState({title:"Chat Templates",tabla:"chttemplates",campoId:"templateId",configuracion:{permiteBorrar:!0,permiteCrear:!0,permiteSubirArchivo:{permite:!0,campoId:"imagenUrl"},buttons:[{title:"Crear twilio template",fn:h}],defaultValues:{contentType:"libre",esTwilioTemplate:"0"}},query:{name:"templateId",type:"supercombobox",dominio:"",tabla:"chttemplates AS cht LEFT JOIN wfproc AS wf ON cht.procId = wf.ProcId LEFT JOIN dmn AS dmn ON (cht.templategroup = dmn.dmnabr AND dmn.dmnfilt = 'tgroup') ",id:"templateId",text:"templateMensaje",where:"",otrosCampos:"cht.*, wf.ProcNom, dmn.DmnDet",ordenBy:"",buscado:"",orLikeCampo:"templateDetalle",limit:"20"},columnas:[{visible:!0,esId:!0,name:"templateId",disabled:!1,label:"Identificador",type:"text",required:!0},{visible:!0,name:"templateMensaje",disabled:!1,tooltip:"No se permite la edición del mensaje de templates ya creados",label:"Mensaje",type:"text",multiline:!0,required:!0},{visible:!0,disabled:!1,label:"Proceso",name:"procId",type:"supercombobox",tabla:"wfproc p, wfseq s, wfcomerprc w",id:"p.ProcId",text:"p.ProcNom",dominio:"",otrosCampos:"s.TarId, p.*,s.SeqId",where:"p.ProcId = s.ProcId AND s.SeqTip = 'INI' AND w.ProcId = p.ProcId",whereCallback:()=>`p.EmpId = ${i==null?void 0:i.empId}`,groupBy:"p.ProcId",recargaAlAbrir:!0},{visible:!0,disabled:!1,name:"templateGroup",type:"supercombobox",label:"Grupo",tabla:"dmn",id:"DmnAbr",text:"DmnDet",dominio:"",otrosCampos:"",where:"DmnFilt = 'TGROUP'",recargaAlAbrir:!0},{visible:!0,name:"templateDetalle",disabled:!1,label:"Detalle",type:"text",multiline:!0,required:!0},{visible:!0,disabled:!1,label:"Image",type:"file",name:"imagenUrl"}],tablaColDef:[{field:"templateId",headerName:"Identificador",type:"number",width:250,align:"left",headerAlign:"left"},{field:"templateMensaje",headerName:"Mensaje",type:"string",width:370,align:"left",headerAlign:"left"},{field:"contentId",headerName:"contentId",type:"number",width:200,align:"right",headerAlign:"right"},{field:"imagenUrl",headerName:"Image URL",type:"string",width:150,align:"left",headerAlign:"left",renderCell:r=>r.row.imagenUrl.length===0?l("p",{children:"Sin imagen"}):l("strong",{children:l(N,{variant:"contained",size:"small",sx:{color:"#FFF"},onClick:async()=>{const t=await F(r.row.imagenUrl);t&&(b(),p(t.data))},children:"Ver imagen"})})},{field:"contentType",headerName:"Tipo de mensaje",type:"string",width:120,align:"right",headerAlign:"right"},{field:"ProcNom",headerName:"Proceso",type:"string",width:150,align:"left",headerAlign:"left"},{field:"DmnDet",headerName:"Grupo",type:"string",width:120,align:"left",headerAlign:"left"}],filtros:[]}),o=a.useCallback(S.debounce(async r=>{f(r),I(t=>({...t,query:{...t.query,buscado:r}}))},1200),[]),w=r=>{const t=r.target.value;g(t),o(t)};return a.useEffect(()=>()=>{o.cancel()},[o]),x("div",{children:[l(T,{children:l(v,{fullWidth:!0,label:"Buscar...",variant:"outlined",value:u,onChange:w})}),l(P,{tabla:e.tabla,title:e.title,configuracion:e.configuracion,query:e.query,columnasData:e.columnas,tablaColDef:e.tablaColDef,campoId:e.campoId,filtros:e.filtros}),l(q,{src:m,setShowDialog:d,showDialog:s})]})};export{$ as default};
