1import{j as e,C as z,f as B,G as J,d as K,e as O,A as V,m as j,S as Y,a4 as Z,B as M,r as b,c as ee,a as te,X as se,k as x,I as ae}from"./index-IxvR3ybE.js";import{u as _}from"./use-mobile-DuMQ0aYp.js";import{L as F}from"./lightbulb-SYqac5W0.js";import{C as L}from"./clock-DaRv8o2j.js";import{C as P}from"./circle-check-big-DrZso9hg.js";import{A as re,a as ie,b as ne}from"./avatar-BaQ7HthH.js";import{B as le}from"./building-DgJOkNQe.js";import{C as oe}from"./circle-x-Dst20DfF.js";import{f as me}from"./format-DUXQdFez.js";import{E as D}from"./EventSelector-Bpv922Gw.js";import{P as ce}from"./PaymentGuard-CsV7Fhnv.js";import{P as de}from"./plus-ByP2IBiw.js";import"./en-US-CujKlCMr.js";import"./startOfWeek-CKe6unVT.js";import"./select-C66k4zpo.js";import"./index-BdQq_4o_.js";import"./index-PCA-xeVB.js";import"./chevron-up-Kie37_ZB.js";import"./usePaystackConfig-BiPyfAu1.js";import"./usePayment-DbOsPFvK.js";import"./loader-IuTMkbZP.js";import"./credit-card-CqkMcI0L.js";import"./useReferralCode-DoUD49Ha.js";import"./AccessCodeInput-MBolaJC1.js";import"./lock-open-BznoiT3l.js";import"./key-p_SgkhAy.js";const xe=[{key:"total",icon:F,bg:"from-blue-400 to-indigo-400",label:"Total Suggestions"},{key:"newCount",icon:L,bg:"from-orange-300 to-red-400",label:"New"},{key:"implemented",icon:P,bg:"from-green-300 to-emerald-400",label:"Implemented"}],ue=({total:t,newCount:o,implemented:u,loading:v})=>{const f={total:t,newCount:o,implemented:u},c=_();return e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 sm:gap-5",children:xe.map(m=>e.jsxs(z,{className:J("glass-card flex items-center p-3 sm:p-4 min-h-[72px] sm:min-h-[84px] relative",v&&"animate-pulse"),children:[e.jsx("div",{className:`bg-gradient-to-br ${m.bg} rounded-full p-2 sm:p-3 mr-3 sm:mr-4 flex items-center justify-center flex-shrink-0`,children:e.jsx(m.icon,{className:`text-white ${c?"w-4 h-4":"w-5 h-5"}`})}),e.jsxs(B,{className:"p-0 flex flex-col min-w-0 flex-1",children:[e.jsx("span",{className:`${c?"text-xl":"text-2xl"} font-bold`,children:v?"â":f[m.key]}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1 font-medium truncate",children:m.label})]})]},m.key))})},fe=({suggestion:t,onUpdateStatus:o,onDelete:u,selectedEventId:v,isDeleting:f})=>{var y,p;const c=((y=t.profile)==null?void 0:y.name)||"Anonymous User",m=(p=t.profile)==null?void 0:p.photo_url,i=_(),S=d=>{switch(d){case"new":return e.jsx(j,{className:"bg-blue-100 text-blue-800 text-xs",children:"New"});case"reviewed":return e.jsx(j,{className:"bg-yellow-100 text-yellow-800 text-xs",children:"Reviewed"});case"implemented":return e.jsx(j,{className:"bg-green-100 text-green-800 text-xs",children:"Implemented"});default:return e.jsx(j,{variant:"outline",className:"text-xs",children:d})}};return e.jsxs(z,{className:"glass-card overflow-hidden hover:shadow-xl transition-all",children:[e.jsxs(K,{className:`pb-2 flex ${i?"flex-col gap-3":"flex-row"} items-start justify-between`,children:[e.jsxs("div",{className:"flex items-center gap-3 w-full",children:[e.jsxs(re,{className:i?"w-8 h-8":"w-10 h-10",children:[e.jsx(ie,{src:m||""}),e.jsx(ne,{className:"text-xs",children:c.charAt(0)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(O,{className:`${i?"text-sm":"text-base"} truncate`,children:c}),e.jsx(V,{className:"text-xs",children:me(new Date(t.created_at),i?"MMM d, yyyy":"MMM d, yyyy h:mm a")})]})]}),e.jsxs("div",{className:`flex ${i?"flex-row flex-wrap justify-start w-full":"flex-col items-end"} gap-2`,children:[S(t.status),e.jsx(j,{variant:t.type==="rating"?"default":"outline",className:"text-xs",children:t.type==="rating"?"Rating":"Suggestion"}),!v&&t.event_name&&e.jsxs(j,{variant:"secondary",className:"flex items-center gap-1 text-xs max-w-full",children:[e.jsx(le,{size:10}),e.jsx("span",{className:"truncate",children:t.event_name})]})]})]}),e.jsxs(B,{className:"px-4 sm:px-6",children:[e.jsx("p",{className:`${i?"text-sm":"text-base"} mb-3 leading-relaxed`,children:t.content}),t.type==="rating"&&t.rating&&e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[[...Array(5)].map((d,n)=>e.jsx(Y,{size:i?14:16,className:n<t.rating?"fill-yellow-400 text-yellow-400":"text-gray-300"},n)),e.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:[t.rating,"/5 stars"]})]})]}),e.jsxs(Z,{className:`border-t pt-3 ${i?"flex-col gap-3":"flex-row justify-between"}`,children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:["ID: ",t.id.slice(0,8),"..."]}),e.jsxs("div",{className:`flex gap-2 ${i?"flex-col w-full":"flex-row"}`,children:[t.status==="new"&&e.jsxs(M,{size:"sm",variant:"outline",className:`text-yellow-600 border-yellow-200 hover:bg-yellow-50 ${i?"w-full justify-center":""}`,onClick:()=>o(t,"reviewed"),children:[e.jsx(L,{size:14,className:"mr-1"}),e.jsx("span",{className:"text-xs",children:"Mark Reviewed"})]}),t.status!=="implemented"&&e.jsxs(M,{size:"sm",variant:"outline",className:`text-green-600 border-green-200 hover:bg-green-50 ${i?"w-full justify-center":""}`,onClick:()=>o(t,"implemented"),children:[e.jsx(P,{size:14,className:"mr-1"}),e.jsx("span",{className:"text-xs",children:"Mark Implemented"})]}),e.jsxs(M,{size:"sm",variant:"outline",className:`text-destructive border-destructive/20 hover:bg-destructive/10 ${i?"w-full justify-center":""}`,onClick:()=>u(t),disabled:f,children:[e.jsx(oe,{size:14,className:"mr-1"}),e.jsx("span",{className:"text-xs",children:"Delete"})]})]})]})]})},pe=()=>
1{const[t,o]=b.useState("all"),[u,v]=b.useState(""),[f,c]=b.useState([]),[m,i]=b.useState(!0),[S,y]=b.useState(!1),{toast:p}=ee(),{currentUser:d}=te(),{selectedEventId:n,selectedEvent:w,adminEvents:R}=se(),T=_();b.useEffect(()=>{C();const s=x.channel("admin-suggestions-changes").on("postgres_changes",{event:"*",schema:"public",table:"suggestions"},()=>{C()}).subscribe();return()=>{x.removeChannel(s)}},[d,n]);const C=async()=>{if(d!=null&&d.id){i(!0);try{let s;if(n)s=x.from("suggestions").select("*").eq("event_id",n);else{const{data:r,error:h}=await x.from("events").select("id").eq("host_id",d.id);if(h)throw h;if(!r||r.length===0){c([]),i(!1);return}const $=r.map(W=>W.id);s=x.from("suggestions").select("*").in("event_id",$)}const{data:a,error:l}=await s.order("created_at",{ascending:!1});if(l)throw l;if(!a||a.length===0){c([]),i(!1);return}const g=[...new Set(a.map(r=>r.user_id).filter(Boolean))],{data:N}=await x.from("profiles").select("id, name, photo_url").in("id",g);let k=null;if(!n){const r=[...new Set(a.map($=>$.event_id).filter(Boolean))],{data:h}=await x.from("events").select("id, name").in("id",r);k=h}const E=new Map;
1N&&N.forEach(r=>{E.set(r.id,r)});const I=new Map;k&&k.forEach(r=>{I.set(r.id,r)});const H=a.map(r=>{var h;return{...r,type:r.type,status:r.status,profile:r.user_id&&E.get(r.user_id)||null,event_name:r.event_id?((h=I.get(r.event_id))==null?void 0:h.name)||"Unknown Event":void 0}});c(H)}catch{p({title:"Error",description:"Failed to fetch suggestions. Please try again.",variant:"destructive"})}finally{i(!1)}}},q=()=>{const s=f.length,a=f.filter(g=>g.status==="new").length,l=f.filter(g=>g.status==="implemented").length;return{total:s,newCount:a,implemented:l}},Q=()=>{let s=f;return t==="suggestions"&&(s=s.filter(a=>a.type==="suggestion")),t==="ratings"&&(s=s.filter(a=>a.type==="rating")),t==="new"&&(s=s.filter(a=>a.status==="new")),t==="reviewed"&&(s=s.filter(a=>a.status==="reviewed")),u&&(s=s.filter(a=>{var l,g,N;return((l=a.content)==null?void 0:l.toLowerCase().includes(u.toLowerCase()))||((N=(g=a.profile)==null?void 0:g.name)==null?void 0:N.toLowerCase().includes(u.toLowerCase()))})),s},G=async(s,a)=>{try{const{error:l}=await x.from("suggestions").update({status:a}).eq("id",s.id);if(l)throw l;p({title:"Success",description:`Suggestion marked as ${a}`}),C()}catch{p({title:"Error",description:"Failed to update suggestion",variant:"destructive"})}},U=async s=>{y(!0);try{const{error:a}=await x.from("suggestions").delete().eq("id",s.id);if(a)throw a;p({title:"Success",description:"Suggestion deleted successfully"}),C()}catch{p({title:"Error",description:"Failed to delete suggestion",variant:"destructive"})}finally{y(!1)}},X=q(),A=Q();return m?e.jsxs("div",{className:"space-y-8 animate-fade-in",children:[e.jsx("div",{className:"flex justify-between items-center",children:e.jsx(D,{})}),e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto"}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading suggestions..."})]})})]}):e.jsxs("div",{className:"space-y-6 sm:space-y-8 animate-fade-in px-4 sm:px-0",children:[e.jsx("div",{className:"flex justify-between items-center",children:e.jsx(D,{})}),R.length>0&&!n&&e.jsxs("div",{className:"text-center py-8 sm:py-12",children:[e.jsx("div",{className:"p-4 rounded-full bg-primary/10 inline-block mb-4",children:e.jsx(de,{className:"h-6 w-6 sm:h-8 sm:w-8 text-primary"})}),e.jsx("p",{className:"text-muted-foreground text-base sm:text-lg mb-2",children:"No event selected"}),e.jsx("p",{className:"text-sm text-muted-foreground px-4",children:"Please select an event above to view suggestions"})]}),n&&e.jsxs(ce,{eventId:n,eventName:(w==null?void 0:w.name)||"this event",feature:"Suggestions & Ratings",children:[e.jsxs("div",{className:"p-4 sm:p-6 lg:p-8 rounded-xl sm:rounded-2xl bg-gradient-to-br from-primary-100 via-blue-100 to-indigo-50 text-primary-900 dark:text-white shadow-lg sm:shadow-2xl shadow-primary/10 mb-2 relative overflow-hidden",children:[e.jsx("div",{className:"absolute -top-12 -right-10 w-32 h-32 sm:w-56 sm:h-56 bg-white/10 rounded-full opacity-40 blur-2xl pointer-events-none"}),e.jsx("div",{className:"absolute -bottom-14 -left-14 w-24 h-24 sm:w-36 sm:h-36 bg-white/20 rounded-full opacity-30 pointer-events-none"}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl lg:text-4xl font-bold tracking-tight",children:"Feedback Management"}),e.jsxs("p",{className:"mt-2 max-w-2xl text-sm sm:text-base text-primary-700 dark:text-primary-100",children:["Manage feedback and suggestions for"," ",e.jsx("span",{className:"font-semibold",children:w==null?void 0:w.name}),"."]}),e.jsx("div",{className:"mt-4 sm:mt-6",children:e.jsx(ue,{...X,loading:m})})]})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"text-center sm:text-left",children:[e.jsx("h2",{className:"text-xl sm:text-2xl font-bold",children:"Feedback"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"Review, filter, and manage suggestions and feedback."})]}),e.jsxs("div",{className:`flex gap-2 ${T?"flex-wrap justify-center":"flex-wrap"}`,children:[e.jsx("button",{onClick:()=>o("all"),className:`px-3 py-1.5 rounded-lg text-sm font-medium transition ${t==="all"?"bg-primary text-white":"bg-muted text-muted-foreground hover:bg-primary-50"}`,children:"All"}),e.jsx("button",{onClick:()=>o("suggestions"),className:`px-3 py-1.5 rounded-lg text-sm font-medium transition ${t==="suggestions"?"bg-primary text-white":"bg-muted text-muted-foreground hover:bg-primary-50"}`,children:"Suggestions"}),e.jsx("button",{onClick:()=>o("ratings"),className:`px-3 py-1.5 rounded-lg text-sm font-medium transition ${t==="ratings"?"bg-primary text-white":"bg-muted text-muted-foreground hover:bg-primary-50"}`,children:"Ratings"}),e.jsx("button",{onClick:()=>o("new"),className:`px-3 py-1.5 rounded-lg text-sm font-medium transition ${t==="new"?"bg-primary text-white":"bg-muted text-muted-foreground hover:bg-primary-50"}`,children:"New"}),e.jsx("button",{onClick:()=>o("reviewed"),className:`px-3 py-1.5 rounded-lg text-sm font-medium transition ${t==="reviewed"?"bg-primary text-white":"bg-muted text-muted-foreground hover:bg-primary-50"}`,children:"Reviewed"})]})]}),e.jsx("div",{className:"flex justify-center sm:justify-start mb-4",children:e.jsx(ae,{placeholder:"Search suggestions...",value:u,onChange:s=>v(s.target.value),className:"w-full sm:max-w-sm"})}),e.jsx("div",{className:"space-y-4",children:A.length>0?A.map(s=>e.jsx(fe,{suggestion:s,onUpdateStatus:G,onDelete:U,selectedEventId:n,isDeleting:S},s.id)):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(F,{className:"mx-auto h-10 w-10 sm:h-12 sm:w-12 text-muted-foreground opacity-30"}),e.jsx("h3",{className:"mt-4 text-base sm:text-lg font-medium",children:"No suggestions foun
1d"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 px-4",children:"No suggestions match your filter or search criteria."})]})})]})]})},Qe=pe;export{Qe 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.