1import{b,r as h,d as g,t as r,j as t}from"./index-BllDdWz7.js";import{u as c}from"./useMutation-BJhod7fn.js";import{A as j}from"./AdminLayout-BAVvS6fw.js";const l="https://api.vidpipe.ai";function w(){const n=b(),[a,x]=h.useState("pending"),{data:u,isLoading:p}=g({queryKey:["admin-testimonials",a],queryFn:async()=>{const e=a==="all"?`${l}/api/testimonials`:`${l}/api/testimonials?status=${a}`,s=await fetch(e,{credentials:"include"});if(!s.ok)throw new Error("Failed to load");return s.json()}}),i=c({mutationFn:async({id:e,status:s})=>{const m=await fetch(`${l}/api/testimonials/${e}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:s})});if(!m.ok)throw new Error("Failed to update status");return m.json()},onSuccess:(e,s)=>{r.success(`Testimonial ${s.status}`),n.invalidateQueries({queryKey:["admin-testimonials"]})},onError:e=>r.error(e.message)}),d=c({mutationFn:async e=>{const s=await fetch(`${l}/api/testimonials/${e}`,{method:"DELETE",credentials:"include"});if(!s.ok)throw new Error("Failed to delete");return s.json()},onSuccess:()=>{r.success("Testimonial deleted"),n.invalidateQueries({queryKey:["admin-testimonials"]})},onError:e=>r.error(e.message)}),o=u?.testimonials||[];return t.jsx(j,{children:t.jsxs("div",{className:"max-w-5xl",children:[t.jsx("div",{className:"mb-6 flex items-center justify-between",children:t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-slate-900",children:"Testimonials"}),t.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Review user-submitted testimonials. Approved ones appear on the public marketing site."})]})}),t.jsx("div",{className:"mb-4 flex flex-wrap gap-2 text-sm",children:["pending","approved","rejected","hidden","all"].map(e=>t.jsx("button",{type:"button",onClick:()=>x(e),className:a===e?"rounded-full bg-slate-900 px-3 py-1 font-medium text-white":"rounded-full border border-slate-200 bg-white px-3 py-1 font-medium text-slate-700 hover:bg-slate-100",children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),p?t.jsx("div",{className:"rounded-xl border border-slate-200 bg-white p-8 text-center text-sm text-slate-500",children:"Loadingâ¦"}):o.length===0?t.jsx("div",{className:"rounded-xl border border-slate-200 bg-white p-8 text-center text-sm text-slate-500",children:"No testimonials in this status."}):t.jsx("div",{className:"space-y-4",children:o.map(e=>t.jsxs("article",{className:"rounded-xl border border-slate-200 bg-white p-5 shadow-sm",children:[t.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"text-sm font-semibold text-slate-900",children:[e.authorName,e.channelName?t.jsxs("span",{className:"ml-1.5 text-xs font-normal text-slate-500",children:["· ",e.channelName]}):null]}),t.jsxs("div",{className:"text-xs text-slate-500",children:[e.user.email," · ",new Date(e.createdAt).toLocaleString()]}),e.channelUrl?t.jsx("a",{href:e.channelUrl,target:"_blank",rel:"noreferrer noopener",className:"text-xs text-primary-600 hover:underline",children:e.channelUrl}):null]}),t.jsx(y,{status:e.status})]}),t.jsx("blockquote",{className:"text-sm leading-relaxed text-slate-800",children:e.content}),t.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.status!=="approved"?t.jsx("button",{type:"button",onClick:()=>i.mutate({id:e.id,status:"approved"}),disabled:i.isPending,className:"rounded-md bg-emerald-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-emerald-700 disabled:opacity-50",children:"Approve"}):null,e.status!=="hidden"?t.jsx("button",{type:"button",onClick:()=>i.mutate({id:e.id,status:"hidden"}),disabled:i.isPending,className:"rounded-md border border-slate-300 bg-white px-3 py-1.5 text-xs font-semibold text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:"Hide"}):null,e.status!=="rejected"?t.jsx("button",{type:"button",onClick:()=>i.mutate({id:e.id,status:"rejected"}),disabled:i.isPending,className:"rounded-md border border-amber-300 bg-amber-50 px-3 py-1.5 text-xs font-semibold text-amber-700 hover:bg-amber-100 disabled:opacity-50",children:"Reject"}):null,t.jsx("button",{type:"button",onClick:()=>{confirm("Delete this testimonial permanently?")&&d.mutate(e.id)},disabled:d.isPending,className:"rounded-md border border-rose-300 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700 hover:bg-rose-100 disabled:opacity-50",children:"Delete"})]})]},e.id))})]})})}function y({status:n}){const a={pending:"bg-amber-50 text-amber-700 ring-amber-200",approved:"bg-emerald-50 text-emerald-700 ring-emerald-200",rejected:"bg-slate-100 text-slate-600 ring-slate-200",hidden:"bg-slate-100 text-slate-600 ring-slate-200"}[n];return t.jsx("span",{className:`shrink-0 rounded-full px-2.5 py-0.5 text-[11px] font-semibold ring-1 ${a}`,children:n})}export{w 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.