@imj_media/tareas 1.5.46 → 1.5.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tareas.cjs +1 -1
- package/dist/tareas.es.js +2 -1
- package/package.json +1 -1
package/dist/tareas.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime");require("@imj_media/imj-ui/styles.css");require("@imj_media/ui/index.css");const pe=require("@tanstack/react-query");require("ui-ds/index.css");const ie=require("@imj_media/tasks-modules"),as=require("primereact/paginator"),w=require("react"),jt=require("axios"),Pe=require("qs"),tt=require("react-dom"),Ie=require("@fortawesome/pro-regular-svg-icons"),ve=require("@imj_media/ui"),je=require("@imj_media/imj-ui"),it=require("date-fns"),_t=require("date-fns/locale"),Ce=require("react-hook-form"),A=require("ui-ds"),re=require("@xyflow/react"),ze=require("zustand"),xt=require("moment"),ue=require("@fortawesome/pro-solid-svg-icons"),$e=require("@fortawesome/pro-duotone-svg-icons"),Me=require("@fortawesome/free-solid-svg-icons");require("@xyflow/react/dist/style.css");const ss=require("react-pick-color"),Z={bg:{content:"#FAFAFA"},texts:{DEFAULT:"#252525",subtext:"#4f4f4f",placeholder:"#929292"},primary:{regular:"#425CAC"},success:{dark:"#368156",regular:"#43B071"},danger:{dark:"#8C352C",regular:"#C34335"},warning:{dark:"#B4782F",regular:"#D38A31"},silver:{silver_light:" #F5F5F5",silver_dark:" #E9E9E9"},progressbar:{orange_regular:"#DC8921",blue_regular:"#3658C1",green_regular:"#039B59"},gray:{gray_regular:"#D1D1D1",gray_dark:"#C4C4C4"},black:{black_light:"#929292",black_medium:"#4F4F4F",black_dark:"#131313"}},qt=t=>{let a={};return Object.entries(t).forEach(([n,r])=>{if(n.includes(".")){let[s,i]=n.split(".");a[s]=a[s]||{},a[s][i]=r}else a[n]=r}),a},aa=w.createContext({}),rs=({children:t})=>{const[a,n]=w.useState({}),[r,s]=w.useState({}),[i,o]=w.useState([]),[d,l]=w.useState(""),c=({name:p,value:f})=>{function g(b){return!isNaN(b)&&b!==null&&b!==""?parseFloat(b):null}let h=g(f);s(b=>{let v={...b},I=i==null?void 0:i.find($=>$.label.toLowerCase().replace(/ /g,"_")===p);return I?v[I.id]=h??f:v[p]=h??f,v})};w.useEffect(()=>{let p=i.map(f=>f.id==="owner.config"?[f.id,"yo_y_mis_equipos"]:f.id==="dependency"?[f.id,"ambas"]:[f.id,null]);s(f=>{let g={search:f==null?void 0:f.search,taskName:f==null?void 0:f.taskName};return g={...g,...Object.fromEntries(p)},g})},[i]);const u=()=>{let p=i.map(f=>f.id==="owner.config"?[f.id,"yo_y_mis_equipos"]:f.id==="dependency"?[f.id,"ambas"]:[f.id,null]);s(Object.fromEntries(p)),n(qt(Object.fromEntries(p)))},m=p=>({1:"Muy facil",2:"Facil",3:"Media",4:"Dificil",5:"Muy dificil"})[p],x=()=>{let p=qt(r);p.difficulty&&(p.difficulty=m(p.difficulty)),n(p)};return e.jsx(aa.Provider,{value:{fields:i,filters:a,path:d,defineFields:o,updateFilters:c,cleanFilters:u,applyFilters:x,initialFilters:r,selectPath:l},children:t})},Le=()=>w.useContext(aa),sa=w.createContext({}),ns=({children:t,user:a,url:n,mode:r})=>{const s=r==="prod"?"https://services.imjmedia.com.mx":"https://devobp.imjmedia.com.mx",i=jt.create({baseURL:n,headers:{Authorization:`Bearer ${a.accessToken}`},paramsSerializer:l=>Pe.stringify(l,{encodeValuesOnly:!0})}),o=()=>s,d=l=>l==="undefined"||l===void 0?"":`${s}${l}`;return e.jsx(sa.Provider,{value:{tasks_api:i,getOBPUrlApi:o,getImageOBP:d},children:t})},fe=()=>w.useContext(sa),ra=w.createContext({}),os=({children:t,user:a,url:n})=>{const r=jt.create({baseURL:n,headers:{Authorization:`Bearer ${a.accessToken}`},paramsSerializer:s=>Pe.stringify(s,{encodeValuesOnly:!0})});return e.jsx(ra.Provider,{value:{user:a,tasks_api:r},children:t})},Ee=()=>w.useContext(ra),he=t=>{const a=i=>Object.prototype.toString.call(i)==="[object Object]",n=i=>i&&typeof i=="object"&&("source"in i||"target"in i)&&!("attributes"in i),r=i=>i&&typeof i=="object"&&"position"in i&&typeof i.position=="object"&&("x"in i.position||"y"in i.position)&&!("attributes"in i),s=i=>i.attributes?{id:i.id,...i.attributes}:i;if(Array.isArray(t))return t.map(i=>he(i));if(a(t)){if(n(t)){const i={};for(const o in t)i[o]=he(t[o]);return i}if(r(t)){const i={};for(const o in t)i[o]=he(t[o]);return i}Array.isArray(t.data)?t=[...t.data]:a(t.data)?t=s({...t.data}):t.data===null?t=null:t=s(t);for(const i in t)t[i]=he(t[i]);return t}return t},qe=({imageUrl:t="https://www.uv.unach.mx/assets/img/prueba/directorio/userM.png",alt:a="avatar",size:n="s"})=>{const r={xs:"tw-w-[24px] tw-h-[24px] tw-min-w-[24px] tw-min-h-[24px]",s:"tw-w-[28px] tw-h-[28px] tw-min-w-[28px] tw-min-h-[28px]",m:"tw-w-[32px] tw-h-[32px] tw-min-w-[32px] tw-min-h-[32px]",l:"tw-w-[36px] tw-h-[36px] tw-min-w-[36px] tw-min-h-[36px]",xl:"tw-w-[40px] tw-h-[40px] tw-min-w-[40px] tw-min-h-[40px]",xxl:"tw-w-[44px] tw-h-[44px] tw-min-w-[44px] tw-min-h-[44px]"}[n];return e.jsx("img",{src:t===""?"https://www.uv.unach.mx/assets/img/prueba/directorio/userM.png":t,alt:a??"avatar",className:`${r} tw-bg-containers tw-rounded-full tw-border-2 tw-border-white`})},vt=t=>new Intl.DateTimeFormat("es-MX",{month:"long"}).format(t);function is(t){const a=["domingo","lunes","martes","miércoles","jueves","viernes","sábado"],n=new Date(t).getDay();return a[n]}const Lt=t=>{let a=t||new Date,n=a.getDate(),r=vt(a.getMonth()).slice(0,3),s=a.getFullYear().toString().slice(-2),i=is(a).slice(0,3);return`${i.charAt(0).toUpperCase()+i.slice(1)} ${n} ${r.charAt(0).toUpperCase()+r.slice(1)} ${s}`},Nt=(t,a)=>({...t,image:t.image?`${a}${t.image}`:""}),Ze=t=>{var a,n;return t?(a=t.responsable)!=null&&a.nombre?t.responsable.nombre:(n=t.equipo)!=null&&n.nombre?t.equipo.nombre:null:null};class ls{static toCampaignTasks(a){var i,o,d,l,c,u,m,x,p,f,g,h,b,v,I;const n=Ze(a==null?void 0:a.id_t_requerida),r=Ze(a==null?void 0:a.tarea_padre);let s=[];return a!=null&&a.responsable&&s.push({id:a.responsable.id,name:a.responsable.nombre,image:(c=(l=(d=(o=(i=a.responsable)==null?void 0:i.userOBP)==null?void 0:o.imagen)==null?void 0:d.formats)==null?void 0:l.thumbnail)==null?void 0:c.url,role:((u=a.responsable.userOBP)==null?void 0:u.role)||{id:0,name:""}}),(m=a==null?void 0:a.equipo)!=null&&m.miembros&&a.equipo.miembros.forEach($=>{var R,U,P,C,y;s!=null&&s.find(H=>H.id===$.idUser.id)||$.idUser&&s.push({id:$.idUser.id,name:$.idUser.nombre,image:(C=(P=(U=(R=$==null?void 0:$.userOBP)==null?void 0:R.imagen)==null?void 0:U.formats)==null?void 0:P.thumbnail)==null?void 0:C.url,role:((y=$.userOBP)==null?void 0:y.role)||{id:0,name:""}})}),{paused:a==null?void 0:a.pausada,isPrincipalTask:(a==null?void 0:a.tarea_principal)??!1,orden:(a==null?void 0:a.orden)??null,id:(a==null?void 0:a.id)??null,task:(a==null?void 0:a.texto_corto)??null,status:(a==null?void 0:a.estatus)??null,difficulty:(a==null?void 0:a.nivel_dificultad)??null,priority:(a==null?void 0:a.prioridad)??0,endDate:new Date((a==null?void 0:a.ffin)??null),startDate:new Date((a==null?void 0:a.finicio)??null),users:s,repeatsToDo:(a==null?void 0:a.repeticiones)??null,repeats:(a==null?void 0:a.repeticiones_realizadas)??null,comments:((x=a==null?void 0:a.comentarios)==null?void 0:x.length)??null,willBePaused:a==null?void 0:a.es_pausable,nameProject:((p=a==null?void 0:a.proyecto)==null?void 0:p.nombre)??null,idProject:((f=a==null?void 0:a.proyecto)==null?void 0:f.id)??null,medioName:(a==null?void 0:a.nombre_medio)??null,statusRequiredTask:((g=a==null?void 0:a.id_t_requerida)==null?void 0:g.estatus)??null,nameRequiredTask:((h=a==null?void 0:a.id_t_requerida)==null?void 0:h.texto_corto)??null,nameRequiredTaskResponsible:n,name_father_required_task:((b=a==null?void 0:a.tarea_padre)==null?void 0:b.texto_corto)??null,name_father_required_task_responsible:r,responsible:((v=a==null?void 0:a.responsable)==null?void 0:v.id)??null,tasks:((I=a==null?void 0:a.tareas)==null?void 0:I.map($=>({id:$.id,name:$.texto_corto,status:$.estatus})))??null,atraso:(a==null?void 0:a.atraso)??null,categoria:(a==null?void 0:a.categoria)??null,...(a==null?void 0:a.cambio_arte)&&{cambio_arte:a==null?void 0:a.cambio_arte}}}}const cs=async({filters:t,tasks_api:a,project:n})=>{try{const r=await a.get("/api/listado_tareas_flujo",{params:{...t,project:{id:n},includeAllTasks:!0,populate:"*"}}),s=he(r.data.tareas),i=Array.isArray(s)?s:[s],o=new Set;if(i.forEach(d=>{var l;(l=d==null?void 0:d.id_t_requerida)!=null&&l.id&&o.add(d.id_t_requerida.id)}),o.size>0){const d=Array.from(o),l=Pe.stringify({filters:{id:{$in:d}},populate:{responsable:{fields:["id","nombre"]},equipo:{fields:["id","nombre"]}}},{encodeValuesOnly:!0});try{const c=await a.get(`/api/tareas?${l}`),u=he(c.data.data||c.data),m=Array.isArray(u)?u:[u],x=new Map(m.map(p=>[p.id,p]));i.forEach(p=>{var f;if((f=p==null?void 0:p.id_t_requerida)!=null&&f.id){const g=x.get(p.id_t_requerida.id);g&&(p.id_t_requerida={...p.id_t_requerida,responsable:g.responsable||null,equipo:g.equipo||null})}})}catch{}}return i.map(ls.toCampaignTasks)}catch(r){console.log(r)}},na=w.createContext({}),ds=({children:t,project:a})=>{var b;const[n,r]=w.useState([]),[s,i]=w.useState(!1),[o,d]=w.useState([]),{tasks_api:l}=fe(),{filters:c}=Le(),{user:u}=Ee(),[m,x]=w.useState({owner:{user:u.id,config:((b=c==null?void 0:c.owner)==null?void 0:b.config)??"yo_y_mis_equipos"},project:{id:a}});w.useEffect(()=>{var v;if(Object.keys(c).length>0){const I={...c,owner:{user:u.id,config:((v=c==null?void 0:c.owner)==null?void 0:v.config)??"yo_y_mis_equipos"},project:{id:a}};x(I)}},[c,u.id,a]);const p=pe.useQuery({queryKey:["tasksProject",m,a],queryFn:()=>{const v={...m,taskName:c==null?void 0:c.taskName,owner:{...m.owner,config:m.owner.config||"yo_y_mis_equipos"}};return cs({filters:v,project:a,tasks_api:l})},refetchOnWindowFocus:!1}),f=v=>{r(I=>[...I,v])},g=v=>{d(I=>I.includes(v)?I.filter($=>$!==v):[...I,v])},h=a??null;return e.jsx(na.Provider,{value:{tasksProject:p,selectedTasks:n,projectID:h,openTasks:o,selectTask:f,filtersToSend:m,openTask:g,isRefetching:s,project:a,filters:c,setIsRefetching:i},children:t})},Qe=()=>w.useContext(na),oa=w.createContext(null),us=({children:t})=>{const[a,n]=w.useState({message:"",type:"success"}),r=(s,i)=>{n({message:s,type:i}),setTimeout(()=>n({message:"",type:"success"}),3e3)};return e.jsx(oa.Provider,{value:{toast:a,showSuccess:s=>r(s,"success"),showError:s=>r(s,"error")},children:t})},Tt=()=>w.useContext(oa);class ia{static toAtrasoReasons(a){return{id:a.id,motivo_imj:a.motivo_imj,categoria:a.categoria??null}}}const ps=async({tasks_api:t})=>{try{const a=await t.get("/api/motivos",{params:{populate:{categoria:{fields:["id","nombre","tipo"]}},filters:{tipo:{$eq:"atraso"}}}});return he(a.data).map(ia.toAtrasoReasons)}catch(a){throw console.log("Error al obtener los motivos de atraso",a),`Error al obtener los motivos de atraso: ${a}`}},la=({enabled:t=!1}={})=>{const{tasks_api:a}=fe(),{user:n}=Ee(),r=pe.useQueryClient(),{showSuccess:s,showError:i}=Tt(),{filters:o,path:d}=Le(),{data:l,isLoading:c}=pe.useQuery({queryKey:["atraso_reasons"],queryFn:()=>ps({tasks_api:a}),staleTime:1e3*60*60*24,enabled:t}),u=async()=>{const $=await a.get("/api/motivos",{params:{filters:{tipo:{$eq:"atraso"}}}});return he($.data).map(ia.toAtrasoReasons)},m=async({taskId:$,motivoId:R,projectID:U})=>{try{return(await a.post("/api/atrasos",{data:{inicio:new Date,fin:null,motivo:R,proyecto:U,tarea:$,creada_por:n==null?void 0:n.id}})).data}catch(P){console.log("error",P)}},x=async $=>{try{return(await a.delete(`/api/atrasos/${$}`)).data}catch(R){console.log("error",R)}},p=async $=>{try{return(await a.put(`/api/atrasos/${$}`,{data:{fin:new Date}})).data}catch(R){console.log("error",R)}},f=async({taskId:$,projectID:R,motivo:U})=>{await b({taskId:$,motivoId:U,projectID:R})},g=async $=>{await v($)},h=async $=>{await I($)},{mutateAsync:b}=pe.useMutation({mutationFn:m,onSuccess:()=>{s("Atraso registrado correctamente"),d==="kanban-general"&&(r.invalidateQueries({queryKey:["to_do_tasks",o]}),r.invalidateQueries({queryKey:["working_tasks",o]})),d==="kanban-campania"&&r.invalidateQueries({queryKey:["tasksProject"]})},onError:()=>{i("Error al registrar el atraso")}}),{mutateAsync:v}=pe.useMutation({mutationFn:x,onSuccess:()=>{s("Atraso eliminado correctamente"),d==="kanban-general"&&(r.invalidateQueries({queryKey:["to_do_tasks"]}),r.invalidateQueries({queryKey:["working_tasks"]}),r.invalidateQueries({queryKey:["done_tasks"]})),d==="kanban-campania"&&r.invalidateQueries({queryKey:["tasksProject"]})},onError:()=>{i("Error al eliminar el atraso")}}),{mutateAsync:I}=pe.useMutation({mutationFn:p,onSuccess:()=>{s("Atraso finalizado correctamente")},onError:()=>{i("Error al finalizar el atraso")}});return{atrasoReasons:l,isLoading:c,createAtraso:f,getAtrasoReasons:u,deleteAtraso:g,finalizarAtraso:h}},Ue=()=>{const{tasks_api:t}=fe(),{user:a}=Ee(),{filters:n,path:r}=Le(),s=pe.useQueryClient(),{projectID:i}=Qe(),{showSuccess:o,showError:d}=Tt(),{finalizarAtraso:l}=la({enabled:!1}),c=async({id:F})=>(await t.put(`/api/tareas/${F}`,{data:{estatus:1,responsable:a==null?void 0:a.id,updated_by:a==null?void 0:a.id}})).data,u=async({id:F})=>(await t.put(`/api/tareas/${F}`,{data:{estatus:0,responsable:a==null?void 0:a.id,updated_by:a==null?void 0:a.id}})).data,m=async({id:F,idAtraso:D})=>{const M=await t.post("/api/terminarTarea",{id_task:F,ended_at:new Date().toISOString(),id_user:a==null?void 0:a.id});return await l(D),M.data},x=async({id:F,repeats:D})=>(await t.put(`/api/tareas/${F}`,{data:{repeticiones_realizadas:D,updated_by:a==null?void 0:a.id}})).data,p=async({id:F,motiveId:D})=>{try{const M=await t.post("/api/pausarTarea",{taskId:F,userId:a==null?void 0:a.id,motivoId:D});return o("Tarea pausada correctamente"),M.data}catch(M){d("Error al pausar la tarea: "+M)}},f=async({id:F})=>{try{const D=await t.post("/api/reanudarTarea",{taskId:F});return o("Tarea reanudada correctamente"),D.data}catch(D){d("Error al reanudar la tarea: "+D)}},g=async({id:F,idNewResponsible:D,typeOfSelect:M})=>{let L={updated_by:a==null?void 0:a.id};return M==="responsible"&&(L={...L,responsable:D}),M==="team"&&(L={...L,responsable:null,equipo:D}),(await t.put(`/api/tareas/${F}`,{data:L})).data},h=async({id:F,data:D,user:M})=>{try{return(await t.put(`/api/tareas/${F}`,{data:{...D,updated_by:M==null?void 0:M.id}})).data}catch(L){console.error("Error updating the element:",L)}},b=async({id:F})=>{await $({id:F})},v=async({id:F,data:D,user:M})=>{await I({id:F,data:D,user:M})},{mutateAsync:I}=pe.useMutation({mutationFn:h,onSuccess:()=>{o("Tarea actualizada correctamente");const F={"kanban-general":"to_do_tasks","kanban-campania":"tasksProject"};try{r==="kanban-general"&&(s.invalidateQueries({queryKey:[F[r],n]}),s.invalidateQueries({queryKey:["done_tasks",n]}),s.invalidateQueries({queryKey:["working_tasks",n]})),r==="kanban-campania"&&(s.invalidateQueries({queryKey:["tasksProject"]}),s.invalidateQueries({queryKey:["tasksProject",n,i]}))}catch(D){console.error("Error invalidating queries:",D)}},onError:F=>{console.error("Failed to update the task.",F)},onMutate:async()=>{await s.cancelQueries({queryKey:["working_tasks"]})}}),{mutateAsync:$}=pe.useMutation({mutationFn:c,onSuccess:()=>{const F={"kanban-general":"to_do_tasks","kanban-campania":"tasksProject"};try{r==="kanban-general"&&(s.invalidateQueries({queryKey:[F[r],n]}),s.invalidateQueries({queryKey:["working_tasks",n]})),r==="kanban-campania"&&(s.invalidateQueries({queryKey:["tasksProject"]}),s.invalidateQueries({queryKey:["tasksProject",n,i]}))}catch(D){console.error("Error updating the element:",D)}},onError:F=>{console.error("Failed to update the task.",F)},onMutate:async()=>{await s.cancelQueries({queryKey:["working_tasks"]}),await s.cancelQueries({queryKey:["to_do_tasks"]})}}),{mutateAsync:R}=pe.useMutation({mutationFn:m,onSuccess:()=>{const F={"kanban-general":"to_do_tasks","kanban-campania":"tasksProject"};try{s.setQueryData([F[r],n],D=>{console.log({oldData:D})}),r==="kanban-general"&&(s.invalidateQueries({queryKey:[F[r],n]}),s.invalidateQueries({queryKey:["done_tasks",n]}),s.invalidateQueries({queryKey:["working_tasks",n]})),r==="kanban-campania"&&(s.invalidateQueries({queryKey:["tasksProject"]}),s.invalidateQueries({queryKey:["tasksProject",n,i]}))}catch(D){console.error("Error invalidating queries:",D)}},onError:F=>{console.error("Failed to update the task.",F)},onMutate:async()=>{await s.cancelQueries({queryKey:["working_tasks"]}),await s.cancelQueries({queryKey:["done_tasks"]}),await s.cancelQueries({queryKey:["to_do_tasks"]})}}),{mutateAsync:U}=pe.useMutation({mutationFn:x,onSuccess:()=>{const F={"kanban-general":"to_do_tasks","kanban-campania":"tasksProject"};try{r==="kanban-general"&&(s.invalidateQueries({queryKey:[F[r],n]}),s.invalidateQueries({queryKey:["done_tasks",n]}),s.invalidateQueries({queryKey:["working_tasks",n]})),r==="kanban-campania"&&(s.invalidateQueries({queryKey:["tasksProject"]}),s.invalidateQueries({queryKey:["tasksProject",n,i]}))}catch(D){console.error("Error invalidating queries:",D)}},onError:F=>{console.error("Failed to update the task.",F)},onMutate:async()=>{await s.cancelQueries({queryKey:["working_tasks"]}),await s.cancelQueries({queryKey:["done_tasks"]}),await s.cancelQueries({queryKey:["to_do_tasks"]})}}),{mutateAsync:P}=pe.useMutation({mutationFn:g,onSuccess:()=>{const F={"kanban-general":"to_do_tasks","kanban-campania":"tasksProject"};try{r==="kanban-general"&&(s.invalidateQueries({queryKey:[F[r],n]}),s.invalidateQueries({queryKey:["done_tasks",n]}),s.invalidateQueries({queryKey:["working_tasks",n]})),r==="kanban-campania"&&(s.invalidateQueries({queryKey:["tasksProject"]}),s.invalidateQueries({queryKey:["tasksProject",n,i]}))}catch(D){console.error("Error invalidating queries:",D)}},onError:F=>{console.error("Failed to reassign the task.",F)},onMutate:async()=>{await s.cancelQueries({queryKey:["working_tasks"]}),await s.cancelQueries({queryKey:["done_tasks"]}),await s.cancelQueries({queryKey:["to_do_tasks"]})}}),{mutateAsync:C}=pe.useMutation({mutationFn:u,onSuccess:()=>{const F={"kanban-general":"to_do_tasks","kanban-campania":"tasksProject"};try{r==="kanban-general"&&(s.invalidateQueries({queryKey:[F[r],n]}),s.invalidateQueries({queryKey:["working_tasks",n]})),r==="kanban-campania"&&(s.invalidateQueries({queryKey:["tasksProject"]}),s.invalidateQueries({queryKey:["tasksProject",n,i]}))}catch(D){console.error("Error updating the element:",D)}},onError:F=>{console.error("Failed to update the task.",F)},onMutate:async()=>{await s.cancelQueries({queryKey:["working_tasks"]}),await s.cancelQueries({queryKey:["to_do_tasks"]})}});return{updatingTask:v,updateTask:h,startTask:async({id:F})=>{await C({id:F})},startWorking:b,completeTask:async({id:F,idAtraso:D})=>{await R({id:F,idAtraso:D})},reasignResponsible:async({id:F,idNewResponsible:D,typeOfSelect:M})=>{await P({id:F,idNewResponsible:D,typeOfSelect:M})},updateUnitys:async({repeats:F,id:D})=>{await U({repeats:F,id:D})},pauseTask:async({id:F,motiveId:D})=>{console.log({taksId:F,motivoId:D,user:a==null?void 0:a.id})},postPauseTask:p,postReanudeTask:f}},ws=({id:t,idAtraso:a})=>{const[n,r]=w.useState(!1),{completeTask:s}=Ue();return{checked:n,checkTask:()=>{r(!n),s({id:t,idAtraso:a})}}},Ot={checked:"tw-mx-[2px] tw-flex tw-h-[20px] tw-w-[20px] tw-items-center tw-justify-center tw-rounded-full tw-bg-success-regular tw-transition-all",unchecked:"tw-transition-colors"},ms="tw-mx-[2px] tw-flex tw-items-center tw-justify-center tw-rounded-full tw-bg-success-regular tw-transition-all",Rt="tw-shadow-black-300 tw-text-s tw-absolute tw-left-0 tw-top-full tw-z-10 tw-ml-[-2rem] tw-mt-2 tw-flex tw-w-fit tw-max-w-[400px] tw-flex-col tw-gap-m tw-rounded-lg tw-border-l-[5px] tw-border-warning-regular tw-bg-warning-light tw-p-l tw-text-warning-dark tw-shadow-xl",ca=({id:t,nameRequiredTask:a,statusRequiredTask:n,status:r,idAtraso:s,nameRequiredTaskResponsible:i,name_father_required_task:o,name_father_required_task_responsible:d,repeatsAreCompleted:l=!1})=>{const c=w.useId(),u=`checkbox-${t}-${c}`,{checked:m,checkTask:x}=ws({id:t,idAtraso:s}),f=!!(a&&a!==""&&n===2)||!a,g=!!o,h=r===1&&l,b=()=>e.jsx("label",{htmlFor:u,className:m?Ot.checked:Ot.unchecked,children:e.jsx(ie.Icons,{icon:m?"check_outline":"circle_checked",color:m?"white":Z.texts.placeholder,strokeWidth:4,size:m?"xs":"s"})});return r===2?e.jsx("div",{className:ms,children:e.jsx(ie.Icons,{icon:"circle_checked",color:"white",strokeWidth:4,size:"xs"})}):g?e.jsxs(e.Fragment,{children:[e.jsx(ie.Tooltip,{dispatch:e.jsx("label",{className:"tw-cursor-help","aria-hidden":!0,children:e.jsx(ie.Icons,{icon:"info_circle",color:Z.warning.regular,strokeWidth:4})}),children:e.jsxs("div",{className:Rt,children:[e.jsx("p",{className:"tw-w-[210px] tw-font-bold",children:"Tarea padre:"}),e.jsx("p",{children:o}),d&&e.jsxs("p",{className:"tw-font-bold",children:["Responsable: ",e.jsx("span",{className:"tw-font-normal",children:d})]}),e.jsx("span",{className:"tw-font-normal tw-italic tw-text-[#919191]",children:"Esta tarea completa automáticamente la tarea padre."})]})}),h&&b(),e.jsx("input",{id:u,checked:m,onChange:x,type:"checkbox",className:"tw-hidden","aria-hidden":!0})]}):f?e.jsxs(e.Fragment,{children:[r===1&&b(),e.jsx("input",{id:u,checked:m,onChange:x,type:"checkbox",className:"tw-hidden","aria-hidden":!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(ie.Tooltip,{dispatch:e.jsx("label",{className:"tw-cursor-help","aria-hidden":!0,children:e.jsx(ie.Icons,{icon:"info_circle",color:Z.warning.regular,strokeWidth:4})}),children:e.jsxs("div",{className:Rt,children:[e.jsx("p",{className:"tw-w-[210px] tw-font-bold",children:"Requiere completar su tarea:"}),e.jsx("p",{children:a}),i&&e.jsxs("p",{className:"tw-font-bold",children:["Responsable: ",e.jsx("span",{className:"tw-font-normal",children:i})]})]})}),e.jsx("input",{id:u,checked:m,onChange:x,type:"checkbox",className:"tw-hidden","aria-hidden":!0})]})},da=()=>{const t=()=>e.jsxs("div",{className:"tw-flex tw-w-full tw-gap-m",children:[e.jsx("div",{className:"tw-h-[30px] tw-min-h-[30px] tw-w-[30px] tw-min-w-[30px] tw-animate-pulse tw-rounded-full tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-w-[30%] tw-animate-pulse tw-rounded-md tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-min-h-[30px] tw-w-[30px] tw-min-w-[30px] tw-animate-pulse tw-rounded-lg tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-min-h-[30px] tw-w-[30px] tw-min-w-[30px] tw-animate-pulse tw-rounded-lg tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-min-h-[30px] tw-w-[30px] tw-min-w-[30px] tw-animate-pulse tw-rounded-lg tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-w-[10%] tw-animate-pulse tw-rounded-md tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-min-h-[30px] tw-w-[30px] tw-min-w-[30px] tw-animate-pulse tw-rounded-lg tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-w-[10%] tw-animate-pulse tw-rounded-md tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-min-h-[30px] tw-w-[30px] tw-min-w-[30px] tw-animate-pulse tw-rounded-lg tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-min-h-[30px] tw-w-[30px] tw-min-w-[30px] tw-animate-pulse tw-rounded-lg tw-bg-gray-200"})]});return e.jsxs("div",{className:"tw-flex tw-flex-col tw-gap-m",children:[e.jsx(t,{}),e.jsxs("div",{className:"tw-flex tw-flex-col tw-gap-m tw-pl-5",children:[e.jsx(t,{}),e.jsx("div",{className:"tw-pl-5",children:e.jsx(t,{})})]}),e.jsx(t,{}),e.jsxs("div",{className:"tw-flex tw-flex-col tw-gap-m tw-pl-5",children:[e.jsx(t,{}),e.jsx("div",{className:"tw-pl-5",children:e.jsx(t,{})})]})]})},Bt=[{label:"Tipo de dependencia",type:"select",id:"dependency",options:[{id:"con",name:"Con dependencia"},{id:"sin",name:"Sin dependencia"},{id:"ambas",name:"Ambas"}]},{label:"Por campaña",type:"select",id:"project.id",options:[]},{label:"Por responsable",type:"select",id:"owner.config",options:[{id:"yo",name:"Mis tareas"},{id:"yo_y_mis_equipos",name:"Tareas mías y de mis equipos"},{id:"mis_equipos",name:"Tareas de mis equipos"}]},{label:"Por ejecutivo comercial",type:"select",id:"salesman.id",options:[]},{label:"Por dificultad",type:"select",id:"difficulty",options:[{id:1,name:"Muy facil"},{id:2,name:"Facil"},{id:3,name:"Media"},{id:4,name:"Dificil"},{id:5,name:"Muy dificil"}]}],$t=[{label:"Responsable",type:"select",id:"responsable.responsableType",options:[{id:"yo_y_mis_equipos",name:"Yo y mis equipos"},{id:"mis_equipos",name:"Mis equipos"},{id:"yo",name:"Yo"}]},{label:"Por Ejecutivo",type:"select",id:"ejecutivo",options:[]}],fs=({setPath:t,setProject:a})=>{const[n,r]=w.useState([]),[s,i]=w.useState(!0),[o,d]=w.useState(0),[l,c]=w.useState(10),[u,m]=w.useState(0),[x,p]=w.useState(),[f,g]=w.useState(0),{filters:h,defineFields:b}=Le(),{tasks_api:v,getImageOBP:I}=fe(),{user:$}=Ee(),R=async(j,F)=>{var D,M,L,W,ae;try{i(!0);const X={filters:{search:(h==null?void 0:h.search)??"",responsable:{idUser:$.id,responsableType:(D=h==null?void 0:h.responsable)==null?void 0:D.responsableType},ejecutivo:(h==null?void 0:h.ejecutivo)??""}},oe=await v.get("/api/listado_campanias",{params:{pagination:{page:j,pageSize:F},orderBy:x,...X}}),te=he(oe==null?void 0:oe.data);r(te),m((L=(M=oe==null?void 0:oe.data)==null?void 0:M.meta)==null?void 0:L.total),g((ae=(W=oe==null?void 0:oe.data)==null?void 0:W.meta)==null?void 0:ae.pageCount)}catch(X){console.error("Error fetching data en Lista Campaña:",X)}finally{i(!1)}},U=async()=>{try{const j=await v.get("/api/obtener-comerciales");return[...$t].map(D=>(D.id==="ejecutivo"&&(D.options=j.data.map(M=>({id:M.nombre,name:M.nombre}))),D))}catch(j){return console.error("Error fetching salesman data:",j),[...$t]}};w.useEffect(()=>{(async()=>{const F=await U();b(F)})()},[]),w.useEffect(()=>{const j=Math.floor(o/l)+1;R(j,l)},[o,l,x,h]);const P=j=>{d(j.first),c(j.rows)},C=[{label:"5 filas",value:5},{label:"10 filas",value:10},{label:"15 filas",value:15},{label:"20 filas",value:20},{label:"25 filas",value:25},{label:"50 filas",value:50}],y=j=>{const F=parseInt(j.target.value,10);c(F),P({first:0,rows:F})},H=j=>{p(F=>F===j?`${j}:desc`:j)},G=j=>x===j?"↑↓":x===`${j}:desc`?"↓↑":"↑↓",J=j=>({padding:"auto",backgroundColor:Z.silver.silver_light,borderRadius:"50%",cursor:j?"not-allowed":"pointer",transition:"all 0.2s ease",marginRight:"4px",border:`1px solid ${j?Z.gray.gray_regular:Z.gray.gray_dark}`,color:j?Z.gray.gray_regular:Z.black.black_dark,width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"});return e.jsx("div",{className:"tw-w-full tw-rounded-lg tw-p-4 tw-shadow-md",style:{background:Z.bg.content,display:"flex",flexDirection:"column",height:"100%"},children:s?e.jsx("div",{className:"tw-w-full",children:e.jsx(da,{})}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"tw-flex tw-h-full tw-flex-col",children:[e.jsx("div",{className:"tw-flex-1 tw-overflow-auto",children:e.jsxs("table",{className:"tw-w-full tw-table-auto tw-border-collapse",style:{borderCollapse:"collapse",width:"100%",borderSpacing:"0"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{color:Z.gray.gray_regular},children:[e.jsx("th",{onClick:()=>H("nombre"),style:{color:Z.gray.gray_dark,textAlign:"left"},children:e.jsxs("div",{className:"tw-flex tw-w-fit tw-items-center tw-space-x-1",style:{display:"flex",alignItems:"center"},children:[e.jsx("label",{className:"tw-text-s",style:{color:Z.gray.gray_dark},children:G("nombre")}),e.jsx("span",{className:"tw-align-middle tw-font-sans tw-text-[1.4rem] tw-font-normal tw-leading-[100%] tw-tracking-normal",children:"Campaña"})]})}),e.jsx("th",{onClick:()=>H("inicia"),className:"tw-whitespace-nowrap",style:{color:Z.gray.gray_dark,textAlign:"left"},children:e.jsxs("div",{className:"tw-flex tw-w-fit tw-items-center tw-space-x-1",children:[e.jsx("label",{style:{color:Z.gray.gray_dark},children:G("inicia")}),e.jsx(ie.Icons,{icon:"calendar",size:"xs",strokeWidth:5,color:Z.gray.gray_dark,className:"tw-mt-1 tw-h-[15px] tw-w-[15px]"}),e.jsx("span",{style:{color:Z.gray.gray_dark},className:"tw-align-middle tw-font-sans tw-text-[1.4rem] tw-font-normal tw-leading-[100%] tw-tracking-normal",children:"Fecha Inicio"})]})}),e.jsx("th",{onClick:()=>H("termina"),className:"tw-whitespace-nowrap",style:{color:Z.gray.gray_dark,textAlign:"left"},children:e.jsxs("div",{className:"tw-flex tw-w-fit tw-items-center",children:[e.jsx("label",{style:{color:"#C4C4C4"},children:G("termina")}),e.jsx(ie.Icons,{icon:"calendar",size:"xs",strokeWidth:5,color:Z.gray.gray_dark,className:"tw-mt-1 tw-h-[15px] tw-w-[15px]"}),e.jsx("span",{className:"tw-align-middle tw-font-sans tw-text-[1.4rem] tw-font-normal tw-leading-[100%] tw-tracking-normal",children:"Fecha Fin"})]})}),e.jsx("th",{className:"align-middle tw-whitespace-nowrap tw-text-center",style:{color:Z.gray.gray_dark},children:e.jsx("div",{className:"tw-inline-flex tw-w-full tw-items-center tw-justify-center",children:e.jsx("span",{className:"tw-font-sans tw-text-[1.4rem] tw-font-normal tw-leading-[100%] tw-tracking-normal",children:"Status de campaña"})})}),e.jsx("th",{className:"align-middle tw-whitespace-nowrap tw-text-center",style:{color:Z.gray.gray_dark},children:e.jsx("div",{className:"tw-inline-flex tw-w-full tw-items-center tw-justify-center",children:e.jsx("span",{className:"tw-font-sans tw-text-[1.4rem] tw-font-normal tw-leading-[100%] tw-tracking-normal",children:"Progreso de Ejecución"})})}),e.jsx("th",{className:"align-middle tw-whitespace-nowrap tw-text-center",style:{color:Z.gray.gray_dark},children:e.jsx("div",{className:"tw-inline-flex tw-w-full tw-items-center tw-justify-center",children:e.jsx("span",{className:"tw-font-sans tw-text-[1.4rem] tw-font-normal tw-leading-[100%] tw-tracking-normal",children:"Responsable"})})})]})}),e.jsx("tbody",{children:n==null?void 0:n.map((j,F)=>{var D,M,L,W,ae,X,oe,te,q,z,V,E,S,O,N,_,B,k;return e.jsxs("tr",{style:{background:F%2===0?"#F5F5F5":"#FAFAFA",transition:"background-color 0.2s ease"},className:"tw-cursor-pointer ",onClick:()=>{a({id:j==null?void 0:j.id,project:j==null?void 0:j.nombre}),t("kanban-campania")},onMouseEnter:T=>{T.currentTarget.style.backgroundColor="#E1EBF9"},onMouseLeave:T=>{T.currentTarget.style.backgroundColor=F%2===0?"#F5F5F5":"#FAFAFA"},children:[e.jsx("td",{className:"tw-text-s",children:(D=j==null?void 0:j.campania)==null?void 0:D.nombre}),e.jsx("td",{className:"tw-text-s",children:(M=j==null?void 0:j.campania)==null?void 0:M.inicia}),e.jsx("td",{className:"tw-text-s",children:(L=j==null?void 0:j.campania)==null?void 0:L.termina}),e.jsx("td",{className:"tw-text-s",children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",padding:"none",width:"auto",minWidth:"100px"},children:[e.jsxs("label",{className:"tw-text-black tw-w-[50px] tw-min-w-[50px] tw-text-right",children:[j==null?void 0:j.progreso,"%"]}),e.jsx("div",{style:{position:"relative",height:"10px",flex:1,backgroundColor:Z.gray.gray_dark,borderRadius:"10px",overflow:"hidden",maxWidth:"140px"},children:e.jsx("div",{style:{position:"absolute",top:0,left:0,height:"100%",width:`${j.progreso}%`,backgroundColor:j.progreso===100?Z.progressbar.green_regular:j.progreso>50?Z.progressbar.blue_regular:j.progreso>0?Z.progressbar.orange_regular:Z.gray.gray_dark,borderRadius:"10px",transition:"width 0.3s ease-in-out"}})})]})}),e.jsx("td",{className:"tw-text-s",children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",padding:"none",width:"auto",minWidth:"100px"},children:[e.jsxs("label",{className:"tw-text-black tw-w-[50px] tw-min-w-[50px] tw-text-right",children:[(j==null?void 0:j.progresoVenta)??0,"%"]}),e.jsx("div",{className:"tw-inline-flex tw-w-full tw-items-center tw-justify-center",style:{position:"relative",height:"10px",flex:1,backgroundColor:Z.gray.gray_dark,borderRadius:"10px",overflow:"hidden",maxWidth:"180px"},children:e.jsx("div",{style:{position:"absolute",top:0,left:0,height:"100%",width:`${(j==null?void 0:j.progresoVenta)??0}%`,backgroundColor:(j==null?void 0:j.progresoVenta)===100?Z.progressbar.green_regular:(j==null?void 0:j.progresoVenta)>50?Z.progressbar.blue_regular:(j==null?void 0:j.progresoVenta)>0?Z.progressbar.orange_regular:Z.gray.gray_dark,borderRadius:"10px",transition:"width 0.3s ease-in-out"}})})]})}),e.jsx("td",{className:"tw-text-s tw-pb-[1.2rem] tw-pt-[1.2rem]",children:e.jsxs("div",{className:"tw-text-s tw-flex tw-items-center tw-justify-center",children:[e.jsx(qe,{imageUrl:(te=(oe=(X=(ae=(W=j==null?void 0:j.campania)==null?void 0:W.responsable)==null?void 0:ae.imagen)==null?void 0:X.formats)==null?void 0:oe.thumbnail)!=null&&te.url?I((S=(E=(V=(z=(q=j==null?void 0:j.campania)==null?void 0:q.responsable)==null?void 0:z.imagen)==null?void 0:V.formats)==null?void 0:E.thumbnail)==null?void 0:S.url):"",alt:(_=(N=(O=j==null?void 0:j.campania)==null?void 0:O.responsable)==null?void 0:N.nombre)==null?void 0:_.charAt(0)}),e.jsx("span",{className:"tw-text-s tw-ml-4",children:(k=(B=j==null?void 0:j.campania)==null?void 0:B.responsable)==null?void 0:k.nombre})]})})]},F)})})]})}),e.jsxs("div",{className:"tw-mt-4 tw-flex tw-items-center tw-justify-between tw-p-2",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-start",color:Z.black.black_dark},className:"tw-whitespace-nowrap tw-font-sans tw-text-[1.4rem] tw-font-semibold tw-leading-none tw-tracking-normal tw-text-[#696E79]",children:[f," elementos de ",u]}),e.jsx(as.Paginator,{first:o,rows:l,totalRecords:u,rowsPerPageOptions:[5,10,20,50],onPageChange:P,className:"tw-flex tw-w-full tw-items-center tw-justify-center tw-gap-1 tw-rounded-lg tw-p-2",style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"4px",width:"auto",minWidth:"fit-content"},template:{layout:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink",FirstPageLink:j=>e.jsx("button",{onClick:j.onClick,disabled:j.disabled,style:J(j.disabled),className:"tw-text-s tw-flex tw-items-center tw-justify-center",children:"<<"}),PrevPageLink:j=>e.jsx("button",{onClick:j.onClick,disabled:j.disabled,style:J(j.disabled),className:"tw-text-s",children:"<"}),NextPageLink:j=>e.jsx("button",{onClick:j.onClick,disabled:j.disabled,style:J(j.disabled),className:"tw-text-s",children:">"}),LastPageLink:j=>e.jsx("button",{onClick:j.onClick,disabled:j.disabled,style:J(j.disabled),className:"tw-text-s",children:">>"}),PageLinks:j=>e.jsx("span",{style:{display:"inline-flex",gap:"1px"},children:e.jsx("button",{onClick:F=>j.onClick(F),className:`tw-text-s tw-flex tw-items-center tw-justify-center ${j.className.includes("p-highlight")?"highlighted":""}`,style:{...J(!1),backgroundColor:j.className.includes("p-highlight")?"#E1EBF9":Z.silver.silver_light,color:Z.black.black_dark},children:j.page+1})})}}),e.jsxs("div",{className:"tw-flex tw-items-center tw-gap-2",children:[e.jsx("span",{className:"tw-whitespace-nowrap tw-font-sans tw-text-[1.4rem] tw-font-semibold tw-leading-none tw-tracking-normal tw-text-[#696E79]",children:"Filas por página:"}),e.jsx("select",{style:{padding:"0.25rem",outline:"none",cursor:"pointer",border:`1px solid ${Z.gray.gray_dark}`,borderRadius:"4px"},className:"tw-whitespace-nowrap tw-font-sans tw-text-[1.4rem] tw-font-[400] tw-leading-none tw-tracking-normal tw-text-[#696E79]",value:l,onChange:j=>y(j),children:C.map(j=>e.jsx("option",{value:j.value,className:"tw-text-s",style:{color:Z.gray.gray_dark},children:j.label},j.value))})]})]})]})})})},Ct=()=>{const[t,a]=w.useState(null);return{position:t,setElementPosition:i=>{var c;let o=(c=i.current)==null?void 0:c.getBoundingClientRect(),d=(o==null?void 0:o.x)+((o==null?void 0:o.width)??0),l=(o==null?void 0:o.y)+(o==null?void 0:o.height);a(t?null:{x:d??0,y:l??0})},getChildrenSize:i=>{var o;return(o=i.current)==null?void 0:o.getBoundingClientRect()},clearPosition:()=>{a(null)}}},xs=({children:t,filterChildren:a})=>{const{position:n,setElementPosition:r}=Ct(),s=w.useRef(null),i=({children:o})=>{const[d,l]=w.useState();return w.useEffect(()=>{var c,u;a.current&&l(((n==null?void 0:n.x)??0)-(((u=(c=a.current)==null?void 0:c.getBoundingClientRect())==null?void 0:u.width)??0))},[a==null?void 0:a.current,n==null?void 0:n.x]),n&&tt.createPortal(e.jsx("div",{className:`tw-absolute tw-h-fit tw-w-fit ${d?"tw-block":"tw-hidden"}`,style:{top:`${n==null?void 0:n.y}px`,left:`${d}px`,zIndex:1},"data-portal-host":!0,children:o}),document.body)};return e.jsxs(e.Fragment,{children:[e.jsxs("label",{ref:s,htmlFor:"filter-button",className:"tw-flex tw-h-[30px] tw-cursor-pointer tw-items-center tw-gap-m tw-rounded-lg tw-bg-bg tw-fill-texts-enfasis tw-p-s tw-px-l tw-text-xl tw-text-texts-enfasis tw-shadow-button-primary hover:tw-shadow-button-primary-hover",children:[e.jsx(ie.Icons,{icon:"filter",size:"xs",strokeWidth:5,color:Z.primary.regular}),"Filtrar"]}),e.jsx("button",{className:"tw-hidden",id:"filter-button",onClick:()=>{r(s)}}),e.jsx(i,{children:t})]})};function gs(t,a=300,n={leading:!1,trailing:!0}){let r,s=null;return function(...i){const o=Date.now(),d=n.leading&&!s;clearTimeout(r),d&&t(...i),s=o,r=setTimeout(()=>{n.trailing&&(!n.leading||o-s>=a)&&(t(...i),s=null)},a)}}const hs="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='uuid-870f9847-3249-4f3d-96c6-7627dd5f9e7b'%20data-name='Iconos'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2050%2050'%3e%3cdefs%3e%3cstyle%3e%20.uuid-4d76d382-032b-400f-b22d-b6e7be4cfaae%20{%20fill:%20none;%20stroke:%20%23252525;%20stroke-linecap:%20round;%20stroke-linejoin:%20round;%20stroke-width:%204px;%20}%20%3c/style%3e%3c/defs%3e%3ccircle%20class='uuid-4d76d382-032b-400f-b22d-b6e7be4cfaae'%20cx='19.79'%20cy='19.79'%20r='13.54'/%3e%3cline%20class='uuid-4d76d382-032b-400f-b22d-b6e7be4cfaae'%20x1='41.67'%20y1='41.67'%20x2='29.17'%20y2='29.17'/%3e%3c/svg%3e",ua=({options:t,onselect:a})=>{const[n,r]=w.useState(null),s=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),i=[...t].filter(o=>o.name.toLowerCase().includes((n==null?void 0:n.toLowerCase())??""));return e.jsxs("div",{className:"tw-h-fit tw-w-full tw-min-w-max",children:[e.jsxs("div",{className:"tw-relative tw-flex tw-items-center",children:[e.jsx("input",{id:s,value:n??"",onChange:o=>r(o.target.value),type:"text",className:"tw-border-cards tw-h-[32px] tw-w-full tw-rounded-lg tw-bg-bg-card tw-p-2",placeholder:"Buscar"}),e.jsx("div",{className:"tw-absolute tw-right-[8px]",children:e.jsx("img",{src:hs,alt:"Icono",className:"tw-h-[12px] tw-w-[12px]"})})]}),e.jsx("div",{className:"tw-border-cards tw-flex tw-max-h-[120px] tw-min-w-max tw-flex-col tw-gap-s tw-overflow-y-auto tw-rounded-lg tw-bg-bg-card tw-p-2",children:i.map(o=>e.jsxs("button",{onClick:()=>{a(o)},className:"tw-flex tw-min-w-full tw-max-w-[200px] tw-cursor-pointer tw-items-center tw-gap-s hover:tw-bg-primary-light",children:[o.image&&e.jsx(qe,{imageUrl:o.image,alt:o.name}),e.jsx("p",{className:"tw-text-s tw-content-text tw-truncate tw-py-m tw-font-normal tw-text-texts-subtext",children:o.name})]}))})]})},bs=({error:t,options:a,onSelect:n,initialValue:r})=>{const[s,i]=w.useState(!1),[o,d]=w.useState((r==null?void 0:r.name)??null);return w.useEffect(()=>{r&&d(r)},[r]),e.jsxs("div",{className:"tw-relative",children:[e.jsxs("div",{onBlur:()=>i(!1),onClick:()=>i(!s),className:`tw-z-[1] tw-w-full tw-cursor-pointer tw-bg-bg-card ${t?"tw-border-2 tw-border-danger-regular tw-shadow-danger-regular":"tw-shadow-input"} tw-flex tw-h-[30px] tw-items-center tw-justify-between tw-rounded-md tw-pl-2 ${t?"tw-text-danger-regular":o?"tw-text-texts-subtext":"tw-text-texts-placeholder"}`,children:[e.jsx("p",{children:(o==null?void 0:o.name)??"Selecciona una opción"}),e.jsx(ie.Icons,{icon:"angle_down_outline",color:t?Z.danger.regular:Z.texts.placeholder})]}),s&&e.jsx("div",{className:"absolute tw-z-[10] tw-w-full tw-rounded-lg tw-shadow-md",children:e.jsx(ua,{onselect:l=>{d(l),i(!1),n&&n(l)},options:a})})]})},ys=()=>{const{fields:t,updateFilters:a,cleanFilters:n,applyFilters:r,initialFilters:s}=Le();return e.jsxs("div",{className:"tw-z-[100] tw-flex tw-min-w-[250px] tw-flex-col tw-gap-l",children:[e.jsxs("div",{className:"tw-flex tw-items-center tw-justify-between",children:[e.jsx("p",{className:"tw-text-2xl tw-text-texts",children:"Filtros"}),e.jsx("button",{className:"tw-flex tw-h-fit tw-cursor-pointer tw-items-center tw-gap-m tw-rounded-lg tw-bg-bg tw-fill-texts-enfasis tw-p-s tw-px-l tw-text-lg tw-font-semibold tw-text-texts-enfasis tw-shadow-button-primary hover:tw-shadow-button-primary-hover",onClick:n,children:"Limpiar"})]}),e.jsx("div",{className:"tw-flex tw-flex-col tw-gap-m",children:t==null?void 0:t.map((i,o)=>{var d;return e.jsxs("div",{style:{zIndex:10-o},children:[e.jsx("p",{className:"z-[1] tw-text-xl",children:i.label}),(i==null?void 0:i.type)==="select"?e.jsx("div",{className:"tw-relative tw-z-[10]",children:e.jsx(bs,{error:!1,options:i==null?void 0:i.options,onSelect:l=>{a({name:i==null?void 0:i.id,value:l==null?void 0:l.id})},initialValue:(d=i==null?void 0:i.options)==null?void 0:d.find(l=>l.id===(s==null?void 0:s[i==null?void 0:i.id]))})}):e.jsx("input",{className:"tw-h-[30px] tw-w-full tw-rounded-lg tw-p-s tw-shadow-input",type:i.type,value:s==null?void 0:s[i==null?void 0:i.id],name:i.label.toLowerCase().replace(/ /g,"_"),onChange:gs(l=>{var c,u;return a({name:(c=l==null?void 0:l.target)==null?void 0:c.name,value:(u=l==null?void 0:l.target)==null?void 0:u.value})},1e3)})]},o)})}),e.jsx("button",{className:"tw-rounded-md tw-bg-primary-regular tw-py-s tw-text-xl tw-text-white hover:tw-bg-primary-dark",onClick:r,children:"Filtrar"})]})},js=()=>e.jsxs("div",{className:"tw-flex tw-h-[150px] tw-w-full tw-animate-pulse tw-flex-col tw-gap-[50px] tw-rounded-md tw-bg-gray-200 tw-p-4",children:[e.jsxs("div",{className:"tw-flex tw-h-[30px] tw-gap-3",children:[e.jsx("div",{className:"tw-h-full tw-w-[30px] tw-min-w-[30px] tw-rounded-full tw-bg-gray-300"}),e.jsx("div",{className:"tw-h-full tw-w-full tw-bg-gray-300"}),e.jsx("div",{className:"tw-h-full tw-w-[30px] tw-min-w-[30px] tw-rounded-full tw-bg-gray-300"})]}),e.jsxs("div",{className:"tw-flex tw-h-[30px] tw-w-full tw-justify-between tw-gap-[50px]",children:[e.jsx("div",{className:"tw-h-[30px] tw-w-full tw-bg-gray-300"}),e.jsx("div",{className:"tw-h-[30px] tw-w-full tw-bg-gray-300"})]})]}),zt=({trigger:t,user:a,showUser:n=!0})=>e.jsx(ie.Tooltip,{dispatch:t,children:n&&e.jsxs("div",{className:"tw-border-containers tw-flex tw-h-fit tw-w-fit tw-items-center tw-gap-2 tw-rounded-lg tw-bg-bg-card tw-p-2",children:[e.jsx(qe,{imageUrl:a.image??"",alt:a.name}),e.jsx("p",{className:"tw-text-s tw-font-bold tw-text-texts-subtext",children:a.name})]})});class _s{static toDomain(a){return{id:a.id,name:a.nombre,color:a.color}}}const vs=()=>{const{tasks_api:t}=fe();return{teams:pe.useQuery({queryKey:["teams","all"],queryFn:async()=>{const n=await t.get("/api/equipos");return he(n.data).map(_s.toDomain)},refetchOnWindowFocus:!1})}};class Et{static toUsers(a){var n,r,s;return{id:a.id,name:a.nombre,image:(s=(r=(n=a.imagen)==null?void 0:n.formats)==null?void 0:r.thumbnail)==null?void 0:s.url,tasksUser:{email:a.tasksUser.email,id:a.tasksUser.id,nombre:a.tasksUser.nombre},role:a.role}}static toUsersV2(a){var n,r,s;return{id:a.id,name:a.nombre,image:(s=(r=(n=a.imagen)==null?void 0:n.formats)==null?void 0:r.thumbnail)==null?void 0:s.url,role:a.role}}static toUsersWithIndex(a){var r,s,i;const n={};for(const o of a)n[o.email]={...o,image:(i=(s=(r=o.imagen)==null?void 0:r.formats)==null?void 0:s.thumbnail)==null?void 0:i.url};return n}}const Ns=async({tasks_api:t})=>{try{const a=await t.get("/api/getAllOBPusersMembers");return he(a.data).map(Et.toUsers)}catch(a){throw console.log("Error al obtener los usuarios comerciales",a),`Error al obtener los usuarios comerciales: ${a}`}},Ts=async({tasks_api:t})=>{try{const a={filters:{$and:[{role:{name:{$in:["Project Manager","Operation Manager","Administrador"]}}},{blocked:{$eq:!1}}]}},n=Pe.stringify(a,{encodeValuesOnly:!0}),r=await t.get(`/api/users?${n}`),i=he(r.data).map(l=>l.email),o=await t.get(`/api/getAllOBPusers?filters[name][$in]=${i}`);return he(o.data).map(Et.toUsersV2)}catch(a){throw console.log("Error al obtener los usuarios comerciales",a),`Error al obtener los usuarios comerciales: ${a}`}},Cs=async({users:t})=>{try{const a=he(t);return Et.toUsersWithIndex(a)}catch(a){throw console.log("Error al obtener los usuarios comerciales",a),`Error al obtener los usuarios comerciales: ${a}`}},Es=()=>{const{tasks_api:t}=fe();return{users:pe.useQuery({queryKey:["users"],queryFn:()=>Ns({tasks_api:t}),staleTime:1e3*60*60*24})}},Ss=()=>{const{tasks_api:t}=fe();return{users:pe.useQuery({queryKey:["allUsers"],queryFn:()=>Ts({tasks_api:t}),staleTime:1e3*60*60*24})}},pa=({users:t,onClick:a,responsible:n,role:r,status:s})=>{const{getOBPUrlApi:i}=fe(),o=`button-assign-users-${Math.random().toString(36).substring(2,15)}`,{setElementPosition:d,position:l,clearPosition:c}=Ct(),u=w.useRef(null),m="Project Manager",x=()=>n?null:t.length>3&&e.jsx(ie.Tooltip,{dispatch:e.jsx("div",{className:"tw-ml-[-8px] tw-flex tw-h-[28px] tw-w-[28px] tw-items-center tw-justify-center tw-rounded-full tw-border-2 tw-border-white tw-bg-primary-regular",children:e.jsx("p",{className:"tw-text-s tw-font-bold tw-text-white ",children:`+${t.length-3}`})}),children:e.jsx("div",{className:"tw-border-containers tw-h-fit tw-w-fit tw-rounded-lg tw-bg-bg-card tw-p-2",children:t==null?void 0:t.slice(3).map((h,b)=>e.jsxs("div",{className:"tw-flex tw-items-center tw-gap-2 ",children:[e.jsx(qe,{imageUrl:h.image??"",alt:h.name},b),e.jsx("p",{className:"tw-text-s tw-font-bold tw-text-texts-subtext",children:h.name})]},b))})}),p=()=>{if(n){let h=t.find(b=>b.id===n);return e.jsx("div",{children:e.jsx(zt,{trigger:e.jsx(qe,{imageUrl:h==null?void 0:h.image,alt:h==null?void 0:h.name},n),user:h,showUser:!(l!=null&&l.x)})})}return(t==null?void 0:t.length)>0&&t.slice(0,3).map((h,b)=>e.jsx("div",{className:`${b===0?"":"tw-ml-[-8px]"}`,children:e.jsx(zt,{trigger:e.jsx(qe,{imageUrl:h.image,alt:h.name}),user:h,showUser:!(l!=null&&l.x)})},h.id||b))},f=({children:h})=>e.jsx("label",{ref:u,htmlFor:o,className:"tw-flex tw-cursor-pointer tw-items-center",children:h});if(t.length===0)return e.jsx(f,{children:e.jsx(ie.Icons,{icon:"user",size:"xs",strokeWidth:3})});const g=()=>{var P;const[h,b]=w.useState(),[v,I]=w.useState("team"),{teams:$}=vs(),{users:R}=Es();w.useEffect(()=>{var C,y;u.current&&b(((l==null?void 0:l.x)??0)-(((y=(C=u.current)==null?void 0:C.getBoundingClientRect())==null?void 0:y.width)??0))},[u==null?void 0:u.current,l==null?void 0:l.x]);const U=()=>{const C=[{id:"team",label:"Equipo"},{id:"responsible",label:"Responsable"}];return e.jsx("div",{className:"tw-flex tw-w-full tw-justify-center tw-gap-l tw-font-bold tw-text-texts-placeholder",children:C.map((y,H)=>e.jsx("button",{className:`tw-w-full tw-border-texts-placeholder tw-text-center tw-text-sm ${v===y.id?"tw-text-primary-pastel":""} ${H===C.length-1?"tw-border-r-0":" tw-border-r-2"}`,onClick:()=>I(y.id),children:y.label},y.id))})};return r===m||s===0&&r!==m?(l==null?void 0:l.x)&&tt.createPortal(e.jsx("div",{"data-portal-host":!0,className:`absolute tw-h-fit tw-w-[300px] tw-p-[1rem] ${h?"tw-block":"tw-hidden"}`,style:{top:`${l==null?void 0:l.y}px`,left:`${h}px`,zIndex:1},children:e.jsxs("div",{className:"tw-border-cards tw-flex tw-max-h-[200px] tw-flex-col tw-gap-m tw-overflow-y-hidden tw-rounded-lg tw-bg-bg-card tw-p-2",style:{boxShadow:"0px 2px 16px 0px rgba(0, 0, 0, 0.25)"},children:[e.jsx(U,{}),e.jsx(ua,{options:v==="team"?$.data.map(C=>({id:C.id,name:C.name,image:""})):((P=R.data)==null?void 0:P.map(C=>Nt(C,i())))||[],onselect:C=>{var y;c(),a&&a((y=C.tasksUser)==null?void 0:y.id,v)}})]})}),document.body):null};return e.jsxs(e.Fragment,{children:[e.jsxs(f,{children:[p(),x()]}),e.jsx("button",{className:"tw-hidden",id:o,onClick:()=>d(u)}),e.jsx(g,{})]})};function wa({trigger:t,children:a,open:n,setOpen:r}){return e.jsxs(je.DropdownMenu,{open:n,onOpenChange:r,children:[e.jsx(je.DropdownMenuTrigger,{children:t}),e.jsx(je.DropdownMenuContent,{align:"start",className:"tw-rounded-lg tw-border-none tw-bg-white tw-p-4",children:a})]})}const ma=({priority:t,id:a,withLabel:n=!1})=>{var x,p,f,g,h;const{updatingTask:r}=Ue(),s=Math.random().toString(36),[i,o]=w.useState(null),{user:d}=Ee(),[l,c]=w.useState(t);w.useEffect(()=>{c(t)},[t]);const u={0:{title:"Normal",color:Z.primary.regular},1:{title:"Baja",color:Z.success.regular},2:{title:"Media",color:Z.warning.regular},3:{title:"Alta",color:Z.danger.regular}},m=()=>{if(!i)return null;const b=({priorityTask:v,text:I})=>{var $,R;return e.jsxs("button",{onClick:async()=>{o(null),await r({id:a,data:{prioridad:v},user:d==null?void 0:d.id}),c(v)},className:"tw-flex tw-items-center tw-gap-m tw-px-l tw-py-s hover:tw-bg-primary-light",children:[e.jsx(ie.Icons,{icon:"flag",size:"xs",strokeWidth:4,color:($=u[v??0])==null?void 0:$.color}),e.jsx("p",{className:"tw-text-sm",style:{color:(R=u[v??0])==null?void 0:R.color},children:I})]})};return tt.createPortal(e.jsx("div",{onBlur:()=>{o(null)},id:`${s}-options`,style:{top:`${i.y+5}px`,left:`${i.x+5}px`,zIndex:50},className:`tw-absolute tw-flex tw-h-fit tw-w-max tw-flex-col tw-gap-2 tw-rounded-xl tw-bg-bg-card tw-p-m
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime");require("@imj_media/imj-ui/styles.css");require("@imj_media/ui/index.css");const pe=require("@tanstack/react-query");require("ui-ds/index.css");const ie=require("@imj_media/tasks-modules"),as=require("primereact/paginator"),w=require("react"),jt=require("axios"),Pe=require("qs"),tt=require("react-dom"),Ie=require("@fortawesome/pro-regular-svg-icons"),ve=require("@imj_media/ui"),je=require("@imj_media/imj-ui"),it=require("date-fns"),_t=require("date-fns/locale"),Ce=require("react-hook-form"),A=require("ui-ds"),re=require("@xyflow/react"),ze=require("zustand"),xt=require("moment"),ue=require("@fortawesome/pro-solid-svg-icons"),$e=require("@fortawesome/pro-duotone-svg-icons"),Me=require("@fortawesome/free-solid-svg-icons");require("@xyflow/react/dist/style.css");const ss=require("react-pick-color"),Z={bg:{content:"#FAFAFA"},texts:{DEFAULT:"#252525",subtext:"#4f4f4f",placeholder:"#929292"},primary:{regular:"#425CAC"},success:{dark:"#368156",regular:"#43B071"},danger:{dark:"#8C352C",regular:"#C34335"},warning:{dark:"#B4782F",regular:"#D38A31"},silver:{silver_light:" #F5F5F5",silver_dark:" #E9E9E9"},progressbar:{orange_regular:"#DC8921",blue_regular:"#3658C1",green_regular:"#039B59"},gray:{gray_regular:"#D1D1D1",gray_dark:"#C4C4C4"},black:{black_light:"#929292",black_medium:"#4F4F4F",black_dark:"#131313"}},qt=t=>{let a={};return Object.entries(t).forEach(([n,r])=>{if(n.includes(".")){let[s,i]=n.split(".");a[s]=a[s]||{},a[s][i]=r}else a[n]=r}),a},aa=w.createContext({}),rs=({children:t})=>{const[a,n]=w.useState({}),[r,s]=w.useState({}),[i,o]=w.useState([]),[d,l]=w.useState(""),c=({name:p,value:f})=>{function g(b){return!isNaN(b)&&b!==null&&b!==""?parseFloat(b):null}let h=g(f);s(b=>{let v={...b},I=i==null?void 0:i.find($=>$.label.toLowerCase().replace(/ /g,"_")===p);return I?v[I.id]=h??f:v[p]=h??f,v})};w.useEffect(()=>{let p=i.map(f=>f.id==="owner.config"?[f.id,"yo_y_mis_equipos"]:f.id==="dependency"?[f.id,"ambas"]:[f.id,null]);s(f=>{let g={search:f==null?void 0:f.search,taskName:f==null?void 0:f.taskName};return g={...g,...Object.fromEntries(p)},g})},[i]);const u=()=>{let p=i.map(f=>f.id==="owner.config"?[f.id,"yo_y_mis_equipos"]:f.id==="dependency"?[f.id,"ambas"]:[f.id,null]);s(Object.fromEntries(p)),n(qt(Object.fromEntries(p)))},m=p=>({1:"Muy facil",2:"Facil",3:"Media",4:"Dificil",5:"Muy dificil"})[p],x=()=>{let p=qt(r);p.difficulty&&(p.difficulty=m(p.difficulty)),n(p)};return e.jsx(aa.Provider,{value:{fields:i,filters:a,path:d,defineFields:o,updateFilters:c,cleanFilters:u,applyFilters:x,initialFilters:r,selectPath:l},children:t})},Le=()=>w.useContext(aa),sa=w.createContext({}),ns=({children:t,user:a,url:n,mode:r})=>{const s=r==="prod"?"https://services.imjmedia.com.mx":"https://devobp.imjmedia.com.mx",i=jt.create({baseURL:n,headers:{Authorization:`Bearer ${a.accessToken}`},paramsSerializer:l=>Pe.stringify(l,{encodeValuesOnly:!0})}),o=()=>s,d=l=>l==="undefined"||l===void 0?"":`${s}${l}`;return e.jsx(sa.Provider,{value:{tasks_api:i,getOBPUrlApi:o,getImageOBP:d},children:t})},fe=()=>w.useContext(sa),ra=w.createContext({}),os=({children:t,user:a,url:n})=>{const r=jt.create({baseURL:n,headers:{Authorization:`Bearer ${a.accessToken}`},paramsSerializer:s=>Pe.stringify(s,{encodeValuesOnly:!0})});return e.jsx(ra.Provider,{value:{user:a,tasks_api:r},children:t})},Ee=()=>w.useContext(ra),he=t=>{const a=i=>Object.prototype.toString.call(i)==="[object Object]",n=i=>i&&typeof i=="object"&&("source"in i||"target"in i)&&!("attributes"in i),r=i=>i&&typeof i=="object"&&"position"in i&&typeof i.position=="object"&&("x"in i.position||"y"in i.position)&&!("attributes"in i),s=i=>i.attributes?{id:i.id,...i.attributes}:i;if(Array.isArray(t))return t.map(i=>he(i));if(a(t)){if(n(t)){const i={};for(const o in t)i[o]=he(t[o]);return i}if(r(t)){const i={};for(const o in t)i[o]=he(t[o]);return i}Array.isArray(t.data)?t=[...t.data]:a(t.data)?t=s({...t.data}):t.data===null?t=null:t=s(t);for(const i in t)t[i]=he(t[i]);return t}return t},qe=({imageUrl:t="https://www.uv.unach.mx/assets/img/prueba/directorio/userM.png",alt:a="avatar",size:n="s"})=>{const r={xs:"tw-w-[24px] tw-h-[24px] tw-min-w-[24px] tw-min-h-[24px]",s:"tw-w-[28px] tw-h-[28px] tw-min-w-[28px] tw-min-h-[28px]",m:"tw-w-[32px] tw-h-[32px] tw-min-w-[32px] tw-min-h-[32px]",l:"tw-w-[36px] tw-h-[36px] tw-min-w-[36px] tw-min-h-[36px]",xl:"tw-w-[40px] tw-h-[40px] tw-min-w-[40px] tw-min-h-[40px]",xxl:"tw-w-[44px] tw-h-[44px] tw-min-w-[44px] tw-min-h-[44px]"}[n];return e.jsx("img",{src:t===""?"https://www.uv.unach.mx/assets/img/prueba/directorio/userM.png":t,alt:a??"avatar",className:`${r} tw-bg-containers tw-rounded-full tw-border-2 tw-border-white`})},vt=t=>new Intl.DateTimeFormat("es-MX",{month:"long"}).format(t);function is(t){const a=["domingo","lunes","martes","miércoles","jueves","viernes","sábado"],n=new Date(t).getDay();return a[n]}const Lt=t=>{let a=t||new Date,n=a.getDate(),r=vt(a.getMonth()).slice(0,3),s=a.getFullYear().toString().slice(-2),i=is(a).slice(0,3);return`${i.charAt(0).toUpperCase()+i.slice(1)} ${n} ${r.charAt(0).toUpperCase()+r.slice(1)} ${s}`},Nt=(t,a)=>({...t,image:t.image?`${a}${t.image}`:""}),Ze=t=>{var a,n;return t?(a=t.responsable)!=null&&a.nombre?t.responsable.nombre:(n=t.equipo)!=null&&n.nombre?t.equipo.nombre:null:null};class ls{static toCampaignTasks(a){var i,o,d,l,c,u,m,x,p,f,g,h,b,v,I;const n=Ze(a==null?void 0:a.id_t_requerida),r=Ze(a==null?void 0:a.tarea_padre);let s=[];return a!=null&&a.responsable&&s.push({id:a.responsable.id,name:a.responsable.nombre,image:(c=(l=(d=(o=(i=a.responsable)==null?void 0:i.userOBP)==null?void 0:o.imagen)==null?void 0:d.formats)==null?void 0:l.thumbnail)==null?void 0:c.url,role:((u=a.responsable.userOBP)==null?void 0:u.role)||{id:0,name:""}}),(m=a==null?void 0:a.equipo)!=null&&m.miembros&&a.equipo.miembros.forEach($=>{var R,U,P,C,y;s!=null&&s.find(H=>H.id===$.idUser.id)||$.idUser&&s.push({id:$.idUser.id,name:$.idUser.nombre,image:(C=(P=(U=(R=$==null?void 0:$.userOBP)==null?void 0:R.imagen)==null?void 0:U.formats)==null?void 0:P.thumbnail)==null?void 0:C.url,role:((y=$.userOBP)==null?void 0:y.role)||{id:0,name:""}})}),{paused:a==null?void 0:a.pausada,isPrincipalTask:(a==null?void 0:a.tarea_principal)??!1,orden:(a==null?void 0:a.orden)??null,id:(a==null?void 0:a.id)??null,task:(a==null?void 0:a.texto_corto)??null,status:(a==null?void 0:a.estatus)??null,difficulty:(a==null?void 0:a.nivel_dificultad)??null,priority:(a==null?void 0:a.prioridad)??0,endDate:new Date((a==null?void 0:a.ffin)??null),startDate:new Date((a==null?void 0:a.finicio)??null),users:s,repeatsToDo:(a==null?void 0:a.repeticiones)??null,repeats:(a==null?void 0:a.repeticiones_realizadas)??null,comments:((x=a==null?void 0:a.comentarios)==null?void 0:x.length)??null,willBePaused:a==null?void 0:a.es_pausable,nameProject:((p=a==null?void 0:a.proyecto)==null?void 0:p.nombre)??null,idProject:((f=a==null?void 0:a.proyecto)==null?void 0:f.id)??null,medioName:(a==null?void 0:a.nombre_medio)??null,statusRequiredTask:((g=a==null?void 0:a.id_t_requerida)==null?void 0:g.estatus)??null,nameRequiredTask:((h=a==null?void 0:a.id_t_requerida)==null?void 0:h.texto_corto)??null,nameRequiredTaskResponsible:n,name_father_required_task:((b=a==null?void 0:a.tarea_padre)==null?void 0:b.texto_corto)??null,name_father_required_task_responsible:r,responsible:((v=a==null?void 0:a.responsable)==null?void 0:v.id)??null,tasks:((I=a==null?void 0:a.tareas)==null?void 0:I.map($=>({id:$.id,name:$.texto_corto,status:$.estatus})))??null,atraso:(a==null?void 0:a.atraso)??null,categoria:(a==null?void 0:a.categoria)??null,...(a==null?void 0:a.cambio_arte)&&{cambio_arte:a==null?void 0:a.cambio_arte}}}}const cs=async({filters:t,tasks_api:a,project:n})=>{try{const r=await a.get("/api/listado_tareas_flujo",{params:{...t,project:{id:n},includeAllTasks:!0,populate:"*"}}),s=he(r.data.tareas),i=Array.isArray(s)?s:[s],o=new Set;if(i.forEach(d=>{var l;(l=d==null?void 0:d.id_t_requerida)!=null&&l.id&&o.add(d.id_t_requerida.id)}),o.size>0){const d=Array.from(o),l=Pe.stringify({filters:{id:{$in:d}},populate:{responsable:{fields:["id","nombre"]},equipo:{fields:["id","nombre"]}}},{encodeValuesOnly:!0});try{const c=await a.get(`/api/tareas?${l}`),u=he(c.data.data||c.data),m=Array.isArray(u)?u:[u],x=new Map(m.map(p=>[p.id,p]));i.forEach(p=>{var f;if((f=p==null?void 0:p.id_t_requerida)!=null&&f.id){const g=x.get(p.id_t_requerida.id);g&&(p.id_t_requerida={...p.id_t_requerida,responsable:g.responsable||null,equipo:g.equipo||null})}})}catch{}}return i.map(ls.toCampaignTasks)}catch(r){console.log(r)}},na=w.createContext({}),ds=({children:t,project:a})=>{var b;const[n,r]=w.useState([]),[s,i]=w.useState(!1),[o,d]=w.useState([]),{tasks_api:l}=fe(),{filters:c}=Le(),{user:u}=Ee(),[m,x]=w.useState({owner:{user:u.id,config:((b=c==null?void 0:c.owner)==null?void 0:b.config)??"yo_y_mis_equipos"},project:{id:a}});w.useEffect(()=>{var v;if(Object.keys(c).length>0){const I={...c,owner:{user:u.id,config:((v=c==null?void 0:c.owner)==null?void 0:v.config)??"yo_y_mis_equipos"},project:{id:a}};x(I)}},[c,u.id,a]);const p=pe.useQuery({queryKey:["tasksProject",m,a],queryFn:()=>{const v={...m,taskName:c==null?void 0:c.taskName,owner:{...m.owner,config:m.owner.config||"yo_y_mis_equipos"}};return cs({filters:v,project:a,tasks_api:l})},refetchOnWindowFocus:!1}),f=v=>{r(I=>[...I,v])},g=v=>{d(I=>I.includes(v)?I.filter($=>$!==v):[...I,v])},h=a??null;return e.jsx(na.Provider,{value:{tasksProject:p,selectedTasks:n,projectID:h,openTasks:o,selectTask:f,filtersToSend:m,openTask:g,isRefetching:s,project:a,filters:c,setIsRefetching:i},children:t})},Qe=()=>w.useContext(na),oa=w.createContext(null),us=({children:t})=>{const[a,n]=w.useState({message:"",type:"success"}),r=(s,i)=>{n({message:s,type:i}),setTimeout(()=>n({message:"",type:"success"}),3e3)};return e.jsx(oa.Provider,{value:{toast:a,showSuccess:s=>r(s,"success"),showError:s=>r(s,"error")},children:t})},Tt=()=>w.useContext(oa);class ia{static toAtrasoReasons(a){return{id:a.id,motivo_imj:a.motivo_imj,categoria:a.categoria??null}}}const ps=async({tasks_api:t})=>{try{const a=await t.get("/api/motivos",{params:{populate:{categoria:{fields:["id","nombre","tipo"]}},filters:{tipo:{$eq:"atraso"}}}});return he(a.data).map(ia.toAtrasoReasons)}catch(a){throw console.log("Error al obtener los motivos de atraso",a),`Error al obtener los motivos de atraso: ${a}`}},la=({enabled:t=!1}={})=>{const{tasks_api:a}=fe(),{user:n}=Ee(),r=pe.useQueryClient(),{showSuccess:s,showError:i}=Tt(),{filters:o,path:d}=Le(),{data:l,isLoading:c}=pe.useQuery({queryKey:["atraso_reasons"],queryFn:()=>ps({tasks_api:a}),staleTime:1e3*60*60*24,enabled:t}),u=async()=>{const $=await a.get("/api/motivos",{params:{filters:{tipo:{$eq:"atraso"}}}});return he($.data).map(ia.toAtrasoReasons)},m=async({taskId:$,motivoId:R,projectID:U})=>{try{return(await a.post("/api/atrasos",{data:{inicio:new Date,fin:null,motivo:R,proyecto:U,tarea:$,creada_por:n==null?void 0:n.id}})).data}catch(P){console.log("error",P)}},x=async $=>{try{return(await a.delete(`/api/atrasos/${$}`)).data}catch(R){console.log("error",R)}},p=async $=>{try{return(await a.put(`/api/atrasos/${$}`,{data:{fin:new Date}})).data}catch(R){console.log("error",R)}},f=async({taskId:$,projectID:R,motivo:U})=>{await b({taskId:$,motivoId:U,projectID:R})},g=async $=>{await v($)},h=async $=>{await I($)},{mutateAsync:b}=pe.useMutation({mutationFn:m,onSuccess:()=>{s("Atraso registrado correctamente"),d==="kanban-general"&&(r.invalidateQueries({queryKey:["to_do_tasks",o]}),r.invalidateQueries({queryKey:["working_tasks",o]})),d==="kanban-campania"&&r.invalidateQueries({queryKey:["tasksProject"]})},onError:()=>{i("Error al registrar el atraso")}}),{mutateAsync:v}=pe.useMutation({mutationFn:x,onSuccess:()=>{s("Atraso eliminado correctamente"),d==="kanban-general"&&(r.invalidateQueries({queryKey:["to_do_tasks"]}),r.invalidateQueries({queryKey:["working_tasks"]}),r.invalidateQueries({queryKey:["done_tasks"]})),d==="kanban-campania"&&r.invalidateQueries({queryKey:["tasksProject"]})},onError:()=>{i("Error al eliminar el atraso")}}),{mutateAsync:I}=pe.useMutation({mutationFn:p,onSuccess:()=>{s("Atraso finalizado correctamente")},onError:()=>{i("Error al finalizar el atraso")}});return{atrasoReasons:l,isLoading:c,createAtraso:f,getAtrasoReasons:u,deleteAtraso:g,finalizarAtraso:h}},Ue=()=>{const{tasks_api:t}=fe(),{user:a}=Ee(),{filters:n,path:r}=Le(),s=pe.useQueryClient(),{projectID:i}=Qe(),{showSuccess:o,showError:d}=Tt(),{finalizarAtraso:l}=la({enabled:!1}),c=async({id:F})=>(await t.put(`/api/tareas/${F}`,{data:{estatus:1,responsable:a==null?void 0:a.id,updated_by:a==null?void 0:a.id}})).data,u=async({id:F})=>(await t.put(`/api/tareas/${F}`,{data:{estatus:0,responsable:a==null?void 0:a.id,updated_by:a==null?void 0:a.id}})).data,m=async({id:F,idAtraso:D})=>{const M=await t.post("/api/terminarTarea",{id_task:F,ended_at:new Date().toISOString(),id_user:a==null?void 0:a.id});return await l(D),M.data},x=async({id:F,repeats:D})=>(await t.put(`/api/tareas/${F}`,{data:{repeticiones_realizadas:D,updated_by:a==null?void 0:a.id}})).data,p=async({id:F,motiveId:D})=>{try{const M=await t.post("/api/pausarTarea",{taskId:F,userId:a==null?void 0:a.id,motivoId:D});return o("Tarea pausada correctamente"),M.data}catch(M){d("Error al pausar la tarea: "+M)}},f=async({id:F})=>{try{const D=await t.post("/api/reanudarTarea",{taskId:F});return o("Tarea reanudada correctamente"),D.data}catch(D){d("Error al reanudar la tarea: "+D)}},g=async({id:F,idNewResponsible:D,typeOfSelect:M})=>{let L={updated_by:a==null?void 0:a.id};return M==="responsible"&&(L={...L,responsable:D}),M==="team"&&(L={...L,responsable:null,equipo:D}),(await t.put(`/api/tareas/${F}`,{data:L})).data},h=async({id:F,data:D,user:M})=>{try{return(await t.put(`/api/tareas/${F}`,{data:{...D,updated_by:M==null?void 0:M.id}})).data}catch(L){console.error("Error updating the element:",L)}},b=async({id:F})=>{await $({id:F})},v=async({id:F,data:D,user:M})=>{await I({id:F,data:D,user:M})},{mutateAsync:I}=pe.useMutation({mutationFn:h,onSuccess:()=>{o("Tarea actualizada correctamente");const F={"kanban-general":"to_do_tasks","kanban-campania":"tasksProject"};try{r==="kanban-general"&&(s.invalidateQueries({queryKey:[F[r],n]}),s.invalidateQueries({queryKey:["done_tasks",n]}),s.invalidateQueries({queryKey:["working_tasks",n]})),r==="kanban-campania"&&(s.invalidateQueries({queryKey:["tasksProject"]}),s.invalidateQueries({queryKey:["tasksProject",n,i]}))}catch(D){console.error("Error invalidating queries:",D)}},onError:F=>{console.error("Failed to update the task.",F)},onMutate:async()=>{await s.cancelQueries({queryKey:["working_tasks"]})}}),{mutateAsync:$}=pe.useMutation({mutationFn:c,onSuccess:()=>{const F={"kanban-general":"to_do_tasks","kanban-campania":"tasksProject"};try{r==="kanban-general"&&(s.invalidateQueries({queryKey:[F[r],n]}),s.invalidateQueries({queryKey:["working_tasks",n]})),r==="kanban-campania"&&(s.invalidateQueries({queryKey:["tasksProject"]}),s.invalidateQueries({queryKey:["tasksProject",n,i]}))}catch(D){console.error("Error updating the element:",D)}},onError:F=>{console.error("Failed to update the task.",F)},onMutate:async()=>{await s.cancelQueries({queryKey:["working_tasks"]}),await s.cancelQueries({queryKey:["to_do_tasks"]})}}),{mutateAsync:R}=pe.useMutation({mutationFn:m,onSuccess:()=>{const F={"kanban-general":"to_do_tasks","kanban-campania":"tasksProject"};try{s.setQueryData([F[r],n],D=>{console.log({oldData:D})}),r==="kanban-general"&&(s.invalidateQueries({queryKey:[F[r],n]}),s.invalidateQueries({queryKey:["done_tasks",n]}),s.invalidateQueries({queryKey:["working_tasks",n]})),r==="kanban-campania"&&(s.invalidateQueries({queryKey:["tasksProject"]}),s.invalidateQueries({queryKey:["tasksProject",n,i]}))}catch(D){console.error("Error invalidating queries:",D)}},onError:F=>{console.error("Failed to update the task.",F)},onMutate:async()=>{await s.cancelQueries({queryKey:["working_tasks"]}),await s.cancelQueries({queryKey:["done_tasks"]}),await s.cancelQueries({queryKey:["to_do_tasks"]})}}),{mutateAsync:U}=pe.useMutation({mutationFn:x,onSuccess:()=>{const F={"kanban-general":"to_do_tasks","kanban-campania":"tasksProject"};try{r==="kanban-general"&&(s.invalidateQueries({queryKey:[F[r],n]}),s.invalidateQueries({queryKey:["done_tasks",n]}),s.invalidateQueries({queryKey:["working_tasks",n]})),r==="kanban-campania"&&(s.invalidateQueries({queryKey:["tasksProject"]}),s.invalidateQueries({queryKey:["tasksProject",n,i]}))}catch(D){console.error("Error invalidating queries:",D)}},onError:F=>{console.error("Failed to update the task.",F)},onMutate:async()=>{await s.cancelQueries({queryKey:["working_tasks"]}),await s.cancelQueries({queryKey:["done_tasks"]}),await s.cancelQueries({queryKey:["to_do_tasks"]})}}),{mutateAsync:P}=pe.useMutation({mutationFn:g,onSuccess:()=>{const F={"kanban-general":"to_do_tasks","kanban-campania":"tasksProject"};try{r==="kanban-general"&&(s.invalidateQueries({queryKey:[F[r],n]}),s.invalidateQueries({queryKey:["done_tasks",n]}),s.invalidateQueries({queryKey:["working_tasks",n]})),r==="kanban-campania"&&(s.invalidateQueries({queryKey:["tasksProject"]}),s.invalidateQueries({queryKey:["tasksProject",n,i]}))}catch(D){console.error("Error invalidating queries:",D)}},onError:F=>{console.error("Failed to reassign the task.",F)},onMutate:async()=>{await s.cancelQueries({queryKey:["working_tasks"]}),await s.cancelQueries({queryKey:["done_tasks"]}),await s.cancelQueries({queryKey:["to_do_tasks"]})}}),{mutateAsync:C}=pe.useMutation({mutationFn:u,onSuccess:()=>{const F={"kanban-general":"to_do_tasks","kanban-campania":"tasksProject"};try{r==="kanban-general"&&(s.invalidateQueries({queryKey:[F[r],n]}),s.invalidateQueries({queryKey:["working_tasks",n]})),r==="kanban-campania"&&(s.invalidateQueries({queryKey:["tasksProject"]}),s.invalidateQueries({queryKey:["tasksProject",n,i]}))}catch(D){console.error("Error updating the element:",D)}},onError:F=>{console.error("Failed to update the task.",F)},onMutate:async()=>{await s.cancelQueries({queryKey:["working_tasks"]}),await s.cancelQueries({queryKey:["to_do_tasks"]})}});return{updatingTask:v,updateTask:h,startTask:async({id:F})=>{await C({id:F})},startWorking:b,completeTask:async({id:F,idAtraso:D})=>{await R({id:F,idAtraso:D})},reasignResponsible:async({id:F,idNewResponsible:D,typeOfSelect:M})=>{await P({id:F,idNewResponsible:D,typeOfSelect:M})},updateUnitys:async({repeats:F,id:D})=>{await U({repeats:F,id:D})},pauseTask:async({id:F,motiveId:D})=>{console.log({taksId:F,motivoId:D,user:a==null?void 0:a.id})},postPauseTask:p,postReanudeTask:f}},ws=({id:t,idAtraso:a})=>{const[n,r]=w.useState(!1),{completeTask:s}=Ue();return{checked:n,checkTask:()=>{r(!n),s({id:t,idAtraso:a})}}},Ot={checked:"tw-mx-[2px] tw-flex tw-h-[20px] tw-w-[20px] tw-items-center tw-justify-center tw-rounded-full tw-bg-success-regular tw-transition-all",unchecked:"tw-transition-colors"},ms="tw-mx-[2px] tw-flex tw-items-center tw-justify-center tw-rounded-full tw-bg-success-regular tw-transition-all",Rt="tw-shadow-black-300 tw-text-s tw-absolute tw-left-0 tw-top-full tw-z-10 tw-ml-[-2rem] tw-mt-2 tw-flex tw-w-fit tw-max-w-[400px] tw-flex-col tw-gap-m tw-rounded-lg tw-border-l-[5px] tw-border-warning-regular tw-bg-warning-light tw-p-l tw-text-warning-dark tw-shadow-xl",ca=({id:t,nameRequiredTask:a,statusRequiredTask:n,status:r,idAtraso:s,nameRequiredTaskResponsible:i,name_father_required_task:o,name_father_required_task_responsible:d,repeatsAreCompleted:l=!1})=>{const c=w.useId(),u=`checkbox-${t}-${c}`,{checked:m,checkTask:x}=ws({id:t,idAtraso:s}),f=!!(a&&a!==""&&n===2)||!a,g=!!o,h=r===1&&l,b=()=>e.jsx("label",{htmlFor:u,className:m?Ot.checked:Ot.unchecked,children:e.jsx(ie.Icons,{icon:m?"check_outline":"circle_checked",color:m?"white":Z.texts.placeholder,strokeWidth:4,size:m?"xs":"s"})});return r===2?e.jsx("div",{className:ms,children:e.jsx(ie.Icons,{icon:"circle_checked",color:"white",strokeWidth:4,size:"xs"})}):g?e.jsxs(e.Fragment,{children:[e.jsx(ie.Tooltip,{dispatch:e.jsx("label",{className:"tw-cursor-help","aria-hidden":!0,children:e.jsx(ie.Icons,{icon:"info_circle",color:Z.warning.regular,strokeWidth:4})}),children:e.jsxs("div",{className:Rt,children:[e.jsx("p",{className:"tw-w-[210px] tw-font-bold",children:"Tarea padre:"}),e.jsx("p",{children:o}),d&&e.jsxs("p",{className:"tw-font-bold",children:["Responsable: ",e.jsx("span",{className:"tw-font-normal",children:d})]}),e.jsx("span",{className:"tw-font-normal tw-italic tw-text-[#919191]",children:"Esta tarea completa automáticamente la tarea padre."})]})}),h&&b(),e.jsx("input",{id:u,checked:m,onChange:x,type:"checkbox",className:"tw-hidden","aria-hidden":!0})]}):f?e.jsxs(e.Fragment,{children:[r===1&&b(),e.jsx("input",{id:u,checked:m,onChange:x,type:"checkbox",className:"tw-hidden","aria-hidden":!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(ie.Tooltip,{dispatch:e.jsx("label",{className:"tw-cursor-help","aria-hidden":!0,children:e.jsx(ie.Icons,{icon:"info_circle",color:Z.warning.regular,strokeWidth:4})}),children:e.jsxs("div",{className:Rt,children:[e.jsx("p",{className:"tw-w-[210px] tw-font-bold",children:"Requiere completar su tarea:"}),e.jsx("p",{children:a}),i&&e.jsxs("p",{className:"tw-font-bold",children:["Responsable: ",e.jsx("span",{className:"tw-font-normal",children:i})]})]})}),e.jsx("input",{id:u,checked:m,onChange:x,type:"checkbox",className:"tw-hidden","aria-hidden":!0})]})},da=()=>{const t=()=>e.jsxs("div",{className:"tw-flex tw-w-full tw-gap-m",children:[e.jsx("div",{className:"tw-h-[30px] tw-min-h-[30px] tw-w-[30px] tw-min-w-[30px] tw-animate-pulse tw-rounded-full tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-w-[30%] tw-animate-pulse tw-rounded-md tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-min-h-[30px] tw-w-[30px] tw-min-w-[30px] tw-animate-pulse tw-rounded-lg tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-min-h-[30px] tw-w-[30px] tw-min-w-[30px] tw-animate-pulse tw-rounded-lg tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-min-h-[30px] tw-w-[30px] tw-min-w-[30px] tw-animate-pulse tw-rounded-lg tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-w-[10%] tw-animate-pulse tw-rounded-md tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-min-h-[30px] tw-w-[30px] tw-min-w-[30px] tw-animate-pulse tw-rounded-lg tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-w-[10%] tw-animate-pulse tw-rounded-md tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-min-h-[30px] tw-w-[30px] tw-min-w-[30px] tw-animate-pulse tw-rounded-lg tw-bg-gray-200"}),e.jsx("div",{className:"tw-h-[30px] tw-min-h-[30px] tw-w-[30px] tw-min-w-[30px] tw-animate-pulse tw-rounded-lg tw-bg-gray-200"})]});return e.jsxs("div",{className:"tw-flex tw-flex-col tw-gap-m",children:[e.jsx(t,{}),e.jsxs("div",{className:"tw-flex tw-flex-col tw-gap-m tw-pl-5",children:[e.jsx(t,{}),e.jsx("div",{className:"tw-pl-5",children:e.jsx(t,{})})]}),e.jsx(t,{}),e.jsxs("div",{className:"tw-flex tw-flex-col tw-gap-m tw-pl-5",children:[e.jsx(t,{}),e.jsx("div",{className:"tw-pl-5",children:e.jsx(t,{})})]})]})},Bt=[{label:"Tipo de dependencia",type:"select",id:"dependency",options:[{id:"con",name:"Con dependencia"},{id:"sin",name:"Sin dependencia"},{id:"ambas",name:"Ambas"}]},{label:"Por campaña",type:"select",id:"project.id",options:[]},{label:"Por responsable",type:"select",id:"owner.config",options:[{id:"yo",name:"Mis tareas"},{id:"yo_y_mis_equipos",name:"Tareas mías y de mis equipos"},{id:"mis_equipos",name:"Tareas de mis equipos"}]},{label:"Por ejecutivo comercial",type:"select",id:"salesman.id",options:[]},{label:"Por dificultad",type:"select",id:"difficulty",options:[{id:1,name:"Muy facil"},{id:2,name:"Facil"},{id:3,name:"Media"},{id:4,name:"Dificil"},{id:5,name:"Muy dificil"}]}],$t=[{label:"Responsable",type:"select",id:"responsable.responsableType",options:[{id:"yo_y_mis_equipos",name:"Yo y mis equipos"},{id:"mis_equipos",name:"Mis equipos"},{id:"yo",name:"Yo"}]},{label:"Por Ejecutivo",type:"select",id:"ejecutivo",options:[]}],fs=({setPath:t,setProject:a})=>{const[n,r]=w.useState([]),[s,i]=w.useState(!0),[o,d]=w.useState(0),[l,c]=w.useState(10),[u,m]=w.useState(0),[x,p]=w.useState(),[f,g]=w.useState(0),{filters:h,defineFields:b}=Le(),{tasks_api:v,getImageOBP:I}=fe(),{user:$}=Ee(),R=async(j,F)=>{var D,M,L,W,ae;try{i(!0);const X={filters:{search:(h==null?void 0:h.search)??"",responsable:{idUser:$.id,responsableType:(D=h==null?void 0:h.responsable)==null?void 0:D.responsableType},ejecutivo:(h==null?void 0:h.ejecutivo)??"",cancelada:{$eq:!1}}},oe=await v.get("/api/listado_campanias",{params:{pagination:{page:j,pageSize:F},orderBy:x,...X}}),te=he(oe==null?void 0:oe.data);r(te),m((L=(M=oe==null?void 0:oe.data)==null?void 0:M.meta)==null?void 0:L.total),g((ae=(W=oe==null?void 0:oe.data)==null?void 0:W.meta)==null?void 0:ae.pageCount)}catch(X){console.error("Error fetching data en Lista Campaña:",X)}finally{i(!1)}},U=async()=>{try{const j=await v.get("/api/obtener-comerciales");return[...$t].map(D=>(D.id==="ejecutivo"&&(D.options=j.data.map(M=>({id:M.nombre,name:M.nombre}))),D))}catch(j){return console.error("Error fetching salesman data:",j),[...$t]}};w.useEffect(()=>{(async()=>{const F=await U();b(F)})()},[]),w.useEffect(()=>{const j=Math.floor(o/l)+1;R(j,l)},[o,l,x,h]);const P=j=>{d(j.first),c(j.rows)},C=[{label:"5 filas",value:5},{label:"10 filas",value:10},{label:"15 filas",value:15},{label:"20 filas",value:20},{label:"25 filas",value:25},{label:"50 filas",value:50}],y=j=>{const F=parseInt(j.target.value,10);c(F),P({first:0,rows:F})},H=j=>{p(F=>F===j?`${j}:desc`:j)},G=j=>x===j?"↑↓":x===`${j}:desc`?"↓↑":"↑↓",J=j=>({padding:"auto",backgroundColor:Z.silver.silver_light,borderRadius:"50%",cursor:j?"not-allowed":"pointer",transition:"all 0.2s ease",marginRight:"4px",border:`1px solid ${j?Z.gray.gray_regular:Z.gray.gray_dark}`,color:j?Z.gray.gray_regular:Z.black.black_dark,width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"});return e.jsx("div",{className:"tw-w-full tw-rounded-lg tw-p-4 tw-shadow-md",style:{background:Z.bg.content,display:"flex",flexDirection:"column",height:"100%"},children:s?e.jsx("div",{className:"tw-w-full",children:e.jsx(da,{})}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"tw-flex tw-h-full tw-flex-col",children:[e.jsx("div",{className:"tw-flex-1 tw-overflow-auto",children:e.jsxs("table",{className:"tw-w-full tw-table-auto tw-border-collapse",style:{borderCollapse:"collapse",width:"100%",borderSpacing:"0"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{color:Z.gray.gray_regular},children:[e.jsx("th",{onClick:()=>H("nombre"),style:{color:Z.gray.gray_dark,textAlign:"left"},children:e.jsxs("div",{className:"tw-flex tw-w-fit tw-items-center tw-space-x-1",style:{display:"flex",alignItems:"center"},children:[e.jsx("label",{className:"tw-text-s",style:{color:Z.gray.gray_dark},children:G("nombre")}),e.jsx("span",{className:"tw-align-middle tw-font-sans tw-text-[1.4rem] tw-font-normal tw-leading-[100%] tw-tracking-normal",children:"Campaña"})]})}),e.jsx("th",{onClick:()=>H("inicia"),className:"tw-whitespace-nowrap",style:{color:Z.gray.gray_dark,textAlign:"left"},children:e.jsxs("div",{className:"tw-flex tw-w-fit tw-items-center tw-space-x-1",children:[e.jsx("label",{style:{color:Z.gray.gray_dark},children:G("inicia")}),e.jsx(ie.Icons,{icon:"calendar",size:"xs",strokeWidth:5,color:Z.gray.gray_dark,className:"tw-mt-1 tw-h-[15px] tw-w-[15px]"}),e.jsx("span",{style:{color:Z.gray.gray_dark},className:"tw-align-middle tw-font-sans tw-text-[1.4rem] tw-font-normal tw-leading-[100%] tw-tracking-normal",children:"Fecha Inicio"})]})}),e.jsx("th",{onClick:()=>H("termina"),className:"tw-whitespace-nowrap",style:{color:Z.gray.gray_dark,textAlign:"left"},children:e.jsxs("div",{className:"tw-flex tw-w-fit tw-items-center",children:[e.jsx("label",{style:{color:"#C4C4C4"},children:G("termina")}),e.jsx(ie.Icons,{icon:"calendar",size:"xs",strokeWidth:5,color:Z.gray.gray_dark,className:"tw-mt-1 tw-h-[15px] tw-w-[15px]"}),e.jsx("span",{className:"tw-align-middle tw-font-sans tw-text-[1.4rem] tw-font-normal tw-leading-[100%] tw-tracking-normal",children:"Fecha Fin"})]})}),e.jsx("th",{className:"align-middle tw-whitespace-nowrap tw-text-center",style:{color:Z.gray.gray_dark},children:e.jsx("div",{className:"tw-inline-flex tw-w-full tw-items-center tw-justify-center",children:e.jsx("span",{className:"tw-font-sans tw-text-[1.4rem] tw-font-normal tw-leading-[100%] tw-tracking-normal",children:"Status de campaña"})})}),e.jsx("th",{className:"align-middle tw-whitespace-nowrap tw-text-center",style:{color:Z.gray.gray_dark},children:e.jsx("div",{className:"tw-inline-flex tw-w-full tw-items-center tw-justify-center",children:e.jsx("span",{className:"tw-font-sans tw-text-[1.4rem] tw-font-normal tw-leading-[100%] tw-tracking-normal",children:"Progreso de Ejecución"})})}),e.jsx("th",{className:"align-middle tw-whitespace-nowrap tw-text-center",style:{color:Z.gray.gray_dark},children:e.jsx("div",{className:"tw-inline-flex tw-w-full tw-items-center tw-justify-center",children:e.jsx("span",{className:"tw-font-sans tw-text-[1.4rem] tw-font-normal tw-leading-[100%] tw-tracking-normal",children:"Responsable"})})})]})}),e.jsx("tbody",{children:n==null?void 0:n.map((j,F)=>{var D,M,L,W,ae,X,oe,te,q,z,V,E,S,O,N,_,B,k;return e.jsxs("tr",{style:{background:F%2===0?"#F5F5F5":"#FAFAFA",transition:"background-color 0.2s ease"},className:"tw-cursor-pointer ",onClick:()=>{a({id:j==null?void 0:j.id,project:j==null?void 0:j.nombre}),t("kanban-campania")},onMouseEnter:T=>{T.currentTarget.style.backgroundColor="#E1EBF9"},onMouseLeave:T=>{T.currentTarget.style.backgroundColor=F%2===0?"#F5F5F5":"#FAFAFA"},children:[e.jsx("td",{className:"tw-text-s",children:(D=j==null?void 0:j.campania)==null?void 0:D.nombre}),e.jsx("td",{className:"tw-text-s",children:(M=j==null?void 0:j.campania)==null?void 0:M.inicia}),e.jsx("td",{className:"tw-text-s",children:(L=j==null?void 0:j.campania)==null?void 0:L.termina}),e.jsx("td",{className:"tw-text-s",children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",padding:"none",width:"auto",minWidth:"100px"},children:[e.jsxs("label",{className:"tw-text-black tw-w-[50px] tw-min-w-[50px] tw-text-right",children:[j==null?void 0:j.progreso,"%"]}),e.jsx("div",{style:{position:"relative",height:"10px",flex:1,backgroundColor:Z.gray.gray_dark,borderRadius:"10px",overflow:"hidden",maxWidth:"140px"},children:e.jsx("div",{style:{position:"absolute",top:0,left:0,height:"100%",width:`${j.progreso}%`,backgroundColor:j.progreso===100?Z.progressbar.green_regular:j.progreso>50?Z.progressbar.blue_regular:j.progreso>0?Z.progressbar.orange_regular:Z.gray.gray_dark,borderRadius:"10px",transition:"width 0.3s ease-in-out"}})})]})}),e.jsx("td",{className:"tw-text-s",children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",padding:"none",width:"auto",minWidth:"100px"},children:[e.jsxs("label",{className:"tw-text-black tw-w-[50px] tw-min-w-[50px] tw-text-right",children:[(j==null?void 0:j.progresoVenta)??0,"%"]}),e.jsx("div",{className:"tw-inline-flex tw-w-full tw-items-center tw-justify-center",style:{position:"relative",height:"10px",flex:1,backgroundColor:Z.gray.gray_dark,borderRadius:"10px",overflow:"hidden",maxWidth:"180px"},children:e.jsx("div",{style:{position:"absolute",top:0,left:0,height:"100%",width:`${(j==null?void 0:j.progresoVenta)??0}%`,backgroundColor:(j==null?void 0:j.progresoVenta)===100?Z.progressbar.green_regular:(j==null?void 0:j.progresoVenta)>50?Z.progressbar.blue_regular:(j==null?void 0:j.progresoVenta)>0?Z.progressbar.orange_regular:Z.gray.gray_dark,borderRadius:"10px",transition:"width 0.3s ease-in-out"}})})]})}),e.jsx("td",{className:"tw-text-s tw-pb-[1.2rem] tw-pt-[1.2rem]",children:e.jsxs("div",{className:"tw-text-s tw-flex tw-items-center tw-justify-center",children:[e.jsx(qe,{imageUrl:(te=(oe=(X=(ae=(W=j==null?void 0:j.campania)==null?void 0:W.responsable)==null?void 0:ae.imagen)==null?void 0:X.formats)==null?void 0:oe.thumbnail)!=null&&te.url?I((S=(E=(V=(z=(q=j==null?void 0:j.campania)==null?void 0:q.responsable)==null?void 0:z.imagen)==null?void 0:V.formats)==null?void 0:E.thumbnail)==null?void 0:S.url):"",alt:(_=(N=(O=j==null?void 0:j.campania)==null?void 0:O.responsable)==null?void 0:N.nombre)==null?void 0:_.charAt(0)}),e.jsx("span",{className:"tw-text-s tw-ml-4",children:(k=(B=j==null?void 0:j.campania)==null?void 0:B.responsable)==null?void 0:k.nombre})]})})]},F)})})]})}),e.jsxs("div",{className:"tw-mt-4 tw-flex tw-items-center tw-justify-between tw-p-2",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-start",color:Z.black.black_dark},className:"tw-whitespace-nowrap tw-font-sans tw-text-[1.4rem] tw-font-semibold tw-leading-none tw-tracking-normal tw-text-[#696E79]",children:[f," elementos de ",u]}),e.jsx(as.Paginator,{first:o,rows:l,totalRecords:u,rowsPerPageOptions:[5,10,20,50],onPageChange:P,className:"tw-flex tw-w-full tw-items-center tw-justify-center tw-gap-1 tw-rounded-lg tw-p-2",style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"4px",width:"auto",minWidth:"fit-content"},template:{layout:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink",FirstPageLink:j=>e.jsx("button",{onClick:j.onClick,disabled:j.disabled,style:J(j.disabled),className:"tw-text-s tw-flex tw-items-center tw-justify-center",children:"<<"}),PrevPageLink:j=>e.jsx("button",{onClick:j.onClick,disabled:j.disabled,style:J(j.disabled),className:"tw-text-s",children:"<"}),NextPageLink:j=>e.jsx("button",{onClick:j.onClick,disabled:j.disabled,style:J(j.disabled),className:"tw-text-s",children:">"}),LastPageLink:j=>e.jsx("button",{onClick:j.onClick,disabled:j.disabled,style:J(j.disabled),className:"tw-text-s",children:">>"}),PageLinks:j=>e.jsx("span",{style:{display:"inline-flex",gap:"1px"},children:e.jsx("button",{onClick:F=>j.onClick(F),className:`tw-text-s tw-flex tw-items-center tw-justify-center ${j.className.includes("p-highlight")?"highlighted":""}`,style:{...J(!1),backgroundColor:j.className.includes("p-highlight")?"#E1EBF9":Z.silver.silver_light,color:Z.black.black_dark},children:j.page+1})})}}),e.jsxs("div",{className:"tw-flex tw-items-center tw-gap-2",children:[e.jsx("span",{className:"tw-whitespace-nowrap tw-font-sans tw-text-[1.4rem] tw-font-semibold tw-leading-none tw-tracking-normal tw-text-[#696E79]",children:"Filas por página:"}),e.jsx("select",{style:{padding:"0.25rem",outline:"none",cursor:"pointer",border:`1px solid ${Z.gray.gray_dark}`,borderRadius:"4px"},className:"tw-whitespace-nowrap tw-font-sans tw-text-[1.4rem] tw-font-[400] tw-leading-none tw-tracking-normal tw-text-[#696E79]",value:l,onChange:j=>y(j),children:C.map(j=>e.jsx("option",{value:j.value,className:"tw-text-s",style:{color:Z.gray.gray_dark},children:j.label},j.value))})]})]})]})})})},Ct=()=>{const[t,a]=w.useState(null);return{position:t,setElementPosition:i=>{var c;let o=(c=i.current)==null?void 0:c.getBoundingClientRect(),d=(o==null?void 0:o.x)+((o==null?void 0:o.width)??0),l=(o==null?void 0:o.y)+(o==null?void 0:o.height);a(t?null:{x:d??0,y:l??0})},getChildrenSize:i=>{var o;return(o=i.current)==null?void 0:o.getBoundingClientRect()},clearPosition:()=>{a(null)}}},xs=({children:t,filterChildren:a})=>{const{position:n,setElementPosition:r}=Ct(),s=w.useRef(null),i=({children:o})=>{const[d,l]=w.useState();return w.useEffect(()=>{var c,u;a.current&&l(((n==null?void 0:n.x)??0)-(((u=(c=a.current)==null?void 0:c.getBoundingClientRect())==null?void 0:u.width)??0))},[a==null?void 0:a.current,n==null?void 0:n.x]),n&&tt.createPortal(e.jsx("div",{className:`tw-absolute tw-h-fit tw-w-fit ${d?"tw-block":"tw-hidden"}`,style:{top:`${n==null?void 0:n.y}px`,left:`${d}px`,zIndex:1},"data-portal-host":!0,children:o}),document.body)};return e.jsxs(e.Fragment,{children:[e.jsxs("label",{ref:s,htmlFor:"filter-button",className:"tw-flex tw-h-[30px] tw-cursor-pointer tw-items-center tw-gap-m tw-rounded-lg tw-bg-bg tw-fill-texts-enfasis tw-p-s tw-px-l tw-text-xl tw-text-texts-enfasis tw-shadow-button-primary hover:tw-shadow-button-primary-hover",children:[e.jsx(ie.Icons,{icon:"filter",size:"xs",strokeWidth:5,color:Z.primary.regular}),"Filtrar"]}),e.jsx("button",{className:"tw-hidden",id:"filter-button",onClick:()=>{r(s)}}),e.jsx(i,{children:t})]})};function gs(t,a=300,n={leading:!1,trailing:!0}){let r,s=null;return function(...i){const o=Date.now(),d=n.leading&&!s;clearTimeout(r),d&&t(...i),s=o,r=setTimeout(()=>{n.trailing&&(!n.leading||o-s>=a)&&(t(...i),s=null)},a)}}const hs="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='uuid-870f9847-3249-4f3d-96c6-7627dd5f9e7b'%20data-name='Iconos'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2050%2050'%3e%3cdefs%3e%3cstyle%3e%20.uuid-4d76d382-032b-400f-b22d-b6e7be4cfaae%20{%20fill:%20none;%20stroke:%20%23252525;%20stroke-linecap:%20round;%20stroke-linejoin:%20round;%20stroke-width:%204px;%20}%20%3c/style%3e%3c/defs%3e%3ccircle%20class='uuid-4d76d382-032b-400f-b22d-b6e7be4cfaae'%20cx='19.79'%20cy='19.79'%20r='13.54'/%3e%3cline%20class='uuid-4d76d382-032b-400f-b22d-b6e7be4cfaae'%20x1='41.67'%20y1='41.67'%20x2='29.17'%20y2='29.17'/%3e%3c/svg%3e",ua=({options:t,onselect:a})=>{const[n,r]=w.useState(null),s=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),i=[...t].filter(o=>o.name.toLowerCase().includes((n==null?void 0:n.toLowerCase())??""));return e.jsxs("div",{className:"tw-h-fit tw-w-full tw-min-w-max",children:[e.jsxs("div",{className:"tw-relative tw-flex tw-items-center",children:[e.jsx("input",{id:s,value:n??"",onChange:o=>r(o.target.value),type:"text",className:"tw-border-cards tw-h-[32px] tw-w-full tw-rounded-lg tw-bg-bg-card tw-p-2",placeholder:"Buscar"}),e.jsx("div",{className:"tw-absolute tw-right-[8px]",children:e.jsx("img",{src:hs,alt:"Icono",className:"tw-h-[12px] tw-w-[12px]"})})]}),e.jsx("div",{className:"tw-border-cards tw-flex tw-max-h-[120px] tw-min-w-max tw-flex-col tw-gap-s tw-overflow-y-auto tw-rounded-lg tw-bg-bg-card tw-p-2",children:i.map(o=>e.jsxs("button",{onClick:()=>{a(o)},className:"tw-flex tw-min-w-full tw-max-w-[200px] tw-cursor-pointer tw-items-center tw-gap-s hover:tw-bg-primary-light",children:[o.image&&e.jsx(qe,{imageUrl:o.image,alt:o.name}),e.jsx("p",{className:"tw-text-s tw-content-text tw-truncate tw-py-m tw-font-normal tw-text-texts-subtext",children:o.name})]}))})]})},bs=({error:t,options:a,onSelect:n,initialValue:r})=>{const[s,i]=w.useState(!1),[o,d]=w.useState((r==null?void 0:r.name)??null);return w.useEffect(()=>{r&&d(r)},[r]),e.jsxs("div",{className:"tw-relative",children:[e.jsxs("div",{onBlur:()=>i(!1),onClick:()=>i(!s),className:`tw-z-[1] tw-w-full tw-cursor-pointer tw-bg-bg-card ${t?"tw-border-2 tw-border-danger-regular tw-shadow-danger-regular":"tw-shadow-input"} tw-flex tw-h-[30px] tw-items-center tw-justify-between tw-rounded-md tw-pl-2 ${t?"tw-text-danger-regular":o?"tw-text-texts-subtext":"tw-text-texts-placeholder"}`,children:[e.jsx("p",{children:(o==null?void 0:o.name)??"Selecciona una opción"}),e.jsx(ie.Icons,{icon:"angle_down_outline",color:t?Z.danger.regular:Z.texts.placeholder})]}),s&&e.jsx("div",{className:"absolute tw-z-[10] tw-w-full tw-rounded-lg tw-shadow-md",children:e.jsx(ua,{onselect:l=>{d(l),i(!1),n&&n(l)},options:a})})]})},ys=()=>{const{fields:t,updateFilters:a,cleanFilters:n,applyFilters:r,initialFilters:s}=Le();return e.jsxs("div",{className:"tw-z-[100] tw-flex tw-min-w-[250px] tw-flex-col tw-gap-l",children:[e.jsxs("div",{className:"tw-flex tw-items-center tw-justify-between",children:[e.jsx("p",{className:"tw-text-2xl tw-text-texts",children:"Filtros"}),e.jsx("button",{className:"tw-flex tw-h-fit tw-cursor-pointer tw-items-center tw-gap-m tw-rounded-lg tw-bg-bg tw-fill-texts-enfasis tw-p-s tw-px-l tw-text-lg tw-font-semibold tw-text-texts-enfasis tw-shadow-button-primary hover:tw-shadow-button-primary-hover",onClick:n,children:"Limpiar"})]}),e.jsx("div",{className:"tw-flex tw-flex-col tw-gap-m",children:t==null?void 0:t.map((i,o)=>{var d;return e.jsxs("div",{style:{zIndex:10-o},children:[e.jsx("p",{className:"z-[1] tw-text-xl",children:i.label}),(i==null?void 0:i.type)==="select"?e.jsx("div",{className:"tw-relative tw-z-[10]",children:e.jsx(bs,{error:!1,options:i==null?void 0:i.options,onSelect:l=>{a({name:i==null?void 0:i.id,value:l==null?void 0:l.id})},initialValue:(d=i==null?void 0:i.options)==null?void 0:d.find(l=>l.id===(s==null?void 0:s[i==null?void 0:i.id]))})}):e.jsx("input",{className:"tw-h-[30px] tw-w-full tw-rounded-lg tw-p-s tw-shadow-input",type:i.type,value:s==null?void 0:s[i==null?void 0:i.id],name:i.label.toLowerCase().replace(/ /g,"_"),onChange:gs(l=>{var c,u;return a({name:(c=l==null?void 0:l.target)==null?void 0:c.name,value:(u=l==null?void 0:l.target)==null?void 0:u.value})},1e3)})]},o)})}),e.jsx("button",{className:"tw-rounded-md tw-bg-primary-regular tw-py-s tw-text-xl tw-text-white hover:tw-bg-primary-dark",onClick:r,children:"Filtrar"})]})},js=()=>e.jsxs("div",{className:"tw-flex tw-h-[150px] tw-w-full tw-animate-pulse tw-flex-col tw-gap-[50px] tw-rounded-md tw-bg-gray-200 tw-p-4",children:[e.jsxs("div",{className:"tw-flex tw-h-[30px] tw-gap-3",children:[e.jsx("div",{className:"tw-h-full tw-w-[30px] tw-min-w-[30px] tw-rounded-full tw-bg-gray-300"}),e.jsx("div",{className:"tw-h-full tw-w-full tw-bg-gray-300"}),e.jsx("div",{className:"tw-h-full tw-w-[30px] tw-min-w-[30px] tw-rounded-full tw-bg-gray-300"})]}),e.jsxs("div",{className:"tw-flex tw-h-[30px] tw-w-full tw-justify-between tw-gap-[50px]",children:[e.jsx("div",{className:"tw-h-[30px] tw-w-full tw-bg-gray-300"}),e.jsx("div",{className:"tw-h-[30px] tw-w-full tw-bg-gray-300"})]})]}),zt=({trigger:t,user:a,showUser:n=!0})=>e.jsx(ie.Tooltip,{dispatch:t,children:n&&e.jsxs("div",{className:"tw-border-containers tw-flex tw-h-fit tw-w-fit tw-items-center tw-gap-2 tw-rounded-lg tw-bg-bg-card tw-p-2",children:[e.jsx(qe,{imageUrl:a.image??"",alt:a.name}),e.jsx("p",{className:"tw-text-s tw-font-bold tw-text-texts-subtext",children:a.name})]})});class _s{static toDomain(a){return{id:a.id,name:a.nombre,color:a.color}}}const vs=()=>{const{tasks_api:t}=fe();return{teams:pe.useQuery({queryKey:["teams","all"],queryFn:async()=>{const n=await t.get("/api/equipos");return he(n.data).map(_s.toDomain)},refetchOnWindowFocus:!1})}};class Et{static toUsers(a){var n,r,s;return{id:a.id,name:a.nombre,image:(s=(r=(n=a.imagen)==null?void 0:n.formats)==null?void 0:r.thumbnail)==null?void 0:s.url,tasksUser:{email:a.tasksUser.email,id:a.tasksUser.id,nombre:a.tasksUser.nombre},role:a.role}}static toUsersV2(a){var n,r,s;return{id:a.id,name:a.nombre,image:(s=(r=(n=a.imagen)==null?void 0:n.formats)==null?void 0:r.thumbnail)==null?void 0:s.url,role:a.role}}static toUsersWithIndex(a){var r,s,i;const n={};for(const o of a)n[o.email]={...o,image:(i=(s=(r=o.imagen)==null?void 0:r.formats)==null?void 0:s.thumbnail)==null?void 0:i.url};return n}}const Ns=async({tasks_api:t})=>{try{const a=await t.get("/api/getAllOBPusersMembers");return he(a.data).map(Et.toUsers)}catch(a){throw console.log("Error al obtener los usuarios comerciales",a),`Error al obtener los usuarios comerciales: ${a}`}},Ts=async({tasks_api:t})=>{try{const a={filters:{$and:[{role:{name:{$in:["Project Manager","Operation Manager","Administrador"]}}},{blocked:{$eq:!1}}]}},n=Pe.stringify(a,{encodeValuesOnly:!0}),r=await t.get(`/api/users?${n}`),i=he(r.data).map(l=>l.email),o=await t.get(`/api/getAllOBPusers?filters[name][$in]=${i}`);return he(o.data).map(Et.toUsersV2)}catch(a){throw console.log("Error al obtener los usuarios comerciales",a),`Error al obtener los usuarios comerciales: ${a}`}},Cs=async({users:t})=>{try{const a=he(t);return Et.toUsersWithIndex(a)}catch(a){throw console.log("Error al obtener los usuarios comerciales",a),`Error al obtener los usuarios comerciales: ${a}`}},Es=()=>{const{tasks_api:t}=fe();return{users:pe.useQuery({queryKey:["users"],queryFn:()=>Ns({tasks_api:t}),staleTime:1e3*60*60*24})}},Ss=()=>{const{tasks_api:t}=fe();return{users:pe.useQuery({queryKey:["allUsers"],queryFn:()=>Ts({tasks_api:t}),staleTime:1e3*60*60*24})}},pa=({users:t,onClick:a,responsible:n,role:r,status:s})=>{const{getOBPUrlApi:i}=fe(),o=`button-assign-users-${Math.random().toString(36).substring(2,15)}`,{setElementPosition:d,position:l,clearPosition:c}=Ct(),u=w.useRef(null),m="Project Manager",x=()=>n?null:t.length>3&&e.jsx(ie.Tooltip,{dispatch:e.jsx("div",{className:"tw-ml-[-8px] tw-flex tw-h-[28px] tw-w-[28px] tw-items-center tw-justify-center tw-rounded-full tw-border-2 tw-border-white tw-bg-primary-regular",children:e.jsx("p",{className:"tw-text-s tw-font-bold tw-text-white ",children:`+${t.length-3}`})}),children:e.jsx("div",{className:"tw-border-containers tw-h-fit tw-w-fit tw-rounded-lg tw-bg-bg-card tw-p-2",children:t==null?void 0:t.slice(3).map((h,b)=>e.jsxs("div",{className:"tw-flex tw-items-center tw-gap-2 ",children:[e.jsx(qe,{imageUrl:h.image??"",alt:h.name},b),e.jsx("p",{className:"tw-text-s tw-font-bold tw-text-texts-subtext",children:h.name})]},b))})}),p=()=>{if(n){let h=t.find(b=>b.id===n);return e.jsx("div",{children:e.jsx(zt,{trigger:e.jsx(qe,{imageUrl:h==null?void 0:h.image,alt:h==null?void 0:h.name},n),user:h,showUser:!(l!=null&&l.x)})})}return(t==null?void 0:t.length)>0&&t.slice(0,3).map((h,b)=>e.jsx("div",{className:`${b===0?"":"tw-ml-[-8px]"}`,children:e.jsx(zt,{trigger:e.jsx(qe,{imageUrl:h.image,alt:h.name}),user:h,showUser:!(l!=null&&l.x)})},h.id||b))},f=({children:h})=>e.jsx("label",{ref:u,htmlFor:o,className:"tw-flex tw-cursor-pointer tw-items-center",children:h});if(t.length===0)return e.jsx(f,{children:e.jsx(ie.Icons,{icon:"user",size:"xs",strokeWidth:3})});const g=()=>{var P;const[h,b]=w.useState(),[v,I]=w.useState("team"),{teams:$}=vs(),{users:R}=Es();w.useEffect(()=>{var C,y;u.current&&b(((l==null?void 0:l.x)??0)-(((y=(C=u.current)==null?void 0:C.getBoundingClientRect())==null?void 0:y.width)??0))},[u==null?void 0:u.current,l==null?void 0:l.x]);const U=()=>{const C=[{id:"team",label:"Equipo"},{id:"responsible",label:"Responsable"}];return e.jsx("div",{className:"tw-flex tw-w-full tw-justify-center tw-gap-l tw-font-bold tw-text-texts-placeholder",children:C.map((y,H)=>e.jsx("button",{className:`tw-w-full tw-border-texts-placeholder tw-text-center tw-text-sm ${v===y.id?"tw-text-primary-pastel":""} ${H===C.length-1?"tw-border-r-0":" tw-border-r-2"}`,onClick:()=>I(y.id),children:y.label},y.id))})};return r===m||s===0&&r!==m?(l==null?void 0:l.x)&&tt.createPortal(e.jsx("div",{"data-portal-host":!0,className:`absolute tw-h-fit tw-w-[300px] tw-p-[1rem] ${h?"tw-block":"tw-hidden"}`,style:{top:`${l==null?void 0:l.y}px`,left:`${h}px`,zIndex:1},children:e.jsxs("div",{className:"tw-border-cards tw-flex tw-max-h-[200px] tw-flex-col tw-gap-m tw-overflow-y-hidden tw-rounded-lg tw-bg-bg-card tw-p-2",style:{boxShadow:"0px 2px 16px 0px rgba(0, 0, 0, 0.25)"},children:[e.jsx(U,{}),e.jsx(ua,{options:v==="team"?$.data.map(C=>({id:C.id,name:C.name,image:""})):((P=R.data)==null?void 0:P.map(C=>Nt(C,i())))||[],onselect:C=>{var y;c(),a&&a((y=C.tasksUser)==null?void 0:y.id,v)}})]})}),document.body):null};return e.jsxs(e.Fragment,{children:[e.jsxs(f,{children:[p(),x()]}),e.jsx("button",{className:"tw-hidden",id:o,onClick:()=>d(u)}),e.jsx(g,{})]})};function wa({trigger:t,children:a,open:n,setOpen:r}){return e.jsxs(je.DropdownMenu,{open:n,onOpenChange:r,children:[e.jsx(je.DropdownMenuTrigger,{children:t}),e.jsx(je.DropdownMenuContent,{align:"start",className:"tw-rounded-lg tw-border-none tw-bg-white tw-p-4",children:a})]})}const ma=({priority:t,id:a,withLabel:n=!1})=>{var x,p,f,g,h;const{updatingTask:r}=Ue(),s=Math.random().toString(36),[i,o]=w.useState(null),{user:d}=Ee(),[l,c]=w.useState(t);w.useEffect(()=>{c(t)},[t]);const u={0:{title:"Normal",color:Z.primary.regular},1:{title:"Baja",color:Z.success.regular},2:{title:"Media",color:Z.warning.regular},3:{title:"Alta",color:Z.danger.regular}},m=()=>{if(!i)return null;const b=({priorityTask:v,text:I})=>{var $,R;return e.jsxs("button",{onClick:async()=>{o(null),await r({id:a,data:{prioridad:v},user:d==null?void 0:d.id}),c(v)},className:"tw-flex tw-items-center tw-gap-m tw-px-l tw-py-s hover:tw-bg-primary-light",children:[e.jsx(ie.Icons,{icon:"flag",size:"xs",strokeWidth:4,color:($=u[v??0])==null?void 0:$.color}),e.jsx("p",{className:"tw-text-sm",style:{color:(R=u[v??0])==null?void 0:R.color},children:I})]})};return tt.createPortal(e.jsx("div",{onBlur:()=>{o(null)},id:`${s}-options`,style:{top:`${i.y+5}px`,left:`${i.x+5}px`,zIndex:50},className:`tw-absolute tw-flex tw-h-fit tw-w-max tw-flex-col tw-gap-2 tw-rounded-xl tw-bg-bg-card tw-p-m
|
|
2
2
|
tw-shadow-lg`,"data-portal-host":!0,children:Object.values(u).map((v,I)=>e.jsx(b,{priorityTask:I,text:v.title},I))}),document.body)};return e.jsxs("div",{className:"tw-relative tw-h-[22px]",children:[e.jsxs("label",{onBlur:()=>{o(null)},htmlFor:s,className:"tw-flex tw-cursor-pointer tw-items-center tw-gap-2 active:tw-opacity-50",children:[e.jsx(ie.Tooltip,{dispatch:e.jsx(ie.Icons,{icon:"flag",size:"xs",strokeWidth:4,color:(x=u[l??0])==null?void 0:x.color}),children:e.jsx("p",{className:"tw-font-regular tw-rounded-lg tw-bg-bg-card tw-p-5 tw-text-sm",style:{color:(p=u[l??0])==null?void 0:p.color},children:`Prioridad: ${(f=u[l??0])==null?void 0:f.title}`})}),n&&e.jsx("span",{style:{color:(g=u[l??0])==null?void 0:g.color},className:"tw-text-lg tw-font-normal",children:((h=u[l??0])==null?void 0:h.title)??"Sin prioridad"})]}),e.jsx("button",{id:s,onClick:b=>{o(i?null:{x:b.clientX,y:b.clientY})},className:"tw-hidden"}),e.jsx(m,{})]})},Je=new Map,Ds=t=>{Je.forEach((a,n)=>{n!==t&&a()})},Is=({children:t,actionsRef:a,newPosition:n,className:r})=>{const[s,i]=w.useState(),[o,d]=w.useState(!1);return w.useEffect(()=>{var l,c;if(a.current&&n){const u=((n==null?void 0:n.x)??0)-(((c=(l=a.current)==null?void 0:l.getBoundingClientRect())==null?void 0:c.width)??0);i(u),requestAnimationFrame(()=>{d(!0)})}return()=>{d(!1),i(void 0)}},[a==null?void 0:a.current,n==null?void 0:n.x]),!n||s===void 0?null:tt.createPortal(e.jsx("div",{"data-portal-host":!0,className:`
|
|
3
3
|
tw-pointer-events-auto tw-absolute tw-h-fit
|
|
4
4
|
tw-w-fit tw-transition-all tw-duration-200
|
package/dist/tareas.es.js
CHANGED
|
@@ -1015,7 +1015,8 @@ const Fo = async ({
|
|
|
1015
1015
|
idUser: R.id,
|
|
1016
1016
|
responsableType: (P = b == null ? void 0 : b.responsable) == null ? void 0 : P.responsableType
|
|
1017
1017
|
},
|
|
1018
|
-
ejecutivo: (b == null ? void 0 : b.ejecutivo) ?? ""
|
|
1018
|
+
ejecutivo: (b == null ? void 0 : b.ejecutivo) ?? "",
|
|
1019
|
+
cancelada: { $eq: !1 }
|
|
1019
1020
|
}
|
|
1020
1021
|
}, se = await N.get("/api/listado_campanias", {
|
|
1021
1022
|
params: {
|
package/package.json
CHANGED