1import{a as _,d as R,j as e}from"./vendor-query-B-_nDQQY.js";import{B as S,v as A,U as p,C as t,d as l,w as m,x as U,a as o,c as h,I as B,h as q,i as D,j as I,k as P,l as x,e as C,b as E}from"./index-D8ww6b7J.js";import{L as O}from"./vendor-react-BUIlT3ms.js";import{T as $}from"./TeamNav-BriM7U0R.js";import{A as T}from"./award-C2Pk5WYF.js";import{F as z}from"./funnel-Dec4yW_G.js";import"./vendor-three-1K-S22da.js";import"./vendor-charts-i-522T5A.js";import"./vendor-pdf-Bwkk3Ew0.js";import"./vendor-radix-X0WMATEu.js";import"./navigation-TAQUAeuu.js";import"./hammer-Burg9xO0.js";function g(c){const i=String(c??"");return i.includes(",")||i.includes('"')||i.includes(` 2`)?`"${i.replace(/"/g,'""')}"`:i}function se(){const[c,i]=_.useState(""),[n,k]=_.useState(null),{data:f=[],isLoading:L}=R({queryKey:["employees"],queryFn:()=>E.entities.Employee.list(),staleTime:6e4}),{data:N=[]}=R({queryKey:["employee-ratings"],queryFn:()=>E.entities.EmployeeRating.list("-rating_date",100),staleTime:6e4}),r=f.filter(s=>s.average_rating>0).filter(s=>!c||s.name.toLowerCase().includes(c.toLowerCase())||(s.role||"").toLowerCase().includes(c.toLowerCase())).filter(s=>n?n===5?s.average_rating>=4.5:n===4?s.average_rating>=4&&s.average_rating<4.5:n===3?s.average_rating>=3&&s.average_rating<4:s.average_rating<3:!0).sort((s,a)=>a.average_rating-s.average_rating),j=f.filter(s=>s.average_rating===0||!s.average_rating),v=[...r].slice(0,3),w=N.filter(s=>s.rating>0).slice(0,10),b=r.length>0?r.reduce((s,a)=>s+(a.average_rating||0),0)/r.length:0,F=()=>{const s=[["Employee Name","Role","Average Rating","Total Ratings","Phone","Email"].join(","),...r.map(d=>[g(d.name),g(d.role||""),d.average_rating.toFixed(1),d.total_ratings||0,g(d.phone||""),g(d.email||"")].join(","))].join(` 3`),a=new Blob([s],{type:"text/csv"}),y=URL.createObjectURL(a),u=document.createElement("a");u.href=y,u.download=`employee-ratings-${new Date().toISOString().split("T")[0]}.csv`,u.click(),URL.revokeObjectURL(y)};return e.jsx("div",{className:"min-h-screen bg-background p-3 sm:p-6",children:e.jsxs("div",{className:"max-w-7xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-playfair font-bold text-foreground tracking-tight",children:"Employee Ratings"}),e.jsx("p",{className:"text-sm text-muted-foreground font-light mt-1",children:"Customer feedback and performance metrics"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(S,{variant:"outline",size:"sm",onClick:F,children:[e.jsx(A,{className:"w-4 h-4 mr-1.5"})," Export"]}),e.jsx(O,{to:"/team",children:e.jsxs(S,{variant:"outline",size:"sm",children:[e.jsx(p,{className:"w-4 h-4 mr-1.5"})," Manage Team"]})})]})]}),e.jsx($,{currentPath:"/employee-ratings"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsx(t,{children:e.jsx(l,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-warning/10 rounded-lg",children:e.jsx(m,{className:"w-5 h-5 text-warning"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:b>0?b.toFixed(1):"â"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Team Average"})]})]})})}),e.jsx(t,{children:e.jsx(l,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-success/10 rounded-lg",children:e.jsx(T,{className:"w-5 h-5 text-success"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:r.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Rated Employees"})]})]})})}),e.jsx(t,{children:e.jsx(l,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-info/10 rounded-lg",children:e.jsx(p,{className:"w-5 h-5 text-info"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:j.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting Reviews"})]})]})})}),e.jsx(t,{children:e.jsx(l,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(U,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:N.filter(s=>s.rating>0).length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Reviews"})]})]})})})]}),v.length>0&&e.jsxs(t,{children:[e.jsx(o,{className:"pb-3",children:e.jsxs(h,{className:"text-base flex items-center gap-2",children:[e.jsx(T,{className:"w-5 h-5 text-warning"}),"Top Performers"]})}),e.jsx(l,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:v.map((s,a)=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted",children:[e.jsxs("div",{className:"flex-shrink-0",children:[a===0&&e.jsx("div",{className:"w-8 h-8 rounded-full bg-warning flex items-center justify-center text-white font-bold",children:"1"}),a===1&&e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted-foreground flex items-center justify-center text-white font-bold",children:"2"}),a===2&&e.jsx("div",{className:"w-8 h-8 rounded-full bg-orange-600 flex items-center justify-center text-white font-bold",children:"3"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold truncate",children:s.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.role||"Employee"})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(m,{className:"w-4 h-4 fill-primary text-primary"}),e.jsx("span",{className:"font-bold",children:s.average_rating.toFixed(1)})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.total_ratings," reviews"]})]})]},s.id))})})]}),e.jsxs(t,{children:[e.jsx(o,{className:"pb-3",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsx(h,{className:"text-base",children:"All Employees"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs("div",{className:"relative",children:[e.jsx(B,{placeholder:"Search employees...",value:c,onChange:s=>i(s.target.value),className:"pl-8 h-9 w-full sm:w-64"}),e.jsx(z,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"})]}),e.jsxs(q,{value:(n==null?void 0:n.toString())||"all",onValueChange:s=>k(s==="all"?null:Number(s)),children:[e.jsx(D,{className:"w-full sm:w-40",children:e.jsx(I,{placeholder:"All Ratings"})}),e.jsxs(P,{children:[e.jsx(x,{value:"all",children:"All Ratings"}),e.jsx(x,{value:"5",children:"5 Stars (4.5+)"}),e.jsx(x,{value:"4",children:"4+ Stars"}),e.jsx(x,{value:"3",children:"3+ Stars"}),e.jsx(x,{value:"2",children:"Below 3 Stars"})]})]})]})]})}),e.jsx(l,{children:L?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[1,2,3,4,5,6].map(s=>e.jsx("div",{className:"h-28 bg-muted rounded-xl animate-pulse"},s))}):r.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(m,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"font-medium",children:"No rated employees yet"}),e.jsx("p",{className:"text-sm",children:"Ratings will appear here after customers submit feedback"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:r.map(s=>e.jsx(t,{className:"hover:shadow-md transition-shadow",children:e.jsxs(l,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold truncate",children:s.name}),s.role&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.role})]}),e.jsxs(C,{variant:s.average_rating>=4.5?"default":"secondary",children:[e.jsx(m,{className:"w-3 h-3 mr-1 fill-current"}),s.average_rating.toFixed(1)]})]}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Reviews"}),e.jsx("span",{className:"font-medium",children:s.total_ratings||0})]}),s.phone&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Phone"}),e.jsx("span",{className:"font-medium truncate max-w-[150px]",children:s.phone})]})]})]})},s.id))})})]}),w.length>0&&e.jsxs(t,{children:[e.jsx(o,{className:"pb-3",children:e.jsx(h,{className:"text-base",children:"Recent
3Customer Feedback"})}),e.jsx(l,{children:e.jsx("div",{className:"space-y-3",children:w.map(s=>e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg border",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(a=>e.jsx(m,{className:`w-4 h-4 ${a<=s.rating?"fill-primary text-primary":"fill-none text-muted-foreground/30"}`},a))})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:s.employee_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Job #",s.job_number," ⢠",new Date(s.rating_date).toLocaleDateString()]}),s.feedback_text&&e.jsxs("p",{className:"text-sm mt-1 italic",children:['"',s.feedback_text,'"']})]})]},s.id))})})]}),j.length>0&&e.jsxs(t,{children:[e.jsx(o,{className:"pb-3",children:e.jsx(h,{className:"text-base text-muted-foreground",children:"Employees Awaiting First Review"})}),e.jsx(l,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:j.slice(0,9).map(s=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-muted flex items-center justify-center",children:e.jsx(p,{className:"w-5 h-5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.role||"Employee"})]}),e.jsx(C,{variant:"outline",className:"text-xs",children:"No reviews"})]},s.id))})})]})]})})}export{se 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.