1import{a as Z,a$ as ee,c as se,r as l,k as c,j as e,m as d,C as o,f as m,S as f,d as L,e as A,A as M,L as k,B}from"./index-IxvR3ybE.js";import{T as I}from"./textarea-DABzMORD.js";import{T as te,a as ae,b as C,c as E}from"./tabs-_QLeAqis.js";import{P as re}from"./progress-Ck7q00eU.js";import{M as R}from"./message-square-D78-i2rO.js";import{L as T}from"./lightbulb-SYqac5W0.js";import{T as P}from"./trending-up-NAysCqrH.js";import{C as D}from"./circle-check-big-DrZso9hg.js";import{S as ie}from"./send-ApBDavNU.js";import{C as ne}from"./clock-DaRv8o2j.js";const pe=()=>{const{currentUser:g}=Z(),{currentEventId:x}=ee(),{toast:u}=se(),[_,H]=l.useState([]),[a,q]=l.useState({total:0,new:0,reviewed:0,implemented:0,averageRating:0}),[$,J]=l.useState(!0),[p,j]=l.useState(!1),[b,F]=l.useState(""),[h,z]=l.useState(0),[U,Y]=l.useState("");l.useEffect(()=>{g&&(w(),N())},[g]);const w=async()=>{if(g)try{const s=await c.auth.getUser();if(!s.data.user)return;console.log("Fetching suggestions for user:",s.data.user.id);const{data:t,error:n}=await c.from("suggestions").select("*").eq("user_id",s.data.user.id).order("created_at",{ascending:!1});if(n)throw n;console.log("Fetched suggestions:",t);const y=(t||[]).map(r=>({id:r.id,content:r.content,type:r.type,rating:r.rating,status:r.status,created_at:r.created_at,user_id:r.user_id,event_id:r.event_id}));H(y)}catch(s){console.error("Error fetching suggestions:",s),u({title:"Error",description:"Failed to fetch your suggestions",variant:"destructive"})}finally{J(!1)}},N=async()=>{if(g)try{const s=await c.auth.getUser();if(!s.data.user)return;const{data:t,error:n}=await c.from("suggestions").select("*").eq("user_id",s.data.user.id);if(n)throw n;const y=(t==null?void 0:t.length)||0,r=(t==null?void 0:t.filter(i=>i.status==="new").length)||0,G=(t==null?void 0:t.filter(i=>i.status==="reviewed").length)||0,K=(t==null?void 0:t.filter(i=>i.status==="implemented").length)||0,S=(t==null?void 0:t.filter(i=>i.type==="rating"&&i.rating))||[],Q=S.length>0?S.reduce((i,X)=>i+(X.rating||0),0)/S.length:0;q({total:y,new:r,reviewed:G,implemented:K,averageRating:Math.round(Q*10)/10})}catch(s){console.error("Error fetching stats:",s)}},O=async()=>{if(!(!g||!b.trim())){if(!x){u({title:"Error",description:"You must be part of an event to submit suggestions",variant:"destructive"});return}j(!0);try{const s=await c.auth.getUser();if(!s.data.user)throw new Error("User not authenticated");console.log("Submitting suggestion for event:",x);const{error:t}=await c.from("suggestions").insert([{content:b.trim(),type:"suggestion",user_id:s.data.user.id,event_id:x,status:"new",rating:null}]);if(t)throw t;u({title:"Success",description:"Your suggestion has been submitted!"}),F(""),w(),N()}catch(s){console.error("Error submitting suggestion:",s),u({title:"Error",description:"Failed to submit suggestion",variant:"destructive"})}finally{j(!1)}}},V=async()=>{if(!(!g||h===0)){if(!x){u({title:"Error",description:"You must be part of an event to submit ratings",variant:"destructive"});return}j(!0);try{const s=await c.auth.getUser();if(!s.data.user)throw new Error("User not authenticated");console.log("Submitting rating for event:",x);const{error:t}=await c.from("suggestions").insert([{content:U.trim()||`Rated the event ${h} stars`,type:"rating",user_id:s.data.user.id,event_id:x,status:"new",rating:h}]);if(t)throw t;u({title:"Success",description:"Your rating has been submitted!"}),z(0),Y(""),w(),N()}catch(s){console.error("Error submitting rating:",s),u({title:"Error",description:"Failed to submit rating",variant:"destructive"})}finally{j(!1)}}},W=s=>{switch(s){case"new":return e.jsxs(d,{className:"bg-blue-100 text-blue-800",children:[e.jsx(ne,{className:"h-3 w-3 mr-1"}),"New"]});case"reviewed":return e.jsxs(d,{className:"bg-yellow-100 text-yellow-800",children:[e.jsx(P,{className:"h-3 w-3 mr-1"}),"Under Review"]});case"implemented":return e.jsxs(d,{className:"bg-green-100 text-green-800",children:[e.jsx(D,{className:"h-3 w-3 mr-1"}),"Implemented"]});default:return e.jsx(d,{variant:"outline",children:s})}},v=()=>a.total===0?0:(a.reviewed+a.implemented)/a.total*100;return $?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..."})]})}):x?e.jsx("div",{className:"container py-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"mb-8 relative overflow-hidden rounded-3xl bg-gradient-to-br from-indigo-600 via-purple-600 to-pink-500 p-6 sm:p-10 text-white z-10 shadow-xl",children:[e.jsx("div",{className:"absolute inset-0 bg-black/25 z-0"}),e.jsx("div",{className:"relative z-10",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-col items-center sm:items-start",children:[e.jsx("div",{className:"w-16 h-16 bg-white/20 rounded-full flex items-center justify-center mb-4",children:e.jsx(T,{className:"h-8 w-8 text-yellow-300"})}),e.jsx("h1",{className:"text-3xl sm:text-4xl font-bold mb-2",children:"Share Feedback"}),e.jsx("p",{className:"text-lg opacity-95 max-w-2xl",children:"Share your ideas and rate your event experience!"})]}),e.jsxs("div",{className:"flex flex-col items-center sm:items-end space-y-1 mt-4 sm:mt-0",children:[e.jsxs("div",{className:"flex space-x-2",children:[e.jsxs(d,{variant:"info",className:"font-medium",children:[a.implemented," Implemented"]}),e.jsxs(d,{variant:"warning",className:"font-medium",children:[a.new," New"]})]}),e.jsx("div",{children:e.jsxs(d,{variant:"success",className:"font-medium",children:[Math.round(v()),"% Progress"]})})]})]})}),e.jsx("div",{className:"absolute -bottom-12 -right-12 w-44 h-44 bg-white/10 rounded-full z-0"}),e.jsx("div",{className:"absolute -top-12 -left-12 w-60 h-60 bg-white/5 rounded-full z-0"})]}),e.jsx("div",{className:"relative mb-8 z-0 mt-4",children:e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 sm:gap-4",children:[e.jsx(o,{className:"p-3 sm:p-4 shadow-md hover:shadow-xl transition-all duration-200 rounded-2xl bg-white/90 backdrop-blur-sm border-0",children:e.jsx(m,{className:"p-0",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"Total"}),e.jsx("p",{className:"text-lg sm:text-2xl font-bold",children:a.total})]}),e.jsx(R,{className:"h-6 w-6 sm:h-8 sm:w-8 text-blue-500"})]})})}),e.jsx(o,{className:"p-3 sm:p-4 shadow-md hover:shadow-xl transition-all duration-200 rounded-2xl bg-white/90 backdrop-blur-sm border-0",children:e.jsxs(m,{className:"p-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"Progress"}),e.jsxs("p",{className:"text-lg sm:text-2xl font-bold",children:[Math.round(v()),"%"]})]}),e.jsx(P,{className:"h-6 w-6 sm:h-8 sm:w-8 text-green-500"})]}),e.jsx(re,{value:v(),className:"mt-2 h-1"})]})}),e.jsx(o,{className:"p-3 sm:p-4 shadow-md hover:shadow-xl transition-all duration-200 rounded-2xl bg-white/90 backdrop-blur-sm border-0",children:e.jsx(m,{className:"p-0",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"Implemented"}),e.jsx("p",{className:"text-lg sm:text-2xl font-bold",children:a.implemented})]}),e.jsx(D,{className:"h-6 w-6 sm:h-8 sm:w-8 text-green-500"})]})})}),e.jsx(o,{className:"p-3 sm:p-4 shadow-md hover:shadow-xl transition-all duration-200 rounded-2xl bg-white/90 backdrop-blur-sm border-0",children:e.jsx(m,{className:"p-0",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"Avg Rating"}),e.jsx("p",{className:"text-lg sm:text-2xl font-bold",children:a.averageRating})]}),e.jsx(f,{className:"h-6 w-6 sm:h-8 sm:w-8 text-yellow-500"})]})})})]})}),e.jsx("div",{className:"w-full",children:e.jsxs(te,{defaultValue:"suggest",className:"w-full",children:[e.jsxs(ae,{className:"grid w-full grid-cols-3 mb-6 bg-white/80 rounded-xl shadow-md",children:[e.jsx(C,{value:"suggest",className:"text-xs sm:text-sm",children:"Make Suggestion"}),e.jsx(C,{value:"rate",className:"text-xs sm:text-sm",children:"Rate Event"}),e.jsxs(C,{value:"history",className:"text-xs sm:text-sm",children:["History (",a.total,")"]})]}),e.jsx(E,{value:"suggest",className:"space-y-4",children:e.jsxs(o,{className:"rounded-2xl shadow-lg bg-white/95 backdrop-blur-sm border-0",children:[e.jsxs(L,{className:"pb-4",children:[e.jsxs(A,{className:"flex items-center gap-2 text-lg sm:text-xl",children:[e.jsx(T,{className:"h-4 w-4 sm:h-5 sm:w-5 text-connect-600"}),"Share Your Ideas"]}),e.jsx(M,{className:"text-sm",children:"Help us improve future events with your suggestions"})]}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(k,{htmlFor:"suggestion",className:"text-sm",children:"Your Suggestion"}),e.jsx(I,{id:"suggestion",placeholder:"What improvements or new features would you like to see?",value:b,onChange:s=>F(s.target.value),rows:4,className:"mt-2"})]}),e.jsxs("div",{className:"space-y-2 bg-gray-50 dark:bg-gray-800 p-3 rounded-lg",children:[e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground font-medium",children:"Suggestion tips:"}),e.jsxs("ul",{className:"text-xs sm:text-sm text-muted-foreground space-y-1",children:[e.jsx("li",{children:"⢠Be specific and actionable"}),e.jsx("li",{children:"⢠Explain the benefit of your suggestion"}),e.jsx("li",{children:"⢠Consider feasibility and impact"})]})]}),e.jsxs(B,{onClick:O,disabled:!b.trim()||p,className:"w-full sm:w-auto",size:"sm",children:[e.jsx(ie,{className:"h-4 w-4 mr-2"}),p?"Submitting...":"Submit Suggestion"]})]})]})}),e.jsx(E,{value:"rate",className:"space-y-4",children:e.jsxs(o,{className:"rounded-2xl shadow-lg bg-white/95 backdrop-blur-sm border-0",children:[e.jsxs(L,{className:"pb-4",children:[e.jsxs(A,{className:"flex items-center gap-2 text-lg sm:text-xl",children:[e.jsx(f,{className:"h-4 w-4 sm:h-5 sm:w-5 text-connect-600"}),"Rate This Event"]}),e.jsx(M,{className:"text-sm",children:"How would you rate your overall experience?"})]}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-sm",children:"Your Rating"}),e.jsx("div",{className:"flex items-center gap-1 mt-2",children:[1,2,3,4,5].map(s=>e.jsx("button",{onClick:()=>z(s),className:"focus:outline-none transition-colors p-1",children:e.jsx(f,{size:28,className:s<=h?"fill-yellow-400 text-yellow-400":"text-gray-300 hover:text-yellow-300"})},s))}),h>0&&e.jsxs("p",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:["You rated: ",h,"/5 stars"]})]}),e.jsxs("div",{children:[e.jsx(k,{htmlFor:"feedback",className:"text-sm",children:"Additional Feedback (Optional)"}),e.jsx(I,{id:"feedback",placeholder:"Tell us more about your experience...",value:U,onChange:s=>Y(s.target.value),rows:3,className:"mt-2"})]}),e.jsxs(B,{onClick:V,disabled:h===0||p,className:"w-full sm:w-auto",size:"sm",children:[e.jsx(f,{className:"h-4 w-4 mr-2"}),p?"Submitting...":"Submit Rating"]})]})]})}),e.jsx(E,{value:"history",className:"space-y-4",children:_.length>0?e.jsx("div",{className:"space-y-3 sm:space-y-4",children:_.map(s=>e.jsx(o,{className:"hover:shadow-lg rounded-2xl transition-shadow border-0 bg-white/95 backdrop-blur",children:e.jsxs(m,{className:"pt-4 sm:pt-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-start gap-3 mb-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(d,{variant:s.type==="rating"?"default":"outline",className:"text-xs",children:s.type==="rating"?e.jsxs(e.Fragment,{children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),"Rating"]}):e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"h-3 w-3 mr-1"}),"Suggestion"]})}),W(s.status)]}),e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground",children:new Date(s.created_at).toLocaleDateString()})]}),e.jsx("p",{className:"text-sm sm:text-base text-gray-800 dark:text-gray-200 mb-3 break-words",children:s.content}),s.type==="rating"&&s.rating&&e.jsxs("div",{className:"flex items-center gap-1",children:[[...Array(5)].map((t,n)=>e.jsx(f,{size:14,className:n<s.rating?"fill-yellow-400 text-yellow-400":"text-gray-300"},n)),e.jsxs("span",{className:"ml-2 text-xs sm:text-sm text-muted-foreground",children:[s.rating,"/5 stars"]})]})]})},s.id))}):e.jsx(o,{children:e.jsxs(m,{className:"py-10 text-center text-muted-foreground",children:[e.jsx(R,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"text-sm sm:text-base",children:"You haven't submitted any suggestions or ratings yet."}),e.jsx("p",{className:"text-xs sm:text-sm mt-1",children:"Use the tabs above to share your feedback!"})]})})})]})})]})}):e.jsx("div",{className:"animate-fade-in max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(R,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Join an Event First"}),e.jsx("p",{className:"text-muted-foreground",children:"You need to join an event before you can submit suggestions and ratings."})]})})};export{pe 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.