PageSourceSearch

https://slantapp.ai/assets/YouthSportsAdmin-C8KJsGYg.js

js slantapp.ai collected 2026-10-05 15:05:24 UTC 9,777 bytes, 1 lines download raw bytes

1import{c as ae,r as g,W as y,F as c,j as e,L as o,C as r,K,N as Q,aa as R,a as l,O as t,p as $,a4 as te,B as p,a8 as ie,E as v,M as I,U as ne,Q as m,q as i}from"./index-tc5-nNLC.js";import{L as N}from"./label-MwGx_WS4.js";import{S as B,a as O,b as L,c as U,d as f}from"./select-Bsa-6vNv.js";import{T as re,a as le,b as Y,c as z}from"./tabs-D2OfY7RH.js";import{C as V}from"./circle-check-big-CUgqPmz6.js";import{f as b}from"./format-D3jHS6VA.js";import{C as de}from"./circle-x-BO-W5S7j.js";import"./index-C-y5wYFI.js";import"./chevron-down-DOFZ7rzv.js";import"./chevron-up-1gTexUQn.js";import"./differenceInCalendarDays-YJe1lx93.js";const ce=["basketball","football","volleyball","baseball","soccer"],oe=["USA","Texas","California","Florida","Georgia","New York","Illinois","Ohio"];function be(){var F;const{toast:d}=ae(),[x,G]=g.useState("all"),[S,H]=g.useState("USA"),[w,W]=g.useState(3),{data:n=[],isLoading:C,refetch:X,error:A}=y({queryKey:["/api/youth-sports/admin/pending"],retry:!1}),{data:h=[],isLoading:D,refetch:J,error:E}=y({queryKey:["/api/youth-sports/admin/all"],retry:!1}),{data:u,error:Z}=y({queryKey:["/api/youth-sports/admin/stats"],retry:!1}),T=A||E||Z,_=T&&((F=T.message)==null?void 0:F.includes("401")),j=c({mutationFn:async s=>(await m("POST","/api/youth-sports/admin/discover",s)).json(),onSuccess:s=>{var a;d({title:"Events Discovered!",description:`Found ${s.totalSaved} events across ${((a=s.results)==null?void 0:a.length)||0} sports`}),X(),J()},onError:s=>{d({title:"Discovery Failed",description:s.message||"Failed to discover events",variant:"destructive"})}}),M=c({mutationFn:async s=>m("POST",`/api/youth-sports/admin/events/${s}/approve`),onSuccess:()=>{d({title:"Event Approved"}),i.invalidateQueries({queryKey:["/api/youth-sports/admin/pending"]}),i.invalidateQueries({queryKey:["/api/youth-sports/admin/all"]}),i.invalidateQueries({queryKey:["/api/youth-sports/admin/stats"]})}}),P=c({mutationFn:async s=>m("POST",`/api/youth-sports/admin/events/${s}/reject`),onSuccess:()=>{d({title:"Event Rejected"}),i.invalidateQueries({queryKey:["/api/youth-sports/admin/pending"]}),i.invalidateQueries({queryKey:["/api/youth-sports/admin/all"]})}}),q=c({mutationFn:async s=>(await m("POST","/api/youth-sports/admin/events/bulk-approve",{eventIds:s})).json(),onSuccess:s=>{d({title:"Bulk Approval Complete",description:`Approved ${s.approved} events`}),i.invalidateQueries({queryKey:["/api/youth-sports/admin/pending"]}),i.invalidateQueries({queryKey:["/api/youth-sports/admin/all"]}),i.invalidateQueries({queryKey:["/api/youth-sports/admin/stats"]})}}),ee=()=>{j.mutate({sport:x==="all"?void 0:x||void 0,region:S,months:w})},se=()=>{const s=n.map(a=>a.id);s.length>0&&q.mutate(s)},k=s=>({basketball:"bg-orange-100 text-orange-800",football:"bg-green-100 text-green-800",volleyball:"bg-blue-100 text-blue-800",baseball:"bg-red-100 text-red-800",soccer:"bg-purple-100 text-purple-800"})[s]||"bg-gray-100 text-gray-800";return C&&D&&!A&&!E?e.jsx("div",{className:"container mx-auto p-6 flex items-center justify-center min-h-[400px]",children:e.jsx(o,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):_?e.jsx("div",{className:"container mx-auto p-6","data-testid":"auth-required",children:e.jsxs(r,{children:[e.jsxs(K,{children:[e.jsx(Q,{children:"Authentication Required"}),e.jsx(R,{children:"You need to sign in to access the Youth Sports Admin panel."})]}),e.jsx(l,{children:e.jsx("p",{className:"text-muted-foreground",children:"Please log in with an administrator account to manage youth sports events."})})]})}):e.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold","data-testid":"admin-title",children:"Youth Sports Events"}),e.jsx("p",{className:"text-muted-foreground",children:"Discover and manage youth sports events across all major sports"})]}),e.jsx("div",{className:"flex gap-4",children:u&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{variant:"secondary",className:"text-lg py-2 px-4",children:[u.pending," Pending"]}),e.jsxs(t,{variant:"default",className:"text-lg py-2 px-4",children:[u.published," Published"]})]})})]}),e.jsxs(r,{children:[e.jsxs(K,{children:[e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx($,{className:"w-5 h-5"}),"AI Event Discovery"]}),e.jsx(R,{children:"Use AI to discover upcoming youth sports events across basketball, football, volleyball, baseball, and soccer"})]}),e.jsx(l,{children:e.jsxs("div",{className:"flex flex-wrap gap-4 items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Sport (optional)"}),e.jsxs(B,{value:x,onValueChange:G,children:[e.jsx(O,{className:"w-40","data-testid":"sport-select",children:e.jsx(L,{placeholder:"All Sports"})}),e.jsxs(U,{children:[e.jsx(f,{value:"all",children:"All Sports"}),ce.map(s=>e.jsx(f,{value:s,children:s.charAt(0).toUpperCase()+s.slice(1)},s))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Region"}),e.jsxs(B,{value:S,onValueChange:H,children:[e.jsx(O,{className:"w-40","data-testid":"region-select",children:e.jsx(L,{})}),e.jsx(U,{children:oe.map(s=>e.jsx(f,{value:s,children:s},s))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Months Ahead"}),e.jsx(te,{type:"number",value:w,onChange:s=>W(parseInt(s.target.value)||3),className:"w-24",min:1,max:12,"data-testid":"months-input"})]}),e.jsx(p,{onClick:ee,disabled:j.isPending,"data-testid":"discover-button",children:j.isPending?e.jsxs(e.Fragment,{children:[e.jsx(o,{className:"w-4 h-4 mr-2 animate-spin"}),"Discovering..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2"}),"Discover Events"]})})]})})]}),e.jsxs(re,{defaultValue:"pending",children:[e.jsxs(le,{children:[e.jsxs(Y,{value:"pending","data-testid":"pending-tab",children:["Pending Review (",n.length,")"]}),e.jsxs(Y,{value:"all","data-testid":"all-tab",children:["All Events (",h.length,")"]})]}),e.jsxs(z,{value:"pending",className:"space-y-4",children:[n.length>0&&e.jsx("div",{className:"flex justify-end",children:e.jsxs(p,{onClick:se,disabled:q.isPending,"data-testid":"bulk-approve-button",children:[e.jsx(V,{className:"w-4 h-4 mr-2"}),"Approve All (",n.length,")"]})}),C?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(o,{className:"w-8 h-8 animate-spin"})}):n.length===0?e.jsx(r,{children:e.jsxs(l,{className:"py-12 text-center text-muted-foreground",children:[e.jsx($,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No pending events to review"}),e.jsx("p",{className:"text-sm",children:"Use AI Discovery above to find new events"})]})}):e.jsx("div",{className:"grid gap-4",children:n.map(s=>e.jsx(r,{"data-testid":`pending-event-${s.id}`,children:e.jsx(l,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t,{className:k(s.sport),children:s.sport}),e.jsx(t,{variant:"outline",children:s.eventType}),s.organizingBody&&e.jsx(t,{variant:"secondary",children:s.organizingBody})]}),e.jsx("h3",{className:"font-semibold text-lg",children:s.eventName}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(v,{className:"w-4 h-4"}),b(new Date(s.startDate),"MMM d, yyyy"),s.endDate&&` - ${b(new Date(s.endDate),"MMM d, yyyy")}`]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(I,{className:"w-4 h-4"}),s.city,", ",s.state]}
1),s.expectedTeams&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ne,{className:"w-4 h-4"}),s.expectedTeams," teams"]})]}),s.ageDivisions&&s.ageDivisions.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:s.ageDivisions.map(a=>e.jsx(t,{variant:"outline",className:"text-xs",children:a},a))}),s.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:s.description})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{size:"sm",variant:"outline",onClick:()=>P.mutate(s.id),disabled:P.isPending,"data-testid":`reject-${s.id}`,children:e.jsx(de,{className:"w-4 h-4"})}),e.jsxs(p,{size:"sm",onClick:()=>M.mutate(s.id),disabled:M.isPending,"data-testid":`approve-${s.id}`,children:[e.jsx(V,{className:"w-4 h-4 mr-1"}),"Approve"]})]})]})})},s.id))})]}),e.jsx(z,{value:"all",className:"space-y-4",children:D?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(o,{className:"w-8 h-8 animate-spin"})}):h.length===0?e.jsx(r,{children:e.jsxs(l,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(v,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No events found"})]})}):e.jsx("div",{className:"grid gap-4",children:h.map(s=>e.jsx(r,{"data-testid":`event-${s.id}`,children:e.jsx(l,{className:"p-4",children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t,{className:k(s.sport),children:s.sport}),e.jsx(t,{variant:"outline",children:s.eventType}),e.jsx(t,{variant:s.status==="published"?"default":"secondary",children:s.status})]}),e.jsx("h3",{className:"font-semibold",children:s.eventName}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(v,{className:"w-4 h-4"}),b(new Date(s.startDate),"MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(I,{className:"w-4 h-4"}),s.city,", ",s.state]})]})]})})})},s.id))})})]})]})}export{be 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.