1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BbwwgQ_I.js","assets/supabase-vendor-DZMyPAGe.js","assets/react-vendor-DxVGvRr9.js","assets/ui-vendor-DUcFxwzi.js","assets/query-vendor-KXAT96aZ.js","assets/i18n-vendor-bd6ZeL4K.js","assets/index-DpGCxJ4W.css"])))=>i.map(i=>d[i]); 2import{_ as e}from"./supabase-vendor-DZMyPAGe.js";import{j as t}from"./ui-vendor-DUcFxwzi.js";import{r as i,u as s}from"./react-vendor-DxVGvRr9.js";import{bz as r,u as a,s as n,B as c,X as o}from"./index-BbwwgQ_I.js";import{C as d,c as l}from"./card-8sY228PJ.js";import{A as h,a as m}from"./alert-Cz0WXtRr.js";import{T as u,a as p,b as j,c as x,d as v,e as f}from"./table-DpoW2_l-.js";import{A as g}from"./AdminLayout-CwK9f22L.js";import{g as w}from"./errors-B8upxaCP.js";import{u as _}from"./i18n-vendor-bd6ZeL4K.js";import{I as y}from"./info-Ci0MrpH3.js";import{C as N}from"./check-Bqlqrcep.js";import"./query-vendor-KXAT96aZ.js";import"./useResetKeyboardMode-DGhDsrkm.js";import"./arrow-left-BJRKEDn_.js";function b(){const[b,q]=i.useState([]),[A,S]=i.useState([]),[E,D]=i.useState(),{data:z}=r(E),[C,I]=i.useState(!0),O=s(),{toast:R}=a(),{t:k}=_(),L=(null==z?void 0:z.isAdmin)||!1;i.useEffect(()=>{(async()=>{const{getCachedOrFetchUserId:t}=await e(async()=>{const{getCachedOrFetchUserId:e}=await import("./index-BbwwgQ_I.js").then(e=>e.dH);return{getCachedOrFetchUserId:e}},__vite__mapDeps([0,1,2,3,4,5,6])),i=await t();i?(D(i),I(!1)):O("/auth")})()},[O]),i.useEffect(()=>{E&&z&&!z.isAdmin&&(R({title:k("common.error"),description:k("admin.accessDenied"),variant:"destructive"}),O("/app"))},[z,E,O,R,k]),i.useEffect(()=>{L&&(U(),F())},[L]);const U=async()=>{try{const{data:e,error:t}=await n.from("activity_submissions").select("*").eq("status","pending").order("created_at",{ascending:!1});if(t)throw t;q(e||[])}catch(e){R({title:"Error loading submissions",description:w(e),variant:"destructive"})}},F=async()=>{try{const{data:e,error:t}=await n.from("activity_deletion_requests").select("*").eq("status","pending").order("requested_at",{ascending:!1});if(t)throw t;S(e||[])}catch(e){R({title:"Error loading deletion requests",description:w(e),variant:"destructive"})}};return C?t.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):L?t.jsx(g,{title:"Pending Requests",children:t.jsx(d,{children:t.jsxs(l,{className:"space-y-6 pt-6",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Activity Submissions"}),t.jsxs(h,{className:"mb-4",children:[t.jsx(y,{className:"h-4 w-4"}),t.jsxs(m,{children:[t.jsx("strong",{children:"Auto-approval limits:"})," Organizations can post up to 5 activities per day and 10 per week without approval. Individual users can post 1 per day and 2 per week without approval."]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(u,{children:[t.jsx(p,{children:t.jsxs(j,{children:[t.jsx(x,{children:"Title"}),t.jsx(x,{children:"Organization"}),t.jsx(x,{children:"Date"}),t.jsx(x,{children:"Location"}),t.jsx(x,{children:"Submitted"}),t.jsx(x,{className:"text-right",children:"Actions"})]})}),t.jsx(v,{children:0===b.length?t.jsx(j,{children:t.jsx(f,{colSpan:6,className:"text-center text-muted-foreground",children:"No pending submissions"})}):b.map(e=>t.jsxs(j,{children:[t.jsx(f,{className:"font-medium",children:e.title}),t.jsx(f,{children:e.organization_name}),t.jsx(f,{children:e.date}),t.jsx(f,{children:e.location}),t.jsx(f,{children:new Date(e.created_at).toLocaleDateString()}),t.jsx(f,{className:"text-right",children:t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(c,{variant:"ghost",size:"icon",onClick:()=>(async e=>{try{const{error:t}=await n.from("activities").insert([{id:e.id,host_user_id:e.host_user_id,title:e.title,organization_name:e.organization_name,sport_type:e.sport_type,date:e.date,distance:e.distance,time:e.time,pace:e.pace,location:e.location,latitude:e.latitude,longitude:e.longitude,description:e.description,is_private:e.is_private,is_professional:e.is_professional,price_amount:e.price_amount,price_currency:e.price_currency}]);if(t)throw t;const{error:i}=await n.from("activity_submissions").update({status:"approved"}).eq("id",e.id);if(i)throw i;R({title:"Activity approved and published!"}),U()}catch(t){R({title:"Error approving activity",description:w(t),variant:"destructive"})}}
2)(e),title:"Approve",children:t.jsx(N,{className:"h-4 w-4 text-green-600"})}),t.jsx(c,{variant:"ghost",size:"icon",onClick:()=>(async e=>{try{const{error:t}=await n.from("activity_submissions").update({status:"rejected"}).eq("id",e);if(t)throw t;R({title:"Submission rejected"}),U()}catch(t){R({title:"Error rejecting submission",description:w(t),variant:"destructive"})}})(e.id),title:"Reject",children:t.jsx(o,{className:"h-4 w-4 text-red-600"})})]})})]},e.id))})]})})]}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Deletion Requests"}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(u,{children:[t.jsx(p,{children:t.jsxs(j,{children:[t.jsx(x,{children:"Activity Title"}),t.jsx(x,{children:"Reason"}),t.jsx(x,{children:"Participants"}),t.jsx(x,{children:"Requested"}),t.jsx(x,{className:"text-right",children:"Actions"})]})}),t.jsx(v,{children:0===A.length?t.jsx(j,{children:t.jsx(f,{colSpan:5,className:"text-center text-muted-foreground",children:"No pending deletion requests"})}):A.map(e=>t.jsxs(j,{children:[t.jsx(f,{className:"font-medium",children:e.activity_title}),t.jsx(f,{children:e.reason}),t.jsx(f,{children:e.participant_count}),t.jsx(f,{children:new Date(e.requested_at).toLocaleDateString()}),t.jsx(f,{className:"text-right",children:t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(c,{variant:"ghost",size:"icon",onClick:()=>(async e=>{try{const{data:{user:t}}=await n.auth.getUser();if(!t)throw new Error("Not authenticated");const{error:i}=await n.from("activities").delete().eq("id",e.activity_id);if(i)throw i;const{error:s}=await n.from("activity_deletion_requests").update({status:"approved",reviewed_at:(new Date).toISOString(),reviewed_by:t.id}).eq("id",e.id);if(s)throw s;R({title:"Activity deleted successfully!"}),F()}catch(t){R({title:"Error approving deletion",description:w(t),variant:"destructive"})}})(e),title:"Approve & Delete",children:t.jsx(N,{className:"h-4 w-4 text-green-600"})}),t.jsx(c,{variant:"ghost",size:"icon",onClick:()=>(async e=>{try{const{data:{user:t}}=await n.auth.getUser();if(!t)throw new Error("Not authenticated");const{error:i}=await n.from("activity_deletion_requests").update({status:"rejected",reviewed_at:(new Date).toISOString(),reviewed_by:t.id}).eq("id",e);if(i)throw i;R({title:"Deletion request rejected"}),F()}catch(t){R({title:"Error rejecting deletion",description:w(t),variant:"destructive"})}})(e.id),title:"Reject",children:t.jsx(o,{className:"h-4 w-4 text-red-600"})})]})})]},e.id))})]})})]})]})})}):null}export{b 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.