PageSourceSearch

https://elitevolleyball.training/assets/league-hub-Ci0Titbm.js

js elitevolleyball.training collected 2026-10-02 02:12:19 UTC 18,809 bytes, 1 lines download raw bytes

1import{c5 as oe,r as b,az as me,u as he,d as F,e as ue,j as e,S,H as I,B as n,bm as P,T as u,dk as pe,f,g as y,h as w,x as l,i as v,ag as je,a0 as O,ah as ge,M as Ne,Z as B,X as be,p as G,q as H,s as q,t as z,v as D,D as fe,m as ye,n as we,o as ve,aw as ke,L as _,bf as Ae,as as Se,a4 as Te,ax as Ce,a8 as Ee,O as Ie,Q as Pe,aA as W}from"./index-CBYMo-oK.js";import{S as De}from"./SectionErrorState-z53iIBVZ.js";import{M as K}from"./medal-CGgKEPM_.js";import{C as V}from"./crown-PI_d5iFy.js";function Le({leaderboard:T,league:r}){const x=[...T].sort((h,k)=>h.rank-k.rank).slice(0,3);if(x.length<3)return null;const[a,o,m]=x;return e.jsxs(f,{className:"mb-6","data-testid":"podium-card",children:[e.jsxs(y,{children:[e.jsxs(w,{className:"flex items-center justify-center gap-2",children:[e.jsx(V,{className:"w-6 h-6 text-yellow-500"}),r.status==="COMPLETED"?"Final Standings":"Current Leaders",e.jsx(V,{className:"w-6 h-6 text-yellow-500"})]}),r.status==="COMPLETED"&&r.completedAt&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["League completed ",new Date(r.completedAt).toLocaleDateString()]})]}),e.jsx(v,{children:e.jsxs("div",{className:"flex items-end justify-center gap-2 sm:gap-4","data-testid":"podium-display",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(K,{className:"w-8 sm:w-10 h-8 sm:h-10 text-gray-400 mb-2"}),e.jsxs("div",{className:"bg-gray-200 dark:bg-gray-700 rounded-t-lg p-2 sm:p-4 w-20 sm:w-28 h-28 sm:h-32 flex flex-col items-center justify-end",children:[e.jsxs(l,{variant:"outline",className:"mb-1 text-xs",children:["#",o.playerNumber]}),e.jsx("span",{className:"text-xs sm:text-sm font-medium text-center truncate max-w-full",children:o.playerName||`Athlete ${o.playerNumber}`}),e.jsxs("span",{className:"text-sm sm:text-lg font-bold text-gray-500",children:[o.totalPoints," pts"]})]}),e.jsx("div",{className:"bg-gray-300 dark:bg-gray-600 w-20 sm:w-28 text-center py-2 font-bold text-lg sm:text-xl",children:"2nd"})]}),e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(u,{className:"w-10 sm:w-12 h-10 sm:h-12 text-yellow-500 mb-2"}),e.jsxs("div",{className:"bg-yellow-100 dark:bg-yellow-900/40 rounded-t-lg p-2 sm:p-4 w-24 sm:w-32 h-36 sm:h-40 flex flex-col items-center justify-end border-2 border-yellow-400",children:[e.jsxs(l,{variant:"outline",className:"mb-1 border-yellow-500 text-xs",children:["#",a.playerNumber]}),e.jsx("span",{className:"text-xs sm:text-sm font-semibold text-center truncate max-w-full",children:a.playerName||`Athlete ${a.playerNumber}`}),e.jsxs("span",{className:"text-lg sm:text-xl font-bold text-yellow-600 dark:text-yellow-400",children:[a.totalPoints," pts"]})]}),e.jsx("div",{className:"bg-yellow-400 dark:bg-yellow-600 w-24 sm:w-32 text-center py-2 font-bold text-xl sm:text-2xl",children:"1st"})]}),e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(W,{className:"w-8 sm:w-10 h-8 sm:h-10 text-amber-600 mb-2"}),e.jsxs("div",{className:"bg-amber-100 dark:bg-amber-900/30 rounded-t-lg p-2 sm:p-4 w-20 sm:w-28 h-20 sm:h-24 flex flex-col items-center justify-end",children:[e.jsxs(l,{variant:"outline",className:"mb-1 text-xs",children:["#",m.playerNumber]}),e.jsx("span",{className:"text-xs sm:text-sm font-medium text-center truncate max-w-full",children:m.playerName||`Athlete ${m.playerNumber}`}),e.jsxs("span",{className:"text-sm sm:text-lg font-bold text-amber-600",children:[m.totalPoints," pts"]})]}),e.jsx("div",{className:"bg-amber-200 dark:bg-amber-700 w-20 sm:w-28 text-center py-2 font-bold text-lg sm:text-xl",children:"3rd"})]})]})})]})}function Oe(){const[,T]=oe("/league/:leagueId"),r=T?.leagueId,x=new URLSearchParams(window.location.search).get("personId"),[a,o]=b.useState("all"),[m,h]=b.useState(!1),[k,L]=b.useState(null),[A,C]=b.useState(""),[R,E]=b.useState(""),{getAcademyUrl:Y,isAcademy:Q,isLeague:X}=me(),Z=Q&&!X?"/league":"",{toast:$}=he(),{data:p,isLoading:M,error:J,refetch:ee,isFetching:se}=F({queryKey:["/api/leagues",r,"athlete-hub",x?`personId=${x}`:""],queryFn:async()=>{const s=x?`/api/leagues/${r}/athlete-hub?personId=${x}`:`/api/leagues/${r}/athlete-hub`,d=await fetch(s);if(!d.ok)throw new Error("Failed to fetch athlete hub data");return d.json()},enabled:!!r}),{data:te,isLoading:ae}=F({queryKey:["/api/sessions",a,"leaderboard"],queryFn:async()=>{const s=await fetch(`/api/sessions/${a}/leaderboard`);if(!s.ok)throw new Error("Failed to fetch session leaderboard");return s.json()},enabled:a!=="all"&&a!==""}),j=p?.league,g=p?.sessions||[],t=p?.myPlayer,i=p?.myRsvps||{},N=a==="all"?p?.leaderboard||[]:te||[],le=a==="all"?M:ae,re=g.find(s=>
1!s.lockedAt),c=ue({mutationFn:async({sessionId:s,status:d,absenceReason:ce,absenceNotes:xe})=>Pe("POST",`/api/sessions/${s}/rsvps`,{playerId:t?.playerId,status:d,absenceReason:ce,absenceNotes:xe}),onSuccess:()=>{Ie.invalidateQueries({queryKey:["/api/leagues",r,"athlete-hub"]}),$({title:"RSVP Updated"}),h(!1),L(null),C(""),E("")},onError:s=>{$({title:"Error",description:s.message,variant:"destructive"})}}),ne=s=>{switch(s){case 1:return e.jsx(u,{className:"w-5 h-5 text-yellow-500"});case 2:return e.jsx(K,{className:"w-5 h-5 text-gray-400"});case 3:return e.jsx(W,{className:"w-5 h-5 text-amber-600"});default:return null}},de=(s,d)=>{if(t&&t.playerId===d)return"bg-primary/10 dark:bg-primary/20 font-medium";switch(s){case 1:return"bg-yellow-500/10 dark:bg-yellow-500/20";case 2:return"bg-gray-300/20 dark:bg-gray-500/20";case 3:return"bg-amber-600/10 dark:bg-amber-600/20";default:return""}},ie=s=>{switch(s){case"ACTIVE":return e.jsx(l,{variant:"default","data-testid":"badge-league-status",children:"Active"});case"COMPLETED":return e.jsx(l,{variant:"secondary","data-testid":"badge-league-status",children:"Completed"});case"ARCHIVED":return e.jsx(l,{variant:"outline","data-testid":"badge-league-status",children:"Archived"});default:return null}};return M?e.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-4xl",children:[e.jsx(S,{className:"h-8 w-48 mb-6"}),e.jsx(S,{className:"h-32 w-full mb-6"}),e.jsx(S,{className:"h-64 w-full mb-6"}),e.jsx(S,{className:"h-96 w-full"})]}):J?e.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-2xl space-y-4",children:[e.jsx(De,{testId:"league-hub-error",title:"Couldn't load this league",onRetry:()=>ee(),isRetrying:se}),e.jsx(I,{href:"/community",children:e.jsxs(n,{variant:"outline","data-testid":"button-back-community",children:[e.jsx(P,{className:"mr-2 h-4 w-4"}),"Back to Community"]})})]}):j?e.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-4xl",children:[e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3","data-testid":"league-header",children:[e.jsx(n,{variant:"ghost",size:"icon",onClick:()=>window.history.back(),"data-testid":"button-back",children:e.jsx(P,{className:"h-5 w-5"})}),e.jsx("div",{children:e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold","data-testid":"text-league-name",children:j.name})}),ie(j.status)]}),e.jsx("a",{href:Y("/"),"data-testid":"link-back-academy",children:e.jsxs(n,{variant:"outline",size:"sm",children:[e.jsx(pe,{className:"h-4 w-4 mr-2"}),"Academy Home"]})})]}),t&&e.jsxs(f,{"data-testid":"my-stats-card",className:t.rank>0&&t.rank<=3?"border-green-500/30":"",children:[e.jsx(y,{className:"pb-3",children:e.jsxs(w,{className:"text-lg flex items-center gap-2",children:[e.jsx(u,{className:"w-5 h-5"}),"My Stats",e.jsxs(l,{variant:"outline",className:"text-xs",children:["#",t.playerNumber]})]})}),e.jsx(v,{children:e.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[e.jsxs("div",{className:"text-center p-3 rounded-md bg-muted/50","data-testid":"stat-rank",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Rank"}),e.jsx("p",{className:`font-bold text-xl ${t.rank>0&&t.rank<=3?"text-green-600 dark:text-green-400":""}`,children:t.rank>0?`#${t.rank}`:"—"})]}),e.jsxs("div",{className:"text-center p-3 rounded-md bg-muted/50","data-testid":"stat-points",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Points"}),e.jsx("p",{className:"font-bold text-xl",children:t.totalPoints})]}),e.jsxs("div",{className:"text-center p-3 rounded-md bg-muted/50","data-testid":"stat-record",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Record"}),e.jsxs("p",{className:"font-bold text-xl",children:[t.wins,"-",t.ties,"-",t.losses]})]}),e.jsxs("div",{className:"text-center p-3 rounded-md bg-muted/50","data-testid":"stat-games",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Games"}),e.jsx("p",{className:"font-bold text-xl",children:t.gamesPlayed})]})]})})]}),g.length>0&&e.jsxs(f,{"data-testid":"schedule-card",children:[e.jsx(y,{children:e.jsxs(w,{className:"flex items-center gap-2",children:[e.jsx(je,{className:"w-5 h-5"}),"Schedule"]})}),e.jsx(v,{children:e.jsx("div",{className:"space-y-2",children:g.map(s=>{const d=re?.id===s.id;return e.jsxs("div",{className:`flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4 p-3 rounded-md border ${d?"border-primary/30 bg-primary/5":s.lockedAt?"border-transparent bg-muted/30":""}`,"data-testid":`schedule-session-${s.id}`,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-20",children:[e.jsxs("span",{className:"font-medium text-sm",children:["Day ",s.sessionNumber]}),d&&e.jsx(l,{variant:"default",className:"text-xs","data-testid":"badge-next-session",children:"Next"}),s.lockedAt&&e.jsx(O,{className:"w-4 h-4 text-green-600 dark:text-green-400","data-testid":`check-completed-${s.id}`})]}),s.sessionDate&&e.jsx("span",{className:"text-sm text-muted-foreground","data-testid":`session-date-${s.id}`,children:ge(new Date(s.sessionDate),"EEEE, MMMM d, yyyy")}),s.location&&e.jsxs("span",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(Ne,{className:"w-3 h-3"}),s.location]}),t&&!s.lockedAt&&e.jsxs("div",{className:"flex items-center gap-2 sm:ml-auto",children:[i[s.id]?.status&&e.jsx(l,{variant:i[s.id].status==="ATTENDING"?"default":i[s.id].status==="NOT_ATTENDING"?"destructive":"secondary",className:"text-xs","data-testid":`rsvp-badge-${s.id}`,children:i[s.id].status==="ATTENDING"?"Attending":i[s.id].status==="NOT_ATTENDING"?"Not Attending":"Maybe"}),e.jsx(n,{size:"sm",variant:i[s.id]?.status==="ATTENDING"?"default":"outline",onClick:()=>c.mutate({sessionId:s.id,status:"ATTENDING"}),disabled:c.isPending,"data-testid":`button-rsvp-attending-${s.id}`,children:e.jsx(O,{className:"w-3.5 h-3.5"})}),e.jsx(n,{size:"sm",variant:i[s.id]?.status==="MAYBE"?"default":"outline",onClick:()=>c.mutate({sessionId:s.id,status:"MAYBE"}),disabled:c.isPending,"data-testid":`button-rsvp-maybe-${s.id}`,children:e.jsx(B,{className:"w-3.5 h-3.5"})}),e.jsx(n,{size:"sm",variant:i[s.id]?.status==="NOT_ATTENDING"?"destructive":"outline",onClick:()=>{L({sessionId:s.id}),C(""),E(""),h(!0)},disabled:c.isPending,"data-testid":`button-rsvp-not-attending-${s.id}`,children:e.jsx(be,{className:"w-3.5 h-3.5"})})]})]},s.id)})})})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("h2",{className:"text-xl font-bold flex items-center gap-2",children:[e.jsx(u,{className:"w-5 h-5"}),"Leaderboard"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(I,{href:`${Z}/how-it-works`,children:e.jsxs(n,{variant:"outline",size:"sm",className:"gap-1.5","data-testid":"link-how-it-works",children:[e.jsx(B,{className:"w-4 h-4"}),"How It Works"]})}),e.jsxs(G,{value:a,onValueChange:o,children:[e.jsx(H,{className:"w-full sm:w-64","data-testid":"select-leaderboard-scope",children:e.jsx(q,{placeholder:"Select Scope"})}),e.jsxs(z,{children:[e.jsx(D,{value:"all",children:"All Days (League Total)"}),g.map(s=>e.jsxs(D,{value:s.id.toString(),children:["Day ",s.sessionNumber," - ",s.sessionType==="PLAY"?"Play":s.sessionType==="SORTING"?"Sorting":"Regular"]},s.id))]})]})]})]}),a==="all"&&j&&N.length>=3&&e.jsx(Le,{leaderboard:N,league:j}),e.jsxs(f,{"data-testid":"leaderboard-card",children:[e.jsx(y,{children:e.jsxs(w,{className:"flex items-center gap-2",children:[e.jsx(u,{className:"w-5 h-5"}),a==="all"?"League Standings":`Day ${g.find(s=>
1s.id.toString()===a)?.sessionNumber||""} Standings`]})}),e.jsx(v,{children:le?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading leaderboard..."}):!N||N.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground","data-testid":"leaderboard-empty",children:"No games completed yet. Rankings will appear after games are finalized."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full","data-testid":"table-leaderboard",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left",children:[e.jsx("th",{className:"px-3 py-3 font-semibold",children:"Rank"}),e.jsx("th",{className:"px-3 py-3 font-semibold",children:"Athlete"}),e.jsx("th",{className:"px-3 py-3 font-semibold text-center",children:"Total Pts"}),e.jsx("th",{className:"px-3 py-3 font-semibold text-center",children:"Pts For"}),e.jsx("th",{className:"px-3 py-3 font-semibold text-center",children:"Pts Against"}),e.jsx("th",{className:"px-3 py-3 font-semibold text-center",children:"+/-"}),e.jsx("th",{className:"px-3 py-3 font-semibold text-center",children:"W"}),e.jsx("th",{className:"px-3 py-3 font-semibold text-center",children:"T"}),e.jsx("th",{className:"px-3 py-3 font-semibold text-center",children:"L"}),e.jsx("th",{className:"px-3 py-3 font-semibold text-center",children:"A"}),e.jsx("th",{className:"px-3 py-3 font-semibold text-center",children:"GP"})]})}),e.jsx("tbody",{children:N.map(s=>e.jsxs("tr",{className:`border-b ${de(s.rank,s.playerId)}`,"data-testid":`row-player-${s.playerId}`,children:[e.jsx("td",{className:"px-3 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ne(s.rank),e.jsx("span",{className:s.rank<=3?"font-bold":"",children:s.rank})]})}),e.jsx("td",{className:"px-3 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(l,{variant:"outline",className:"text-xs",children:["#",s.playerNumber]}),e.jsx("span",{className:s.rank<=3?"font-semibold":"",children:s.playerName||`Athlete ${s.playerNumber}`}),t&&t.playerId===s.playerId&&e.jsx(l,{variant:"default",className:"text-xs","data-testid":"badge-my-row",children:"You"})]})}),e.jsx("td",{className:"px-3 py-3 text-center",children:e.jsx("span",{className:`font-bold ${s.rank<=3?"text-lg":""}`,children:s.totalPoints})}),e.jsx("td",{className:"px-3 py-3 text-center text-muted-foreground",children:s.pointsFor}),e.jsx("td",{className:"px-3 py-3 text-center text-muted-foreground",children:s.pointsAgainst}),e.jsx("td",{className:"px-3 py-3 text-center",children:e.jsxs("span",{className:s.pointsFor-s.pointsAgainst>0?"text-green-600 dark:text-green-400":s.pointsFor-s.pointsAgainst<0?"text-red-600 dark:text-red-400":"text-muted-foreground",children:[s.pointsFor-s.pointsAgainst>0?"+":"",s.pointsFor-s.pointsAgainst]})}),e.jsx("td",{className:"px-3 py-3 text-center text-green-600 dark:text-green-400",children:s.wins}),e.jsx("td",{className:"px-3 py-3 text-center text-muted-foreground",children:s.ties}),e.jsx("td",{className:"px-3 py-3 text-center text-red-600 dark:text-red-400",children:s.losses}),e.jsx("td",{className:"px-3 py-3 text-center text-orange-600 dark:text-orange-400",children:s.absences}),e.jsx("td",{className:"px-3 py-3 text-center text-muted-foreground",children:s.gamesPlayed})]},s.playerId))})]})})})]}),e.jsxs(f,{"data-testid":"scoring-key-card",children:[e.jsx(y,{children:e.jsx(w,{children:"Scoring Key"})}),e.jsx(v,{children:e.jsxs("div",{className:"flex flex-wrap gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-green-600 dark:text-green-400 w-6 text-center",children:"W"}),e.jsx("span",{children:"="}),e.jsx(l,{variant:"default",children:"Win"}),e.jsx("span",{className:"text-muted-foreground",children:"(3 pts)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-muted-foreground w-6 text-center",children:"T"}),e.jsx("span",{children:"="}),e.jsx(l,{variant:"secondary",children:"Tie"}),e.jsx("span",{className:"text-muted-foreground",children:"(2 pts)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-red-600 dark:text-red-400 w-6 text-center",children:"L"}),e.jsx("span",{children:"="}),e.jsx(l,{variant:"outline",children:"Loss"}),e.jsx("span",{className:"text-muted-foreground",children:"(1 pt)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-orange-600 dar
1k:text-orange-400 w-6 text-center",children:"A"}),e.jsx("span",{children:"="}),e.jsx(l,{variant:"destructive",children:"Absent"}),e.jsx("span",{className:"text-muted-foreground",children:"(0 pts)"})]})]})})]})]}),e.jsx(fe,{open:m,onOpenChange:h,children:e.jsxs(ye,{className:"sm:max-w-md",children:[e.jsxs(we,{children:[e.jsx(ve,{children:"Report Absence"}),e.jsx(ke,{children:"Why will you miss this session?"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_,{children:"Reason"}),e.jsxs(G,{value:A,onValueChange:s=>C(s),children:[e.jsx(H,{"data-testid":"select-hub-absence-reason",children:e.jsx(q,{placeholder:"Select a reason..."})}),e.jsx(z,{children:Ae.map(s=>e.jsx(D,{value:s,"data-testid":`option-hub-absence-${s}`,children:Se[s]},s))})]})]}),e.jsxs("div",{children:[e.jsx(_,{children:"Notes (optional)"}),e.jsx(Te,{value:R,onChange:s=>E(s.target.value),placeholder:"Any additional details...","data-testid":"textarea-hub-absence-notes"})]})]}),e.jsxs(Ce,{children:[e.jsx(n,{variant:"outline",onClick:()=>h(!1),"data-testid":"button-hub-absence-cancel",children:"Cancel"}),e.jsxs(n,{variant:"destructive",disabled:!A||c.isPending,onClick:()=>{k&&A&&c.mutate({sessionId:k.sessionId,status:"NOT_ATTENDING",absenceReason:A,absenceNotes:R||void 0})},"data-testid":"button-hub-absence-confirm",children:[c.isPending?e.jsx(Ee,{className:"w-4 h-4 animate-spin mr-1"}):null,"Confirm Absence"]})]})]})})]}):e.jsxs("div",{className:"container mx-auto px-4 py-8 text-center","data-testid":"league-not-found",children:[e.jsx(u,{className:"h-16 w-16 mx-auto text-muted-foreground/50 mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"League Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"This league doesn't exist or may have been removed."}),e.jsx(I,{href:"/community",children:e.jsxs(n,{"data-testid":"button-back-community",children:[e.jsx(P,{className:"mr-2 h-4 w-4"}),"Back to Community"]})})]})}export{Oe 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.