import{r as a,A as y,U as P,b5 as C,d as N,j as i,l as $,B as b,O as v,b6 as L,b7 as H,_ as h}from"./index-57016b76.js";import{O as q,D as w}from"./OmegaTransferList-324e0c3a.js";import"./NoRowsComponent-f6adf5c7.js";import"./Card-d0765abf.js";import"./CardHeader-52227172.js";const z=A=>{a.useState([]),a.useState([]);const[I,F]=a.useState(!1),[x,E]=a.useState(!1),[n,d]=a.useState([]),[c,f]=a.useState([]),[l,O]=a.useState(""),{empresaActual:o}=a.useContext(y),g=e=>e.map(r=>({id:r.PrfId,...r}));a.useEffect(()=>{l.length!==0&&m(l).then(e=>console.log(e)).catch(e=>console.log(e))},[l]),a.useEffect(()=>{console.log("perfilesEstan",n)},[n]);const S=e=>{if(e.length===0)return;console.log("tareas es",n);const r=n.map(t=>({PrfId:t.PrfId}));P.get(`${H}${JSON.stringify({e,s:o==null?void 0:o.empId,d:r})}`).then(t=>{h.success("Perfiles agregados con éxito"),m(e),t.data.success}).catch(t=>{h.error("Error al guardar"),console.error(t)}).finally(()=>E(!1))},m=async e=>{try{const r=await P.get(`${C}${JSON.stringify({t:e,s:o==null?void 0:o.empId})}`);console.log("res",r),r.data&&(d(g(r.data.estan)),f(g(r.data.noestan)))}catch(r){console.error("Error al obtener datos obtenerPaquetes:",r)}},p=[{field:"PrfNom",headerName:"Perfil",width:200}],T=(e,r)=>{if(r===w.DERECHA){const t=c.filter(s=>e.includes(`${s.PrfId}`));console.log("nuevaProcOrgHabilitadas",t),d(s=>[...s,...t]);const u=c.filter(s=>!e.includes(`${s.PrfId}`));f(u)}else{const t=n.filter(s=>!e.includes(`${s.PrfId}`));d(t);const u=n.filter(s=>e.includes(`${s.PrfId}`));f(s=>[...s,...u])}},{control:U,watch:B,formState:D,handleSubmit:G,resetField:j}=N({mode:"onChange",defaultValues:{UsrId:""}});return i("div",{children:$(b,{children:[i(v,{control:U,name:"PrfId",type:"supercombobox",iField:{id:"UsrId",name:"UsrId",text:'CONCAT(UsrApel," ",UsrNom)',type:"supercombobox",tabla:"usr",where:"",recargaAlAbrir:!1},label:"Perfil de usuario",watchValue:e=>{O(e.id)}}),i(b,{mt:2,children:i(q,{columns:p,columnsTransferidos:p,itemsLoading:I,deshabilitaAcciones:!1,titulos:{sinTransferir:"Tareas que no estan en el paquete",transferidos:"Tareas que si estan en el paquete"},transferirItems:T,itemsSinTransferir:c,itemsTransferidos:n,height:"400px"})}),i(L,{loading:x,type:"button",fullWidth:!0,variant:"outlined",onClick:()=>S(l),style:{marginTop:"10px"},children:"Guardar"})]})})};export{z as default};
