1/*! For license information please see 158.b96e275e.chunk.js.LICENSE.txt */ 2"use strict";(globalThis.webpackChunkfrontend=globalThis.webpackChunkfrontend||[]).push([[158],{69158(e,a,s){s.r(a),s.d(a,{default:()=>I});var r=s(65043),t=s(63362),l=s(23297),i=s(13390),o=s(92264),n=s(79613),d=s(37719),c=s(50516),m=s(70579);class h extends r.Component{constructor(e){super(e),this.handleReset=()=>{this.setState({hasError:!1,error:null,errorInfo:null}),window.location.reload()},this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(e){return{hasError:!0}}componentDidCatch(e,a){console.error("ErrorBoundary caught an error:",e,a),this.setState({error:e,errorInfo:a})}render(){return this.state.hasError?(0,m.jsx)("div",{className:"flex flex-col items-center justify-center min-h-[400px] p-8",children:(0,m.jsxs)("div",{className:"bg-red-50 border border-red-200 rounded-2xl p-8 max-w-md text-center",children:[(0,m.jsx)(d.A,{className:"w-12 h-12 text-red-500 mx-auto mb-4"}),(0,m.jsx)("h2",{className:"text-xl font-semibold text-red-800 mb-2",children:"Something went wrong"}),(0,m.jsx)("p",{className:"text-red-600 mb-4",children:this.props.fallbackMessage||"An unexpected error occurred. Please try refreshing the page."}),!1,(0,m.jsxs)(i.$,{onClick:this.handleReset,className:"gap-2",children:[(0,m.jsx)(c.A,{className:"w-4 h-4"}),"Reload Page"]})]})}):this.props.children}}const p=h;var x=s(53723),g=s(77784);const u=(0,g.A)("dumbbell",[["path",{d:"M17.596 12.768a2 2 0 1 0 2.829-2.829l-1.768-1.767a2 2 0 0 0 2.828-2.829l-2.828-2.828a2 2 0 0 0-2.829 2.828l-1.767-1.768a2 2 0 1 0-2.829 2.829z",key:"9m4mmf"}],["path",{d:"m2.5 21.5 1.4-1.4",key:"17g3f0"}],["path",{d:"m20.1 3.9 1.4-1.4",key:"1qn309"}],["path",{d:"M5.343 21.485a2 2 0 1 0 2.829-2.828l1.767 1.768a2 2 0 1 0 2.829-2.829l-6.364-6.364a2 2 0 1 0-2.829 2.829l1.768 1.767a2 2 0 0 0-2.828 2.829z",key:"1t2c92"}],["path",{d:"m9.6 14.4 4.8-4.8",key:"6umqxw"}]]);var v=s(23165);const j=(0,g.A)("tent",[["path",{d:"M3.5 21 14 3",key:"1szst5"}],["path",{d:"M20.5 21 10 3",key:"1310c3"}],["path",{d:"M15.5 21 12 15l-3.5 6",key:"1ddtfw"}],["path",{d:"M2 21h20",key:"1nyx9w"}]]);var f=s(5244),b=s(20073),N=s(71360),w=s(39292),y=s(40614),A=s(31130),$=s(7118),k=s(28646),C=s(35087),_=s(26533),P=s(72313),z=s(35746),S=s(94805),R=s(9855),B=s(27823),F=s(56328),E=s(62575),M=s(27540);const T={recreational:{label:"Recreational",color:"bg-sky-100 text-sky-700",icon:u},competitive:{label:"Competitive",color:"bg-orange-100 text-orange-700",icon:v.A},camp:{label:"Camp",color:"bg-emerald-100 text-emerald-700",icon:j}},D=()=>{const{user:e,token:a}=(0,l.As)(),s=(0,t.Zp)(),[d,c]=(0,r.useState)(!0),[h,p]=(0,r.useState)([]),[g,u]=(0,r.useState)(!1),[v,j]=(0,r.useState)(""),[D,I]=(0,r.useState)("all"),[q,L]=(0,r.useState)("all"),{canAdd:U,getUsage:V}=(0,E.XX)(),[X,O]=(0,r.useState)(1),[W,Y]=(0,r.useState)(25),[Z,G]=(0,r.useState)(0),[H,J]=(0,r.useState)(1);(0,r.useEffect)(()=>{K()},[a,X,W,g]);const K=async()=>{try{c(!0);const e={Authorization:`Bearer ${a}`},s=g?"archived":void 0,r=await B.A.get(`${l.nC}/programs`,{headers:e,params:{page:X,page_size:W,status:s}});r.data.items?(p(r.data.items),G(r.data.total),J(r.data.total_pages)):(p(Array.isArray(r.data)?r.data:[]),G(r.data.length||0),J(1))}catch(e){console.error("Error fetching data:",e),F.oR.error("Failed to load programs"),p([])}finally{c(!1)}},Q=()=>{s("/admin/programs/new")},ee=Array.isArray(h)?h:[],ae=[...new Set(ee.map(e=>e.season).filter(Boolean))].sort(),se=ee.filter(e=>{const a=`${e.name||""} ${e.sport||""} ${e.season||""}`.toLowerCase().includes(v.trim().toLowerCase()),s="all"===D||e.program_type===D,r="all"===q||e.season===q;return a&&s&&r}),re=Boolean(v)||"all"!==D||"all"!==q,te=g?0:Z;return d?(0,m.jsx)(n.A,{children:(0,m.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,m.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-2 border-slate-200 border-t-slate-900"})})}):(0,m.jsx)(n.A,{children:(0,m.jsxs)("div",{className:"space-y-6 operations-page","data-testid":"admin-programs-page",children:[(0,m.jsxs)("section",{className:"operations-hero","aria-labelledby":"programs-heading",children:[(0,m.jsxs)("div",{children:[(0,m.jsx)("p",{className:"platform-eyebrow",children:"Program operations / 01"}),(0,m.jsx)("h1",{id:"programs-heading",children:"Build the season."}),(0,m.jsx)("p",{children:"Shape every offering, follow capacity, and move drafts into registration."})]}),(0,m.jsxs)("div",{className:"operations-signal","aria-label":`${te} active programs`,children:[(0,m.jsx)("strong",{children:te}),(0,m.jsx)("span",{children:"Active programs"})]})]}),(0,m.jsxs)("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[(0,m.jsxs)("div",{className:"flex items-center gap-4",children:[(0,m.jsxs)("div",{className:"flex items-center gap-2",children:[(0,m.jsxs)(i.$,{variant:g?"outline":"default",size:"sm",onClick:()=>{u(!1),O(1)},className:"rounded-full "+(g?"":"bg-slate-900 text-white"),children:["Active ",!g&&Z>0?`(${Z})`:""]}),(0,m.jsxs)(i.$,{variant:g?"default":"outline",size:"sm",onClick:()=>{u(!0),O(1)},className:"rounded-full "+(g?"bg-slate-900 text-white":""),children:[(0,m.jsx)(f.A,{className:"w-3.5 h-3.5 mr-1.5"}),"Archived ",g&&Z>0?`(${Z})`:""]})]}),"org_admin"===(null===e||void 0===e?void 0:e.role)&&(0,m.jsx)(M.pV,{limitType:"programs",label:"programs"})]}),(0,m.jsxs)("div",{className:"flex items-center gap-2",children:[!U("programs")&&"org_admin"===(null===e||void 0===e?void 0:e.role)&&(0,m.jsxs)(i.$,{variant:"outline",onClick:()=>s("/admin/settings?tab=billing"),className:"rounded-full text-violet-600 border-violet-200 hover:bg-violet-50",size:"sm",children:[(0,m.jsx)(b.A,{className:"w-4 h-4 mr-1"}),"Upgrade"]}),(0,m.jsxs)(i.$,{onClick:Q,disabled:!U("programs")&&"org_admin"===(null===e||void 0===e?void 0:e.role),className:"bg-slate-900 text-white hover:bg-slate-800 rounded-full disabled:opacity-50","data-testid":"add-program-btn",children:[(0,m.jsx)(N.A,{className:"w-4 h-4 mr-2"}),"New program"]})]})]}),(0,m.jsxs)("div",{className:"platform-card operations-toolbar p-3 flex flex-col gap-3 md:flex-row md:items-center","aria-label":"Program filters",children:[(0,m.jsxs)("div",{className:"relative flex-1 min-w-0",children:[(0,m.jsx)(w.A,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}
2),(0,m.jsx)(o.p,{value:v,onChange:e=>j(e.target.value),placeholder:"Search programs, sports, or seasons",className:"pl-9 h-10 bg-[#f8faf7] border-[#dce2dc] rounded-xl","aria-label":"Search programs"})]}),(0,m.jsxs)("select",{value:D,onChange:e=>I(e.target.value),className:"h-10 px-3 rounded-xl border border-[#dce2dc] bg-white text-sm text-slate-700","aria-label":"Filter by program type",children:[(0,m.jsx)("option",{value:"all",children:"All types"}),Object.entries(T).map(e=>{let[a,s]=e;return(0,m.jsx)("option",{value:a,children:s.label},a)})]}),(0,m.jsxs)("select",{value:q,onChange:e=>L(e.target.value),className:"h-10 px-3 rounded-xl border border-[#dce2dc] bg-white text-sm text-slate-700","aria-label":"Filter by season",children:[(0,m.jsx)("option",{value:"all",children:"All seasons"}),ae.map(e=>(0,m.jsx)("option",{value:e,children:e},e))]}),re&&(0,m.jsxs)(i.$,{variant:"ghost",size:"sm",className:"rounded-xl text-slate-500",onClick:()=>{j(""),I("all"),L("all")},children:[(0,m.jsx)(y.A,{className:"w-4 h-4 mr-1"})," Clear"]})]}),!U("programs")&&"org_admin"===(null===e||void 0===e?void 0:e.role)&&(0,m.jsx)(M.CW,{limitType:"programs",current:V("programs").current,limit:V("programs").limit,itemName:"Programs"}),se.length>0?(0,m.jsxs)("div",{className:"platform-card operations-ledger overflow-hidden",children:[(0,m.jsxs)("div",{className:"px-4 py-3 border-b border-[#e5e9e4] flex items-center justify-between",children:[(0,m.jsxs)("p",{className:"text-sm font-medium text-[#101a19]",children:[se.length," program",1===se.length?"":"s"," shown"]}),(0,m.jsx)("p",{className:"text-xs text-slate-500",children:"Select a program to open its workspace"})]}),(0,m.jsx)("div",{className:"divide-y divide-slate-100",children:se.map(e=>{var r;const t="archived"===e.status,o="draft"===e.status;return(0,m.jsxs)("div",{className:"operations-row flex items-center gap-4 p-4 transition-colors cursor-pointer "+(t?"opacity-60":""),"data-testid":`admin-program-${e.program_id}`,onClick:()=>s(`/admin/programs/${e.program_id}`),children:[(0,m.jsx)("div",{className:"w-12 h-12 rounded-xl bg-slate-100 flex items-center justify-center overflow-hidden shrink-0",children:e.logo_url?(0,m.jsx)("img",{src:e.logo_url,alt:e.name,className:"w-full h-full object-contain p-1",loading:"lazy"}):(0,m.jsx)(A.A,{className:"w-5 h-5 text-slate-400"})}),(0,m.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,m.jsxs)("div",{className:"flex items-center gap-2 mb-0.5 flex-wrap",children:[(0,m.jsx)("h3",{className:"font-semibold text-slate-900 truncate",children:e.name}),e.program_type&&T[e.program_type]&&(0,m.jsxs)("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium shrink-0 ${T[e.program_type].color}`,"data-testid":`program-type-badge-${e.program_id}`,children:[(()=>{const a=T[e.program_type].icon;return a?(0,m.jsx)(a,{className:"w-3 h-3"}):null})(),T[e.program_type].label]}),e.sport&&(0,m.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-slate-100 text-slate-700 shrink-0",children:e.sport}),o&&(0,m.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-amber-100 text-amber-700 shrink-0",children:"Draft"}),t&&(0,m.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-slate-200 text-slate-600 shrink-0",children:"Archived"})]}),(0,m.jsxs)("div",{className:"flex items-center gap-4 text-sm text-slate-500",children:[(0,m.jsxs)("span",{className:"flex items-center gap-1",children:[(0,m.jsx)($.A,{className:"w-3.5 h-3.5"}),"Ages ",e.age_min,"-",e.age_max]}),(0,m.jsxs)("span",{className:"flex items-center gap-1",children:[(0,m.jsx)(k.A,{className:"w-3.5 h-3.5"}),e.season]}),(null===(r=e.divisions)||void 0===r?void 0:r.length)>0&&(0,m.jsxs)("span",{children:[e.divisions.length," division",e.divisions.length>1?"s":""]})]})]}),(0,m.jsxs)("div",{className:"flex items-center gap-6 shrink-0",children:[(0,m.jsxs)("div",{className:"text-right hidden sm:block",children:[(0,m.jsxs)("div",{className:"font-semibold text-slate-900",children:["$",e.price]}),(0,m.jsxs)("div",{className:"text-xs text-slate-500",children:[e.current_participants,"/",e.max_participants," spots"]})]}),(0,m.jsxs)("div",{className:"flex items-center gap-1",onClick:e=>e.stopPropagation(),children:[(0,m.jsx)(i.$,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-slate-500 hover:text-slate-900",onClick:()=>s(`/admin/programs/${e.program_id}`),title:"View Program",children:(0,m.jsx)(C.A,{className:"w-4 h-4"})}),(0,m.jsx)(i.$,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-slate-500 hover:text-slate-900",onClick:()=>s(`/admin/programs/${e.program_id}/edit`),title:"Edit Program",children:(0,m.jsx)(_.A,{className:"w-4 h-4"})}),(0,m.jsx)(i.$,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-slate-500 hover:text-indigo-600",onClick:()=>(async e=>{try{const r={Authorization:`Bearer ${a}`},t=await B.A.post(`${l.nC}/programs/${e}/duplicate`,{},{headers:r});F.oR.success("Program duplicated! The copy is saved as a draft."),s(`/admin/programs/${t.data.program_id}/edit`)}catch(r){F.oR.error("Failed to duplicate program")}})(e.program_id),title:"Duplicate Program",children:(0,m.jsx)(P.A,{className:"w-4 h-4"})}),o&&(0,m.jsx)(i.$,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-emerald-500 hover:text-emerald-600",onClick:()=>(async e=>{try{const s={Authorization:`Bearer ${a}`};await B.A.put(`${l.nC}/programs/${e}`,{status:"active"},{headers:s}),F.oR.success("Program published!"),K()}catch(s){F.oR.error("Failed to publish program")}})(e.program_id),title:"Publish Program",children:(0,m.jsx)(z.A,{className:"w-4 h-4"})}),t?(0,m.jsx)(i.$,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-slate-500 hover:text-green-600",onClick:()=>(async e=>{try{const s={Authorization:`Bearer ${a}`};await B.A.put(`${l.nC}/programs/${e}/restore`,{},{headers:s}),F.oR.success("Program restored"),K()}catch(s){F.oR.error("Failed to restore program")}})(e.program_id),title:"Restore Program",children:(0,m.jsx)(S.A,{className:"w-4 h-4"})}):(0,m.jsx)(i.$,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-slate-500 hover:text-amber-600",onClick:()=>(async e=>{if(confirm("Archive this program? It will be hidden from public view but can be restored later."))try{const s={Authorization:`Bearer ${a}`};await B.A.put(`${l.nC}/programs/${e}/archive`,{},{headers:s}),F.oR.success("Program archived"),K()}catch(s){F.oR.error("Failed to archive program")}})(e.program_id),title:"Archive Program",children:(0,m.jsx)(f.A,{className:"w-4 h-4"})}),(0,m.jsx)(i.$,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-slate-500 hover:text-red-600",onClick:()=>(async e=>{if(confirm("Are you sure you want to delete this program? This cannot be undone."))try{const s={Authorization:`Bearer ${a}`};await B.A.delete(`${l.nC}/programs/${e}`,{headers:s}),F.oR.success("Program deleted"),K()}catch(s){F.oR.error("Failed to delete program")}})(e.program_id),title:"Delete Program",children:(0,m.jsx)(R.A,{className:"w-4 h-4"})})]})]})]},e.program_id)})}),H>1&&(0,m.jsx)(x.A,{page:X,totalPages:H,total:Z,pageSize:W,onPageChange:e=>{O(e)},onPageSizeChange:e=>{Y(e),O(1)}})]}):(0,m.jsxs)("div",{className:"platform-card operations-empty text-center py-16","data-testid":"no-programs",children:[(0,m.jsx)(A.A,{className:"w-16 h-16 text-gray-300 mx-auto mb-4"}),(0,m.jsx)("h3",{className:"text-xl font-semibold text-slate-900 mb-2",children:re?"No matching programs":g?"No Archived Programs":"No Programs Yet"}),(0,m.jsx)("p",{className:"text-slate-500 mb-6",children:re?"Try changing or clearing your filters":g?"Archived programs will appear here":"Create your first program to get started"}),!g&&(0,m.jsx)(i.$,{onClick:Q,className:"bg-slate-900 text-white hover:bg-slate-800 rounded-full",children:"Create Program"})]})]})})},I=()=>(0,m.jsx)(p,{fallbackMessage:"Failed to load the Programs page. Please refresh.",children:(0,m.jsx)(D,{})})}}]); 3//# sourceMappingURL=158.b96e275e.chunk.js.map
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.