PageSourceSearch

https://analytics.whiteknight.academy/assets/AdminApplicationsPage-ijCBrMZV.js

js whiteknight.academy collected 2026-10-02 00:42:23 UTC 12,172 bytes, 1 lines download raw bytes

1var H=Object.defineProperty;var a=(s,l)=>H(s,"name",{value:l,configurable:!0});import{j as e}from"./emailRef-C5-h4jsF.js";import{r as i}from"./react-vendor-DAHDpbpd.js";import{a as F}from"./adminService-TG2alI3X.js";import{m as $}from"./avatarUtils-SfZ6QPAx.js";import{D as q}from"./DataTable-CHXGSCOY.js";import{K}from"./KpiStrip-CaOHVTjF.js";import{B as W}from"./BulkBar-UYnBe7NN.js";import{P as Y}from"./PageHeader-BRk3H2H0.js";import{E as G}from"./ErrorBanner-CP9SbrFz.js";import{F as X}from"./FilterBar-BFziZGSD.js";import{T}from"./Tooltip-CpXTi4vs.js";import{D as O}from"./DetailDrawer-DqFusf_Y.js";import{ay as R,W as S,a as L,bd as J,ae as Q}from"./icons-vendor-DuIPDEfl.js";import{a as V,M as Z,f as ee}from"./usersTable-gQUY15bP.js";import{S as te}from"./campaign-icons-DEJbYNbs.js";import"./index-CEt5kvJT.js";import"./supabase-vendor-Ba-0_w4O.js";import"./DataTable-DMUS-zce.js";import"./EmptyState-Dy97loBS.js";import"./main-app-Cg94Q7__.js";import"./InfoTooltip-DcTxUR7x.js";import"./Avatar-CnMqHcI1.js";import"./LessonClocks-Ca99j1FC.js";const se=a(()=>{const[s,l]=i.useState([]),[n,d]=i.useState(""),[c,b]=i.useState(!0),[f,v]=i.useState(!1),[j,h]=i.useState(null),m=i.useCallback(async()=>{b(!0),h(null);try{const u=await F.listCoachApplications({statusFilter:n,pageSize:100,pageOffset:0});l(u)}catch(u){const g=u instanceof Error?u.message:"Failed to load coach applications.";h(g),l([])}finally{b(!1)}},[n]);i.useEffect(()=>{m()},[m]);const C=i.useCallback(async(u,g)=>{v(!0),h(null);try{await F.updateCoachApplication(u,g),await m()}catch(w){const y=w instanceof Error?w.message:"Failed to update application status.";h(y)}finally{v(!1)}},[m]);return{applications:s,statusFilter:n,setStatusFilter:d,loading:c,saving:f,error:j,refresh:m,setApplicationStatus:C}},"useAdminApplications"),ae=a(s=>{const n={pending:"border-amber-400/35 bg-amber-500/15 text-amber-300",reviewing:"border-sky-400/35 bg-sky-500/15 text-sky-300",approved:"border-emerald-400/35 bg-emerald-500/15 text-emerald-300",rejected:"border-red-400/35 bg-red-500/15 text-red-300",info_requested:"border-violet-400/35 bg-violet-500/15 text-violet-300"}[s]??"border-slate-500/35 bg-slate-500/15 text-slate-300",d=s.replace("_"," ");return e.jsx("span",{className:`inline-flex rounded-md border px-2 py-1 font-body text-[10px] font-bold uppercase tracking-wide ${n}`,children:d})},"statusBadge"),_=a(({label:s,value:l})=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-body text-[10px] font-bold uppercase tracking-[0.14em] text-slate-500",children:s}),e.jsx("div",{className:"font-body text-sm text-slate-200",children:l})]}),"Field"),re=a(({application:s,open:l,onClose:n,onSetStatus:d,saving:c})=>{if(!s)return e.jsx(O,{open:l,onClose:n,title:"Application",width:"lg",children:e.jsx("p",{className:"font-body text-sm text-slate-400",children:"No application selected."})});const b=new Date(s.created_at),f=s.updated_at?new Date(s.updated_at):null;return e.jsx(O,{open:l,onClose:n,title:s.full_name||s.email,subtitle:s.email,width:"lg",primaryAction:{label:"Approve",loading:c,icon:e.jsx(L,{size:12}),onClick:a(()=>{d(s.id,"approved")},"onClick")},secondaryActions:[{label:"Hold (reviewing)",icon:e.jsx(R,{size:12}),onClick:a(()=>{d(s.id,"reviewing")},"onClick")},{label:"Reject",danger:!0,icon:e.jsx(S,{size:12}),onClick:a(()=>{d(s.id,"rejected")},"onClick")}],children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(_,{label:"Status",value:ae(s.status)}),e.jsx(_,{label:"Submitted",value:b.toLocaleString()}),e.jsx(_,{label:"Last update",value:f?f.toLocaleString():"—"}),e.jsx(_,{label:"Reviewer",value:s.reviewer_id?e.jsxs("span",{className:"truncate",title:s.reviewer_id,children:[s.reviewer_id.slice(0,8),"…"]}):"—"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-body text-[10px] font-bold uppercase tracking-[0.14em] text-slate-500",children:"Reviewer notes"}),e.jsx("p",{className:"font-body text-sm text-slate-300",children:s.reviewer_notes||e.jsx("span",{className:"text-slate-500",children:"No notes recorded."})})]}),s.rejection_reason?e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-body text-[10px] font-bold uppercase tracking-[0.14em] text-slate-500",children:"Rejection reason"}),e.jsx("p",{className:"font-body text-sm text-red-200",children:s.rejection_reason})]}):null,e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-body text-[10px] font-bold uppercase tracking-[0.14em] text-slate-500",children:"Linked user"}),e.jsx("p",{className:"truncate font-body text-sm text-slate-300",title:s.user_id??"",children:s.user_id??"—"})]}),e.jsx("div",{className:"rounded-xl border border-white/10 bg-white/[0.03] p-3",children:e.jsxs("p",{className:"font-body text-xs text-slate-400",children:["Approving an application automatically upgrades the linked user to"," ",e.jsx("span",{className:"font-semibold text-white",children:"coach"})," and activates"," ",e.jsx("span",{className:"font-semibold text-white",children:"pro"})," access."]})})]})})},"ApplicationDetailDrawer"),le=[{value:"",label:"All"},{value:"pending",label:"Pending"},{value:"reviewing",label:"Reviewing"},{value:"approved",label:"Approved"},{value:"rejected",label:"Rejected"},{value:"info_requested",label:"Needs review"}],ie=[{key:"newest",label:"Newest"},{key:"oldest",label:"Oldest"},{key:"name",label:"Name"}
1],ne={pending:"border-amber-400/35 bg-amber-500/15 text-amber-300",reviewing:"border-sky-400/35 bg-sky-500/15 text-sky-300",approved:"border-emerald-400/35 bg-emerald-500/15 text-emerald-300",rejected:"border-red-400/35 bg-red-500/15 text-red-300",info_requested:"border-slate-400/35 bg-slate-500/15 text-slate-300"},z=a((s,l)=>{const n=new Date(s);return n.getUTCFullYear()===l.getUTCFullYear()&&n.getUTCMonth()===l.getUTCMonth()},"sameMonth"),Le=a(()=>{const{applications:s,statusFilter:l,setStatusFilter:n,loading:d,saving:c,error:b,refresh:f,setApplicationStatus:v}=se(),[j,h]=i.useState(""),[m,C]=i.useState("newest"),[u,g]=i.useState([]),[w,y]=i.useState(null),[P,E]=i.useState(!1),A=new Date,k=i.useMemo(()=>{const t=s.filter(r=>r.status==="pending").length,o=s.filter(r=>r.status==="approved"&&z(r.updated_at??r.created_at,A)).length,p=s.filter(r=>r.status==="rejected"&&z(r.updated_at??r.created_at,A)).length,x=s.filter(r=>r.status==="reviewing"||r.status==="info_requested").length;return{pending:t,approvedThisMonth:o,rejectedThisMonth:p,underReview:x}},[s,A]),M=i.useMemo(()=>{const t=j.trim().toLowerCase(),p=[...t?s.filter(x=>`${x.full_name??""} ${x.email??""}`.toLowerCase().includes(t)):s];return m==="newest"?p.sort((x,r)=>new Date(r.created_at).getTime()-new Date(x.created_at).getTime()):m==="oldest"?p.sort((x,r)=>new Date(x.created_at).getTime()-new Date(r.created_at).getTime()):p.sort((x,r)=>(x.full_name??"").localeCompare(r.full_name??"")),p},[s,j,m]),U=a(t=>{y(t),E(!0)},"openDetail"),I=a(()=>{E(!1),setTimeout(()=>y(null),200)},"closeDetail"),N=a(async(t,o)=>{await v(t,o),y(p=>p&&p.id===t?{...p,status:o}:p)},"handleSetStatus"),D=a(async t=>{for(const o of u)await v(o,t);g([])},"handleBulk"),B=[{key:"applicant",label:"Applicant",width:"min-w-[140px] max-w-[220px]",render:a(t=>{const o=V(t.email);return e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("span",{className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-white/10 bg-gradient-to-br from-red-600/40 to-red-800/20 font-display text-[11px] font-bold text-white",children:$(t.full_name)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate font-body text-sm font-semibold text-white",title:t.full_name??"",children:t.full_name||"—"}),e.jsx("p",{className:`truncate font-body text-xs text-slate-400 ${o?"italic":""}`,title:o?Z:t.email??"",children:ee(t.email)})]})]})},"render")},{key:"submitted",label:"Submitted",width:"min-w-[120px] max-w-[160px]",render:a(t=>e.jsx("span",{className:"block truncate",title:new Date(t.created_at).toLocaleString(),children:new Date(t.created_at).toLocaleDateString()}),"render")},{key:"status",label:"Status",width:"min-w-[120px] max-w-[160px]",render:a(t=>{const o=ne[t.status]??"border-slate-500/35 bg-slate-500/15 text-slate-300";return e.jsx("span",{className:`inline-flex rounded-md border px-2 py-1 font-body text-[10px] font-bold uppercase tracking-wide ${o}`,children:t.status.replace("_"," ")})},"render")},{key:"reviewer",label:"Reviewer",width:"min-w-[120px] max-w-[160px]",render:a(t=>e.jsx("span",{className:"block truncate font-body text-xs text-slate-400",title:t.reviewer_id??"",children:t.reviewer_id?`${t.reviewer_id.slice(0,8)}…`:"—"}),"render")},{key:"actions",label:"Actions",width:"min-w-[220px] max-w-[300px]",align:"right",render:a(t=>e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5",onClick:a(o=>o.stopPropagation(),"onClick"),children:[e.jsx(T,{label:"Approve",side:"top",children:e.jsxs("button",{type:"button",onClick:a(()=>{N(t.id,"approved")},"onClick"),disabled:c||t.status==="approved",className:"inline-flex items-center gap-1 rounded-lg border border-emerald-400/30 bg-emerald-500/10 px-2.5 py-1.5 font-body text-xs font-semibold text-emerald-300 transition hover:bg-emerald-500/20 disabled:cursor-not-allowed disabled:opacity-60","aria-label":"Approve",children:[e.jsx(L,{size:12})," Approve"]})}),e.jsx(T,{label:"Reject",side:"top",children:e.jsxs("button",{type:"button",onClick:a(()=>{N(t.id,"rejected")},"onClick"),disabled:c||t.status==="rejected",className:"inline-flex items-center gap-1 rounded-lg border border-red-400/35 bg-red-500/10 px-2.5 py-1.5 font-body text-xs font-semibold text-red-300 transition hover:bg-red-500/20 disabled:cursor-not-allowed disabled:opacity-60","aria-label":"Reject",children:[e.jsx(S,{size:12})," Reject"]})}),e.jsx(T,{label:"Hold for review",side:"top",children:e.jsxs("button",{type:"button",onClick:a(()=>{N(t.id,"reviewing")},"onClick"),disabled:c||t.status==="reviewing",className:"inline-flex items-center gap-1 rounded-lg border border-sky-400/30 bg-sky-500/10 px-2.5 py-1.5 font-body text-xs font-semibold text-sky-300 transition hover:bg-sky-500/20 disabled:cursor-not-allowed disabled:opacity-60","aria-label":"Hold for review",children:[e.jsx(R,{size:12})," Hold"]})})]}),"render")}];return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Y,{title:"Coach Applications",subtitle:"Ap
1prove, reject or hold coach applications. Approval auto-upgrades the linked user."}),e.jsx(K,{loading:d,metrics:[{label:"Pending",value:k.pending,tone:"amber",icon:R},{label:"Approved this month",value:k.approvedThisMonth,tone:"emerald",icon:te},{label:"Rejected this month",value:k.rejectedThisMonth,tone:"red",icon:S},{label:"Under review",value:k.underReview,tone:"sky",icon:J}]}),b?e.jsx(G,{type:"warning",title:"Could not load applications",message:b}):null,e.jsx(X,{accent:"red",filtersInline:!0,search:{value:j,onChange:h,placeholder:"Search by name or email"},filters:[{id:"status",label:"Status",mode:"single",value:l,onChange:a(t=>n(t),"onChange"),options:le.filter(t=>t.value).map(t=>({value:t.value,label:t.label}))}],sort:{value:m,onChange:a(t=>C(t),"onChange"),options:ie.map(t=>({value:t.key,label:t.label}))},onClearAll:a(()=>{h(""),n("")},"onClearAll"),onRefresh:a(()=>{f()},"onRefresh"),refreshing:d}),e.jsx(q,{columns:B,rows:M,loading:d,rowKey:a(t=>t.id,"rowKey"),selectedRows:u,onSelectionChange:g,onRowClick:U,emptyTitle:"No applications match",emptyDescription:"Try clearing filters or refreshing."}),e.jsx(W,{selectedCount:u.length,total:M.length,onClear:a(()=>g([]),"onClear"),pluralLabel:"applications",actions:[{key:"approve",label:"Approve",icon:e.jsx(L,{size:12}),primary:!0,loading:c,onClick:a(()=>{D("approved")},"onClick")},{key:"review",label:"Move to review",icon:e.jsx(Q,{size:12}),loading:c,onClick:a(()=>{D("reviewing")},"onClick")},{key:"reject",label:"Reject",icon:e.jsx(S,{size:12}),danger:!0,loading:c,onClick:a(()=>{D("rejected")},"onClick")}]}),e.jsx(re,{application:w,open:P,onClose:I,onSetStatus:N,saving:c})]})},"AdminApplicationsPage");export{Le 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.