1import{r as u,M as W,s as I,j as e,N as G,O as J,Q as Y,V as Z,H as R,t as o,W as ee,h as w,m as y,i as L,k,B as b,X as te,d as A}from"./index-DLd_kDlx.js";import{S as se}from"./SuperAdminLayout-BsUvQU2j.js";import{T as ae,a as re,b as E,c as f,d as ne,e as j}from"./table-BOJIo-OD.js";import{S as O,a as U,b as P,c as V,d as S}from"./select-RSrodAEw.js";import{P as H,a as X,b as q}from"./popover-BMD5FOmU.js";import{C as B}from"./calendar-CX7fcgXP.js";import{S as le}from"./scroll-area-BXTuUF24.js";import{S as N}from"./star-BH1OFEcs.js";import{M as ie}from"./message-square-CtxeCfRz.js";import{f as _}from"./format-BTXglRCX.js";import{F as de}from"./filter-BMeMiGQo.js";import{E as ce}from"./eye-CRDofLPH.js";import"./NotificationIcon-C1wwYnH5.js";import"./NotificationItem-Dc2WXW-y.js";import"./formatDistanceToNow-57P64IbE.js";import"./en-US-9SRVm7yB.js";import"./differenceInCalendarMonths-BA0TPVs2.js";import"./endOfDay-DkR3ZXc8.js";import"./endOfMonth-CYn6pTOm.js";import"./trophy-DBX-jNOC.js";import"./triangle-alert-Chqk_WK7.js";import"./dropdown-menu-DSd1c3Vk.js";import"./index-Deh-4PO1.js";import"./index-lTaZyIGy.js";import"./chevron-right-CD1gvy-q.js";import"./crown-hzm_bRIt.js";import"./user-check-DxoAQXwU.js";import"./globe-C057RQ73.js";import"./timer-CZhDpZys.js";import"./briefcase-business-CphIeAJd.js";import"./key-round-B79BulHq.js";import"./search-DFH5eAlA.js";import"./index-BdQq_4o_.js";import"./chevron-down-DpJJsCer.js";import"./chevron-up-M4SAwIjf.js";import"./endOfWeek-6cC00CtY.js";import"./subDays-B5afKHU7.js";import"./isAfter-DDRF2ylA.js";import"./chevron-left-Wewsh5d7.js";function oe(){const[a,g]=u.useState({techLeadId:null,podId:null,dateFrom:null,dateTo:null}),{data:m,isLoading:i}=W({queryKey:["super-admin-tech-lead-ratings"],queryFn:async()=>{const{data:r,error:s}=await I.from("tech_lead_ratings").select(` 2 id, 3 rating, 4 feedback, 5 created_at, 6 sprint_id, 7 pod_id, 8 tech_lead_id, 9 xtern_user_id, 10 sprints!inner ( 11 id, 12 name, 13 sprint_number, 14 status, 15 updated_at 16 ), 17 pods!inner ( 18 id, 19 pod_name 20 ), 21 tech_leads!inner ( 22 id, 23 full_name 24 ) 25 `).order("created_at",{ascending:!1});if(s)throw s;if(!(r!=null&&r.length))return{ratings:[],xternMap:{}};const l=[...new Set(r.map(p=>p.xtern_user_id))],{data:c}=await I.from("xterns_profiles").select("user_id, full_name").in("user_id",l),x={};return c==null||c.forEach(p=>{x[p.user_id]=p.full_name||"Unknown Xtern"}),{ratings:r,xternMap:x}}}),n=u.useMemo(()=>m!=null&&m.ratings?m.ratings.filter(r=>{var s;return((s=r.sprints)==null?void 0:s.status)==="completed"}):[],[m]),h=u.useMemo(()=>n.filter(r=>{if(a.techLeadId&&r.tech_lead_id!==a.techLeadId||a.podId&&r.pod_id!==a.podId||a.dateFrom&&new Date(r.created_at)<a.dateFrom)return!1;if(a.dateTo){const s=new Date(r.created_at),l=new Date(a.dateTo);if(l.setHours(23,59,59,999),s>l)return!1}return!0}),[n,a]),T=u.useMemo(()=>{const r={};return h.forEach(s=>{r[s.sprint_id]||(r[s.sprint_id]=[]),r[s.sprint_id].push(s)}),Object.entries(r).map(([s,l])=>{var p,t,d,F,D;const c=l[0],x=l.reduce(($,K)=>$+K.rating,0)/l.length;return{sprintId:s,sprintName:((p=c.sprints)==null?void 0:p.name)||"Unknown Sprint",sprintNumber:((t=c.sprints)==null?void 0:t.sprint_number)||0,podId:c.pod_id,podName:((d=c.pods)==null?void 0:d.pod_name)||"Unknown Pod",techLeadId:c.tech_lead_id,techLeadName:((F=c.tech_leads)==null?void 0:F.full_name)||"Unknown",averageRating:x,ratingCount:l.length,sprintEndDate:((D=c.sprints)==null?void 0:D.updated_at)||c.created_at}}).sort((s,l)=>new Date(l.sprintEndDate).getTime()-new Date(s.sprintEndDate).getTime())},[h]),v=r=>m?h.filter(s=>s.sprint_id===r).map(s=>({id:s.id,sprintId:s.sprint_id,xternUserId:s.xtern_user_id,xternName:m.xternMap[s.xtern_user_id]||"Unknown Xtern",rating:s.rating,feedback:s.feedback,createdAt:s.created_at})):[],M=u.useMemo(()=>{const r=new Map;return n.forEach(s=>{var l;(l=s.tech_leads)!=null&&l.full_name&&r.set(s.tech_lead_id,s.tech_leads.full_name)}),Array.from(r.entries()).map(([s,l])=>({id:s,name:l}))},[n]),C=u.useMemo(()=>{const r=new Map;
25return n.forEach(s=>{var l;(l=s.pods)!=null&&l.pod_name&&r.set(s.pod_id,s.pods.pod_name)}),Array.from(r.entries()).map(([s,l])=>({id:s,name:l}))},[n]);return{sprintSummaries:T,getSprintRatings:v,isLoading:i,filters:a,setFilters:g,techLeadOptions:M,podOptions:C}}const z=a=>a>=4.5?"text-green-600":a>=4?"text-green-500":a>=3.5?"text-yellow-500":a>=3?"text-orange-500":"text-red-500";function me({sprint:a,ratings:g,open:m,onOpenChange:i}){return a?e.jsx(G,{open:m,onOpenChange:i,children:e.jsxs(J,{className:"max-w-2xl max-h-[80vh]",children:[e.jsxs(Y,{children:[e.jsxs(Z,{className:"flex items-center gap-2",children:[e.jsx(N,{className:"h-5 w-5 text-yellow-500"}),a.sprintName]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-muted-foreground pt-1",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(R,{className:"h-4 w-4"}),_(new Date(a.sprintEndDate),"MMM d, yyyy")]}),e.jsx("span",{children:"â¢"}),e.jsx("span",{children:a.podName}),e.jsx("span",{children:"â¢"}),e.jsxs("span",{children:["Tech Lead: ",a.techLeadName]}),e.jsx("span",{children:"â¢"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"flex",children:[1,2,3,4,5].map(n=>e.jsx(N,{className:o("h-4 w-4",n<=Math.round(a.averageRating)?"fill-yellow-400 text-yellow-400":"fill-transparent text-muted-foreground/30")},n))}),e.jsx("span",{className:o("font-medium",z(a.averageRating)),children:a.averageRating.toFixed(1)}),e.jsxs("span",{className:"text-muted-foreground",children:["(",a.ratingCount," ",a.ratingCount===1?"review":"reviews",")"]})]})]})]}),e.jsx(le,{className:"max-h-[50vh] pr-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Individual Ratings"}),g.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(N,{className:"h-10 w-10 mx-auto mb-2 opacity-40"}),e.jsx("p",{children:"No ratings for this sprint"})]}):e.jsx("div",{className:"space-y-3",children:g.map(n=>e.jsxs("div",{className:"border rounded-lg p-4 bg-muted/30",children:[e.jsx("div",{className:"flex items-start justify-between gap-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(ee,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:n.xternName}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("div",{className:"flex",children:[1,2,3,4,5].map(h=>e.jsx(N,{className:o("h-4 w-4",h<=n.rating?"fill-yellow-400 text-yellow-400":"fill-transparent text-muted-foreground/30")},h))}),e.jsx("span",{className:o("font-medium text-sm",z(n.rating)),children:n.rating.toFixed(1)})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:_(new Date(n.createdAt),"MMM d, yyyy")})]})]})}),n.feedback?e.jsx("div",{className:"mt-3 pl-11",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ie,{className:"h-4 w-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsx("p",{className:"text-sm",children:n.feedback})]})}):e.jsx("p",{className:"mt-3 pl-11 text-sm text-muted-foreground italic",children:"No written feedback"})]},n.id))})]})})]})}):null}const Q=a=>a>=4.5?"text-green-600":a>=4?"text-green-500":a>=3.5?"text-yellow-500":a>=3?"text-orange-500":"text-red-500",Je=()=>{const{sprintSummaries:a,getSprintRatings:g,isLoading:m,filters:i,setFilters:n,techLeadOptions:h,podOptions:T}=oe(),[v,M]=u.useState(null),[C,r]=u.useState(!1),s=t=>{M(t),r(!0)},l=()=>{n({techLeadId:null,podId:null,dateFrom:null,dateTo:null})},c=i.techLeadId||i.podId||i.dateFrom||i.dateTo,x=a.length>0?a.reduce((t,d)=>t+d.averageRating,0)/a.length:0,p=a.reduce((t,d)=>t+d.ratingCount,0);return e.jsx(se,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Tech Lead Ratings"}),e.jsx("p",{className:"text-muted-foreground",children:"View all te
25ch lead ratings from completed sprints across pods"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(w,{children:e.jsxs(y,{className:"pt-6",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:"Total Sprints Rated"}),e.jsx("div",{className:"text-2xl font-bold",children:a.length})]})}),e.jsx(w,{children:e.jsxs(y,{className:"pt-6",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:"Total Reviews"}),e.jsx("div",{className:"text-2xl font-bold",children:p})]})}),e.jsx(w,{children:e.jsxs(y,{className:"pt-6",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:"Overall Avg Rating"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:o("text-2xl font-bold",Q(x)),children:x>0?x.toFixed(1):"â"}),x>0&&e.jsx("div",{className:"flex",children:[1,2,3,4,5].map(t=>e.jsx(N,{className:o("h-4 w-4",t<=Math.round(x)?"fill-yellow-400 text-yellow-400":"fill-transparent text-muted-foreground/30")},t))})]})]})})]}),e.jsxs(w,{children:[e.jsx(L,{className:"pb-3",children:e.jsxs(k,{className:"text-base flex items-center gap-2",children:[e.jsx(de,{className:"h-4 w-4"}),"Filters",c&&e.jsxs(b,{variant:"ghost",size:"sm",onClick:l,className:"ml-2 h-6 px-2 text-xs",children:[e.jsx(te,{className:"h-3 w-3 mr-1"}),"Clear"]})]})}),e.jsx(y,{children:e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs(O,{value:i.techLeadId||"all",onValueChange:t=>n(d=>({...d,techLeadId:t==="all"?null:t})),children:[e.jsx(U,{className:"w-[200px]",children:e.jsx(P,{placeholder:"All Tech Leads"})}),e.jsxs(V,{children:[e.jsx(S,{value:"all",children:"All Tech Leads"}),h.map(t=>e.jsx(S,{value:t.id,children:t.name},t.id))]})]}),e.jsxs(O,{value:i.podId||"all",onValueChange:t=>n(d=>({...d,podId:t==="all"?null:t})),children:[e.jsx(U,{className:"w-[200px]",children:e.jsx(P,{placeholder:"All Pods"})}),e.jsxs(V,{children:[e.jsx(S,{value:"all",children:"All Pods"}),T.map(t=>e.jsx(S,{value:t.id,children:t.name},t.id))]})]}
25),e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsxs(b,{variant:"outline",className:o("w-[160px] justify-start text-left font-normal",!i.dateFrom&&"text-muted-foreground"),children:[e.jsx(R,{className:"mr-2 h-4 w-4"}),i.dateFrom?_(i.dateFrom,"MMM d, yyyy"):"From date"]})}),e.jsx(q,{className:"w-auto p-0",align:"start",children:e.jsx(B,{mode:"single",selected:i.dateFrom||void 0,onSelect:t=>n(d=>({...d,dateFrom:t||null})),initialFocus:!0,className:o("p-3 pointer-events-auto")})})]}),e.jsxs(H,{children:[e.jsx(X,{asChild:!0,children:e.jsxs(b,{variant:"outline",className:o("w-[160px] justify-start text-left font-normal",!i.dateTo&&"text-muted-foreground"),children:[e.jsx(R,{className:"mr-2 h-4 w-4"}),i.dateTo?_(i.dateTo,"MMM d, yyyy"):"To date"]})}),e.jsx(q,{className:"w-auto p-0",align:"start",children:e.jsx(B,{mode:"single",selected:i.dateTo||void 0,onSelect:t=>n(d=>({...d,dateTo:t||null})),initialFocus:!0,className:o("p-3 pointer-events-auto")})})]})]})})]}),e.jsxs(w,{children:[e.jsx(L,{children:e.jsxs(k,{className:"text-lg flex items-center gap-2",children:[e.jsx(A,{className:"h-5 w-5 text-primary"}),"Sprint Ratings"]})}),e.jsx(y,{children:m?e.jsx("div",{className:"animate-pulse space-y-3",children:[1,2,3].map(t=>e.jsx("div",{className:"h-12 bg-muted rounded"},t))}):a.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(A,{className:"h-12 w-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No ratings found"}),e.jsx("p",{className:"text-sm",children:"Ratings will appear here after Xterns submit feedback on completed sprints"})]}):e.jsxs(ae,{children:[e.jsx(re,{children:e.jsxs(E,{children:[e.jsx(f,{children:"Sprint"}),e.jsx(f,{children:"Pod"}),e.jsx(f,{children:"Tech Lead"}),e.jsx(f,{className:"text-center",children:"Rating"}),e.jsx(f,{className:"text-center",children:"Reviews"}),e.jsx(f,{className:"text-right",children:"Completed"}),e.jsx(f,{className:"text-right",children:"Actions"})]})}),e.jsx(ne,{children:a.map(t=>e.jsxs(E,{children:[e.jsx(j,{className:"font-medium",children:t.sprintName}),e.jsx(j,{className:"text-muted-foreground",children:t.podName}),e.jsx(j,{children:t.techLeadName}),e.jsx(j,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx("div",{className:"flex",children:[1,2,3,4,5].map(d=>e.jsx(N,{className:o("h-4 w-4",d<=Math.round(t.averageRating)?"fill-yellow-400 text-yellow-400":"fill-transparent text-muted-foreground/30")},d))}),e.jsx("span",{className:o("font-medium ml-1",Q(t.averageRating)),children:t.averageRating.toFixed(1)})]})}),e.jsx(j,{className:"text-center text-muted-foreground",children:t.ratingCount}),e.jsx(j,{className:"text-right text-muted-foreground",children:_(new Date(t.sprintEndDate),"MMM d, yyyy")}),e.jsx(j,{className:"text-right",children:e.jsxs(b,{variant:"ghost",size:"sm",onClick:()=>s(t),className:"gap-1",children:[e.jsx(ce,{className:"h-4 w-4"}),"View"]})})]},t.sprintId))})]})})]}),e.jsx(me,{sprint:v,ratings:v?g(v.sprintId):[],open:C,onOpenChange:r})]})})};export{Je as default};
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.