import{j as s}from"./vendor-query-B2UbickB.js";import{j as b,s as j,p as v,r as P}from"./index-BZu5zewH.js";import{f as C}from"./useEventHooks-CPxcH6zx.js";import{u as $}from"./roles-CQsPYJXe.js";import{u as L}from"./useFilterParams-x-Dg0Vgz.js";import{D as R}from"./DataTable-D9yuBv0w.js";import{P as _}from"./PageHeader-CR6TpJG_.js";import{S as w}from"./StickyPagination-BWhFSr2d.js";import{R as F,a as N}from"./RowActions-Dg-Fsm5O.js";import{a as T,T as k,E as z}from"./escalation-columns-DgY8c1hM.js";import{L as A}from"./ListToolbar-4lObXT3_.js";import{a8 as M}from"./vendor-icons-CrrAvF2g.js";import{c as O}from"./vendor-react-CXumBFUA.js";import"./EmptyState-BcsfPq9T.js";import"./FilterBar-Ck4K4rzu.js";import"./PriorityBadge-DfQY9St9.js";import"./RolePill-BC54Vn-U.js";import"./WorkflowPill-54px0YiY.js";import"./TimestampCell-DGEGdbOW.js";import"./escalation-Bf_SO_75.js";function re(){C();const c=O(),{user:n}=b(),{filters:e,setFilter:d,pagination:t,sort:r,setSort:g}=L({filters:{role:"",type:"",priority:""}}),u=j(),{data:l}=$(),{data:p}=v(),{data:a,isLoading:f,error:i,refetch:y,isFetching:x}=P({assigned_to:n==null?void 0:n.userId,status:"pending",role:e.role||void 0,type:e.type||void 0,priority:e.priority?parseInt(e.priority):void 0,limit:t.pageSize,offset:t.offset,sort_by:r.sort_by||void 0,order:r.sort_by?r.order:void 0}),h=((a==null?void 0:a.escalations)??[]).filter(o=>o.assigned_until&&new Date(o.assigned_until)>new Date),m=(a==null?void 0:a.total)??0,E={key:"actions",label:"",render:o=>s.jsx(F,{children:s.jsx(N,{icon:M,title:"Release escalation",onClick:()=>u.mutate(o.id),colorClass:"text-text-tertiary hover:text-status-warning"})}),className:"w-16 text-right"},S=[k,...z,E];return s.jsxs("div",{children:[s.jsx(_,{title:"My Escalations"}),s.jsx(T,{filters:e,setFilter:d,roles:(l==null?void 0:l.roles)??[],types:(p==null?void 0:p.types)??[],actions:s.jsx(A,{onRefresh:()=>y(),isFetching:x,apiPath:`/escalations?status=claimed&limit=${t.pageSize}&offset=${t.offset}${e.role?`&role=${e.role}`:""}${e.type?`&type=${e.type}`:""}${e.priority?`&priority=${e.priority}`:""}`})}),i&&s.jsx("div",{className:"mb-4 px-4 py-3 rounded-md bg-status-error/10 border border-status-error/20 text-xs text-status-error",children:i.message==="Session expired"?"Your session has expired. Please log in again.":`Failed to load escalations: ${i.message}`}),s.jsx(R,{columns:S,data:h,keyFn:o=>o.id,onRowClick:o=>c(`/escalations/detail/${o.id}`,{state:{from:"/escalations/queue"}}),isLoading:f,emptyMessage:i?"Unable to load data":"No assigned escalations",sort:r,onSort:g}),s.jsx(w,{page:t.page,totalPages:t.totalPages(m),onPageChange:t.setPage,total:m,pageSize:t.pageSize,onPageSizeChange:t.setPageSize})]})}export{re as OperatorDashboard};
//# sourceMappingURL=OperatorDashboard-B_QmNzLw.js.map
