@imj_media/tareas 0.1.21 → 0.1.22
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/packages/tareas/src/components/kanban-general/filters.d.ts +9 -0
- package/dist/packages/tareas/src/context/filtersLayout.context.d.ts +1 -0
- package/dist/packages/tareas/src/hooks/useFunctionsTasks.d.ts +3 -0
- package/dist/tareas.cjs +2 -2
- package/dist/tareas.es.js +833 -776
- package/package.json +2 -2
package/dist/tareas.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime");require("@imj_media/imj-ui/styles.css");const A=require("@tanstack/react-query"),c=require("react"),w=require("@imj_media/tasks-modules"),Q=require("react-dom"),ue=require("axios"),me=require("qs"),K=require("date-fns"),G=require("date-fns/locale"),F=require("@imj_media/imj-ui"),qe=require("react-hook-form"),Ee=require("primereact/paginator"),De=({label:t,active:s,onClick:n,disabled:a})=>a?e.jsx(w.Tooltip,{dispatch:e.jsxs("button",{className:"text-texts-placeholder text-xs font-semibold cursor-help",children:[" ",t," "]}),children:e.jsx("div",{className:"flex items-center justify-center px-3 py-2 bg-bg-card rounded-lg border border-border-card",children:e.jsx("p",{className:"text-texts-placeholder text-xs font-semibold",children:"Espéralo muy pronto..."})})}):e.jsx("button",{disabled:a,onClick:n,className:`${s?"text-texts-enfasis border-b-2 border-texts-enfasis":""} text-xs font-semibold ${a?"cursor-not-allowed text-texts-placeholder":"text-texts-subtext"} `,children:t}),Ie=({tabs:t,renderItem:s,initialTab:n})=>{const[a,r]=c.useState(n??t[0].toLowerCase());c.useEffect(()=>{n&&r(n)},[n]);const l=i=>{r(i),s(i)};return e.jsx("div",{className:"flex",children:t.map((i,x)=>e.jsx("div",{className:`${x===0?"border-l-2":""} border-r-2 border-gray-200 px-m`,children:e.jsx(De,{onClick:()=>l(i.toLowerCase()),label:i,active:i.toLowerCase()===a,disabled:["gantt"].includes(i.toLowerCase())},x)}))})},_={bg:{DEFAULT:"#EFEFEF",content:"#FAFAFA",card:"#FAFAFA"},texts:{DEFAULT:"#252525",enfasis:"#3658c1",subtext:"#4f4f4f",placeholder:"#929292"},primary:{light:"#E7E9F2",medium:"#dae2ec",dark:"#334990",regular:"#425CAC",pastel:"#5c7ddd"},success:{light:"#368156",medium:"#D2E9DC",dark:"#368156",regular:"#43B071",pastel:"#57BA81"},danger:{light:"#F1E5E4",medium:"#EBDBD9",dark:"#8C352C",regular:"#C34335",pastel:"#C4335"},warning:{light:"#F2ECE5",medium:"#EBE3D9",dark:"#B4782F",regular:"#D38A31",pastel:"#D38A31"},alert:{light:"#F1F1E4",medium:"#EAE9D9",dark:"#ADA63A",regular:"#D6CC48",pastel:"#D6CC48"},info:{light:"#E7F5FF",medium:"#D9E6EE",dark:"#1C5073",regular:"#1B6698",pastel:"#1B6698"},link:{light:"#ECF8FE",medium:"#D8F1FD",dark:"#0A7AAE",regular:"#0EA5E9",pastel:"#0EA5E9"}},Y=()=>{const[t,s]=c.useState(null);return{position:t,setElementPosition:l=>{var m;let i=(m=l.current)==null?void 0:m.getBoundingClientRect(),x=(i==null?void 0:i.x)+((i==null?void 0:i.width)??0),o=(i==null?void 0:i.y)+(i==null?void 0:i.height);s(t?null:{x:x??0,y:o??0})},getChildrenSize:l=>{var i;return(i=l.current)==null?void 0:i.getBoundingClientRect()},clearPosition:()=>{s(null)}}},$e=({children:t,filterChildren:s})=>{const{position:n,setElementPosition:a}=Y(),r=c.useRef(null),l=({children:i})=>{const[x,o]=c.useState();return c.useEffect(()=>{var m,d;s.current&&o(((n==null?void 0:n.x)??0)-(((d=(m=s.current)==null?void 0:m.getBoundingClientRect())==null?void 0:d.width)??0))},[s==null?void 0:s.current,n==null?void 0:n.x]),n&&Q.createPortal(e.jsx("div",{className:`absolute w-fit h-fit ${x?"block":"hidden"}`,style:{top:`${n==null?void 0:n.y}px`,left:`${x}px`,zIndex:1},children:i}),document.body)};return e.jsxs(e.Fragment,{children:[e.jsxs("label",{ref:r,htmlFor:"filter-button",className:"flex cursor-pointer items-center gap-m p-s text-texts-enfasis fill-texts-enfasis bg-bg rounded-lg px-l h-[30px] shadow-button-primary hover:shadow-button-primary-hover ",children:[e.jsx(w.Icons,{icon:"filter",size:"xs",strokeWidth:5,color:_.primary.regular}),"Filtrar"]}),e.jsx("button",{className:"hidden",id:"filter-button",onClick:()=>{a(r)}}),e.jsx(l,{children:t})]})},ce=t=>{let s={};return Object.entries(t).forEach(([n,a])=>{if(n.includes(".")){let[r,l]=n.split(".");s[r]=s[r]||{},s[r][l]=a}else s[n]=a}),s},pe=c.createContext({}),Me=({children:t})=>{const[s,n]=c.useState({}),[a,r]=c.useState({}),[l,i]=c.useState([]),[x,o]=c.useState(""),m=({name:u,value:h})=>{function b(N){return!isNaN(N)&&N!==null&&N!==""?parseFloat(N):null}let f=b(h);r(N=>{let j={...N},y=l==null?void 0:l.find(v=>v.label.toLowerCase().replace(/ /g,"_")===u);return y?j[y.id]=f??h:j[u]=f??h,j})};c.useEffect(()=>{let u=l.map(h=>h.id==="owner.config"?[h.id,"yo_y_mis_equipos"]:h.id==="dependency"?[h.id,"ambas"]:[h.id,null]);r(Object.fromEntries(u))},[l]);const d=()=>{let u=l.map(h=>h.id==="owner.config"?[h.id,"yo_y_mis_equipos"]:h.id==="dependency"?[h.id,"ambas"]:[h.id,null]);r(Object.fromEntries(u)),n(ce(Object.fromEntries(u)))},g=()=>{let u=ce(a);console.log({filtersWithEstructure:u}),n(u)};return e.jsx(pe.Provider,{value:{fields:l,filters:s,path:x,defineFields:i,updateFilters:m,cleanFilters:d,applyFilters:g,initialFilters:a,selectPath:o},children:t})},E=()=>c.useContext(pe);function he(t,s=300,n={leading:!1,trailing:!0}){let a,r=null;return function(...l){const i=Date.now(),x=n.leading&&!r;clearTimeout(a),x&&t(...l),r=i,a=setTimeout(()=>{n.trailing&&(!n.leading||i-r>=s)&&(t(...l),r=null)},s)}}const Be=()=>{const{fields:t,updateFilters:s,cleanFilters:n,applyFilters:a,initialFilters:r}=E();return e.jsxs("div",{className:"flex flex-col gap-l min-w-[250px] z-[100]",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("p",{className:"text-texts text-m",children:"Filtros"}),e.jsx("button",{className:"text-xs font-semibold flex cursor-pointer items-center gap-m p-s text-texts-enfasis fill-texts-enfasis bg-bg rounded-lg px-l h-fit shadow-button-primary hover:shadow-button-primary-hover ",onClick:n,children:"Limpiar"})]}),e.jsx("div",{className:"flex flex-col gap-m",children:t==null?void 0:t.map((l,i)=>{var x;return e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:l.label}),(l==null?void 0:l.type)==="select"?e.jsx("select",{onChange:o=>{var m,d;s({name:(m=o==null?void 0:o.target)==null?void 0:m.name,value:(d=o==null?void 0:o.target)==null?void 0:d.value})},value:r==null?void 0:r[l==null?void 0:l.id],className:"w-full h-[30px] shadow-input rounded-lg p-s",name:l.id,id:l.id,children:(x=l==null?void 0:l.options)==null?void 0:x.map((o,m)=>e.jsx("option",{value:o.id,children:o.name},m))}):e.jsx("input",{className:"w-full h-[30px] shadow-input rounded-lg p-s",type:l.type,value:r==null?void 0:r[l==null?void 0:l.id],name:l.label.toLowerCase().replace(/ /g,"_"),onChange:he(o=>{var m,d;return s({name:(m=o==null?void 0:o.target)==null?void 0:m.name,value:(d=o==null?void 0:o.target)==null?void 0:d.value})},1e3)})]},i)})}),e.jsx("button",{className:"btn-primary rounded-md py-s",onClick:a,children:"Filtrar"})]})},M=t=>{const s=a=>Object.prototype.toString.call(a)==="[object Object]",n=a=>a.attributes?{id:a.id,...a.attributes}:a;if(Array.isArray(t))return t.map(a=>M(a));if(s(t)){Array.isArray(t.data)?t=[...t.data]:s(t.data)?t=n({...t.data}):t.data===null?t=null:t=n(t);for(const a in t)t[a]=M(t[a]);return t}return t};class ze{static toCampaignTasks(s){var a,r,l,i,x,o,m,d,g,u,h,b;let n=[];return s!=null&&s.responsable&&n.push({id:s.responsable.id,name:s.responsable.nombre,image:(x=(i=(l=(r=(a=s.responsable)==null?void 0:a.userOBP)==null?void 0:r.imagen)==null?void 0:l.formats)==null?void 0:i.thumbnail)==null?void 0:x.url}),console.log("task",s),(o=s==null?void 0:s.equipo)!=null&&o.miembros&&s.equipo.miembros.forEach(f=>{var N,j,y,v;n!=null&&n.find(C=>C.id===f.idUser.id)||f.idUser&&n.push({id:f.idUser.id,name:f.idUser.nombre,image:(v=(y=(j=(N=f==null?void 0:f.userOBP)==null?void 0:N.imagen)==null?void 0:j.formats)==null?void 0:y.thumbnail)==null?void 0:v.url})}),{isPrincipalTask:(s==null?void 0:s.tarea_principal)??!1,projectName:((m=s==null?void 0:s.proyecto)==null?void 0:m.nombre)??null,orden:(s==null?void 0:s.orden)??null,id:(s==null?void 0:s.id)??null,task:(s==null?void 0:s.texto_corto)??null,status:(s==null?void 0:s.estatus)??null,difficulty:(s==null?void 0:s.nivel_dificultad)??null,priority:(s==null?void 0:s.prioridad)??0,endDate:new Date((s==null?void 0:s.ffin)??null),startDate:new Date((s==null?void 0:s.finicio)??null),mediumName:(s==null?void 0:s.nombre_medio)??null,users:n,repeatsToDo:(s==null?void 0:s.repeticiones)??null,repeats:(s==null?void 0:s.repeticiones_realizadas)??null,comments:((d=s==null?void 0:s.comentarios)==null?void 0:d.length)??null,willBePaused:s==null?void 0:s.es_pausable,statusRequiredTask:((g=s==null?void 0:s.id_t_requerida)==null?void 0:g.estatus)??null,nameRequiredTask:((u=s==null?void 0:s.id_t_requerida)==null?void 0:u.texto_corto)??null,responsible:((h=s==null?void 0:s.responsable)==null?void 0:h.id)??null,tasks:((b=s==null?void 0:s.tareas)==null?void 0:b.map(f=>({id:f.id,name:f.texto_corto,status:f.estatus})))??null}}}const Le=async({filters:t,tasks_api:s,project:n})=>{try{const a=await s.get("/api/listado_tareas",{params:{...t,project:{id:n},includeAllTasks:!0}});return M(a.data.tareas).map(ze.toCampaignTasks)}catch(a){console.log(a)}},ge=c.createContext({}),Re=({children:t,user:s,url:n})=>{const a=ue.create({baseURL:n,headers:{Authorization:`Bearer ${s.accessToken}`},paramsSerializer:r=>me.stringify(r,{encodeValuesOnly:!0})});return e.jsx(ge.Provider,{value:{tasks_api:a},children:t})},D=()=>c.useContext(ge),fe=c.createContext({}),Oe=({children:t,user:s,url:n})=>{const a=ue.create({baseURL:n,headers:{Authorization:`Bearer ${s.accessToken}`},paramsSerializer:r=>me.stringify(r,{encodeValuesOnly:!0})});return e.jsx(fe.Provider,{value:{user:s,tasks_api:a},children:t})},B=()=>c.useContext(fe),je=c.createContext({}),We=({children:t,project:s})=>{var N;const n=A.useQueryClient(),[a,r]=c.useState([]),[l,i]=c.useState([]),{tasks_api:x}=D(),{filters:o}=E(),{user:m}=B(),[d,g]=c.useState({owner:{user:m.id,config:((N=o==null?void 0:o.owner)==null?void 0:N.config)??"yo_y_mis_equipos"},project:{id:s}}),u=A.useQuery({queryKey:["tasksProject",o,s],queryFn:()=>Le({filters:{...d},project:s,tasks_api:x})});c.useEffect(()=>{var j;Object.keys(o).length>0&&g({...o,owner:{user:m.id,config:((j=o==null?void 0:o.owner)==null?void 0:j.config)??"yo_y_mis_equipos"},project:{id:s}})},[o]),c.useEffect(()=>{n.invalidateQueries({queryKey:["tasksProject",o,s]})},[d]);const h=j=>{r(y=>[...y,j])},b=j=>{i(y=>y.includes(j)?y.filter(v=>v!==j):[...y,j])},f=s??null;return e.jsx(je.Provider,{value:{tasksProject:u,selectedTasks:a,projectID:f,openTasks:l,selectTask:h,openTask:b},children:t})},U=()=>c.useContext(je),Ue=[{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 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 dificultad",type:"select",id:"difficulty",options:[{id:0,name:"Muy facil"},{id:1,name:"Facil"},{id:2,name:"Media"},{id:3,name:"Dificil"},{id:4,name:"Muy dificil"}]}],Ke=({id:t})=>{const[s,n]=c.useState(!1);return{checked:s,checkTask:()=>{n(!s),console.log("completar tarea",t)}}},be=({id:t,nameRequiredTask:s,statusRequiredTask:n,status:a})=>{const{checked:r,checkTask:l}=Ke({id:t});let i=Math.random().toString();return e.jsxs(e.Fragment,{children:[a===1&&(n<2&&s!==""?e.jsx(w.Tooltip,{dispatch:e.jsx("label",{htmlFor:i,children:e.jsx(w.Icons,{icon:"info_circle",color:_.warning.regular,strokeWidth:4})}),children:e.jsxs("div",{className:"px-m py-s max-w-[200px] bg-warning-light rounded-lg border-l-[5px] border-warning-regular text-warning-dark text-xs",children:[e.jsx("p",{className:"font-bold",children:"Requiere completar su tarea requerida:"}),e.jsxs("p",{children:[" ",s," "]})]})}):e.jsx("label",{htmlFor:i,className:r?"bg-success-regular rounded-full w-[20px] h-[20px] flex items-center justify-center mx-[2px] transition-all":" transition-colors",children:e.jsx(w.Icons,{icon:r?"check_outline":"circle_checked",color:r?"white":_.texts.placeholder,strokeWidth:4,size:r?"xs":"s"})})),e.jsx("input",{id:i,checked:r,onChange:l,type:"checkbox",className:"hidden"})]})},L=({imageUrl:t="https://www.uv.unach.mx/assets/img/prueba/directorio/userM.png",alt:s="avatar"})=>e.jsx("img",{src:t===""?"https://www.uv.unach.mx/assets/img/prueba/directorio/userM.png":t,alt:s??"avatar",className:"w-[28px] h-[28px] min-w-[28px] min-h-[28px] rounded-full bg-containers border-2 border-white"}),de=({trigger:t,user:s,showUser:n=!0})=>e.jsx(w.Tooltip,{dispatch:t,children:n&&e.jsxs("div",{className:"flex items-center gap-2 bg-containers w-fit h-fit p-2 rounded-lg border-containers",children:[e.jsx(L,{imageUrl:s.image??"",alt:s.name}),e.jsx("p",{className:"text-xs font-bold content-text",children:s.name})]})}),Qe=({options:t,onselect:s})=>{const[n,a]=c.useState(null),r=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),l=[...t].filter(i=>i.name.toLowerCase().includes((n==null?void 0:n.toLowerCase())??""));return e.jsxs("div",{className:"h-fit w-full min-w-max",children:[e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("input",{id:r,value:n??"",onChange:i=>a(i.target.value),type:"text",className:"w-full h-[32px] bg-bg-card border-cards rounded-lg p-2",placeholder:"Buscar"}),e.jsx("div",{className:"absolute right-[8px]",children:e.jsx(w.Icons,{icon:"search",size:"xs",strokeWidth:3})})]}),e.jsx("div",{className:"bg-bg-card border-cards rounded-lg p-2 flex flex-col gap-s overflow-y-auto max-h-[120px] min-w-max",children:l.map(i=>e.jsxs("button",{onClick:()=>{s(i)},className:"flex gap-s items-center max-w-[200px] min-w-full hover:bg-primary-light cursor-pointer",children:[e.jsx(L,{imageUrl:i.image,alt:i.name}),e.jsx("p",{className:"text-xs font-bold content-text",children:i.name})]}))})]})};class He{static toDomain(s){return{id:s.id,name:s.nombre,color:s.color}}}const Ve=()=>{const{tasks_api:t}=D();return{teams:A.useQuery({queryKey:["teams","all"],queryFn:async()=>{const n=await t.get("/api/equipos");return M(n.data).map(He.toDomain)}})}};class Ge{static toUsers(s){var n,a,r;return{id:s.id,name:s.nombre,image:(r=(a=(n=s.imagen)==null?void 0:n.formats)==null?void 0:a.thumbnail)==null?void 0:r.url}}}const Ye=async({tasks_api:t})=>{try{const s=await t.get("/api/allOBPUsers");return M(s.data).map(Ge.toUsers)}catch(s){throw console.log("Error al obtener los usuarios comerciales",s),`Error al obtener los usuarios comerciales: ${s}`}},Xe=()=>{const{tasks_api:t}=D();return{users:A.useQuery({queryKey:["users"],queryFn:()=>Ye({tasks_api:t}),staleTime:1e3*60*60*24})}},ye=t=>new Intl.DateTimeFormat("es-MX",{month:"long"}).format(t);function Je(t){const s=["domingo","lunes","martes","miércoles","jueves","viernes","sábado"],n=new Date(t).getDay();return s[n]}const xe=t=>{let s=t||new Date,n=s.getDate(),a=ye(s.getMonth()).slice(0,3),r=s.getFullYear().toString().slice(-2),l=Je(s).slice(0,3);return`${l.charAt(0).toUpperCase()+l.slice(1)} ${n} ${a.charAt(0).toUpperCase()+a.slice(1)} ${r}`},X=t=>({...t,image:t.image?`https://devobp.imjmedia.com.mx${t.image}`:""}),we=({users:t,onClick:s,responsible:n})=>{let a=`button-assign-users-${Math.random().toString(36).substring(2,15)}`;const{setElementPosition:r,position:l,clearPosition:i}=Y(),x=c.useRef(null),o=()=>n?null:t.length>3&&e.jsx(w.Tooltip,{dispatch:e.jsx("div",{className:"w-[28px] h-[28px] rounded-full btn-primary flex items-center justify-center border-2 border-white ml-[-8px]",children:e.jsx("p",{className:"text-xs font-bold text-white ",children:`+${t.length-3}`})}),children:e.jsx("div",{className:"bg-containers w-fit h-fit p-2 rounded-lg border-containers",children:t==null?void 0:t.slice(3).map((u,h)=>e.jsxs("div",{className:"flex items-center gap-2 ",children:[e.jsx(L,{imageUrl:u.image??"",alt:u.name},h),e.jsx("p",{className:"text-xs font-bold content-text",children:u.name})]},h))})}),m=()=>{if(n){let u=t.find(h=>h.id===n);return e.jsx("div",{children:e.jsx(de,{trigger:e.jsx(L,{imageUrl:u==null?void 0:u.image,alt:u==null?void 0:u.name},n),user:u,showUser:!(l!=null&&l.x)})})}return(t==null?void 0:t.length)>0&&t.slice(0,3).map((u,h)=>e.jsx("div",{className:`${h===0?"":"ml-[-8px]"}`,children:e.jsx(de,{trigger:e.jsx(L,{imageUrl:u.image,alt:u.name},h),user:u,showUser:!(l!=null&&l.x)})}))},d=({children:u})=>e.jsx("label",{ref:x,htmlFor:a,className:"cursor-pointer flex items-center",children:u});if(t.length===0)return e.jsx(d,{children:e.jsx(w.Icons,{icon:"user",size:"xs",strokeWidth:3})});const g=()=>{var v;const[u,h]=c.useState(),[b,f]=c.useState("team"),{teams:N}=Ve(),{users:j}=Xe();c.useEffect(()=>{var C,S;x.current&&h(((l==null?void 0:l.x)??0)-(((S=(C=x.current)==null?void 0:C.getBoundingClientRect())==null?void 0:S.width)??0))},[x==null?void 0:x.current,l==null?void 0:l.x]);const y=()=>{const C=[{id:"team",label:"Equipo"},{id:"responsible",label:"Responsable"}];return e.jsx("div",{className:"w-full flex justify-center gap-l text-texts-placeholder font-bold",children:C.map((S,p)=>e.jsx("button",{className:`w-full text-sm border-texts-placeholder text-center ${b===S.id?"text-primary-pastel":""} ${p===C.length-1?"border-r-0":" border-r-2"}`,onClick:()=>f(S.id),children:S.label}))})};return(l==null?void 0:l.x)&&Q.createPortal(e.jsx("div",{className:`absolute w-[300px] h-fit ${u?"block":"hidden"}`,style:{top:`${l==null?void 0:l.y}px`,left:`${u}px`,zIndex:1},children:e.jsxs("div",{className:"flex flex-col gap-m bg-bg-card border-cards rounded-lg p-2 max-h-[200px] overflow-y-hidden",children:[e.jsx(y,{}),e.jsx(Qe,{options:b==="team"?N.data.map(C=>({id:C.id,name:C.name,image:""})):(v=j.data)==null?void 0:v.map(X),onselect:C=>{i(),s&&s(C)}})]})}),document.body)};return e.jsxs(e.Fragment,{children:[e.jsxs(d,{children:[m(),o()]}),e.jsx("button",{className:"hidden",id:a,onClick:()=>r(x)}),e.jsx(g,{})]})},Ne=()=>{const{tasks_api:t}=D(),{user:s}=B(),{filters:n,path:a}=E(),r=A.useQueryClient(),{projectID:l}=U(),i=async({id:d})=>(await t.put(`/api/tareas/${d}`,{data:{estatus:1,responsable:s==null?void 0:s.id,updated_by:s==null?void 0:s.id}})).data,x=async({id:d,data:g,user:u})=>{},o=async({id:d})=>{await m({id:d})},{mutateAsync:m}=A.useMutation({mutationFn:i,onSuccess:()=>{const d={"kanban-general":"to_do_tasks","kanban-campania":"tasksProject"};try{a==="kanban-general"&&(r.invalidateQueries({queryKey:[d[a],n]}),r.invalidateQueries({queryKey:["working_tasks",n]})),a==="kanban-campania"&&r.invalidateQueries({queryKey:[d[a],n,l]})}catch(g){console.error("Error updating the element:",g)}},onError:d=>{console.error("Failed to update the task.",d)}});return{updateTask:x,startWorking:o}},ve=({priority:t,id:s})=>{const{updateTask:n}=Ne(),a=Math.random().toString(36),[r,l]=c.useState(null),i=o=>({0:_.primary.regular,1:_.success.regular,2:_.warning.regular,3:_.danger.regular})[o],x=()=>{if(!r)return null;const o=({priority:m,text:d})=>e.jsxs("button",{onClick:()=>{n({id:s,data:{prioridad:m},user:272}),l(null)},className:"flex gap-m items-center px-l py-s hover:bg-primary-light",children:[e.jsx(w.Icons,{icon:"flag",size:"xs",strokeWidth:3,color:i(m)}),e.jsx("p",{className:"text-sm",style:{color:i(m)},children:d})]});return Q.createPortal(e.jsxs("div",{onBlur:()=>{l(null)},id:`${a}-options`,style:{top:`${r.y+5}px`,left:`${r.x+5}px`,zIndex:1},className:`absolute h-fit p-m flex flex-col gap-2 bg-bg-card rounded-xl shadow-lg
|
|
2
|
-
w-max`,children:[e.jsx(o,{priority:0,text:"Baja"}),e.jsx(o,{priority:1,text:"Normal"}),e.jsx(o,{priority:2,text:"Media"}),e.jsx(o,{priority:3,text:"Alta"})]}),document.body)};return e.jsxs("div",{className:"relative h-[22px]",children:[e.jsx("label",{onBlur:()=>{l(null)},htmlFor:a,className:"flex items-center gap-2 cursor-pointer active:opacity-50",children:e.jsx(w.Icons,{icon:"flag",size:"xs",strokeWidth:3,color:i(t)})}),e.jsx("button",{id:a,onClick:o=>{l(r?null:{x:o.clientX,y:o.clientY})},className:"hidden"}),e.jsx(x,{})]})};function Ze({items:t}){var a;const[s,n]=c.useState(1);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-row mb-2 border-b border-neutral-100 bg-white mt-4",children:t.map((r,l)=>e.jsx("div",{className:`border-r border-neutral-100 pr-3 py-1 ${l!==0?"px-3":""}`,children:e.jsx(F.Button,{variant:"ghost",onClick:()=>n(r.id),className:`text-sm font-normal rounded-none py-1 h-8 ${s===r.id?"text-primary border-b border-primary":"text-neutral-400 border-b-0"}`,children:r.label},r.id)},r.id))}),e.jsx("div",{className:"pt-4 flex-1 overflow-y-auto bg-white",children:(a=t.find(r=>r.id===s))==null?void 0:a.component})]})}const Ce="https://devobp.imjmedia.com.mx";function J(t){return t?t.split(" ").map(a=>{var r;return(r=a[0])==null?void 0:r.toUpperCase()}).slice(0,2).join(""):""}const ke="https://devobp.imjmedia.com.mx";function es({comment:t}){var n,a,r,l,i,x;function s(o){const m=K.parseISO(o);return K.formatDistanceToNow(m,{locale:G.es,addSuffix:!0})}return e.jsx("div",{children:e.jsxs("div",{className:"flex flex-row gap-3 items-start",children:[e.jsxs(F.Avatar,{className:"w-[28px] h-[28px]",children:[e.jsx(F.AvatarImage,{src:`${ke}${(l=(r=(a=(n=t==null?void 0:t.autor)==null?void 0:n.imagen)==null?void 0:a.formats)==null?void 0:r.thumbnail)==null?void 0:l.url}`,alt:"@shadcn"}),e.jsx(F.AvatarFallback,{children:J((i=t==null?void 0:t.autor)==null?void 0:i.nombre)})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx("p",{className:"text-sm text-neutral-900 font-medium",children:(x=t==null?void 0:t.autor)==null?void 0:x.nombre}),e.jsx("span",{className:"text-xs text-neutral-600 font-normal mt-[2px]",children:s(t==null?void 0:t.createdAt)})]}),e.jsx("p",{className:"text-sm text-neutral-600 font-normal",children:t==null?void 0:t.comentario})]})]})})}function ss({currentUser:t,data:s,taskId:n,onNewComment:a}){var g,u,h;const{tasks_api:r}=D(),{register:l,handleSubmit:i,reset:x}=qe.useForm(),[o,m]=c.useState([]);c.useEffect(()=>{if(s!=null&&s.comentarios){const b=[...s.comentarios].sort((f,N)=>new Date(N.createdAt).getTime()-new Date(f.createdAt).getTime());m(b)}},[s]);const d=async b=>{try{const f={autor:{id:t==null?void 0:t.id,email:t==null?void 0:t.email,nombre:t==null?void 0:t.nombre,imagen:t==null?void 0:t.imagen},comentario:b==null?void 0:b.comment,createdAt:new Date().toISOString()};await r.post("/api/comentarios",{data:{autor:t==null?void 0:t.id,comentario:b.comment,tarea:n}}),a(!0),m(N=>[f,...N]),x()}catch(f){console.error("Error al agregar comentario:",f)}};return e.jsxs("div",{className:"flex flex-col h-full gap-4",children:[e.jsxs("form",{onSubmit:i(d),className:"flex flex-row items-center gap-3",children:[e.jsxs(F.Avatar,{className:"w-[28px] h-[28px]",children:[e.jsx(F.AvatarImage,{src:`${Ce}${(h=(u=(g=t==null?void 0:t.imagen)==null?void 0:g.formats)==null?void 0:u.thumbnail)==null?void 0:h.url}`,alt:"@shadcn"}),e.jsx(F.AvatarFallback,{className:"border border-x-primary-pastel",children:J(t==null?void 0:t.nombre)})]}),e.jsx(F.Input,{...l("comment",{required:!0}),autoComplete:"off",placeholder:"Escribe un comentario",className:"w-full bg-white border border-neutral-200"})]}),o.map((b,f)=>e.jsx(es,{comment:b},f))]})}function ts({data:t}){const s={0:{color:"bg-gray-400",label:"Sin estado"},1:{color:"bg-primary-regular",label:"En curso"},2:{color:"bg-success-regular",label:"Finalizada"},3:{color:"bg-success-regular",label:"Finalizada"}},n=a=>a?K.format(new Date(a),"d MMM",{locale:G.es}):"";return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-row items-center gap-4",children:[e.jsx(F.Label,{className:"text-lg font-medium text-neutral-900",children:"Tareas dependientes"}),e.jsx("span",{className:"text-sm font-normal text-neutral-600 bg-[#E1EBF9] w-6 h-6 rounded-full flex items-center justify-center text-primary",children:t==null?void 0:t.length})]}),e.jsx("div",{className:"flex flex-col gap-2 border border-neutral-200 rounded-lg mt-3",children:t==null?void 0:t.map(a=>{var r,l,i,x,o;return e.jsxs("div",{className:"flex flex-row w-full items-center justify-between gap-s border-b border-neutral-200 py-1 px-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{imageUrl:(x=(i=(l=(r=a.responsable)==null?void 0:r.image)==null?void 0:l.formats)==null?void 0:i.thumbnail)==null?void 0:x.url}),e.jsx("p",{className:"text-sm font-normal w-[400px] text-nowrap text-ellipsis overflow-hidden",children:a==null?void 0:a.texto_corto})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("p",{className:"text-sm font-normal",children:n(a==null?void 0:a.createdAt)}),e.jsx("div",{className:`w-4 h-4 bg-gray-400 block rounded-full ${((o=s[a==null?void 0:a.estatus])==null?void 0:o.color)??"bg-gray-400"}`})]})]},a.id)})})]})}const as="https://devobp.imjmedia.com.mx";function ns({isOpen:t,setIsOpen:s,taskId:n}){var b,f,N,j,y,v,C,S,p,T,P;const[a,r]=c.useState(null),[l,i]=c.useState(!1),[x,o]=c.useState(null),{tasks_api:m}=D(),{user:d}=B();c.useEffect(()=>{if(t&&n||l){const q=async()=>{const I=await m.get(`/api/detalleTarea/${n}`);r(I==null?void 0:I.data)},$=async()=>{var O,W;const I=await m.get(`/api/users/${d.id}`),z=await m.post("/api/obtenerUsuarioOBP/",{emailList:[(O=I==null?void 0:I.data)==null?void 0:O.email]});o((W=z==null?void 0:z.data)==null?void 0:W.data[0])};q(),$()}},[t,n,l]);const g={0:{label:"Sin prioridad",color:"text-primary-regular",iconColor:"#425CAC"},1:{label:"Baja",color:"text-success-regular",iconColor:"#43B071"},2:{label:"Media",color:"text-warning-regular",iconColor:"#D38A31"},3:{label:"Alta",color:"text-danger-regular",iconColor:"#C34335"}},u=q=>q?K.format(q,"d MMM yyyy, h:mmaaa",{locale:G.es}):"Fecha no disponible",h=[{id:1,label:"Todo",component:e.jsx(ss,{taskId:n,currentUser:x,data:a,onNewComment:i})},{id:2,label:"Dependencias",component:e.jsx(ts,{data:a==null?void 0:a.ids_t_dependientes})}];return e.jsx(e.Fragment,{children:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`fixed inset-0 bg-transparent bg-opacity-50 flex justify-center items-center z-20 ${t?"pointer-events-auto block":"pointer-events-none hidden"}`,onClick:()=>s(!1)}),e.jsx("section",{className:`fixed top-0 bottom-0 bg-white bg-opacity-50 flex justify-center items-center w-[40rem] h-screen z-50 overflow-hidden transition-all ease-in-out duration-500 shadow-2xl ${t?"right-0 pointer-events-auto block":"right-[-100%] pointer-events-none hidden"}`,children:e.jsxs("div",{className:"flex w-full h-full flex-col overflow-y-scroll bg-white border-none shadow-xl px-4 py-6",children:[e.jsxs("div",{className:"w-full flex flex-row justify-between pb-4 gap-10 border-none",children:[e.jsx("h3",{className:"text-lg font-semibold text-neutral-900",children:a==null?void 0:a.texto_corto}),e.jsx(F.Button,{variant:"shadow",size:"sm",onClick:()=>s(!1),className:"bg-neutral-100 w-10 h-10",children:e.jsx(w.Icons,{icon:"x_outline"})})]}),e.jsx("div",{className:"w-full flex flex-row justify-between",children:e.jsxs("span",{className:"text-neutral-600 text-sm",children:[a==null?void 0:a.campania," / ",a==null?void 0:a.nombre_medio]})}),e.jsxs("div",{className:"w-full flex flex-col gap-3 mt-4",children:[e.jsx("h6",{className:"text-neutral-900 font-semibold text-base",children:"Descripción"}),e.jsx("p",{className:"text-neutral-600 font-normal text-sm",children:(a==null?void 0:a.texto_largo)??"Sin descripción"})]}),e.jsx(F.Accordion,{type:"single",collapsible:!0,defaultValue:"item-1",className:"w-full flex flex-col border border-neutral-200 rounded-xl mt-4",children:e.jsxs(F.AccordionItem,{value:"item-1",className:"border-none",children:[e.jsx(F.AccordionTrigger,{className:"text-neutral-900 font-medium text-sm w-full flex flex-row border-b border-neutral-200 p-4 ",children:"Detalles"}),e.jsx(F.AccordionContent,{className:"border-none",children:e.jsxs("div",{className:"w-full grid grid-cols-3 gap-4 p-4",children:[e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Responsable"}),(b=a==null?void 0:a.responsable)!=null&&b.nombre?e.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[e.jsxs(F.Avatar,{className:"w-[28px] h-[28px]",children:[e.jsx(F.AvatarImage,{src:`${as}${(y=(j=(N=(f=a==null?void 0:a.responsable)==null?void 0:f.imagen)==null?void 0:N.formats)==null?void 0:j.thumbnail)==null?void 0:y.url}`,alt:"@shadcn"}),e.jsx(F.AvatarFallback,{children:J((v=a==null?void 0:a.responsable)==null?void 0:v.nombre)})]}),e.jsx("span",{className:"text-xs text-neutral-600 font-normal",children:(C=a==null?void 0:a.responsable)==null?void 0:C.nombre})]}):e.jsx("span",{className:"text-xs text-neutral-600 font-normal",children:"Sin responsable"})]}),e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Equipo asignado"}),e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx("span",{className:"text-xs text-neutral-600 font-normal",children:((S=a==null?void 0:a.equipo)==null?void 0:S.nombre)??"Sin equipo"})})]}),e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Prioridad"}),e.jsxs("div",{className:"flex flex-row items-center gap-2",children:[e.jsx(w.Icons,{icon:"flag",size:"xs",strokeWidth:5,color:(p=g[a==null?void 0:a.prioridad])==null?void 0:p.iconColor}),e.jsx("span",{className:`text-sm text-neutral-600 font-normal ${(T=g[a==null?void 0:a.prioridad])==null?void 0:T.color}`,children:((P=g[a==null?void 0:a.prioridad])==null?void 0:P.label)??"Sin prioridad"})]})]}),e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Lista"}),e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx("span",{className:"text-xs text-neutral-600 font-normal",children:(a==null?void 0:a.lista)??"Sin lista"})})]}),e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Fecha estimada de inicio"}),e.jsx("p",{className:"text-xs text-neutral-600 font-normal",children:u(a==null?void 0:a.f_inicio_estimada)})]}),e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Fecha estimada de fin"}),e.jsx("p",{className:"text-xs text-neutral-600 font-normal",children:u(a==null?void 0:a.f_fin_estimada)})]}),e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Fecha de fin"}),e.jsx("p",{className:"text-xs text-neutral-600 font-normal",children:u(a==null?void 0:a.ffin)})]}),e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Creado"}),e.jsx("p",{className:"text-xs text-neutral-600 font-normal",children:u(a==null?void 0:a.createdAt)})]}),e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Última modificación"}),e.jsx("p",{className:"text-xs text-neutral-600 font-normal",children:u(a==null?void 0:a.updatedAt)})]})]})})]})}),e.jsx(Ze,{items:h})]})})]})})}const rs=({id:t,task:s,endDate:n,users:a,willBePaused:r,nameProject:l,idProject:i,comments:x,priority:o,responsible:m,nameRequiredTask:d,statusRequiredTask:g,status:u})=>{const h=c.useRef(null),[b,f]=c.useState(!1),{setElementPosition:N,position:j}=Y(),{startWorking:y}=Ne(),v=c.useRef(!1),C=({children:p})=>{const[T,P]=c.useState();return c.useEffect(()=>{var q,$;h.current&&P(((j==null?void 0:j.x)??0)-((($=(q=h.current)==null?void 0:q.getBoundingClientRect())==null?void 0:$.width)??0))},[h==null?void 0:h.current,j==null?void 0:j.x]),j&&Q.createPortal(e.jsx("div",{className:`absolute w-fit h-fit ${T?"block":"hidden"}`,style:{top:`${j==null?void 0:j.y}px`,left:`${T}px`,zIndex:1},children:p}),document.body)},S=()=>e.jsxs("div",{className:"flex justify-between items-center w-full h-fit relative",children:[e.jsxs("div",{className:"flex items-center gap-[8px] w-[calc(100%-32px)] ",children:[e.jsx(be,{id:t,nameRequiredTask:d??"",statusRequiredTask:g??0,status:u}),e.jsx("p",{className:"title-text",onClick:()=>f(!0),children:s})]}),u<2&&e.jsx("button",{ref:h,onClick:()=>{N(h)},className:"flex items-center justify-center text-sm font-extrabold bg-bg hover:filter-[drop-shadow(0_0_10px_#000000)] rounded-full w-[24px] h-[24px] m-block",children:e.jsx("span",{className:"rotate-90",children:e.jsx(w.Icons,{icon:"elipsis",size:"xs"})})}),e.jsx(C,{children:v!=null&&v.current?e.jsx("div",{className:"w-max h-fit bg-bg-card rounded-lg p-l shadow-lg flex items-center gap-2 hover:bg-primary-light",children:e.jsx("p",{className:"text-sm font-normal text-primary-pastel font-regular",children:"Moviendo..."})}):e.jsxs("button",{className:"w-max h-fit bg-bg-card rounded-lg p-l shadow-lg flex items-center gap-2 hover:bg-primary-light",onClick:()=>{v.current=!0,u===0&&y({id:t})},children:[e.jsx("p",{className:"text-sm font-normal text-texts-placeholder font-regular",children:u===0?"Mover a trabajando":"Mover a completadas"}),e.jsx(w.Icons,{icon:"arrow_right",size:"xs",strokeWidth:4,color:_.primary.regular})]})})]});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-bg-card border-cards max-w-[350px] rounded-lg relative h-fit p-[12px_12px] hover:border-active hover:bg-active cursor-pointer ",children:[e.jsx(S,{}),e.jsxs("div",{className:"flex flex-col gap-[4px] py-2",children:[e.jsx("p",{className:"subtitle-text",children:l}),i&&e.jsx("p",{className:"content-text",children:i})]}),e.jsxs("div",{className:"flex justify-between items-center w-full h-fit relative pt-5 pb-1",children:[e.jsxs("div",{className:"flex items-center relative",children:[e.jsx(we,{responsible:m,users:a.filter(p=>m?p.id===m:!0).map(X),onClick:()=>{}}),r&&e.jsx(w.Tooltip,{dispatch:e.jsxs("button",{className:"text-sm font-regular text-gray-400 flex items-center gap-2",children:[e.jsx(w.Icons,{icon:"pause",size:"s",strokeWidth:2}),e.jsx("span",{children:"Pause"})]}),children:e.jsx("p",{className:"text-sm font-regular text-white p-5",children:"Al pulsar el botón se solicitará razón del pausado"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w.Icons,{icon:"difficulty",size:"xs"}),e.jsx(ve,{priority:o,id:t}),e.jsx(w.Icons,{icon:"calendar",size:"xs",strokeWidth:3,color:_.texts.subtext}),e.jsx("p",{className:"text-sm font-regular text-texts-subtext",children:`${n.getDate()} ${ye(n.getMonth()).slice(0,3)}`})]})]}),x>0&&e.jsx("div",{className:"border-t border-gray-200 mt-4 pt-2",children:e.jsxs("button",{className:"flex items-center gap-2",children:[e.jsx(w.Icons,{icon:"comment",size:"xs",strokeWidth:4}),e.jsx("span",{className:"text-sm font-regular text-gray-400",children:x})]})})]}),e.jsx(ns,{taskId:t,isOpen:b,setIsOpen:f})]})},ls=()=>e.jsxs("div",{className:"bg-gray-200 h-[150px] w-full animate-pulse rounded-md flex flex-col gap-[50px] p-4",children:[e.jsxs("div",{className:"flex h-[30px] gap-3",children:[e.jsx("div",{className:"w-[30px] min-w-[30px] h-full bg-gray-300 rounded-full"}),e.jsx("div",{className:"w-full h-full bg-gray-300"}),e.jsx("div",{className:"w-[30px] min-w-[30px] h-full bg-gray-300 rounded-full"})]}),e.jsxs("div",{className:"flex justify-between w-full h-[30px] gap-[50px]",children:[e.jsx("div",{className:"w-full h-[30px] bg-gray-300"}),e.jsx("div",{className:"w-full h-[30px] bg-gray-300"})]})]}),H=({title:t,tasks:s,loadNextPage:n,isFetching:a,total:r})=>{const l=c.useRef(null),i=c.useRef(null),x=c.useRef(!1);c.useEffect(()=>{var d;l!=null&&l.current&&(i!=null&&i.current)&&(i.current.style.minHeight=`${((d=l==null?void 0:l.current)==null?void 0:d.clientHeight)-50}px`)},[l==null?void 0:l.current]);const o=d=>{if(x.current)return;const{scrollTop:g,clientHeight:u,scrollHeight:h}=d==null?void 0:d.target,b=g/(h-u)*100;b<=95||b>=95&&(x.current=!0,n&&n(),setTimeout(()=>{x.current=!1},200))},m={"Por hacer":"border-texts-placeholder",Trabajando:"border-primary-regular",Completadas:"border-success-regular"};return e.jsxs("div",{ref:l,className:` flex flex-col bg-containers w-fit max-w-[400px] min-w-[400px] h-full min-h-[100%] pb-[200px] relative p-[16px] rounded-lg overflow-hidden border-t-4 ${m[t]}`,children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("div",{className:"flex items-center gap-[8px]",children:e.jsx("p",{className:"text-base",children:t})}),e.jsx("div",{className:"flex items-center gap-[8px]",children:e.jsxs("div",{className:"flex items-center gap-[4px]",children:[e.jsx(w.Icons,{icon:"group_files",size:"xs",strokeWidth:5,color:_.texts.placeholder}),e.jsx("p",{className:"text-md text-texts-placeholder",children:r??0})]})})]}),e.jsxs("div",{ref:i,className:"flex flex-col gap-[12px] overflow-y-auto scrollbar-none py-4",onScroll:o,children:[s==null?void 0:s.map(d=>e.jsx(rs,{...d},d.id)),a?e.jsx(ls,{}):e.jsx("p",{className:"text-center text-gray-500",children:"No hay más tareas por mostrar..."})]})]})},is=()=>{var r;const{defineFields:t}=E(),{tasksProject:s}=U();c.useEffect(()=>{(async()=>{let i=[...Ue];t(i)})()},[]);let n=(r=s==null?void 0:s.data)==null?void 0:r.filter(l=>{var i;return((i=l==null?void 0:l.tasks)==null?void 0:i.length)===0}).reduce((l,i)=>(l[i.status]=l[i.status]||[],l[i.status].push(i),l),{});const a=["Por hacer","Trabajando","Completadas"];return e.jsx("div",{className:"flex gap-4 w-full h-full min-h-[100%] relative ",children:a.map((l,i)=>{var x;return e.jsx(H,{total:((x=n==null?void 0:n[i])==null?void 0:x.length)??0,title:l,tasks:(n==null?void 0:n[i])??[],isFetching:s==null?void 0:s.isFetching,isLoadingData:s==null?void 0:s.isLoading})})})};class os{static toKanbanTasks(s){var a,r,l,i,x,o,m,d,g,u,h;let n=[];return s!=null&&s.responsable&&n.push({id:s.responsable.id,name:s.responsable.nombre,image:(x=(i=(l=(r=(a=s.responsable)==null?void 0:a.userOBP)==null?void 0:r.imagen)==null?void 0:l.formats)==null?void 0:i.thumbnail)==null?void 0:x.url}),(o=s==null?void 0:s.equipo)!=null&&o.miembros&&s.equipo.miembros.forEach(b=>{var f,N,j,y;n!=null&&n.find(v=>v.id===b.idUser.id)||b.idUser&&n.push({id:b.idUser.id,name:b.idUser.nombre,image:(y=(j=(N=(f=b==null?void 0:b.userOBP)==null?void 0:f.imagen)==null?void 0:N.formats)==null?void 0:j.thumbnail)==null?void 0:y.url})}),{comments:0,nameProject:(m=s==null?void 0:s.proyecto)==null?void 0:m.nombre,idProject:(d=s==null?void 0:s.proyecto)==null?void 0:d.id,willBePaused:s.es_pausable,difficulty:s.nivel_dificultad,endDate:new Date(s.ffin),id:s.id,priority:s.prioridad??0,status:s.estatus,task:s.texto_corto,users:n,responsible:((g=s==null?void 0:s.responsable)==null?void 0:g.id)??null,statusRequiredTask:((u=s.id_t_requerida)==null?void 0:u.estatus)??null,nameRequiredTask:((h=s.id_t_requerida)==null?void 0:h.texto_corto)??null}}}const Z=async({filters:t,tasks_api:s})=>{try{return(await s.get("/api/listado_tareas",{params:t})).data.tareas.map(M).map(os.toKanbanTasks)}catch(n){throw console.log({error:n}),`Error al obtener las tareas: ${n}`}},k=t=>{var s;if(t!=null&&t.hasNextPage){const n=(s=t==null?void 0:t.data)==null?void 0:s.pages[t.data.pages.length-1];(n==null?void 0:n.length)===30&&(t==null||t.fetchNextPage())}},R=t=>({pagination:{page:t,pageSize:30,withCount:!0}}),cs=()=>{var m;const t=A.useQueryClient(),{tasks_api:s}=D(),{user:n}=B(),{filters:a}=E(),[r,l]=c.useState(0),[i,x]=c.useState({owner:{user:n.id,config:((m=a==null?void 0:a.owner)==null?void 0:m.config)??"yo_y_mis_equipos"},status:"por_hacer"}),o=A.useInfiniteQuery({initialPageParam:1,queryKey:["to_do_tasks",i],queryFn:({pageParam:d})=>Z({filters:{...i,status:"por_hacer",...R(d)},tasks_api:s,page:d}),staleTime:1e3*60*60*24,getNextPageParam:(d,g)=>g.length+1});return c.useEffect(()=>{var d;Object.keys(a).length>0&&x({...a,owner:{user:n.id,config:((d=a==null?void 0:a.owner)==null?void 0:d.config)??"yo_y_mis_equipos"},status:"por_hacer"})},[a]),c.useEffect(()=>{t.invalidateQueries({queryKey:["to_do_tasks",i]})},[i]),c.useEffect(()=>{(async()=>{const g=await s.get("/api/listado_tareas",{params:{...i,status:"por_hacer",...R(1),tasks_api:s,justCount:!0}});l(g.data.total)})()},[i,o==null?void 0:o.data]),{toDoTasks:o,total:r}},ds=()=>{var a,r;const{toDoTasks:t,total:s}=cs(),n=[...((r=(a=t==null?void 0:t.data)==null?void 0:a.pages)==null?void 0:r.flat())??[]];return e.jsx(H,{total:s,title:"Por hacer",tasks:n,loadNextPage:()=>k(t),isFetching:t==null?void 0:t.isFetching,isLoadingData:t==null?void 0:t.isLoading})},xs=()=>{var m;const t=A.useQueryClient(),{tasks_api:s}=D(),{user:n}=B(),{filters:a}=E(),[r,l]=c.useState(0),[i,x]=c.useState({owner:{user:n.id,config:((m=a==null?void 0:a.owner)==null?void 0:m.config)??"yo_y_mis_equipos"},status:"trabajando"}),o=A.useInfiniteQuery({initialPageParam:1,queryKey:["working_tasks",a],queryFn:({pageParam:d})=>Z({filters:{...i,status:"trabajando",...R(d)},tasks_api:s,page:d}),staleTime:1e3*60*60*24,getNextPageParam:(d,g)=>g.length+1});return c.useEffect(()=>{var d;Object.keys(a).length>0&&x({...a,owner:{user:n.id,config:((d=a==null?void 0:a.owner)==null?void 0:d.config)??"yo_y_mis_equipos"},status:"trabajando"})},[a]),c.useEffect(()=>{t.invalidateQueries({queryKey:["working_tasks",a]})},[i]),c.useEffect(()=>{(async()=>{const g=await s.get("/api/listado_tareas",{params:{...i,status:"trabajando",...R(1),tasks_api:s,justCount:!0}});l(g.data.total)})()},[i,o==null?void 0:o.data]),{workingTasks:o,total:r}},us=()=>{var a,r;const{workingTasks:t,total:s}=xs(),n=[...((r=(a=t==null?void 0:t.data)==null?void 0:a.pages)==null?void 0:r.flat())??[]];return e.jsx(H,{total:s,title:"Trabajando",tasks:n,loadNextPage:()=>k(t),isFetching:t==null?void 0:t.isFetching})},ms=()=>{var m;const t=A.useQueryClient(),{user:s}=B(),{tasks_api:n}=D(),{filters:a}=E(),[r,l]=c.useState(0),[i,x]=c.useState({owner:{user:s.id,config:((m=a==null?void 0:a.owner)==null?void 0:m.config)??"yo_y_mis_equipos"},status:"completadas"}),o=A.useInfiniteQuery({initialPageParam:1,queryKey:["done_tasks",i],queryFn:({pageParam:d})=>Z({filters:{...i,status:"completadas",...R(d)},tasks_api:n,page:d}),staleTime:1e3*60*60*24,getNextPageParam:(d,g)=>g.length+1});return c.useEffect(()=>{var d;Object.keys(a).length>0&&x({...a,owner:{user:s.id,config:((d=a==null?void 0:a.owner)==null?void 0:d.config)??"yo_y_mis_equipos"},status:"completadas"})},[a]),c.useEffect(()=>{t.invalidateQueries({queryKey:["done_tasks",i]})},[i]),c.useEffect(()=>{(async()=>{const g=await n.get("/api/listado_tareas",{params:{...i,status:"completadas",...R(1),justCount:!0,tasks_api:n}});l(g.data.total)})()},[o==null?void 0:o.data,i]),{doneTasks:o,total:r}},ps=()=>{var a,r;const{doneTasks:t,total:s}=ms(),n=[...((r=(a=t==null?void 0:t.data)==null?void 0:a.pages)==null?void 0:r.flat())??[]];return e.jsx(H,{title:"Completadas",tasks:n,loadNextPage:()=>k(t),isFetching:t==null?void 0:t.isFetching,total:s})};class V{static toSalesmanUsers(s){return{id:s.id,name:s.nombre}}}const hs=()=>{const{tasks_api:t}=D(),{filters:s}=E(),{user:n}=B();return{getSalesmanAndProjects:async()=>{const[i]=await Promise.all([t.get("/api/obtener-comerciales")]);return{salesmanUsers:i.data.map(V.toSalesmanUsers)}},getProjects:async()=>{var x;return(await t.get("/api/listado_tareas",{params:{...s,owner:{user:n.id,config:((x=s==null?void 0:s.owner)==null?void 0:x.config)??"yo_y_mis_equipos"},justProjects:!0}})).data.map(V.toSalesmanUsers)},getSalesmans:async()=>(await t.get("/api/obtener-comerciales")).data.map(V.toSalesmanUsers)}},gs=[{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 proyecto",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",type:"select",id:"salesman.name",options:[]},{label:"Por dificultad",type:"select",id:"difficulty",options:[{id:0,name:"Muy facil"},{id:1,name:"Facil"},{id:2,name:"Media"},{id:3,name:"Dificil"},{id:4,name:"Muy dificil"}]}],fs=()=>{const{defineFields:t}=E(),{getSalesmanAndProjects:s}=hs();return c.useEffect(()=>{(async()=>{let a=[...gs],{salesmanUsers:r}=await s();t(a.map(l=>(l.id==="salesman.name"&&(l.options=r),l)))})()},[]),e.jsxs("div",{className:"flex gap-4 w-full h-full min-h-[100%] relative ",children:[e.jsx(ds,{}),e.jsx(us,{}),e.jsx(ps,{})]})},Fe=c.createContext({}),js=({children:t})=>{const[s,n]=c.useState([]);c.useEffect(()=>{console.log({selectedTasks:s})},[s]);const a=r=>{n(l=>l.includes(r)?l.filter(i=>i!==r):[...l,r])};return e.jsx(Fe.Provider,{value:{selectedTasks:s,selectTask:a},children:t})},bs=()=>c.useContext(Fe),_e=()=>{const t=()=>e.jsxs("div",{className:"w-full flex gap-m",children:[e.jsx("div",{className:"w-[30px] h-[30px] min-w-[30px] min-h-[30px] bg-gray-200 rounded-full animate-pulse"}),e.jsx("div",{className:"w-[30%] h-[30px] bg-gray-200 rounded-md animate-pulse"}),e.jsx("div",{className:"w-[30px] h-[30px] min-w-[30px] min-h-[30px] bg-gray-200 rounded-lg animate-pulse"}),e.jsx("div",{className:"w-[30px] h-[30px] min-w-[30px] min-h-[30px] bg-gray-200 rounded-lg animate-pulse"}),e.jsx("div",{className:"w-[30px] h-[30px] min-w-[30px] min-h-[30px] bg-gray-200 rounded-lg animate-pulse"}),e.jsx("div",{className:"w-[10%] h-[30px] bg-gray-200 rounded-md animate-pulse"}),e.jsx("div",{className:"w-[30px] h-[30px] min-w-[30px] min-h-[30px] bg-gray-200 rounded-lg animate-pulse"}),e.jsx("div",{className:"w-[10%] h-[30px] bg-gray-200 rounded-md animate-pulse"}),e.jsx("div",{className:"w-[30px] h-[30px] min-w-[30px] min-h-[30px] bg-gray-200 rounded-lg animate-pulse"}),e.jsx("div",{className:"w-[30px] h-[30px] min-w-[30px] min-h-[30px] bg-gray-200 rounded-lg animate-pulse"})]});return e.jsxs("div",{className:"flex flex-col gap-m",children:[e.jsx(t,{}),e.jsxs("div",{className:"pl-5 flex flex-col gap-m",children:[e.jsx(t,{}),e.jsx("div",{className:"pl-5",children:e.jsx(t,{})})]}),e.jsx(t,{}),e.jsxs("div",{className:"pl-5 flex flex-col gap-m",children:[e.jsx(t,{}),e.jsx("div",{className:"pl-5",children:e.jsx(t,{})})]})]})},Se=({startDate:t,endDate:s})=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"gap-s bg-gray-100 rounded-md h-[30px] w-fit flex justify-center items-center px-xxxl",children:[e.jsx(w.Icons,{icon:"calendar",size:"xs",strokeWidth:4,color:_.texts.subtext}),e.jsxs("p",{className:"text-sm",children:[" ",xe(t)]})]}),e.jsx(w.Icons,{icon:"arrow_right",size:"xs",strokeWidth:4,color:_.texts.DEFAULT}),e.jsxs("div",{className:"gap-s bg-gray-100 rounded-md h-[30px] w-fit flex justify-center items-center px-xxxl",children:[e.jsx(w.Icons,{icon:"calendar",size:"xs",strokeWidth:4,color:_.texts.subtext}),e.jsxs("p",{className:"text-sm",children:[" ",xe(s)]})]})]}),ys=({id:t})=>e.jsx(e.Fragment,{children:e.jsx("button",{onClick:()=>alert("pausar tarea "+t),children:e.jsx(w.Icons,{icon:"pause",size:"xs",strokeWidth:4,color:_.texts.subtext})})}),Te=({id:t,priority:s})=>e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"gap-s bg-gray-100 rounded-md h-[30px] w-[30px] flex justify-center items-center hover:bg-gray-200",children:e.jsx(w.Icons,{icon:"align_center",size:"xs",strokeWidth:4,color:_.texts.subtext})}),e.jsx("div",{className:"gap-s bg-success-medium border border-success-pastel rounded-md h-[30px] w-[30px] flex justify-center items-center",children:e.jsx(ve,{id:t,priority:s})}),e.jsx("button",{className:"gap-s bg-danger-light border border-danger-regular rounded-md h-[30px] w-[30px] flex justify-center items-center",children:e.jsx(w.Icons,{icon:"difficulty",size:"xs",strokeWidth:4,color:_.danger.regular})})]}),ws=({id:t})=>{const{selectedTasks:s,selectTask:n}=bs();return e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"cursor-pointer w-[20px] h-[20px] border-2 border-gray-200 rounded-md flex justify-center items-center",htmlFor:t.toString(),children:e.jsx("span",{className:`${s.includes(t)?"opacity-100":"opacity-0"} transition-opacity duration-500`,children:e.jsx(w.Icons,{icon:"check_outline",size:"xs",color:_.primary.regular,strokeWidth:6})})}),e.jsx("input",{className:"hidden",id:t.toString(),type:"checkbox",onChange:()=>n(t)})]})},Ae=({task:t})=>e.jsx(w.Tooltip,{dispatch:e.jsx("p",{className:"text-sm text-texts-subtext max-w-[400px] truncate",children:t}),children:e.jsx("p",{className:"text-sm text-texts-subtext p-2 max-w-[400px]",children:t})}),Ns=({id:t})=>{var a,r;const{tasksProject:s}=U(),n=(a=s==null?void 0:s.data)==null?void 0:a.find(l=>l.id===t);return e.jsxs("div",{className:"ml-[30px] mb-3 mt-1 flex flex-wrap items-center gap-xl",children:[!(n!=null&&n.nameRequiredTask)||(n==null?void 0:n.nameRequiredTask)!==""&&(n==null?void 0:n.statusRequiredTask)===2&&e.jsx(ws,{id:t}),e.jsx(be,{id:t,nameRequiredTask:(n==null?void 0:n.nameRequiredTask)??"",status:n==null?void 0:n.status,statusRequiredTask:(n==null?void 0:n.statusRequiredTask)??0},t),(n==null?void 0:n.willBePaused)&&e.jsx(ys,{id:t}),e.jsx(we,{onClick:()=>{},responsible:n==null?void 0:n.responsible,users:((r=n==null?void 0:n.users)==null?void 0:r.map(X))??[]}),e.jsx(Ae,{task:(n==null?void 0:n.task)??""}),e.jsx(Te,{id:t,priority:n==null?void 0:n.priority}),e.jsx(Se,{startDate:n==null?void 0:n.startDate,endDate:n==null?void 0:n.endDate})]})},Pe=({id:t})=>{var l,i,x,o,m,d,g;const{tasksProject:s,openTasks:n,openTask:a}=U(),r=(l=s==null?void 0:s.data)==null?void 0:l.find(u=>u.id===t);return r?(console.log({task:r}),e.jsxs("div",{className:"flex flex-col gap-m mb-2 ",children:[e.jsxs("div",{className:"flex items-center gap-m flex-wrap hover:bg-gray-100",children:[e.jsx("button",{className:`${n.includes(t)?"":"-rotate-90"} transition-all duration-300`,onClick:()=>a(t),children:e.jsx(w.Icons,{icon:"angle_down_outline",color:_.texts.subtext})}),e.jsx("div",{className:"flex items-center justify-center min-w-[20px] min-h-[20px] w-fit h-[20px] mx-1 bg-primary-medium rounded-full",children:e.jsx("p",{className:"text-sm text-primary",children:((i=r==null?void 0:r.tasks)==null?void 0:i.length)===0?1:(x=r==null?void 0:r.tasks)==null?void 0:x.length})}),e.jsx(Ae,{task:(r==null?void 0:r.task)??""}),e.jsx(Te,{id:t,priority:r==null?void 0:r.priority}),e.jsx(Se,{startDate:r==null?void 0:r.startDate,endDate:r==null?void 0:r.endDate}),e.jsxs("button",{className:"gap-s bg-gray-100 rounded-md h-[30px] flex justify-center items-center w-fit px-m hover:bg-gray-200",children:[e.jsx(w.Icons,{icon:"subtasks",size:"xs",strokeWidth:5,color:_.texts.subtext}),e.jsx("p",{children:((o=r==null?void 0:r.tasks)==null?void 0:o.length)===0?1:(m=r==null?void 0:r.tasks)==null?void 0:m.length})]})]}),n.includes(t)&&e.jsx("div",{className:"ml-[30px]",children:((d=r==null?void 0:r.tasks)==null?void 0:d.length)>0?(g=r==null?void 0:r.tasks)==null?void 0:g.map(u=>e.jsx(Pe,{id:u==null?void 0:u.id})):e.jsx(Ns,{id:r==null?void 0:r.id})})]})):null},vs=()=>{var a;const{tasksProject:t,projectID:s}=U();if(t!=null&&t.isFetching||t!=null&&t.isLoading)return e.jsx(_e,{});let n=[...(a=t==null?void 0:t.data)==null?void 0:a.filter(r=>r.isPrincipalTask)];return e.jsx("div",{className:"flex flex-col gap-m",children:e.jsx(js,{project:s,children:n==null?void 0:n.sort((r,l)=>r.orden-l.orden).map(r=>e.jsx("div",{className:"flex flex-col gap-m border-b border-gray-200 pb-m",children:e.jsx(Pe,{id:r.id})}))})})},Cs=({setPath:t,setProject:s})=>{const[n,a]=c.useState([]),[r,l]=c.useState(!0),[i,x]=c.useState(0),[o,m]=c.useState(10),[d,g]=c.useState(0),[u,h]=c.useState("nombre"),{defineFields:b}=E(),{tasks_api:f}=D(),N=async(p,T)=>{try{l(!0);const P=await f.get("/api/listado_campanias",{params:{pagination:{page:p,pageSize:T},orderBy:u}}),q=M(P.data);a(q),g(P.data.meta.total)}catch(P){console.error("Error fetching data en Lista Campaña:",P)}finally{l(!1)}};c.useEffect(()=>{b([{label:"Búsqueda",type:"text",id:"search"},{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:"Ejecutivo",type:"text",id:"ejecutivo"}])},[]),c.useEffect(()=>{const p=Math.floor(i/o)+1;N(p,o)},[i,o,u]);const j=p=>{x(p.first),m(p.rows)},y=[{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}],v=p=>{const T=parseInt(p.target.value,10);m(T),j({first:0,rows:T})},C=p=>{h(T=>T===p?`${p}:desc`:p)},S=p=>u===p?"↑↓":u===`${p}:desc`?"↓↑":"↑↓";return e.jsx("div",{className:"table-container",children:r?e.jsx("div",{style:{width:"100%"},children:e.jsx(_e,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"table",style:{borderCollapse:"collapse",width:"100%",borderSpacing:"0"},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsxs("th",{onClick:()=>C("nombre"),children:[e.jsx("label",{style:{color:"#C4C4C4",fontSize:"10px"},children:S("nombre")}),"Campaña"]}),e.jsx("th",{onClick:()=>C("inicia"),style:{textAlign:"center",whiteSpace:"nowrap"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"fit-content"},children:[e.jsx("label",{style:{color:"#C4C4C4",fontSize:"10px"},children:S("inicia")})," ",e.jsx(w.Icons,{icon:"calendar",size:"xs",strokeWidth:5,color:"#C4C4C4"}),e.jsx("span",{children:"Fecha Inicio"})]})}),e.jsx("th",{onClick:()=>C("termina"),style:{whiteSpace:"nowrap",textAlign:"center"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"fit-content"},children:[e.jsx("label",{style:{color:"#C4C4C4",fontSize:"10px"},children:S("termina")}),e.jsx(w.Icons,{icon:"calendar",size:"xs",strokeWidth:5,color:"#C4C4C4"}),e.jsx("span",{children:"Fecha Fin"})]})}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Responsable"})]})}),e.jsx("tbody",{children:n==null?void 0:n.map((p,T)=>{var P,q,$,I,z,O,W,ee,se,te,ae,ne,re,le,ie,oe;return e.jsxs("tr",{className:"table-row",children:[e.jsx("td",{children:(P=p==null?void 0:p.campania)==null?void 0:P.nombre}),e.jsxs("td",{children:[" ",(q=p==null?void 0:p.campania)==null?void 0:q.inicia]}),e.jsx("td",{children:($=p==null?void 0:p.campania)==null?void 0:$.termina}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",padding:"none",fontSize:"10px",width:"auto",minWidth:"170px"},children:[e.jsxs("label",{style:{width:"50px",minWidth:"50px",textAlign:"right",color:"#000"},children:[p==null?void 0:p.progreso,"%"]}),e.jsx("div",{style:{position:"relative",height:"10px",flex:1,backgroundColor:"#C4C4C4",borderRadius:"10px",overflow:"hidden"},children:e.jsx("div",{style:{position:"absolute",top:0,left:0,height:"100%",width:`${p.progreso}%`,backgroundColor:p.progreso===100?"#039B59":p.progreso>50?"#3658C1":p.progreso>0?"#DC8921":"#C4C4C4",borderRadius:"10px",transition:"width 0.3s ease-in-out"}})})]})}),e.jsx("td",{children:e.jsxs("div",{className:"avatar-container",children:[e.jsxs(F.Avatar,{className:"w-[28px] h-[28px]",children:[e.jsx(F.AvatarImage,{src:`${Ce}${(ee=(W=(O=(z=(I=p==null?void 0:p.campania)==null?void 0:I.responsable)==null?void 0:z.imagen)==null?void 0:O.formats)==null?void 0:W.thumbnail)==null?void 0:ee.url}`,alt:(ae=(te=(se=p==null?void 0:p.campania)==null?void 0:se.responsable)==null?void 0:te.nombre)==null?void 0:ae.charAt(0)}),e.jsx(F.AvatarFallback,{style:{boxShadow:"10px 5px 10px rgba(0, 0, 0, 0.5)"},children:(le=(re=(ne=p==null?void 0:p.campania)==null?void 0:ne.responsable)==null?void 0:re.nombre)==null?void 0:le.charAt(0)})]}),e.jsx("span",{style:{marginLeft:"8px",fontSize:"10px"},children:(oe=(ie=p==null?void 0:p.campania)==null?void 0:ie.responsable)==null?void 0:oe.nombre})]})})]},T)})})]}),e.jsxs("div",{className:"pagination",style:{background:"#FAFAFA",display:"flex"},children:[e.jsxs("span",{style:{alignItems:"center",fontSize:"10px",textAlign:"left",width:"auto",height:"auto",padding:"12px",whiteSpace:"nowrap"},children:[n.length," elementos de ",d]}),e.jsx(Ee.Paginator,{first:i,rows:o,totalRecords:d,rowsPerPageOptions:[5,10,20,50],onPageChange:j,className:"pagination",template:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"10px",whiteSpace:"nowrap"},children:"Filas por página:"}),e.jsx("select",{className:"select",value:o,onChange:p=>v(p),children:y.map(p=>e.jsx("option",{className:"option-select",value:p.value,style:{background:"#F5F5F5"},children:p.label},p.value))})]})]})]})})},Fs=({path:t,tab:s,setPath:n,project:a,setProject:r})=>{const l={"kanban-general":{kanban:e.jsx(fs,{})},"lista-campanias":{lista:e.jsx(Cs,{setPath:n,setProject:r}),gantt:e.jsx("div",{children:"gantt-campanias"})},"kanban-campania":{kanban:e.jsx(is,{}),lista:e.jsx(vs,{}),gantt:e.jsx("div",{children:"kanban-campania-gantt"})}};return t==="kanban-campania"?e.jsx(We,{project:a==null?void 0:a.id,children:l[t][s]}):l[t][s]},_s=({path:t})=>{const s=()=>{const{selectPath:n,updateFilters:a,applyFilters:r}=E(),[l,i]=c.useState("kanban"),[x,o]=c.useState(t),[m,d]=c.useState({id:1839,project:"Kanban de Campania"}),[g,u]=c.useState(""),h=c.useRef(null);c.useEffect(()=>{i("kanban"),n(x)},[t]),c.useEffect(()=>{(g==null?void 0:g.trim())===""&&a({name:"taskName",value:null}),r()},[g]);const b=y=>({"kanban-general":"Kanban General","lista-campanias":"Campanias","kanban-campania":`Kanban de ${m.project}`})[y],f=y=>{o(y)},N=["lista-campanias","kanban-campania"],j={"lista-campanias":["lista","gantt"],"kanban-campania":["kanban","lista","gantt"]};return e.jsxs("div",{className:"bg-bg-card p-m rounded-lg border border-gray-200 flex flex-col gap-m w-full h-full min-h-[100%] relative overflow-hidden",children:[e.jsxs("div",{className:"w-full justify-between flex items-end border-b border-gray-200 pb-m px-l flex-wrap gap-l",children:[e.jsxs("div",{className:"flex gap-xl",children:[e.jsx("h2",{className:"text-texts font-medium",children:b(x)}),N.includes(x)&&e.jsx(Ie,{tabs:j[x],renderItem:y=>{i(y)}})]}),e.jsxs("div",{className:"flex items-center gap-s",children:[e.jsx("input",{onChange:he(y=>{var v,C,S;a({name:"taskName",value:(C=(v=y==null?void 0:y.target)==null?void 0:v.value)==null?void 0:C.trim()}),u((S=y==null?void 0:y.target)==null?void 0:S.value)},1e3),type:"text",placeholder:"Buscar",className:"w-[200px] h-[30px] border-none bg-bg-card shadow-input border border-gray-200 rounded-lg px-l "}),e.jsx($e,{filterChildren:h,children:e.jsx("div",{ref:h,className:"w-max max-w-[400px] h-fit bg-bg-card shadow-lg rounded-lg p-l",children:e.jsx(Be,{})})})]})]}),e.jsx("div",{className:"overflow-auto scrollbar-none",children:e.jsx(Fs,{path:x,tab:l,setPath:f,project:m,setProject:d})})]})};return e.jsx(Me,{children:e.jsx(s,{})})},Ss=()=>e.jsx("div",{className:"w-full h-full min-h-[100%] relative",children:e.jsx("div",{className:"flex justify-center items-center h-full",children:e.jsxs("div",{className:"text-2xl font-bold flex flex-col items-center",children:[e.jsx("div",{className:"w-10 h-10 bg-primary-regular rounded-full animate-pulse"}),e.jsx("p",{className:"text-l text-texts-enfasis",children:"un momento..."}),e.jsx("p",{className:"text-sm text-texts-placeholder",children:"estamos buscando tu usuario"})]})})}),Ts=()=>e.jsx("div",{className:"w-full h-full min-h-[100%] relative",children:e.jsx("div",{className:"flex justify-center items-center h-full",children:e.jsxs("div",{className:"text-2xl font-bold flex flex-col items-center",children:[e.jsx("div",{className:"w-10 h-10 bg-primary-regular rounded-full animate-pulse"}),e.jsx("p",{className:"text-l text-texts-enfasis",children:"No encontramos tu acceso"}),e.jsx("p",{className:"text-sm text-texts-placeholder",children:"por favor, contacta al administrador"})]})})}),As=({path:t,user:s,url:n})=>{const a=new A.QueryClient;if(!s)return e.jsx(Ss,{});if(!s.accessToken)return e.jsx(Ts,{});let r={user:s,url:n};return e.jsx(e.Fragment,{children:e.jsx(Oe,{...r,children:e.jsx(Re,{...r,children:e.jsx("div",{className:"w-full h-full min-h-[100%] relative",children:e.jsxs(A.QueryClientProvider,{client:a,children:[e.jsx(_s,{path:t})," "]})})})})})};exports.AppTasks=As;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime");require("@imj_media/imj-ui/styles.css");const P=require("@tanstack/react-query"),c=require("react"),w=require("@imj_media/tasks-modules"),V=require("react-dom"),fe=require("axios"),je=require("qs"),H=require("date-fns"),X=require("date-fns/locale"),_=require("@imj_media/imj-ui"),$e=require("react-hook-form"),Me=require("primereact/paginator"),Le=({label:t,active:s,onClick:n,disabled:a})=>a?e.jsx(w.Tooltip,{dispatch:e.jsxs("button",{className:"text-texts-placeholder text-xs font-semibold cursor-help",children:[" ",t," "]}),children:e.jsx("div",{className:"flex items-center justify-center px-3 py-2 bg-bg-card rounded-lg border border-border-card",children:e.jsx("p",{className:"text-texts-placeholder text-xs font-semibold",children:"Espéralo muy pronto..."})})}):e.jsx("button",{disabled:a,onClick:n,className:`${s?"text-texts-enfasis border-b-2 border-texts-enfasis":""} text-xs font-semibold ${a?"cursor-not-allowed text-texts-placeholder":"text-texts-subtext"} `,children:t}),ze=({tabs:t,renderItem:s,initialTab:n})=>{const[a,r]=c.useState(n??t[0].toLowerCase());c.useEffect(()=>{n&&r(n)},[n]);const l=i=>{r(i),s(i)};return e.jsx("div",{className:"flex",children:t.map((i,x)=>e.jsx("div",{className:`${x===0?"border-l-2":""} border-r-2 border-gray-200 px-m`,children:e.jsx(Le,{onClick:()=>l(i.toLowerCase()),label:i,active:i.toLowerCase()===a,disabled:["gantt"].includes(i.toLowerCase())},x)}))})},S={bg:{DEFAULT:"#EFEFEF",content:"#FAFAFA",card:"#FAFAFA"},texts:{DEFAULT:"#252525",enfasis:"#3658c1",subtext:"#4f4f4f",placeholder:"#929292"},primary:{light:"#E7E9F2",medium:"#dae2ec",dark:"#334990",regular:"#425CAC",pastel:"#5c7ddd"},success:{light:"#368156",medium:"#D2E9DC",dark:"#368156",regular:"#43B071",pastel:"#57BA81"},danger:{light:"#F1E5E4",medium:"#EBDBD9",dark:"#8C352C",regular:"#C34335",pastel:"#C4335"},warning:{light:"#F2ECE5",medium:"#EBE3D9",dark:"#B4782F",regular:"#D38A31",pastel:"#D38A31"},alert:{light:"#F1F1E4",medium:"#EAE9D9",dark:"#ADA63A",regular:"#D6CC48",pastel:"#D6CC48"},info:{light:"#E7F5FF",medium:"#D9E6EE",dark:"#1C5073",regular:"#1B6698",pastel:"#1B6698"},link:{light:"#ECF8FE",medium:"#D8F1FD",dark:"#0A7AAE",regular:"#0EA5E9",pastel:"#0EA5E9"}},J=()=>{const[t,s]=c.useState(null);return{position:t,setElementPosition:l=>{var h;let i=(h=l.current)==null?void 0:h.getBoundingClientRect(),x=(i==null?void 0:i.x)+((i==null?void 0:i.width)??0),o=(i==null?void 0:i.y)+(i==null?void 0:i.height);s(t?null:{x:x??0,y:o??0})},getChildrenSize:l=>{var i;return(i=l.current)==null?void 0:i.getBoundingClientRect()},clearPosition:()=>{s(null)}}},Be=({children:t,filterChildren:s})=>{const{position:n,setElementPosition:a}=J(),r=c.useRef(null),l=({children:i})=>{const[x,o]=c.useState();return c.useEffect(()=>{var h,d;s.current&&o(((n==null?void 0:n.x)??0)-(((d=(h=s.current)==null?void 0:h.getBoundingClientRect())==null?void 0:d.width)??0))},[s==null?void 0:s.current,n==null?void 0:n.x]),n&&V.createPortal(e.jsx("div",{className:`absolute w-fit h-fit ${x?"block":"hidden"}`,style:{top:`${n==null?void 0:n.y}px`,left:`${x}px`,zIndex:1},children:i}),document.body)};return e.jsxs(e.Fragment,{children:[e.jsxs("label",{ref:r,htmlFor:"filter-button",className:"flex cursor-pointer items-center gap-m p-s text-texts-enfasis fill-texts-enfasis bg-bg rounded-lg px-l h-[30px] shadow-button-primary hover:shadow-button-primary-hover ",children:[e.jsx(w.Icons,{icon:"filter",size:"xs",strokeWidth:5,color:S.primary.regular}),"Filtrar"]}),e.jsx("button",{className:"hidden",id:"filter-button",onClick:()=>{a(r)}}),e.jsx(l,{children:t})]})},me=t=>{let s={};return Object.entries(t).forEach(([n,a])=>{if(n.includes(".")){let[r,l]=n.split(".");s[r]=s[r]||{},s[r][l]=a}else s[n]=a}),s},be=c.createContext({}),Re=({children:t})=>{const[s,n]=c.useState({}),[a,r]=c.useState({}),[l,i]=c.useState([]),[x,o]=c.useState(""),h=({name:m,value:u})=>{function g(v){return!isNaN(v)&&v!==null&&v!==""?parseFloat(v):null}let j=g(u);r(v=>{let b={...v},y=l==null?void 0:l.find(C=>C.label.toLowerCase().replace(/ /g,"_")===m);return y?b[y.id]=j??u:b[m]=j??u,b})};c.useEffect(()=>{let m=l.map(u=>u.id==="owner.config"?[u.id,"yo_y_mis_equipos"]:u.id==="dependency"?[u.id,"ambas"]:[u.id,null]);r(Object.fromEntries(m))},[l]);const d=()=>{let m=l.map(u=>u.id==="owner.config"?[u.id,"yo_y_mis_equipos"]:u.id==="dependency"?[u.id,"ambas"]:[u.id,null]);r(Object.fromEntries(m)),n(me(Object.fromEntries(m)))},f=()=>{let m=me(a);console.log({filtersWithEstructure:m}),n(m)};return e.jsx(be.Provider,{value:{fields:l,filters:s,path:x,defineFields:i,updateFilters:h,cleanFilters:d,applyFilters:f,initialFilters:a,selectPath:o},children:t})},E=()=>c.useContext(be);function ye(t,s=300,n={leading:!1,trailing:!0}){let a,r=null;return function(...l){const i=Date.now(),x=n.leading&&!r;clearTimeout(a),x&&t(...l),r=i,a=setTimeout(()=>{n.trailing&&(!n.leading||i-r>=s)&&(t(...l),r=null)},s)}}const Oe=()=>{const{fields:t,updateFilters:s,cleanFilters:n,applyFilters:a,initialFilters:r}=E();return e.jsxs("div",{className:"flex flex-col gap-l min-w-[250px] z-[100]",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("p",{className:"text-texts text-m",children:"Filtros"}),e.jsx("button",{className:"text-xs font-semibold flex cursor-pointer items-center gap-m p-s text-texts-enfasis fill-texts-enfasis bg-bg rounded-lg px-l h-fit shadow-button-primary hover:shadow-button-primary-hover ",onClick:n,children:"Limpiar"})]}),e.jsx("div",{className:"flex flex-col gap-m",children:t==null?void 0:t.map((l,i)=>{var x;return e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:l.label}),(l==null?void 0:l.type)==="select"?e.jsx("select",{onChange:o=>{var h,d;s({name:(h=o==null?void 0:o.target)==null?void 0:h.name,value:(d=o==null?void 0:o.target)==null?void 0:d.value})},value:r==null?void 0:r[l==null?void 0:l.id],className:"w-full h-[30px] shadow-input rounded-lg p-s",name:l.id,id:l.id,children:(x=l==null?void 0:l.options)==null?void 0:x.map((o,h)=>e.jsx("option",{value:o.id,children:o.name},h))}):e.jsx("input",{className:"w-full h-[30px] shadow-input rounded-lg p-s",type:l.type,value:r==null?void 0:r[l==null?void 0:l.id],name:l.label.toLowerCase().replace(/ /g,"_"),onChange:ye(o=>{var h,d;return s({name:(h=o==null?void 0:o.target)==null?void 0:h.name,value:(d=o==null?void 0:o.target)==null?void 0:d.value})},1e3)})]},i)})}),e.jsx("button",{className:"btn-primary rounded-md py-s",onClick:a,children:"Filtrar"})]})},O=t=>{const s=a=>Object.prototype.toString.call(a)==="[object Object]",n=a=>a.attributes?{id:a.id,...a.attributes}:a;if(Array.isArray(t))return t.map(a=>O(a));if(s(t)){Array.isArray(t.data)?t=[...t.data]:s(t.data)?t=n({...t.data}):t.data===null?t=null:t=n(t);for(const a in t)t[a]=O(t[a]);return t}return t};class We{static toCampaignTasks(s){var a,r,l,i,x,o,h,d,f,m,u,g;let n=[];return s!=null&&s.responsable&&n.push({id:s.responsable.id,name:s.responsable.nombre,image:(x=(i=(l=(r=(a=s.responsable)==null?void 0:a.userOBP)==null?void 0:r.imagen)==null?void 0:l.formats)==null?void 0:i.thumbnail)==null?void 0:x.url}),console.log("task",s),(o=s==null?void 0:s.equipo)!=null&&o.miembros&&s.equipo.miembros.forEach(j=>{var v,b,y,C;n!=null&&n.find(N=>N.id===j.idUser.id)||j.idUser&&n.push({id:j.idUser.id,name:j.idUser.nombre,image:(C=(y=(b=(v=j==null?void 0:j.userOBP)==null?void 0:v.imagen)==null?void 0:b.formats)==null?void 0:y.thumbnail)==null?void 0:C.url})}),{isPrincipalTask:(s==null?void 0:s.tarea_principal)??!1,projectName:((h=s==null?void 0:s.proyecto)==null?void 0:h.nombre)??null,orden:(s==null?void 0:s.orden)??null,id:(s==null?void 0:s.id)??null,task:(s==null?void 0:s.texto_corto)??null,status:(s==null?void 0:s.estatus)??null,difficulty:(s==null?void 0:s.nivel_dificultad)??null,priority:(s==null?void 0:s.prioridad)??0,endDate:new Date((s==null?void 0:s.ffin)??null),startDate:new Date((s==null?void 0:s.finicio)??null),mediumName:(s==null?void 0:s.nombre_medio)??null,users:n,repeatsToDo:(s==null?void 0:s.repeticiones)??null,repeats:(s==null?void 0:s.repeticiones_realizadas)??null,comments:((d=s==null?void 0:s.comentarios)==null?void 0:d.length)??null,willBePaused:s==null?void 0:s.es_pausable,statusRequiredTask:((f=s==null?void 0:s.id_t_requerida)==null?void 0:f.estatus)??null,nameRequiredTask:((m=s==null?void 0:s.id_t_requerida)==null?void 0:m.texto_corto)??null,responsible:((u=s==null?void 0:s.responsable)==null?void 0:u.id)??null,tasks:((g=s==null?void 0:s.tareas)==null?void 0:g.map(j=>({id:j.id,name:j.texto_corto,status:j.estatus})))??null}}}const Ke=async({filters:t,tasks_api:s,project:n})=>{try{const a=await s.get("/api/listado_tareas_flujo",{params:{...t,project:{id:n},includeAllTasks:!0}});return O(a.data.tareas).map(We.toCampaignTasks)}catch(a){console.log(a)}},we=c.createContext({}),Qe=({children:t,user:s,url:n})=>{const a=fe.create({baseURL:n,headers:{Authorization:`Bearer ${s.accessToken}`},paramsSerializer:r=>je.stringify(r,{encodeValuesOnly:!0})});return e.jsx(we.Provider,{value:{tasks_api:a},children:t})},D=()=>c.useContext(we),ve=c.createContext({}),Ue=({children:t,user:s,url:n})=>{const a=fe.create({baseURL:n,headers:{Authorization:`Bearer ${s.accessToken}`},paramsSerializer:r=>je.stringify(r,{encodeValuesOnly:!0})});return e.jsx(ve.Provider,{value:{user:s,tasks_api:a},children:t})},R=()=>c.useContext(ve),Ne=c.createContext({}),He=({children:t,project:s})=>{var v;const n=P.useQueryClient(),[a,r]=c.useState([]),[l,i]=c.useState([]),{tasks_api:x}=D(),{filters:o}=E(),{user:h}=R(),[d,f]=c.useState({owner:{user:h.id,config:((v=o==null?void 0:o.owner)==null?void 0:v.config)??"yo_y_mis_equipos"},project:{id:s}}),m=P.useQuery({queryKey:["tasksProject",o,s],queryFn:()=>Ke({filters:{...d},project:s,tasks_api:x})});c.useEffect(()=>{var b;Object.keys(o).length>0&&f({...o,owner:{user:h.id,config:((b=o==null?void 0:o.owner)==null?void 0:b.config)??"yo_y_mis_equipos"},project:{id:s}})},[o]),c.useEffect(()=>{n.invalidateQueries({queryKey:["tasksProject",o,s]})},[d]);const u=b=>{r(y=>[...y,b])},g=b=>{i(y=>y.includes(b)?y.filter(C=>C!==b):[...y,b])},j=s??null;return e.jsx(Ne.Provider,{value:{tasksProject:m,selectedTasks:a,projectID:j,openTasks:l,selectTask:u,openTask:g},children:t})},Q=()=>c.useContext(Ne),Ve=[{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 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 dificultad",type:"select",id:"difficulty",options:[{id:0,name:"Muy facil"},{id:1,name:"Facil"},{id:2,name:"Media"},{id:3,name:"Dificil"},{id:4,name:"Muy dificil"}]}],Z=()=>{const{tasks_api:t}=D(),{user:s}=R(),{filters:n,path:a}=E(),r=P.useQueryClient(),{projectID:l}=Q(),i=async({id:u})=>(await t.put(`/api/tareas/${u}`,{data:{estatus:1,responsable:s==null?void 0:s.id,updated_by:s==null?void 0:s.id}})).data,x=async({id:u})=>(await t.post("/api/terminarTarea",{id_task:u,ended_at:new Date().toISOString(),id_user:s==null?void 0:s.id})).data,o=async({id:u,data:g,user:j})=>{},h=async({id:u})=>{await d({id:u})},{mutateAsync:d}=P.useMutation({mutationFn:i,onSuccess:()=>{const u={"kanban-general":"to_do_tasks","kanban-campania":"tasksProject"};try{a==="kanban-general"&&(r.invalidateQueries({queryKey:[u[a],n]}),r.invalidateQueries({queryKey:["working_tasks",n]})),a==="kanban-campania"&&r.invalidateQueries({queryKey:[u[a],n,l]})}catch(g){console.error("Error updating the element:",g)}},onError:u=>{console.error("Failed to update the task.",u)}}),{mutateAsync:f}=P.useMutation({mutationFn:x,onSuccess:()=>{const u={"kanban-general":"to_do_tasks","kanban-campania":"tasksProject"};a==="kanban-general"&&(r.invalidateQueries({queryKey:[u[a],n]}),r.invalidateQueries({queryKey:["done_tasks",n]})),a==="kanban-campania"&&r.invalidateQueries({queryKey:[u[a],n,l]})},onError:u=>{console.error("Failed to update the task.",u)}});return{updateTask:o,startWorking:h,completeTask:async({id:u})=>{await f({id:u})}}},Ge=({id:t})=>{const[s,n]=c.useState(!1),{completeTask:a}=Z();return{checked:s,checkTask:()=>{n(!s),a({id:t})}}},Ce=({id:t,nameRequiredTask:s,statusRequiredTask:n,status:a})=>{const{checked:r,checkTask:l}=Ge({id:t});let i=Math.random().toString();return e.jsxs(e.Fragment,{children:[s!==""&&n===2||!s?a===1?e.jsx("label",{htmlFor:i,className:r?"bg-success-regular rounded-full w-[20px] h-[20px] flex items-center justify-center mx-[2px] transition-all":" transition-colors",children:e.jsx(w.Icons,{icon:r?"check_outline":"circle_checked",color:r?"white":S.texts.placeholder,strokeWidth:4,size:r?"xs":"s"})}):e.jsx(e.Fragment,{children:" "}):e.jsx(w.Tooltip,{dispatch:e.jsx("label",{className:"cursor-help",children:e.jsx(w.Icons,{icon:"info_circle",color:S.warning.regular,strokeWidth:4})}),children:e.jsxs("div",{className:" p-l max-w-[400px] w-fit bg-warning-light rounded-lg border-l-[5px] border-warning-regular text-warning-dark text-xs flex flex-col gap-m",children:[e.jsx("p",{className:"font-bold",children:" Requiere completar su tarea requerida: "}),e.jsxs("p",{children:[" ",s," "]})]})}),e.jsx("input",{id:i,checked:r,onChange:l,type:"checkbox",className:"hidden"})]})},W=({imageUrl:t="https://www.uv.unach.mx/assets/img/prueba/directorio/userM.png",alt:s="avatar"})=>e.jsx("img",{src:t===""?"https://www.uv.unach.mx/assets/img/prueba/directorio/userM.png":t,alt:s??"avatar",className:"w-[28px] h-[28px] min-w-[28px] min-h-[28px] rounded-full bg-containers border-2 border-white"}),pe=({trigger:t,user:s,showUser:n=!0})=>e.jsx(w.Tooltip,{dispatch:t,children:n&&e.jsxs("div",{className:"flex items-center gap-2 bg-containers w-fit h-fit p-2 rounded-lg border-containers",children:[e.jsx(W,{imageUrl:s.image??"",alt:s.name}),e.jsx("p",{className:"text-xs font-bold content-text",children:s.name})]})}),Ye=({options:t,onselect:s})=>{const[n,a]=c.useState(null),r=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),l=[...t].filter(i=>i.name.toLowerCase().includes((n==null?void 0:n.toLowerCase())??""));return e.jsxs("div",{className:"h-fit w-full min-w-max",children:[e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("input",{id:r,value:n??"",onChange:i=>a(i.target.value),type:"text",className:"w-full h-[32px] bg-bg-card border-cards rounded-lg p-2",placeholder:"Buscar"}),e.jsx("div",{className:"absolute right-[8px]",children:e.jsx(w.Icons,{icon:"search",size:"xs",strokeWidth:3})})]}),e.jsx("div",{className:"bg-bg-card border-cards rounded-lg p-2 flex flex-col gap-s overflow-y-auto max-h-[120px] min-w-max",children:l.map(i=>e.jsxs("button",{onClick:()=>{s(i)},className:"flex gap-s items-center max-w-[200px] min-w-full hover:bg-primary-light cursor-pointer",children:[e.jsx(W,{imageUrl:i.image,alt:i.name}),e.jsx("p",{className:"text-xs font-bold content-text",children:i.name})]}))})]})};class Xe{static toDomain(s){return{id:s.id,name:s.nombre,color:s.color}}}const Je=()=>{const{tasks_api:t}=D();return{teams:P.useQuery({queryKey:["teams","all"],queryFn:async()=>{const n=await t.get("/api/equipos");return O(n.data).map(Xe.toDomain)}})}};class Ze{static toUsers(s){var n,a,r;return{id:s.id,name:s.nombre,image:(r=(a=(n=s.imagen)==null?void 0:n.formats)==null?void 0:a.thumbnail)==null?void 0:r.url}}}const ke=async({tasks_api:t})=>{try{const s=await t.get("/api/allOBPUsers");return O(s.data).map(Ze.toUsers)}catch(s){throw console.log("Error al obtener los usuarios comerciales",s),`Error al obtener los usuarios comerciales: ${s}`}},es=()=>{const{tasks_api:t}=D();return{users:P.useQuery({queryKey:["users"],queryFn:()=>ke({tasks_api:t}),staleTime:1e3*60*60*24})}},Fe=t=>new Intl.DateTimeFormat("es-MX",{month:"long"}).format(t);function ss(t){const s=["domingo","lunes","martes","miércoles","jueves","viernes","sábado"],n=new Date(t).getDay();return s[n]}const he=t=>{let s=t||new Date,n=s.getDate(),a=Fe(s.getMonth()).slice(0,3),r=s.getFullYear().toString().slice(-2),l=ss(s).slice(0,3);return`${l.charAt(0).toUpperCase()+l.slice(1)} ${n} ${a.charAt(0).toUpperCase()+a.slice(1)} ${r}`},k=t=>({...t,image:t.image?`https://devobp.imjmedia.com.mx${t.image}`:""}),_e=({users:t,onClick:s,responsible:n})=>{let a=`button-assign-users-${Math.random().toString(36).substring(2,15)}`;const{setElementPosition:r,position:l,clearPosition:i}=J(),x=c.useRef(null),o=()=>n?null:t.length>3&&e.jsx(w.Tooltip,{dispatch:e.jsx("div",{className:"w-[28px] h-[28px] rounded-full btn-primary flex items-center justify-center border-2 border-white ml-[-8px]",children:e.jsx("p",{className:"text-xs font-bold text-white ",children:`+${t.length-3}`})}),children:e.jsx("div",{className:"bg-containers w-fit h-fit p-2 rounded-lg border-containers",children:t==null?void 0:t.slice(3).map((m,u)=>e.jsxs("div",{className:"flex items-center gap-2 ",children:[e.jsx(W,{imageUrl:m.image??"",alt:m.name},u),e.jsx("p",{className:"text-xs font-bold content-text",children:m.name})]},u))})}),h=()=>{if(n){let m=t.find(u=>u.id===n);return e.jsx("div",{children:e.jsx(pe,{trigger:e.jsx(W,{imageUrl:m==null?void 0:m.image,alt:m==null?void 0:m.name},n),user:m,showUser:!(l!=null&&l.x)})})}return(t==null?void 0:t.length)>0&&t.slice(0,3).map((m,u)=>e.jsx("div",{className:`${u===0?"":"ml-[-8px]"}`,children:e.jsx(pe,{trigger:e.jsx(W,{imageUrl:m.image,alt:m.name},u),user:m,showUser:!(l!=null&&l.x)})}))},d=({children:m})=>e.jsx("label",{ref:x,htmlFor:a,className:"cursor-pointer flex items-center",children:m});if(t.length===0)return e.jsx(d,{children:e.jsx(w.Icons,{icon:"user",size:"xs",strokeWidth:3})});const f=()=>{var C;const[m,u]=c.useState(),[g,j]=c.useState("team"),{teams:v}=Je(),{users:b}=es();c.useEffect(()=>{var N,T;x.current&&u(((l==null?void 0:l.x)??0)-(((T=(N=x.current)==null?void 0:N.getBoundingClientRect())==null?void 0:T.width)??0))},[x==null?void 0:x.current,l==null?void 0:l.x]);const y=()=>{const N=[{id:"team",label:"Equipo"},{id:"responsible",label:"Responsable"}];return e.jsx("div",{className:"w-full flex justify-center gap-l text-texts-placeholder font-bold",children:N.map((T,z)=>e.jsx("button",{className:`w-full text-sm border-texts-placeholder text-center ${g===T.id?"text-primary-pastel":""} ${z===N.length-1?"border-r-0":" border-r-2"}`,onClick:()=>j(T.id),children:T.label}))})};return(l==null?void 0:l.x)&&V.createPortal(e.jsx("div",{className:`absolute w-[300px] h-fit ${m?"block":"hidden"}`,style:{top:`${l==null?void 0:l.y}px`,left:`${m}px`,zIndex:1},children:e.jsxs("div",{className:"flex flex-col gap-m bg-bg-card border-cards rounded-lg p-2 max-h-[200px] overflow-y-hidden",children:[e.jsx(y,{}),e.jsx(Ye,{options:g==="team"?v.data.map(N=>({id:N.id,name:N.name,image:""})):(C=b.data)==null?void 0:C.map(k),onselect:N=>{i(),s&&s(N)}})]})}),document.body)};return e.jsxs(e.Fragment,{children:[e.jsxs(d,{children:[h(),o()]}),e.jsx("button",{className:"hidden",id:a,onClick:()=>r(x)}),e.jsx(f,{})]})},Se=({priority:t,id:s})=>{const{updateTask:n}=Z(),a=Math.random().toString(36),[r,l]=c.useState(null),i=o=>({0:S.primary.regular,1:S.success.regular,2:S.warning.regular,3:S.danger.regular})[o],x=()=>{if(!r)return null;const o=({priority:h,text:d})=>e.jsxs("button",{onClick:()=>{n({id:s,data:{prioridad:h},user:272}),l(null)},className:"flex gap-m items-center px-l py-s hover:bg-primary-light",children:[e.jsx(w.Icons,{icon:"flag",size:"xs",strokeWidth:3,color:i(h)}),e.jsx("p",{className:"text-sm",style:{color:i(h)},children:d})]});return V.createPortal(e.jsxs("div",{onBlur:()=>{l(null)},id:`${a}-options`,style:{top:`${r.y+5}px`,left:`${r.x+5}px`,zIndex:1},className:`absolute h-fit p-m flex flex-col gap-2 bg-bg-card rounded-xl shadow-lg
|
|
2
|
+
w-max`,children:[e.jsx(o,{priority:0,text:"Baja"}),e.jsx(o,{priority:1,text:"Normal"}),e.jsx(o,{priority:2,text:"Media"}),e.jsx(o,{priority:3,text:"Alta"})]}),document.body)};return e.jsxs("div",{className:"relative h-[22px]",children:[e.jsx("label",{onBlur:()=>{l(null)},htmlFor:a,className:"flex items-center gap-2 cursor-pointer active:opacity-50",children:e.jsx(w.Icons,{icon:"flag",size:"xs",strokeWidth:3,color:i(t)})}),e.jsx("button",{id:a,onClick:o=>{l(r?null:{x:o.clientX,y:o.clientY})},className:"hidden"}),e.jsx(x,{})]})};function ts({items:t}){var a;const[s,n]=c.useState(1);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-row mb-2 border-b border-neutral-100 bg-white mt-4",children:t.map((r,l)=>e.jsx("div",{className:`border-r border-neutral-100 pr-3 py-1 ${l!==0?"px-3":""}`,children:e.jsx(_.Button,{variant:"ghost",onClick:()=>n(r.id),className:`text-sm font-normal rounded-none py-1 h-8 ${s===r.id?"text-primary border-b border-primary":"text-neutral-400 border-b-0"}`,children:r.label},r.id)},r.id))}),e.jsx("div",{className:"pt-4 flex-1 overflow-y-auto bg-white",children:(a=t.find(r=>r.id===s))==null?void 0:a.component})]})}const Te="https://devobp.imjmedia.com.mx";function ee(t){return t?t.split(" ").map(a=>{var r;return(r=a[0])==null?void 0:r.toUpperCase()}).slice(0,2).join(""):""}const as="https://devobp.imjmedia.com.mx";function ns({comment:t}){var n,a,r,l,i,x;function s(o){const h=H.parseISO(o);return H.formatDistanceToNow(h,{locale:X.es,addSuffix:!0})}return e.jsx("div",{children:e.jsxs("div",{className:"flex flex-row gap-3 items-start",children:[e.jsxs(_.Avatar,{className:"w-[28px] h-[28px]",children:[e.jsx(_.AvatarImage,{src:`${as}${(l=(r=(a=(n=t==null?void 0:t.autor)==null?void 0:n.imagen)==null?void 0:a.formats)==null?void 0:r.thumbnail)==null?void 0:l.url}`,alt:"@shadcn"}),e.jsx(_.AvatarFallback,{children:ee((i=t==null?void 0:t.autor)==null?void 0:i.nombre)})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx("p",{className:"text-sm text-neutral-900 font-medium",children:(x=t==null?void 0:t.autor)==null?void 0:x.nombre}),e.jsx("span",{className:"text-xs text-neutral-600 font-normal mt-[2px]",children:s(t==null?void 0:t.createdAt)})]}),e.jsx("p",{className:"text-sm text-neutral-600 font-normal",children:t==null?void 0:t.comentario})]})]})})}function rs({currentUser:t,data:s,taskId:n,onNewComment:a}){var f,m,u;const{tasks_api:r}=D(),{register:l,handleSubmit:i,reset:x}=$e.useForm(),[o,h]=c.useState([]);c.useEffect(()=>{if(s!=null&&s.comentarios){const g=[...s.comentarios].sort((j,v)=>new Date(v.createdAt).getTime()-new Date(j.createdAt).getTime());h(g)}},[s]);const d=async g=>{try{const j={autor:{id:t==null?void 0:t.id,email:t==null?void 0:t.email,nombre:t==null?void 0:t.nombre,imagen:t==null?void 0:t.imagen},comentario:g==null?void 0:g.comment,createdAt:new Date().toISOString()};await r.post("/api/comentarios",{data:{autor:t==null?void 0:t.id,comentario:g.comment,tarea:n}}),a(!0),h(v=>[j,...v]),x()}catch(j){console.error("Error al agregar comentario:",j)}};return e.jsxs("div",{className:"flex flex-col h-full gap-4",children:[e.jsxs("form",{onSubmit:i(d),className:"flex flex-row items-center gap-3",children:[e.jsxs(_.Avatar,{className:"w-[28px] h-[28px]",children:[e.jsx(_.AvatarImage,{src:`${Te}${(u=(m=(f=t==null?void 0:t.imagen)==null?void 0:f.formats)==null?void 0:m.thumbnail)==null?void 0:u.url}`,alt:"@shadcn"}),e.jsx(_.AvatarFallback,{className:"border border-x-primary-pastel",children:ee(t==null?void 0:t.nombre)})]}),e.jsx(_.Input,{...l("comment",{required:!0}),autoComplete:"off",placeholder:"Escribe un comentario",className:"w-full bg-white border border-neutral-200"})]}),o.map((g,j)=>e.jsx(ns,{comment:g},j))]})}function ls({data:t}){const s={0:{color:"bg-gray-400",label:"Sin estado"},1:{color:"bg-primary-regular",label:"En curso"},2:{color:"bg-success-regular",label:"Finalizada"},3:{color:"bg-success-regular",label:"Finalizada"}},n=a=>a?H.format(new Date(a),"d MMM",{locale:X.es}):"";return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-row items-center gap-4",children:[e.jsx(_.Label,{className:"text-lg font-medium text-neutral-900",children:"Tareas dependientes"}),e.jsx("span",{className:"text-sm font-normal text-neutral-600 bg-[#E1EBF9] w-6 h-6 rounded-full flex items-center justify-center text-primary",children:t==null?void 0:t.length})]}),e.jsx("div",{className:"flex flex-col gap-2 border border-neutral-200 rounded-lg mt-3",children:t==null?void 0:t.map(a=>{var r,l,i,x,o;return e.jsxs("div",{className:"flex flex-row w-full items-center justify-between gap-s border-b border-neutral-200 py-1 px-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{imageUrl:(x=(i=(l=(r=a.responsable)==null?void 0:r.image)==null?void 0:l.formats)==null?void 0:i.thumbnail)==null?void 0:x.url}),e.jsx("p",{className:"text-sm font-normal w-[400px] text-nowrap text-ellipsis overflow-hidden",children:a==null?void 0:a.texto_corto})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("p",{className:"text-sm font-normal",children:n(a==null?void 0:a.createdAt)}),e.jsx("div",{className:`w-4 h-4 bg-gray-400 block rounded-full ${((o=s[a==null?void 0:a.estatus])==null?void 0:o.color)??"bg-gray-400"}`})]})]},a.id)})})]})}const is="https://devobp.imjmedia.com.mx";function os({isOpen:t,setIsOpen:s,taskId:n}){var g,j,v,b,y,C,N,T,z,I,M;const[a,r]=c.useState(null),[l,i]=c.useState(!1),[x,o]=c.useState(null),{tasks_api:h}=D(),{user:d}=R();c.useEffect(()=>{if(t&&n||l){const p=async()=>{const F=await h.get(`/api/detalleTarea/${n}`);r(F==null?void 0:F.data)},A=async()=>{var B,$;const F=await h.get(`/api/users/${d.id}`),q=await h.post("/api/obtenerUsuarioOBP/",{emailList:[(B=F==null?void 0:F.data)==null?void 0:B.email]});o(($=q==null?void 0:q.data)==null?void 0:$.data[0])};p(),A()}},[t,n,l]);const f={0:{label:"Sin prioridad",color:"text-primary-regular",iconColor:"#425CAC"},1:{label:"Baja",color:"text-success-regular",iconColor:"#43B071"},2:{label:"Media",color:"text-warning-regular",iconColor:"#D38A31"},3:{label:"Alta",color:"text-danger-regular",iconColor:"#C34335"}},m=p=>p?H.format(p,"d MMM yyyy, h:mmaaa",{locale:X.es}):"Fecha no disponible",u=[{id:1,label:"Todo",component:e.jsx(rs,{taskId:n,currentUser:x,data:a,onNewComment:i})},{id:2,label:"Dependencias",component:e.jsx(ls,{data:a==null?void 0:a.ids_t_dependientes})}];return e.jsx(e.Fragment,{children:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`fixed inset-0 bg-transparent bg-opacity-50 flex justify-center items-center z-20 ${t?"pointer-events-auto block":"pointer-events-none hidden"}`,onClick:()=>s(!1)}),e.jsx("section",{className:`fixed top-0 bottom-0 bg-white bg-opacity-50 flex justify-center items-center w-[40rem] h-screen z-50 overflow-hidden transition-all ease-in-out duration-500 shadow-2xl ${t?"right-0 pointer-events-auto block":"right-[-100%] pointer-events-none hidden"}`,children:e.jsxs("div",{className:"flex w-full h-full flex-col overflow-y-scroll bg-white border-none shadow-xl px-4 py-6",children:[e.jsxs("div",{className:"w-full flex flex-row justify-between pb-4 gap-10 border-none",children:[e.jsx("h3",{className:"text-lg font-semibold text-neutral-900",children:a==null?void 0:a.texto_corto}),e.jsx(_.Button,{variant:"shadow",size:"sm",onClick:()=>s(!1),className:"bg-neutral-100 w-10 h-10",children:e.jsx(w.Icons,{icon:"x_outline"})})]}),e.jsx("div",{className:"w-full flex flex-row justify-between",children:e.jsxs("span",{className:"text-neutral-600 text-sm",children:[a==null?void 0:a.campania," / ",a==null?void 0:a.nombre_medio]})}),e.jsxs("div",{className:"w-full flex flex-col gap-3 mt-4",children:[e.jsx("h6",{className:"text-neutral-900 font-semibold text-base",children:"Descripción"}),e.jsx("p",{className:"text-neutral-600 font-normal text-sm",children:(a==null?void 0:a.texto_largo)??"Sin descripción"})]}),e.jsx(_.Accordion,{type:"single",collapsible:!0,defaultValue:"item-1",className:"w-full flex flex-col border border-neutral-200 rounded-xl mt-4",children:e.jsxs(_.AccordionItem,{value:"item-1",className:"border-none",children:[e.jsx(_.AccordionTrigger,{className:"text-neutral-900 font-medium text-sm w-full flex flex-row border-b border-neutral-200 p-4 ",children:"Detalles"}),e.jsx(_.AccordionContent,{className:"border-none",children:e.jsxs("div",{className:"w-full grid grid-cols-3 gap-4 p-4",children:[e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Responsable"}),(g=a==null?void 0:a.responsable)!=null&&g.nombre?e.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[e.jsxs(_.Avatar,{className:"w-[28px] h-[28px]",children:[e.jsx(_.AvatarImage,{src:`${is}${(y=(b=(v=(j=a==null?void 0:a.responsable)==null?void 0:j.imagen)==null?void 0:v.formats)==null?void 0:b.thumbnail)==null?void 0:y.url}`,alt:"@shadcn"}),e.jsx(_.AvatarFallback,{children:ee((C=a==null?void 0:a.responsable)==null?void 0:C.nombre)})]}),e.jsx("span",{className:"text-xs text-neutral-600 font-normal",children:(N=a==null?void 0:a.responsable)==null?void 0:N.nombre})]}):e.jsx("span",{className:"text-xs text-neutral-600 font-normal",children:"Sin responsable"})]}),e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Equipo asignado"}),e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx("span",{className:"text-xs text-neutral-600 font-normal",children:((T=a==null?void 0:a.equipo)==null?void 0:T.nombre)??"Sin equipo"})})]}),e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Prioridad"}),e.jsxs("div",{className:"flex flex-row items-center gap-2",children:[e.jsx(w.Icons,{icon:"flag",size:"xs",strokeWidth:5,color:(z=f[a==null?void 0:a.prioridad])==null?void 0:z.iconColor}),e.jsx("span",{className:`text-sm text-neutral-600 font-normal ${(I=f[a==null?void 0:a.prioridad])==null?void 0:I.color}`,children:((M=f[a==null?void 0:a.prioridad])==null?void 0:M.label)??"Sin prioridad"})]})]}),e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Lista"}),e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx("span",{className:"text-xs text-neutral-600 font-normal",children:(a==null?void 0:a.lista)??"Sin lista"})})]}),e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Fecha estimada de inicio"}),e.jsx("p",{className:"text-xs text-neutral-600 font-normal",children:m(a==null?void 0:a.f_inicio_estimada)})]}),e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Fecha estimada de fin"}),e.jsx("p",{className:"text-xs text-neutral-600 font-normal",children:m(a==null?void 0:a.f_fin_estimada)})]}),e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Fecha de fin"}),e.jsx("p",{className:"text-xs text-neutral-600 font-normal",children:m(a==null?void 0:a.ffin)})]}),e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Creado"}),e.jsx("p",{className:"text-xs text-neutral-600 font-normal",children:m(a==null?void 0:a.createdAt)})]}),e.jsxs("div",{className:"flex flex-col w-auto gap-2",children:[e.jsx("span",{className:"text-sm text-neutral-900 font-medium",children:"Última modificación"}),e.jsx("p",{className:"text-xs text-neutral-600 font-normal",children:m(a==null?void 0:a.updatedAt)})]})]})})]})}),e.jsx(ts,{items:u})]})})]})})}const cs=({id:t,task:s,endDate:n,users:a,willBePaused:r,nameProject:l,idProject:i,comments:x,priority:o,responsible:h,nameRequiredTask:d,statusRequiredTask:f,status:m})=>{const u=c.useRef(null),[g,j]=c.useState(!1),{setElementPosition:v,position:b}=J(),{startWorking:y,completeTask:C}=Z(),N=c.useRef(!1),T=({children:I})=>{const[M,p]=c.useState();return c.useEffect(()=>{var A,F;u.current&&p(((b==null?void 0:b.x)??0)-(((F=(A=u.current)==null?void 0:A.getBoundingClientRect())==null?void 0:F.width)??0))},[u==null?void 0:u.current,b==null?void 0:b.x]),b&&V.createPortal(e.jsx("div",{className:`absolute w-fit h-fit ${M?"block":"hidden"}`,style:{top:`${b==null?void 0:b.y}px`,left:`${M}px`,zIndex:1},children:I}),document.body)},z=()=>e.jsxs("div",{className:"flex justify-between items-center w-full h-fit relative",children:[e.jsxs("div",{className:"flex items-center gap-[8px] w-[calc(100%-32px)] ",children:[m<2&&e.jsx(Ce,{id:t,nameRequiredTask:d??"",statusRequiredTask:f??0,status:m}),e.jsx("p",{className:"title-text",onClick:()=>j(!0),children:s})]}),m<2&&(d!==""&&f===2||!d)&&e.jsx("button",{ref:u,onClick:()=>{v(u)},className:"flex items-center justify-center text-sm font-extrabold bg-bg hover:filter-[drop-shadow(0_0_10px_#000000)] rounded-full w-[24px] h-[24px] m-block",children:e.jsx("span",{className:"rotate-90",children:e.jsx(w.Icons,{icon:"elipsis",size:"xs"})})}),e.jsx(T,{children:N!=null&&N.current?e.jsx("div",{className:"w-max h-fit bg-bg-card rounded-lg p-l shadow-lg flex items-center gap-2 hover:bg-primary-light",children:e.jsx("p",{className:"text-sm font-normal text-primary-pastel font-regular",children:"Moviendo..."})}):e.jsxs("button",{className:"w-max h-fit bg-bg-card rounded-lg p-l shadow-lg flex items-center gap-2 hover:bg-primary-light",onClick:()=>{N.current=!0,m===0?y({id:t}):C({id:t})},children:[e.jsx("p",{className:"text-sm font-normal text-texts-placeholder font-regular",children:m===0?"Mover a trabajando":"Mover a completadas"}),e.jsx(w.Icons,{icon:"arrow_right",size:"xs",strokeWidth:4,color:S.primary.regular})]})})]});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-bg-card border-cards max-w-[350px] rounded-lg relative h-fit p-[12px_12px] hover:border-active hover:bg-active cursor-pointer ",children:[e.jsx(z,{}),e.jsxs("div",{className:"flex flex-col gap-[4px] py-2",children:[e.jsx("p",{className:"subtitle-text",children:l}),i&&e.jsx("p",{className:"content-text",children:i})]}),e.jsxs("div",{className:"flex justify-between items-center w-full h-fit relative pt-5 pb-1",children:[e.jsxs("div",{className:"flex items-center relative",children:[e.jsx(_e,{responsible:h,users:a.filter(I=>h?I.id===h:!0).map(k),onClick:()=>{}}),r&&e.jsx(w.Tooltip,{dispatch:e.jsxs("button",{className:"text-sm font-regular text-gray-400 flex items-center gap-2",children:[e.jsx(w.Icons,{icon:"pause",size:"s",strokeWidth:2}),e.jsx("span",{children:"Pause"})]}),children:e.jsx("p",{className:"text-sm font-regular text-white p-5",children:"Al pulsar el botón se solicitará razón del pausado"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w.Icons,{icon:"difficulty",size:"xs"}),e.jsx(Se,{priority:o,id:t}),e.jsx(w.Icons,{icon:"calendar",size:"xs",strokeWidth:3,color:S.texts.subtext}),e.jsx("p",{className:"text-sm font-regular text-texts-subtext",children:`${n.getDate()} ${Fe(n.getMonth()).slice(0,3)}`})]})]}),x>0&&e.jsx("div",{className:"border-t border-gray-200 mt-4 pt-2",children:e.jsxs("button",{className:"flex items-center gap-2",children:[e.jsx(w.Icons,{icon:"comment",size:"xs",strokeWidth:4}),e.jsx("span",{className:"text-sm font-regular text-gray-400",children:x})]})})]}),e.jsx(os,{taskId:t,isOpen:g,setIsOpen:j})]})},ds=()=>e.jsxs("div",{className:"bg-gray-200 h-[150px] w-full animate-pulse rounded-md flex flex-col gap-[50px] p-4",children:[e.jsxs("div",{className:"flex h-[30px] gap-3",children:[e.jsx("div",{className:"w-[30px] min-w-[30px] h-full bg-gray-300 rounded-full"}),e.jsx("div",{className:"w-full h-full bg-gray-300"}),e.jsx("div",{className:"w-[30px] min-w-[30px] h-full bg-gray-300 rounded-full"})]}),e.jsxs("div",{className:"flex justify-between w-full h-[30px] gap-[50px]",children:[e.jsx("div",{className:"w-full h-[30px] bg-gray-300"}),e.jsx("div",{className:"w-full h-[30px] bg-gray-300"})]})]}),G=({title:t,tasks:s,loadNextPage:n,isFetching:a,total:r})=>{const l=c.useRef(null),i=c.useRef(null),x=c.useRef(!1);c.useEffect(()=>{var d;l!=null&&l.current&&(i!=null&&i.current)&&(i.current.style.minHeight=`${((d=l==null?void 0:l.current)==null?void 0:d.clientHeight)-50}px`)},[l==null?void 0:l.current]);const o=d=>{if(x.current)return;const{scrollTop:f,clientHeight:m,scrollHeight:u}=d==null?void 0:d.target,g=f/(u-m)*100;g<=95||g>=95&&(x.current=!0,n&&n(),setTimeout(()=>{x.current=!1},200))},h={"Por hacer":"border-texts-placeholder",Trabajando:"border-primary-regular",Completadas:"border-success-regular"};return e.jsxs("div",{ref:l,className:` flex flex-col bg-containers w-fit max-w-[400px] min-w-[400px] h-full min-h-[100%] pb-[200px] relative p-[16px] rounded-lg overflow-hidden border-t-4 ${h[t]}`,children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("div",{className:"flex items-center gap-[8px]",children:e.jsx("p",{className:"text-base",children:t})}),e.jsx("div",{className:"flex items-center gap-[8px]",children:e.jsxs("div",{className:"flex items-center gap-[4px]",children:[e.jsx(w.Icons,{icon:"group_files",size:"xs",strokeWidth:5,color:S.texts.placeholder}),e.jsx("p",{className:"text-md text-texts-placeholder",children:r??0})]})})]}),e.jsxs("div",{ref:i,className:"flex flex-col gap-[12px] overflow-y-auto scrollbar-none py-4",onScroll:o,children:[s==null?void 0:s.map(d=>e.jsx(cs,{...d},d.id)),a?e.jsx(ds,{}):e.jsx("p",{className:"text-center text-gray-500",children:"No hay más tareas por mostrar..."})]})]})},xs=()=>{var r;const{defineFields:t}=E(),{tasksProject:s}=Q();c.useEffect(()=>{(async()=>{let i=[...Ve];t(i)})()},[]);let n=(r=s==null?void 0:s.data)==null?void 0:r.filter(l=>{var i;return((i=l==null?void 0:l.tasks)==null?void 0:i.length)===0}).reduce((l,i)=>(l[i.status]=l[i.status]||[],l[i.status].push(i),l),{});const a=["Por hacer","Trabajando","Completadas"];return e.jsx("div",{className:"flex gap-4 w-full h-full min-h-[100%] relative ",children:a.map((l,i)=>{var x;return e.jsx(G,{total:((x=n==null?void 0:n[i])==null?void 0:x.length)??0,title:l,tasks:(n==null?void 0:n[i])??[],isFetching:s==null?void 0:s.isFetching,isLoadingData:s==null?void 0:s.isLoading})})})};class us{static toKanbanTasks(s){var a,r,l,i,x,o,h,d,f,m,u;let n=[];return s!=null&&s.responsable&&n.push({id:s.responsable.id,name:s.responsable.nombre,image:(x=(i=(l=(r=(a=s.responsable)==null?void 0:a.userOBP)==null?void 0:r.imagen)==null?void 0:l.formats)==null?void 0:i.thumbnail)==null?void 0:x.url}),(o=s==null?void 0:s.equipo)!=null&&o.miembros&&s.equipo.miembros.forEach(g=>{var j,v,b,y;n!=null&&n.find(C=>C.id===g.idUser.id)||g.idUser&&n.push({id:g.idUser.id,name:g.idUser.nombre,image:(y=(b=(v=(j=g==null?void 0:g.userOBP)==null?void 0:j.imagen)==null?void 0:v.formats)==null?void 0:b.thumbnail)==null?void 0:y.url})}),{comments:0,nameProject:(h=s==null?void 0:s.proyecto)==null?void 0:h.nombre,idProject:(d=s==null?void 0:s.proyecto)==null?void 0:d.id,willBePaused:s.es_pausable,difficulty:s.nivel_dificultad,endDate:new Date(s.ffin),id:s.id,priority:s.prioridad??0,status:s.estatus,task:s.texto_corto,users:n,responsible:((f=s==null?void 0:s.responsable)==null?void 0:f.id)??null,statusRequiredTask:((m=s.id_t_requerida)==null?void 0:m.estatus)??null,nameRequiredTask:((u=s.id_t_requerida)==null?void 0:u.texto_corto)??null}}}const se=async({filters:t,tasks_api:s})=>{try{return(await s.get("/api/listado_tareas",{params:t})).data.tareas.map(O).map(us.toKanbanTasks)}catch(n){throw console.log({error:n}),`Error al obtener las tareas: ${n}`}},te=t=>{var s;if(t!=null&&t.hasNextPage){const n=(s=t==null?void 0:t.data)==null?void 0:s.pages[t.data.pages.length-1];(n==null?void 0:n.length)===30&&(t==null||t.fetchNextPage())}},K=t=>({pagination:{page:t,pageSize:30,withCount:!0}}),ms=()=>{var h;const t=P.useQueryClient(),{tasks_api:s}=D(),{user:n}=R(),{filters:a}=E(),[r,l]=c.useState(0),[i,x]=c.useState({owner:{user:n.id,config:((h=a==null?void 0:a.owner)==null?void 0:h.config)??"yo_y_mis_equipos"},status:"por_hacer"}),o=P.useInfiniteQuery({initialPageParam:1,queryKey:["to_do_tasks",i],queryFn:({pageParam:d})=>se({filters:{...i,status:"por_hacer",...K(d)},tasks_api:s,page:d}),staleTime:1e3*60*60*24,getNextPageParam:(d,f)=>f.length+1});return c.useEffect(()=>{var d;Object.keys(a).length>0&&x({...a,owner:{user:n.id,config:((d=a==null?void 0:a.owner)==null?void 0:d.config)??"yo_y_mis_equipos"},status:"por_hacer"})},[a]),c.useEffect(()=>{t.invalidateQueries({queryKey:["to_do_tasks",i]})},[i]),c.useEffect(()=>{(async()=>{const f=await s.get("/api/listado_tareas",{params:{...i,status:"por_hacer",...K(1),tasks_api:s,justCount:!0}});l(f.data.total)})()},[i,o==null?void 0:o.data]),{toDoTasks:o,total:r}},ps=()=>{var a,r;const{toDoTasks:t,total:s}=ms(),n=[...((r=(a=t==null?void 0:t.data)==null?void 0:a.pages)==null?void 0:r.flat())??[]];return e.jsx(G,{total:s,title:"Por hacer",tasks:n,loadNextPage:()=>te(t),isFetching:t==null?void 0:t.isFetching,isLoadingData:t==null?void 0:t.isLoading})},hs=()=>{var h;const t=P.useQueryClient(),{tasks_api:s}=D(),{user:n}=R(),{filters:a}=E(),[r,l]=c.useState(0),[i,x]=c.useState({owner:{user:n.id,config:((h=a==null?void 0:a.owner)==null?void 0:h.config)??"yo_y_mis_equipos"},status:"trabajando"}),o=P.useInfiniteQuery({initialPageParam:1,queryKey:["working_tasks",a],queryFn:({pageParam:d})=>se({filters:{...i,status:"trabajando",...K(d)},tasks_api:s,page:d}),staleTime:1e3*60*60*24,getNextPageParam:(d,f)=>f.length+1});return c.useEffect(()=>{var d;Object.keys(a).length>0&&x({...a,owner:{user:n.id,config:((d=a==null?void 0:a.owner)==null?void 0:d.config)??"yo_y_mis_equipos"},status:"trabajando"})},[a]),c.useEffect(()=>{t.invalidateQueries({queryKey:["working_tasks",a]})},[i]),c.useEffect(()=>{(async()=>{const f=await s.get("/api/listado_tareas",{params:{...i,status:"trabajando",...K(1),tasks_api:s,justCount:!0}});l(f.data.total)})()},[i,o==null?void 0:o.data]),{workingTasks:o,total:r}},gs=()=>{var a,r;const{workingTasks:t,total:s}=hs(),n=[...((r=(a=t==null?void 0:t.data)==null?void 0:a.pages)==null?void 0:r.flat())??[]];return e.jsx(G,{total:s,title:"Trabajando",tasks:n,loadNextPage:()=>te(t),isFetching:t==null?void 0:t.isFetching})},fs=()=>{var h;const t=P.useQueryClient(),{user:s}=R(),{tasks_api:n}=D(),{filters:a}=E(),[r,l]=c.useState(0),[i,x]=c.useState({owner:{user:s.id,config:((h=a==null?void 0:a.owner)==null?void 0:h.config)??"yo_y_mis_equipos"},status:"completadas"}),o=P.useInfiniteQuery({initialPageParam:1,queryKey:["done_tasks",i],queryFn:({pageParam:d})=>se({filters:{...i,status:"completadas",...K(d)},tasks_api:n,page:d}),staleTime:1e3*60*60*24,getNextPageParam:(d,f)=>f.length+1});return c.useEffect(()=>{var d;Object.keys(a).length>0&&x({...a,owner:{user:s.id,config:((d=a==null?void 0:a.owner)==null?void 0:d.config)??"yo_y_mis_equipos"},status:"completadas"})},[a]),c.useEffect(()=>{t.invalidateQueries({queryKey:["done_tasks",i]})},[i]),c.useEffect(()=>{(async()=>{const f=await n.get("/api/listado_tareas",{params:{...i,status:"completadas",...K(1),justCount:!0,tasks_api:n}});l(f.data.total)})()},[o==null?void 0:o.data,i]),{doneTasks:o,total:r}},js=()=>{var a,r;const{doneTasks:t,total:s}=fs(),n=[...((r=(a=t==null?void 0:t.data)==null?void 0:a.pages)==null?void 0:r.flat())??[]];return e.jsx(G,{title:"Completadas",tasks:n,loadNextPage:()=>te(t),isFetching:t==null?void 0:t.isFetching,total:s})};class Y{static toSalesmanUsers(s){return{id:s.id,name:s.nombre}}}const bs=()=>{const{tasks_api:t}=D(),{filters:s}=E(),{user:n}=R();return{getSalesmanAndProjects:async()=>{const[i]=await Promise.all([t.get("/api/obtener-comerciales")]);return{salesmanUsers:i.data.map(Y.toSalesmanUsers)}},getProjects:async()=>{var x;return(await t.get("/api/listado_tareas",{params:{...s,owner:{user:n.id,config:((x=s==null?void 0:s.owner)==null?void 0:x.config)??"yo_y_mis_equipos"},justProjects:!0}})).data.map(Y.toSalesmanUsers)},getSalesmans:async()=>(await t.get("/api/obtener-comerciales")).data.map(Y.toSalesmanUsers)}},ys=[{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 proyecto",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",type:"select",id:"salesman.name",options:[]},{label:"Por dificultad",type:"select",id:"difficulty",options:[{id:0,name:"Muy facil"},{id:1,name:"Facil"},{id:2,name:"Media"},{id:3,name:"Dificil"},{id:4,name:"Muy dificil"}]}],ge=[{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:[]}],ws=()=>{const{defineFields:t}=E(),{getSalesmanAndProjects:s}=bs();return c.useEffect(()=>{(async()=>{let a=[...ys],{salesmanUsers:r}=await s();t(a.map(l=>(l.id==="salesman.name"&&(l.options=r),l)))})()},[]),e.jsxs("div",{className:"flex gap-4 w-full h-full min-h-[100%] relative ",children:[e.jsx(ps,{}),e.jsx(gs,{}),e.jsx(js,{})]})},Ae=c.createContext({}),vs=({children:t})=>{const[s,n]=c.useState([]);c.useEffect(()=>{console.log({selectedTasks:s})},[s]);const a=r=>{n(l=>l.includes(r)?l.filter(i=>i!==r):[...l,r])};return e.jsx(Ae.Provider,{value:{selectedTasks:s,selectTask:a},children:t})},Ns=()=>c.useContext(Ae),Pe=()=>{const t=()=>e.jsxs("div",{className:"w-full flex gap-m",children:[e.jsx("div",{className:"w-[30px] h-[30px] min-w-[30px] min-h-[30px] bg-gray-200 rounded-full animate-pulse"}),e.jsx("div",{className:"w-[30%] h-[30px] bg-gray-200 rounded-md animate-pulse"}),e.jsx("div",{className:"w-[30px] h-[30px] min-w-[30px] min-h-[30px] bg-gray-200 rounded-lg animate-pulse"}),e.jsx("div",{className:"w-[30px] h-[30px] min-w-[30px] min-h-[30px] bg-gray-200 rounded-lg animate-pulse"}),e.jsx("div",{className:"w-[30px] h-[30px] min-w-[30px] min-h-[30px] bg-gray-200 rounded-lg animate-pulse"}),e.jsx("div",{className:"w-[10%] h-[30px] bg-gray-200 rounded-md animate-pulse"}),e.jsx("div",{className:"w-[30px] h-[30px] min-w-[30px] min-h-[30px] bg-gray-200 rounded-lg animate-pulse"}),e.jsx("div",{className:"w-[10%] h-[30px] bg-gray-200 rounded-md animate-pulse"}),e.jsx("div",{className:"w-[30px] h-[30px] min-w-[30px] min-h-[30px] bg-gray-200 rounded-lg animate-pulse"}),e.jsx("div",{className:"w-[30px] h-[30px] min-w-[30px] min-h-[30px] bg-gray-200 rounded-lg animate-pulse"})]});return e.jsxs("div",{className:"flex flex-col gap-m",children:[e.jsx(t,{}),e.jsxs("div",{className:"pl-5 flex flex-col gap-m",children:[e.jsx(t,{}),e.jsx("div",{className:"pl-5",children:e.jsx(t,{})})]}),e.jsx(t,{}),e.jsxs("div",{className:"pl-5 flex flex-col gap-m",children:[e.jsx(t,{}),e.jsx("div",{className:"pl-5",children:e.jsx(t,{})})]})]})},qe=({startDate:t,endDate:s})=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"gap-s bg-gray-100 rounded-md h-[30px] w-fit flex justify-center items-center px-xxxl",children:[e.jsx(w.Icons,{icon:"calendar",size:"xs",strokeWidth:4,color:S.texts.subtext}),e.jsxs("p",{className:"text-sm",children:[" ",he(t)]})]}),e.jsx(w.Icons,{icon:"arrow_right",size:"xs",strokeWidth:4,color:S.texts.DEFAULT}),e.jsxs("div",{className:"gap-s bg-gray-100 rounded-md h-[30px] w-fit flex justify-center items-center px-xxxl",children:[e.jsx(w.Icons,{icon:"calendar",size:"xs",strokeWidth:4,color:S.texts.subtext}),e.jsxs("p",{className:"text-sm",children:[" ",he(s)]})]})]}),Cs=({id:t})=>e.jsx(e.Fragment,{children:e.jsx("button",{onClick:()=>alert("pausar tarea "+t),children:e.jsx(w.Icons,{icon:"pause",size:"xs",strokeWidth:4,color:S.texts.subtext})})}),Ee=({id:t,priority:s})=>e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"gap-s bg-gray-100 rounded-md h-[30px] w-[30px] flex justify-center items-center hover:bg-gray-200",children:e.jsx(w.Icons,{icon:"align_center",size:"xs",strokeWidth:4,color:S.texts.subtext})}),e.jsx("div",{className:"gap-s bg-success-medium border border-success-pastel rounded-md h-[30px] w-[30px] flex justify-center items-center",children:e.jsx(Se,{id:t,priority:s})}),e.jsx("button",{className:"gap-s bg-danger-light border border-danger-regular rounded-md h-[30px] w-[30px] flex justify-center items-center",children:e.jsx(w.Icons,{icon:"difficulty",size:"xs",strokeWidth:4,color:S.danger.regular})})]}),Fs=({id:t})=>{const{selectedTasks:s,selectTask:n}=Ns();return e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"cursor-pointer w-[20px] h-[20px] border-2 border-gray-200 rounded-md flex justify-center items-center",htmlFor:t.toString(),children:e.jsx("span",{className:`${s.includes(t)?"opacity-100":"opacity-0"} transition-opacity duration-500`,children:e.jsx(w.Icons,{icon:"check_outline",size:"xs",color:S.primary.regular,strokeWidth:6})})}),e.jsx("input",{className:"hidden",id:t.toString(),type:"checkbox",onChange:()=>n(t)})]})},De=({task:t})=>e.jsx(w.Tooltip,{dispatch:e.jsx("p",{className:"text-sm text-texts-subtext max-w-[400px] truncate",children:t}),children:e.jsx("p",{className:"text-sm text-texts-subtext p-2 max-w-[400px]",children:t})}),_s=({id:t})=>{var a,r;const{tasksProject:s}=Q(),n=(a=s==null?void 0:s.data)==null?void 0:a.find(l=>l.id===t);return e.jsxs("div",{className:"ml-[30px] mb-3 mt-1 flex flex-wrap items-center gap-xl",children:[!(n!=null&&n.nameRequiredTask)||(n==null?void 0:n.nameRequiredTask)!==""&&(n==null?void 0:n.statusRequiredTask)===2&&e.jsx(Fs,{id:t}),e.jsx(Ce,{id:t,nameRequiredTask:(n==null?void 0:n.nameRequiredTask)??"",status:n==null?void 0:n.status,statusRequiredTask:(n==null?void 0:n.statusRequiredTask)??0},t),(n==null?void 0:n.willBePaused)&&e.jsx(Cs,{id:t}),e.jsx(_e,{onClick:()=>{},responsible:n==null?void 0:n.responsible,users:((r=n==null?void 0:n.users)==null?void 0:r.map(k))??[]}),e.jsx(De,{task:(n==null?void 0:n.task)??""}),e.jsx(Ee,{id:t,priority:n==null?void 0:n.priority}),e.jsx(qe,{startDate:n==null?void 0:n.startDate,endDate:n==null?void 0:n.endDate})]})},Ie=({id:t})=>{var l,i,x,o,h,d,f;const{tasksProject:s,openTasks:n,openTask:a}=Q(),r=(l=s==null?void 0:s.data)==null?void 0:l.find(m=>m.id===t);return r?(console.log({task:r}),e.jsxs("div",{className:"flex flex-col gap-m mb-2 ",children:[e.jsxs("div",{className:"flex items-center gap-m flex-wrap hover:bg-gray-100",children:[e.jsx("button",{className:`${n.includes(t)?"":"-rotate-90"} transition-all duration-300`,onClick:()=>a(t),children:e.jsx(w.Icons,{icon:"angle_down_outline",color:S.texts.subtext})}),e.jsx("div",{className:"flex items-center justify-center min-w-[20px] min-h-[20px] w-fit h-[20px] mx-1 bg-primary-medium rounded-full",children:e.jsx("p",{className:"text-sm text-primary",children:((i=r==null?void 0:r.tasks)==null?void 0:i.length)===0?1:(x=r==null?void 0:r.tasks)==null?void 0:x.length})}),e.jsx(De,{task:(r==null?void 0:r.task)??""}),e.jsx(Ee,{id:t,priority:r==null?void 0:r.priority}),e.jsx(qe,{startDate:r==null?void 0:r.startDate,endDate:r==null?void 0:r.endDate}),e.jsxs("button",{className:"gap-s bg-gray-100 rounded-md h-[30px] flex justify-center items-center w-fit px-m hover:bg-gray-200",children:[e.jsx(w.Icons,{icon:"subtasks",size:"xs",strokeWidth:5,color:S.texts.subtext}),e.jsx("p",{children:((o=r==null?void 0:r.tasks)==null?void 0:o.length)===0?1:(h=r==null?void 0:r.tasks)==null?void 0:h.length})]})]}),n.includes(t)&&e.jsx("div",{className:"ml-[30px]",children:((d=r==null?void 0:r.tasks)==null?void 0:d.length)>0?(f=r==null?void 0:r.tasks)==null?void 0:f.map(m=>e.jsx(Ie,{id:m==null?void 0:m.id})):e.jsx(_s,{id:r==null?void 0:r.id})})]})):null},Ss=()=>{var a;const{tasksProject:t,projectID:s}=Q();if(t!=null&&t.isFetching||t!=null&&t.isLoading)return e.jsx(Pe,{});let n=[...(a=t==null?void 0:t.data)==null?void 0:a.filter(r=>r.isPrincipalTask)];return e.jsx("div",{className:"flex flex-col gap-m",children:e.jsx(vs,{project:s,children:n==null?void 0:n.sort((r,l)=>r.orden-l.orden).map(r=>e.jsx("div",{className:"flex flex-col gap-m border-b border-gray-200 pb-m",children:e.jsx(Ie,{id:r.id})}))})})},Ts=({setPath:t,setProject:s})=>{const[n,a]=c.useState([]),[r,l]=c.useState(!0),[i,x]=c.useState(0),[o,h]=c.useState(10),[d,f]=c.useState(0),[m,u]=c.useState("nombre"),{filters:g,defineFields:j}=E(),{tasks_api:v}=D(),{user:b}=R(),y=async(p,A)=>{var F,q,B;try{l(!0);const $={filters:{search:(g==null?void 0:g.taskName)??"",responsable:{idUser:b.id,responsableType:(F=g==null?void 0:g.responsable)==null?void 0:F.responsableType},ejecutivo:(g==null?void 0:g.ejecutivo)??""}};console.log("FiltrosPARAMS: ",$);const L=await v.get("/api/listado_campanias",{params:{pagination:{page:p,pageSize:A},orderBy:m,...$}}),U=O(L==null?void 0:L.data);a(U),f((B=(q=L==null?void 0:L.data)==null?void 0:q.meta)==null?void 0:B.total)}catch($){console.error("Error fetching data en Lista Campaña:",$)}finally{l(!1)}},C=async()=>{try{const p=await v.get("/api/obtener-comerciales");return[...ge].map(F=>(F.id==="ejecutivo"&&(F.options=p.data.map(q=>({id:q.nombre,name:q.nombre}))),F))}catch(p){return console.error("Error fetching salesman data:",p),[...ge]}};c.useEffect(()=>{(async()=>{const A=await C();j(A)})()},[]),c.useEffect(()=>{const p=Math.floor(i/o)+1;y(p,o)},[i,o,m,g]);const N=p=>{x(p.first),h(p.rows)},T=[{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}],z=p=>{const A=parseInt(p.target.value,10);h(A),N({first:0,rows:A})},I=p=>{u(A=>A===p?`${p}:desc`:p)},M=p=>m===p?"↑↓":m===`${p}:desc`?"↓↑":"↑↓";return e.jsx("div",{className:"table-container",children:r?e.jsx("div",{style:{width:"100%"},children:e.jsx(Pe,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"table",style:{borderCollapse:"collapse",width:"100%",borderSpacing:"0"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{color:"#F5F5F5"},children:[e.jsxs("th",{onClick:()=>I("nombre"),children:[e.jsx("label",{style:{color:"#C4C4C4",fontSize:"10px"},children:M("nombre")}),"Campaña"]}),e.jsx("th",{onClick:()=>I("inicia"),style:{textAlign:"center",whiteSpace:"nowrap"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"fit-content"},children:[e.jsx("label",{style:{color:"#C4C4C4",fontSize:"10px"},children:M("inicia")})," ",e.jsx(w.Icons,{icon:"calendar",size:"xs",strokeWidth:5,color:"#C4C4C4"}),e.jsx("span",{children:"Fecha Inicio"})]})}),e.jsx("th",{onClick:()=>I("termina"),style:{whiteSpace:"nowrap",textAlign:"center"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"fit-content"},children:[e.jsx("label",{style:{color:"#C4C4C4",fontSize:"10px"},children:M("termina")}),e.jsx(w.Icons,{icon:"calendar",size:"xs",strokeWidth:5,color:"#C4C4C4"}),e.jsx("span",{children:"Fecha Fin"})]})}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Responsable"})]})}),e.jsx("tbody",{children:n==null?void 0:n.map((p,A)=>{var F,q,B,$,L,U,ae,ne,re,le,ie,oe,ce,de,xe,ue;return e.jsxs("tr",{className:"table-row",onClick:()=>{s({id:p==null?void 0:p.id,project:p==null?void 0:p.nombre}),t("kanban-campania")},children:[e.jsx("td",{children:(F=p==null?void 0:p.campania)==null?void 0:F.nombre}),e.jsxs("td",{children:[" ",(q=p==null?void 0:p.campania)==null?void 0:q.inicia]}),e.jsx("td",{children:(B=p==null?void 0:p.campania)==null?void 0:B.termina}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",padding:"none",fontSize:"10px",width:"auto",minWidth:"170px"},children:[e.jsxs("label",{style:{width:"50px",minWidth:"50px",textAlign:"right",color:"#000"},children:[p==null?void 0:p.progreso,"%"]}),e.jsx("div",{style:{position:"relative",height:"10px",flex:1,backgroundColor:"#C4C4C4",borderRadius:"10px",overflow:"hidden"},children:e.jsx("div",{style:{position:"absolute",top:0,left:0,height:"100%",width:`${p.progreso}%`,backgroundColor:p.progreso===100?"#039B59":p.progreso>50?"#3658C1":p.progreso>0?"#DC8921":"#C4C4C4",borderRadius:"10px",transition:"width 0.3s ease-in-out"}})})]})}),e.jsx("td",{children:e.jsxs("div",{className:"avatar-container",children:[e.jsxs(_.Avatar,{className:"avatar w-[28px] h-[28px]",children:[e.jsx(_.AvatarImage,{src:`${Te}${(ne=(ae=(U=(L=($=p==null?void 0:p.campania)==null?void 0:$.responsable)==null?void 0:L.imagen)==null?void 0:U.formats)==null?void 0:ae.thumbnail)==null?void 0:ne.url}`,alt:(ie=(le=(re=p==null?void 0:p.campania)==null?void 0:re.responsable)==null?void 0:le.nombre)==null?void 0:ie.charAt(0)}),e.jsx(_.AvatarFallback,{style:{boxShadow:"10px 5px 10px rgba(0, 0, 0, 0.5)"},children:(de=(ce=(oe=p==null?void 0:p.campania)==null?void 0:oe.responsable)==null?void 0:ce.nombre)==null?void 0:de.charAt(0)})]}),e.jsx("span",{style:{marginLeft:"8px",fontSize:"10px"},children:(ue=(xe=p==null?void 0:p.campania)==null?void 0:xe.responsable)==null?void 0:ue.nombre})]})})]},A)})})]}),e.jsxs("div",{className:"pagination",style:{background:"#FAFAFA",display:"flex"},children:[e.jsxs("span",{style:{alignItems:"center",fontSize:"10px",textAlign:"left",width:"auto",height:"auto",whiteSpace:"nowrap"},children:[n.length," elementos de ",d]}),e.jsx(Me.Paginator,{first:i,rows:o,totalRecords:d,rowsPerPageOptions:[5,10,20,50],onPageChange:N,className:"pagination",template:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"10px",whiteSpace:"nowrap"},children:"Filas por página:"}),e.jsx("select",{className:"select",value:o,onChange:p=>z(p),children:T.map(p=>e.jsx("option",{className:"option-select",value:p.value,style:{background:"#F5F5F5"},children:p.label},p.value))})]})]})]})})},As=({path:t,tab:s,setPath:n,project:a,setProject:r})=>{const l={"kanban-general":{kanban:e.jsx(ws,{})},"lista-campanias":{lista:e.jsx(Ts,{setPath:n,setProject:r}),gantt:e.jsx("div",{children:"gantt-campanias"})},"kanban-campania":{kanban:e.jsx(xs,{}),lista:e.jsx(Ss,{}),gantt:e.jsx("div",{children:"kanban-campania-gantt"})}};return t==="kanban-campania"?e.jsx(He,{project:a==null?void 0:a.id,children:l[t][s]}):l[t][s]},Ps=({path:t})=>{const s=()=>{const{selectPath:n,updateFilters:a,applyFilters:r}=E(),[l,i]=c.useState("kanban"),[x,o]=c.useState(t),[h,d]=c.useState({id:1839,project:"Kanban de Campania"}),[f,m]=c.useState(""),u=c.useRef(null);c.useEffect(()=>{i("kanban"),n(x)},[t]),c.useEffect(()=>{(f==null?void 0:f.trim())===""&&a({name:"taskName",value:null}),r()},[f]);const g=y=>({"kanban-general":"Kanban General","lista-campanias":"Campanias","kanban-campania":`Kanban de ${h.project}`})[y],j=y=>{o(y)},v=["lista-campanias","kanban-campania"],b={"lista-campanias":["lista","gantt"],"kanban-campania":["kanban","lista","gantt"]};return e.jsxs("div",{className:"bg-bg-card p-m rounded-lg border border-gray-200 flex flex-col gap-m w-full h-full min-h-[100%] relative overflow-hidden",children:[e.jsxs("div",{className:"w-full justify-between flex items-end border-b border-gray-200 pb-m px-l flex-wrap gap-l",children:[e.jsxs("div",{className:"flex gap-xl",children:[e.jsx("h2",{className:"text-texts font-medium",children:g(x)}),v.includes(x)&&e.jsx(ze,{tabs:b[x],renderItem:y=>{i(y)}})]}),e.jsxs("div",{className:"flex items-center gap-s",children:[e.jsx("input",{onChange:ye(y=>{var C,N,T;a({name:"taskName",value:(N=(C=y==null?void 0:y.target)==null?void 0:C.value)==null?void 0:N.trim()}),m((T=y==null?void 0:y.target)==null?void 0:T.value)},1e3),type:"text",placeholder:"Buscar",className:"w-[200px] h-[30px] border-none bg-bg-card shadow-input border border-gray-200 rounded-lg px-l "}),e.jsx(Be,{filterChildren:u,children:e.jsx("div",{ref:u,className:"w-max max-w-[400px] h-fit bg-bg-card shadow-lg rounded-lg p-l",children:e.jsx(Oe,{})})})]})]}),e.jsx("div",{className:"overflow-auto scrollbar-none",children:e.jsx(As,{path:x,tab:l,setPath:j,project:h,setProject:d})})]})};return e.jsx(Re,{children:e.jsx(s,{})})},qs=()=>e.jsx("div",{className:"w-full h-full min-h-[100%] relative",children:e.jsx("div",{className:"flex justify-center items-center h-full",children:e.jsxs("div",{className:"text-2xl font-bold flex flex-col items-center",children:[e.jsx("div",{className:"w-10 h-10 bg-primary-regular rounded-full animate-pulse"}),e.jsx("p",{className:"text-l text-texts-enfasis",children:"un momento..."}),e.jsx("p",{className:"text-sm text-texts-placeholder",children:"estamos buscando tu usuario"})]})})}),Es=()=>e.jsx("div",{className:"w-full h-full min-h-[100%] relative",children:e.jsx("div",{className:"flex justify-center items-center h-full",children:e.jsxs("div",{className:"text-2xl font-bold flex flex-col items-center",children:[e.jsx("div",{className:"w-10 h-10 bg-primary-regular rounded-full animate-pulse"}),e.jsx("p",{className:"text-l text-texts-enfasis",children:"No encontramos tu acceso"}),e.jsx("p",{className:"text-sm text-texts-placeholder",children:"por favor, contacta al administrador"})]})})}),Ds=({path:t,user:s,url:n})=>{const a=new P.QueryClient;if(!s)return e.jsx(qs,{});if(!s.accessToken)return e.jsx(Es,{});let r={user:s,url:n};return e.jsx(e.Fragment,{children:e.jsx(Ue,{...r,children:e.jsx(Qe,{...r,children:e.jsx("div",{className:"w-full h-full min-h-[100%] relative",children:e.jsxs(P.QueryClientProvider,{client:a,children:[e.jsx(Ps,{path:t})," "]})})})})})};exports.AppTasks=Ds;
|