1import{r as m,j as e}from"./react-vendor-Dn21Q8Fs.js";import{u as p}from"./query-vendor-BOclGpT9.js";import{C as j,b as g,c as y,a as b}from"./card-C1awzoPj.js";import{T as w,a as E,b as u,c,d as N,e as d}from"./table-l9g054Pd.js";import{e as C,n as v,B as T}from"./index-PcgOL2Tp.js";import{aw as k,E as A,p as H}from"./icons-vendor-DsIwRmZp.js";import{f as S}from"./date-vendor-Dnln1Ij3.js";import"./jszip-vendor-Dj6QSqRp.js";import"./flow-vendor-By_djiIV.js";import"./radix-vendor-FugzqopL.js";import"./motion-vendor-BfbUKusM.js";const D="https://pictara-api.mute-dream-49e9.workers.dev";async function R(t){const a=t.status===404?"Contest submission is temporarily unavailable.":"Something went wrong. Please try again.";try{const n=await t.json(),s=new Error(n.error||a);return n.fieldErrors&&typeof n.fieldErrors=="object"&&(s.fieldErrors=n.fieldErrors),s}catch{return new Error(a)}}async function B(t,a={},n=!1){const s=new Headers({"Content-Type":"application/json"});if(a.headers&&new Headers(a.headers).forEach((i,l)=>{s.set(l,i)}),n){const i=C();if(!i)throw new Error("Not authenticated");s.set("Authorization",`Bearer ${i}`)}const o=await fetch(`${D}${t}`,{...a,headers:s});if(!o.ok)throw await R(o);return o.status===204?null:o.json()}async function x(t,a={}){return B(t,a,!0)}async function L(){return x("/admin/contest-submissions",{method:"GET"})}async function _(t){return x(`/admin/contest-submissions/${encodeURIComponent(t)}`,{method:"DELETE"})}const P=()=>{const{toast:t}=v(),[a,n]=m.useState(null),{data:s,error:o,isLoading:i,refetch:l}=p({queryKey:["contest-submissions"],queryFn:L});m.useEffect(()=>{o&&t({title:"Could not load submissions",description:o.message,variant:"destructive"})},[o,t]);const h=async r=>{n(r);try{await _(r),t({title:"Deleted"}),l()}catch(f){t({title:"Error",description:f.message,variant:"destructive"})}n(null)};return e.jsxs(j,{className:"bg-card border-border",children:[e.jsx(g,{children:e.jsxs(y,{className:"flex items-center gap-2 text-foreground",children:[e.jsx(k,{className:"h-5 w-5 text-primary"}),"Video Contest Submissions",s&&e.jsxs("span",{className:"text-sm font-normal text-muted-foreground ml-2",children:["(",s.length," total)"]})]})}),e.jsx(b,{children:i?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Loading..."}):o?e.jsx("p",{className:"text-destructive text-sm text-center py-8",children:"Couldnât load submissions."}):s!=null&&s.length?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(w,{children:[e.jsx(E,{children:e.jsxs(u,{children:[e.jsx(c,{children:"Name"}),e.jsx(c,{children:"Nickname"}),e.jsx(c,{children:"Email"}),e.jsx(c,{children:"Video"}),e.jsx(c,{children:"Date"}),e.jsx(c,{className:"w-12"})]})}),e.jsx(N,{children:s.map(r=>e.jsxs(u,{children:[e.jsx(d,{className:"font-medium text-foreground",children:r.name}),e.jsx(d,{className:"text-muted-foreground",children:r.nickname||"â"}),e.jsx(d,{className:"text-muted-foreground",children:r.email}),e.jsx(d,{children:e.jsxs("a",{href:r.video_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline inline-flex items-center gap-1 text-sm",children:["View ",e.jsx(A,{className:"h-3 w-3"})]})}),e.jsx(d,{className:"text-muted-foreground text-sm",children:S(new Date(r.created_at),"MMM d, yyyy HH:mm")}),e.jsx(d,{children:e.jsx(T,{variant:"ghost",size:"icon",onClick:()=>h(r.id),disabled:a===r.id,className:"text-destructive hover:text-destructive",children:e.jsx(H,{className:"h-4 w-4"})})})]},r.id))})]})}):e.jsx("p",{className:"text-muted-foreground text-sm text-center py-8",children:"No submissions yet."})})]})};export{P as AdminContestSubmissions};
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.