import{i as x}from"./emotion-use-insertion-effect-with-fallbacks.browser.esm-2ce7a1bc.js";import{a as n,j as y}from"./Tooltip-5ec3092e.js";import{O as v,D as L}from"./OmegaTransferList-a5586470.js";import{A as H,i as h,w as N,h as $,O as q,x as F,y as S,z as P}from"./index-50f78195.js";const{Box:b}=await x("@mui/material"),{useContext:D,useEffect:I,useState:o}=await x("react"),Q=G=>{o([]),o([]);const[T,j]=o(!1),[E,O]=o(!1),[t,l]=o([]),[c,d]=o([]),[i,A]=o(""),{empresaActual:u}=D(H),m=e=>e.map(r=>({id:r.PrfId,...r}));I(()=>{i.length!==0&&p(i).then(e=>console.log(e)).catch(e=>console.log(e))},[i]),I(()=>{console.log("perfilesEstan",t)},[t]);const C=e=>{if(e.length===0)return;console.log("tareas es",t);const r=t.map(a=>({PrfId:a.PrfId}));h.post(`${S}`,{e,s:u?.empId,d:r}).then(a=>{P.success("Perfiles agregados con éxito"),p(e),a.data.success}).catch(a=>{P.error("Error al guardar"),console.error(a)}).finally(()=>O(!1))},p=async e=>{try{const r=await h.post(`${N}`,{t:e,s:u?.empId});console.log("res",r),r.data&&(l(m(r.data.estan)),d(m(r.data.noestan)))}catch(r){console.error("Error al obtener datos obtenerPaquetes:",r)}},g=[{field:"PrfNom",headerName:"Perfil",width:200}],U=(e,r)=>{if(r===L.DERECHA){const a=c.filter(s=>e.includes(`${s.PrfId}`));console.log("nuevaProcOrgHabilitadas",a),l(s=>[...s,...a]);const f=c.filter(s=>!e.includes(`${s.PrfId}`));d(f)}else{const a=t.filter(s=>!e.includes(`${s.PrfId}`));l(a);const f=t.filter(s=>e.includes(`${s.PrfId}`));d(s=>[...s,...f])}},{control:w,watch:z,formState:B,handleSubmit:V,resetField:k}=$({mode:"onChange",defaultValues:{UsrId:""}});return n("div",{children:y(b,{children:[n(q,{control:w,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=>{A(e.id)}}),n(b,{mt:2,children:n(v,{columns:g,columnsTransferidos:g,itemsLoading:T,deshabilitaAcciones:!1,titulos:{sinTransferir:"Tareas que no estan en el paquete",transferidos:"Tareas que si estan en el paquete"},transferirItems:U,itemsSinTransferir:c,itemsTransferidos:t,height:"400px"})}),n(F,{loading:E,type:"button",fullWidth:!0,variant:"outlined",onClick:()=>C(i),style:{marginTop:"10px"},children:"Guardar"})]})})};export{Q as default};
