import{i as u}from"./emotion-use-insertion-effect-with-fallbacks.browser.esm-6809063d.js";import{a as o,F as g,j as f}from"./Tooltip-ae8d7992.js";import{i as p,A as h,h as x,z as r,ai as b,O as C,L as y}from"./index-dfa17bed.js";const E="https://archt.com.ar",$="quo",j=`${E}/${$}/Engine?paquete=wf&clase=ExportaTramites&metodo=getExportadorCols&data=&parametros=`,v=async()=>(await p.get(`${j}`)).data.data,w="https://archt.com.ar",S="quo",A=`${w}/${S}/Engine?paquete=wf&clase=ExportaTramites&metodo=setColsExportador&data=&parametros=`,O=async(a,s)=>(await p.get(`${A}${JSON.stringify({empId:a,data:s})}`)).data,{Container:T,Divider:q,Chip:F}=await u("@mui/material"),{useContext:L,useEffect:U}=await u("react"),D=()=>{const{empresaActual:a}=L(h),{watch:s,reset:n,control:i,handleSubmit:d,formState:B}=x({defaultValues:{columnas:[]}});U(()=>{v().then(e=>{console.log("data",e);const t=Object.entries(e.config).map(([l,m])=>({...m,visible:m.visible!==0}));n({columnas:t})}).catch(e=>{r.error("Hubo un error al recuperar configuración de columnas"),console.error(e)})},[]);const{fields:c}=b({control:i,name:"columnas"});return console.log("fields",c),o(g,{children:o(T,{children:f("form",{style:{marginTop:"1em"},onSubmit:d(async e=>{console.log("data",e);let t={};t.config=e.columnas,console.log("obj",t);try{(await O(a?.empId,t)).success?r.success("Configuración guardada con éxito"):r.error("Ocurrió un error al guardar configuración, por favor reintente")}catch{}}),children:[o(q,{textAlign:"left",style:{marginBottom:"10px"},children:o(F,{label:"Columnas visibles en el exportador de bandeja"})}),o("div",{style:{marginBottom:"10px"},children:c.map((e,t)=>o("div",{style:{display:"grid",gridTemplateColumns:"1fr 2fr",alignItems:"flex-end"},children:o(C,{control:i,name:`columnas.${t}.visible`,type:"checkbox",label:e.columna})},`input-group-${t}`))}),o("div",{style:{marginTop:"1.5em"},children:o(y,{type:"submit",variant:"contained",sx:{color:"white"},children:"Guardar Cambios"})})]})})})};export{D as default};
