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