PageSourceSearch

https://stepily.com/assets/AdminReports-7r2MSTSQ.js

js stepily.com collected 2026-10-02 01:45:04 UTC 3,063 bytes, 1 lines download raw bytes

1import{h as C,n as k,k as _,r as n,s as m,j as s,au as R,t as E,v as S,w as T,J as L,U as z,y as u,C as A,Y as D,_ as v}from"./index-Dmz6Wrx6.js";import{E as B}from"./eye-C9rt2ORG.js";const I=()=>{const{t}=C(),{isAdmin:d,loading:o}=k(),c=_(),[x,N]=n.useState([]),[b,l]=n.useState(!0),[w,y]=n.useState({});n.useEffect(()=>{!o&&!d&&c("/")},[d,o,c]),n.useEffect(()=>{d&&p()},[d]);const p=async()=>{l(!0);const{data:e,error:a}=await m.from("tutorial_reports").select("*").order("created_at",{ascending:!1});if(a){console.error("Error fetching reports:",a),l(!1);return}N(e||[]);const r=[...new Set((e||[]).map(i=>i.tutorial_id))];if(r.length>0){const{data:i}=await m.from("tutorials").select("id, title").in("id",r),g={};i==null||i.forEach(j=>{g[j.id]=j.title}),y(g)}l(!1)},h={pending:t("adminReports.statuses.pending"),actioned:t("adminReports.statuses.actioned"),dismissed:t("adminReports.statuses.dismissed")},f=async(e,a)=>{const{error:r}=await m.from("tutorial_reports").update({status:a,reviewed_at:new Date().toISOString()}).eq("id",e);if(r){v.error(t("adminReports.toasts.updateFailed"));return}v.success(t("adminReports.toasts.reportMarkedAs",{status:h[a]??a})),p()};return o||b?s.jsxs("div",{className:"min-h-screen bg-background",children:[s.jsx(R,{}),s.jsx("div",{className:"container py-16 text-center text-muted-foreground",children:t("adminReports.loading")})]}):s.jsxs("div",{className:"min-h-screen bg-background",children:[s.jsx(R,{}),s.jsxs("div",{className:"container py-8 px-4 md:px-8 max-w-4xl",children:[s.jsx("h1",{className:"text-3xl font-bold mb-6",children:t("adminReports.heading")}),x.length===0?s.jsx("p",{className:"text-muted-foreground",children:t("adminReports.noReports")}):s.jsx("div",{className:"space-y-4",children:x.map(e=>s.jsxs(E,{children:[s.jsx(S,{className:"pb-2",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(T,{className:"text-base",children:w[e.tutorial_id]||t("adminReports.unknownTutorial")}),s.jsx(L,{variant:e.status==="pending"?"destructive":e.status==="dismissed"?"secondary":"default",children:h[e.status]??e.status})]})}),s.jsxs(z,{children:[s.jsx("p",{className:"text-sm font-medium mb-1",children:e.reason}),e.details&&s.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:e.details}),s.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:t("adminReports.reportedOn",{date:new Date(e.created_at).toLocaleDateString()})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(u,{size:"sm",variant:"outline",onClick:()=>c(`/t/${e.tutorial_id}`),children:[s.jsx(B,{className:"w-3 h-3 mr-1"})," ",t("adminReports.buttons.view")]}),e.status==="pending"&&s.jsxs(s.Fragment,{children:[s.jsxs(u,{size:"sm",variant:"destructive",onClick:()=>f(e.id,"actioned"),children:[s.jsx(A,{className:"w-3 h-3 mr-1"})," ",t("adminReports.buttons.action")]}),s.jsxs(u,{size:"sm",variant:"secondary",onClick:()=>f(e.id,"dismissed"),children:[s.jsx(D,{className:"w-3 h-3 mr-1"})," ",t("adminReports.buttons.dismiss")]})]})]})]})]},e.id))})]})]})};export{I 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.