PageSourceSearch

https://msastroacademy.com/assets/leaderboard-DPiKzO-D.js

js msastroacademy.com collected 2026-10-02 01:36:38 UTC 5,441 bytes, 1 lines download raw bytes

1import{r as l,j as e}from"./react-vendor-DDlTsOEd.js";import{g as C,b as L,d as m,S,B as E,v as G}from"./index-BBAL-XO_.js";const z=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],I=C("globe",z),$=["🥇","🥈","🥉"];function M({entry:a,isMe:n,isTop3:r}){const o=a.rank,c=a.name||a.email,i="enrolledCourses"in a;return e.jsxs("div",{className:`flex items-center gap-4 p-3 rounded-xl border transition-colors ${n?"bg-blue-50 border-blue-200":r?"bg-amber-50 border-amber-100":"bg-gray-50 border-gray-100 hover:border-gray-200"}`,children:[e.jsx("div",{className:"w-8 text-center text-lg font-bold shrink-0",children:r?$[o-1]:e.jsxs("span",{className:"text-sm text-gray-900",children:["#",o]})}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-blue-500 to-purple-600 flex items-center justify-center font-bold text-white text-sm shrink-0",children:c[0].toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-semibold text-gray-900 truncate",children:[c,n&&e.jsx("span",{className:"text-blue-500 text-xs ml-1.5 font-normal",children:"(You)"})]}),e.jsx("div",{className:"flex gap-3 text-xs text-gray-900",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:[a.enrolledCourses," courses"]}),e.jsxs("span",{children:[a.completedLessons," lessons"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:[a.lessonsCompleted," lessons"]}),e.jsxs("span",{children:[a.quizzesPassed," quizzes passed"]})]})})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("p",{className:`text-lg font-bold ${r?"text-amber-700":"text-gray-900"}`,children:a.totalScore}),e.jsx("p",{className:"text-xs text-gray-900",children:"points"})]})]})}function R(){const[a,n]=l.useState("global"),[r,o]=l.useState([]),[c,i]=l.useState({}),[b,f]=l.useState([]),[N,y]=l.useState(!0),[v,h]=l.useState(!1),{user:g}=L();l.useEffect(()=>{m.get("/evaluation/global/leaderboard").then(s=>o(s.data??[])).catch(()=>{m.get("/leaderboard").then(s=>o(s.data??[])).catch(()=>o([]))}).finally(()=>y(!1)),m.get("/enrollments").then(s=>f(s.data??[])).catch(()=>{})},[]),l.useEffect(()=>{if(a==="global")return;const s=a;c[s]||(h(!0),m.get(`/evaluation/course/${s}/leaderboard`).then(d=>i(u=>({...u,[s]:d.data??[]}))).catch(()=>i(d=>({...d,[s]:[]}))).finally(()=>h(!1)))},[a]);const x=a==="global",p=x?r:c[a]??[],w=x?N:v,t=r.find(s=>s.email===g?.email),k=x&&t&&t.rank>3,j=s=>`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition-colors whitespace-nowrap ${a===s?"bg-blue-600 text-white":"bg-gray-100 text-gray-900 hover:bg-gray-200"}`;return e.jsxs(S,{title:"Leaderboard",subtitle:"Top explorers of the cosmos",backHref:"/dashboard",backLabel:"Dashboard",children:[e.jsxs("div",{className:"flex gap-2 flex-wrap mb-4",children:[e.jsxs("button",{className:j("global"),onClick:()=>n("global"),children:[e.jsx(I,{size:12})," Global"]}),b.map(s=>e.jsxs("button",{className:j(s.courseId),onClick:()=>n(s.courseId),children:[e.jsx(E,{size:12}),e.jsx("span",{className:"max-w-[120px] truncate",children:s.course.title})]},s.courseId))]}),k&&t&&e.jsx("div",{className:"bg-blue-50 border border-blue-100 rounded-2xl p-4 mb-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-2xl font-bold text-blue-600",children:["#",t.rank]}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-blue-500 to-purple-600 flex items-center justify-center font-bold text-white text-sm",children:(t.name||t.email)[0].toUpperCase()}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-gray-900",children:[t.name||t.email," ",e.jsx("span",{className:"text-gray-900",children:"(You)"})]}),e.jsxs("p",{className:"text-xs text-gray-900",children:[t.enrolledCourses," courses · ",t.completedLessons," lessons"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-xl font-bold text-amber-700",children:t.totalScore}),e.jsx("p",{className:"text-xs text-gray-900",children:"points"})]})]})}),e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(G,{size:18,className:"text-amber-500"}),e.jsx("h2",{className:"font-bold text-gray-900",children:x?"Global Top Students":`${b.find(s=>
1s.courseId===a)?.course.title??"Course"} Leaderboard`})]}),w?e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex items-center gap-4 animate-pulse",children:[e.jsx("div",{className:"w-8 h-8 bg-gray-100 rounded-full"}),e.jsx("div",{className:"w-10 h-10 bg-gray-100 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"h-4 bg-gray-100 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-gray-100 rounded w-1/4"})]}),e.jsx("div",{className:"h-6 w-16 bg-gray-100 rounded"})]},s))}):p.length===0?e.jsxs("div",{className:"text-center py-10 text-gray-900",children:[e.jsx("p",{className:"text-4xl mb-3",children:"🌟"}),e.jsx("p",{className:"text-gray-900 font-medium",children:"No data yet — be the first!"})]}):e.jsx("div",{className:"space-y-2",children:p.map(s=>{const d=s.email===g?.email,u=s.rank<=3;return e.jsx(M,{entry:s,isMe:d,isTop3:u},s.userId)})})]})]})}export{R 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.