PageSourceSearch

https://nucsports.com/assets/admin.claim-code-audit-rCk6GUv-.js

js nucsports.com collected 2026-10-09 17:19:52 UTC 7,054 bytes, 1 lines download raw bytes

1import{H as O,J as P,r as i,j as e,S as R}from"./index-BnlaQecQ.js";import{a as y,u as D}from"./useQuery-BKJ6JOgR.js";import{A as F}from"./AdminShell-D6GQASS6.js";import{C as M}from"./chevron-left-C4uUgv6X.js";import{C as q}from"./chevron-right-DcNEHbGI.js";import{L as N}from"./loader-circle-DJpbfIyK.js";import{D as T}from"./download-B7FnDG4S.js";import"./useRouterState-BqQkhVQV.js";import"./log-out-BJcEikLb.js";const V={created:{text:"Code created",tone:"bg-ink/5 text-ink"},regenerated:{text:"Code regenerated",tone:"bg-amber-100 text-amber-900"},link_success:{text:"Parent linked",tone:"bg-green-100 text-green-900"},link_failed_expired:{text:"Link · expired",tone:"bg-red-100 text-red-900"},link_failed_not_found:{text:"Link · not found",tone:"bg-red-100 text-red-900"},unlinked:{text:"Parent unlinked",tone:"bg-ink/10 text-ink"}},B=[{value:"all",label:"All events"},{value:"created",label:"Created"},{value:"regenerated",label:"Regenerated"},{value:"link_success",label:"Link · success"},{value:"link_failed_expired",label:"Link · expired"},{value:"link_failed_not_found",label:"Link · not found"},{value:"unlinked",label:"Unlinked"}];function Y(){const w=y(O),_=y(P),[b,C]=i.useState(""),[u,L]=i.useState("all"),[h,S]=i.useState(""),[g,E]=i.useState(""),[r,o]=i.useState(1),[k,f]=i.useState(!1),j=50,s={search:b,event:u,since:h||null,until:g||null},a=D({queryKey:["admin-claim-audit",s,r],queryFn:()=>w({data:{search:s.search||void 0,event:s.event,since:s.since,until:s.until,page:r,pageSize:j}})});async function A(){f(!0);try{const t=await _({data:{search:s.search||void 0,event:s.event,since:s.since,until:s.until}}),c=new Blob([t.csv],{type:"text/csv;charset=utf-8"}),n=URL.createObjectURL(c),l=document.createElement("a");l.href=n,l.download=`claim-code-audit-${new Date().toISOString().slice(0,10)}.csv`,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(n)}finally{f(!1)}}function U(t){t.preventDefault(),o(1),a.refetch()}const v=a.data?.rows??[],d=a.data?.total??0,x=Math.max(1,Math.ceil(d/j));return e.jsxs(F,{title:"Claim Code Audit",subtitle:"Every claim-code event across all athletes. Use filters to investigate suspicious activity.",actions:e.jsxs("button",{onClick:A,disabled:k||a.isLoading,className:"inline-flex items-center gap-2 border-2 border-ink bg-ink px-4 py-2 font-display text-sm tracking-wider text-bone disabled:opacity-50",children:[k?e.jsx(N,{className:"h-4 w-4 animate-spin"}):e.jsx(T,{className:"h-4 w-4"}),"Export CSV"]}),children:[e.jsxs("form",{onSubmit:U,className:"mb-4 grid gap-3 border-2 border-ink bg-bone p-4 md:grid-cols-[2fr_1fr_1fr_1fr_auto]",children:[e.jsxs("label",{className:"block text-sm",children:[e.jsx("span",{className:"mb-1 block font-display text-[10px] uppercase tracking-widest text-ink/60",children:"Athlete name or slug"}),e.jsxs("div",{className:"flex items-center gap-2 border-2 border-ink bg-bone px-2",children:[e.jsx(R,{className:"h-4 w-4 text-ink/50"}),e.jsx("input",{value:b,onChange:t=>C(t.target.value),placeholder:"e.g. Smith",className:"w-full bg-transparent py-2 outline-none"})]})]}),e.jsxs("label",{className:"block text-sm",children:[e.jsx("span",{className:"mb-1 block font-display text-[10px] uppercase tracking-widest text-ink/60",children:"Event"}),e.jsx("select",{value:u,onChange:t=>L(t.target.value),className:"w-full border-2 border-ink bg-bone px-3 py-2",children:B.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs("label",{className:"block text-sm",children:[e.jsx("span",{className:"mb-1 block font-display text-[10px] uppercase tracking-widest text-ink/60",children:"Since"}),e.jsx("input",{type:"datetime-local",value:h,onChange:t=>S(t.target.value),className:"w-full border-2 border-ink bg-bone px-3 py-2"})]}),e.jsxs("label",{className:"block text-sm",children:[e.jsx("span",{className:"mb-1 block font-display text-[10px] uppercase tracking-widest text-ink/60",children:"Until"}),e.jsx("input",{type:"datetime-local",value:g,onChange:t=>E(t.target.value),className:"w-full border-2 border-ink bg-bone px-3 py-2"})]}),e.jsx("button",{type:"submit",className:"self-end border-2 border-ink bg-ignition px-4 py-2 font-display text-sm tracking-wider text-bone",children:"Apply"})]}),e.jsxs("div",{className:"border-2 border-ink bg-bone",children:[e.jsxs("div",{className:"flex items-center justify-between border-b-2 border-ink/10 px-4 py-2 text-xs text-ink/60",children:[e.jsx("div",{children:a.isLoading?"Loading…":`${d.toLocaleStr
1ing()} event${d===1?"":"s"}`}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>o(t=>Math.max(1,t-1)),disabled:r===1||a.isLoading,className:"border-2 border-ink p-1 disabled:opacity-40",children:e.jsx(M,{className:"h-3 w-3"})}),e.jsxs("span",{className:"font-display text-[11px]",children:["Page ",r," / ",x]}),e.jsx("button",{onClick:()=>o(t=>Math.min(x,t+1)),disabled:r>=x||a.isLoading,className:"border-2 border-ink p-1 disabled:opacity-40",children:e.jsx(q,{className:"h-3 w-3"})})]})]}),a.isLoading?e.jsxs("div",{className:"flex items-center gap-2 p-6 text-sm text-ink/60",children:[e.jsx(N,{className:"h-4 w-4 animate-spin"})," Loading audit log…"]}):v.length===0?e.jsx("div",{className:"p-6 text-sm text-ink/60",children:"No events match these filters."}):e.jsxs("table",{className:"w-full border-collapse text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b-2 border-ink/10 text-left font-display text-[10px] uppercase tracking-widest text-ink/60",children:[e.jsx("th",{className:"px-4 py-2",children:"When"}),e.jsx("th",{className:"px-4 py-2",children:"Event"}),e.jsx("th",{className:"px-4 py-2",children:"Athlete"}),e.jsx("th",{className:"px-4 py-2",children:"Code"}),e.jsx("th",{className:"px-4 py-2",children:"Actor"}),e.jsx("th",{className:"px-4 py-2",children:"Detail"})]})}),e.jsx("tbody",{children:v.map(t=>{const c=V[t.event]??{text:t.event,tone:"bg-ink/5 text-ink"},n=t.athlete,l=t.metadata??{},$=Object.entries(l).filter(([p])=>p!=="expires_at").map(([p,m])=>`${p}: ${typeof m=="string"?m:JSON.stringify(m)}`).join(" · ");return e.jsxs("tr",{className:"border-b border-ink/5 align-top",children:[e.jsx("td",{className:"px-4 py-2 text-xs text-ink/70",children:new Date(t.created_at).toLocaleString()}),e.jsx("td",{className:"px-4 py-2",children:e.jsx("span",{className:`inline-block px-2 py-1 text-[10px] font-display uppercase tracking-widest ${c.tone}`,children:c.text})}),e.jsx("td",{className:"px-4 py-2 text-sm",children:n?e.jsxs("a",{href:`/athletes/${n.slug}`,target:"_blank",rel:"noreferrer",className:"hover:underline",children:[n.first_name," ",n.last_name]}):e.jsx("span",{className:"text-ink/40",children:"— (unknown code)"})}),e.jsx("td",{className:"px-4 py-2 font-mono text-xs text-ink/70",children:t.code_fingerprint??""}),e.jsx("td",{className:"px-4 py-2 font-mono text-[11px] text-ink/60",children:t.actor_user_id?`…${t.actor_user_id.slice(-8)}`:""}),e.jsx("td",{className:"px-4 py-2 text-xs text-ink/70",children:$||""})]},t.id)})})]})]})]})}export{Y as component};

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.