PageSourceSearch

https://mostreams-com.lovable.app/assets/moderation-pNEer5Hf.js

js mostreams-com.lovable.app collected 2026-10-03 03:35:49 UTC 4,066 bytes, 1 lines download raw bytes

1import{bz as j,r as n,j as t,bA as m,w as _,L as i,aE as N,s as o,v as l}from"./index-BNrdOJig.js";import{T as w}from"./trash-2-DqSHrMYS.js";function q(){const a=j(),[d,x]=n.useState("open"),[p,u]=n.useState([]),[g,f]=n.useState({}),c=async()=>{const{data:e}=await o.from("reports").select("*").eq("status",d).order("created_at",{ascending:!1});if(!e)return;u(e);const s={};for(const r of e){const v=r.target_type==="post"?"posts":r.target_type==="channel"?"channels":r.target_type==="track"?"tracks":r.target_type==="video"?"videos":"profiles",{data:y}=await o.from(v).select("*").eq("id",r.target_id).maybeSingle();s[r.id]=y}f(s)};if(n.useEffect(()=>{a?.role==="super_admin"&&c()},[d,a?.role]),a&&a.role!=="super_admin")return t.jsx(m,{profile:a,title:"Moderation",children:t.jsx("p",{className:"text-muted-foreground",children:"Admin only."})});const h=async e=>{const{error:s}=await o.from("reports").update({status:"approved",resolved_by:a?.id,resolved_at:new Date().toISOString()}).eq("id",e.id);s?l.error(s.message):(l.success("Marked approved"),c())},b=async e=>{const s=e.target_type==="post"?"posts":e.target_type==="channel"?"channels":e.target_type==="track"?"tracks":e.target_type==="video"?"videos":null;if(!s){l.error("Cannot remove this target type");return}s==="tracks"||s==="videos"?await o.from(s).update({removed:!0,status:"draft"}).eq("id",e.target_id):await o.from(s).delete().eq("id",e.target_id),await o.from("reports").update({status:"removed",resolved_by:a?.id,resolved_at:new Date().toISOString()}).eq("id",e.id),l.success("Content removed"),c()};return t.jsxs(m,{profile:a,title:"Moderation",subtitle:"Review and resolve reported content.",children:[t.jsx("div",{className:"flex gap-2 mb-6",children:["open","approved","removed"].map(e=>t.jsx("button",{onClick:()=>x(e),className:`px-4 py-2 rounded-full text-xs font-bold uppercase tracking-wider border ${d===e?"bg-primary/20 border-primary/40 text-primary":"border-border"}`,children:e},e))}),p.length===0&&t.jsx("p",{className:"text-muted-foreground",children:"Nothing here."}),t.jsx("ul",{className:"space-y-3",children:p.map(e=>{const s=g[e.id];return t.jsx("li",{className:"rounded-2xl border border-border bg-card p-5",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wider font-bold",children:[t.jsx(_,{className:"w-4 h-4 text-destructive"})," ",e.target_type,t.jsxs("span",{className:"text-muted-foreground",children:["· ",new Date(e.created_at).toLocaleString()]})]}),t.jsx("p",{className:"mt-2 text-sm",children:e.reason}),s&&t.jsxs("div",{className:"mt-3 rounded-xl bg-background border border-border p-3 text-xs text-muted-foreground",children:[t.jsx("div",{className:"font-bold text-foreground mb-1",children:s.title??s.name??s.display_name??s.body?.slice(0,80)??e.target_id}),e.target_type==="track"&&t.jsx(i,{to:"/tracks/$id",params:{id:e.target_id},className:"text-primary",children:"Open track →"}),e.target_type==="video"&&t.jsx(i,{to:"/videos/$id",params:{id:e.target_id},className:"text-primary",children:"Open video →"}),e.target_type==="profile"&&s?.handle&&t.jsx(i,{to:"/network/u/$handle",params:{handle:s.handle},className:"text-primary",children:"Open profile →"}),e.target_type==="channel"&&s?.slug&&t.jsx(i,{to:"/network/channels/$slug",params:{slug:s.slug},className:"text-primary",children:"Open channel →"})]})]}),d==="open"&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("button",{onClick:()=>h(e),className:"px-4 py-2 rounded-full bg-emerald-500/20 text-emerald-300 text-xs font-bold uppercase tracking-wider flex items-center gap-1",children:[t.jsx(N,{className:"w-3.5 h-3.5"})," Approve"]}),t.jsxs("button",{onClick:()=>b(e),className:"px-4 py-2 rounded-full bg-destructive/20 text-destructive text-xs font-bold uppercase tracking-wider flex items-center gap-1",children:[t.jsx(w,{className:"w-3.5 h-3.5"})," Remove"]})]})]})},e.id)})})]})}export{q 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.