PageSourceSearch

https://mgw-service-desk.lovable.app/assets/_authenticated.my-tickets-BLVjpGLs.js

js mgw-service-desk.lovable.app collected 2026-10-03 03:34:31 UTC 5,124 bytes, 1 lines download raw bytes

1import{b as w,d as b,g as v,s as d,j as e,L as l,B as f,a2 as k,w as C,z as M,K as g,p as j}from"./index-26Acqbp3.js";import{S as $,P}from"./TicketBadges-mzPxmvDT.js";import{S}from"./SLABadge-B0xk0via.js";import"./badge-CI4bhZeT.js";import"./circle-check-DY642iHD.js";import"./circle-x-_qzBuhM9.js";import"./clock-Bm3U5HaH.js";function z(){const{user:a}=w(),y=b(),{data:N,isLoading:_}=v({queryKey:["my-tickets",a?.id],enabled:!!a,queryFn:async()=>{const{data:t}=await d.from("project_clients").select("id").eq("user_id",a.id),r=(t??[]).map(s=>s.id),{data:i}=await d.from("project_agents").select("id").eq("user_id",a.id),o=(i??[]).map(s=>s.id),n=[`created_by.eq.${a.id}`];r.length>0&&n.push(`client_id.in.(${r.join(",")})`),o.length>0&&n.push(`agent_id.in.(${o.join(",")})`);const{data:x,error:p}=await d.from("tickets").select("id,number,title,priority,created_at,resolved_at,sla_resolution_at,sla_paused_seconds,first_response_at,sla_first_response_at,reopen_count,agent_id,project:projects(code,name),status:ticket_statuses(name,color),client:project_clients(name)").or(n.join(",")).order("created_at",{ascending:!1}).limit(200);if(p)throw p;const u=Array.from(new Set((x??[]).map(s=>s.agent_id).filter(Boolean)));let h=new Map;if(u.length>0){const{data:s}=await d.rpc("get_agent_display_names",{_agent_ids:u});h=new Map((s??[]).map(c=>[c.id,{full_name:c.full_name??null,email:c.email??null}]))}return(x??[]).map(s=>({...s,agent:s.agent_id?h.get(s.agent_id)??null:null}))}}),m=N??[];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-eyebrow",children:"Meus pedidos"}),e.jsx("h1",{className:"text-h1 text-foreground mt-1",children:"Meus chamados"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Chamados que você abriu ou estão atribuídos a você."})]}),e.jsx(l,{to:"/tickets/new",children:e.jsxs(f,{className:"bg-gradient-brand text-brand-foreground hover:opacity-95 shadow-elegant",children:[e.jsx(k,{className:"mr-2 h-4 w-4"})," Novo chamado"]})})]}),e.jsx(C,{className:"shadow-card",children:e.jsx(M,{className:"p-0",children:_?e.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:"Carregando..."}):m.length===0?e.jsxs("div",{className:"py-16 text-center space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhum chamado atribuído a você ainda."}),e.jsx(l,{to:"/tickets",children:e.jsx(f,{variant:"outline",size:"sm",children:"Ver todos os chamados"})})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border bg-muted/40 text-xs uppercase text-muted-foreground",children:[e.jsx("th",{className:"px-4 py-2.5 text-left font-medium w-20",children:"Nº"}),e.jsx("th",{className:"px-4 py-2.5 text-left font-medium",children:"Título"}),e.jsx("th",{className:"px-4 py-2.5 text-left font-medium",children:"Cliente"}),e.jsx("th",{className:"px-4 py-2.5 text-left font-medium",children:"Status"}),e.jsx("th",{className:"px-4 py-2.5 text-left font-medium",children:"Prioridade"}),e.jsx("th",{className:"px-4 py-2.5 text-left font-medium",children:"SLA"}),e.jsx("th",{className:"px-4 py-2.5 text-left font-medium",children:"Prazo SLA"}),e.jsx("th",{className:"px-4 py-2.5 text-left font-medium",children:"Agente"}),e.jsx("th",{className:"px-4 py-2.5 text-left font-medium",children:"Criado em"})]})}),e.jsx("tbody",{className:"divide-y divide-border",children:m.map(t=>{const r=t.agent?.full_name||t.agent?.email||"Não atribuído",i=!t.agent?.full_name&&!t.agent?.email,o=t.project?.code?`${t.project.code}-${t.number??"—"}`:`#${t.number??"—"}`;return e.jsxs("tr",{className:"hover:bg-muted/40 transition-colors cursor-pointer",onClick:()=>y({to:"/tickets/$ticketId",params:{ticketId:t.id}}),children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs text-muted-foreground",children:o}),e.jsx("td",{className:"px-4 py-3 max-w-[280px]",children:e.jsx(l,{to:"/tickets/$ticketId",params:{ticketId:t.id},className:"text-foreground font-medium hover:underline truncate block",onClick:n=>n.stopPropagation(),children:t.title})}),e.jsx("td",{className:"px-4 py-3 text-muted-foreground truncate max-w-[180px]",children:t.client?.name??"—"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx($,{name:t.status?.name,color:t.status?.color})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(P,{priority:t.priority})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(S,{ticket:t})}),e.jsx("td",{className:"px-4 py-3 text-xs text-muted-foreground whitespace-nowrap",children:t.sla_resolution_at?g(new Date(t.sla_resolution_at),"dd/MM/yyyy HH:mm",{locale:j}):"—"}),e.jsx("td",{className:`px-4 py-3 truncate max-w-[160px] ${i?"text-muted-foreground italic":"text-foreground"}`,children:r}),e.jsx("td",{className:"px-4 py-3 text-xs text-muted-foreground whitespace-nowrap",children:g(new Date(t.created_at),"dd/MM/yyyy HH:mm",{locale:j})})]},t.id)})})]})})})})]})}export{z as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.