module.exports=[35453,a=>{a.v({actionsBar:"reviews-module__ngcMdq__actionsBar",analyticsCard:"reviews-module__ngcMdq__analyticsCard",analyticsGrid:"reviews-module__ngcMdq__analyticsGrid",cardTitle:"reviews-module__ngcMdq__cardTitle",cardValue:"reviews-module__ngcMdq__cardValue",container:"reviews-module__ngcMdq__container",customerName:"reviews-module__ngcMdq__customerName",emptyState:"reviews-module__ngcMdq__emptyState",errorText:"reviews-module__ngcMdq__errorText",header:"reviews-module__ngcMdq__header",pageButton:"reviews-module__ngcMdq__pageButton",pageControls:"reviews-module__ngcMdq__pageControls",pagination:"reviews-module__ngcMdq__pagination",productName:"reviews-module__ngcMdq__productName",reviewCard:"reviews-module__ngcMdq__reviewCard",reviewComment:"reviews-module__ngcMdq__reviewComment",reviewDate:"reviews-module__ngcMdq__reviewDate",reviewHeader:"reviews-module__ngcMdq__reviewHeader",reviewsGrid:"reviews-module__ngcMdq__reviewsGrid",searchInput:"reviews-module__ngcMdq__searchInput",selectInput:"reviews-module__ngcMdq__selectInput",stars:"reviews-module__ngcMdq__stars",title:"reviews-module__ngcMdq__title"})},66230,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(33540),e=a.i(26634);let f=(0,a.i(64831).default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);var g=a.i(29562);let h=new class{async fetchVendorReviews(a){let{data:b,error:c}=await g.supabase.from("reviews").select(`
        *,
        products!inner (
          id,
          product_name,
          vendor_id
        ),
        users!left (
          id,
          email,
          name
        )
      `).eq("products.vendor_id",a).order("created_at",{ascending:!1});if(c)throw console.error("Error fetching reviews:",c),c;return b||[]}};var i=a.i(35453),j=a.i(31470);function k(){return(0,b.jsx)(j.default,{text:"Loading Reviews..."})}a.s(["default",0,function(){let[a,j]=(0,c.useState)(!1);(0,c.useEffect)(()=>{j(!0)},[]);let{data:l,analytics:m,loading:n,error:o,filters:p,pagination:q}=function(){let[a,b]=(0,c.useState)([]),[d,e]=(0,c.useState)(!0),[f,i]=(0,c.useState)(null),[j,k]=(0,c.useState)("all"),[l,m]=(0,c.useState)(""),[n,o]=(0,c.useState)(1);(0,c.useEffect)(()=>{p()},[]);let p=async()=>{try{e(!0),i(null);let{data:{user:a}}=await g.supabase.auth.getUser();if(!a)throw Error("Not authenticated");let{data:c,error:d}=await g.supabase.from("vendor_profiles").select("id").eq("user_id",a.id).single();if(d)throw d;if(!c)throw Error("Vendor profile not found");let f=await h.fetchVendorReviews(c.id);b(f)}catch(a){console.warn("Failed to load reviews:",a.message),i(`Failed to load reviews: ${a.message}`)}finally{e(!1)}},q=(0,c.useMemo)(()=>a.filter(a=>{let b=a.products?.product_name?.toLowerCase().includes(l.toLowerCase())||a.comment?.toLowerCase().includes(l.toLowerCase()),c=!0;return"all"!==j&&(c=a.rating===parseInt(j,10)),b&&c}),[a,l,j]),r=Math.ceil(q.length/10);return{data:q.slice((n-1)*10,10*n),analytics:(0,c.useMemo)(()=>{let b=a.length,c=0,d=0,e=0,f=0,g=0,h=0;a.forEach(a=>{c+=a.rating,5===a.rating&&d++,4===a.rating&&e++,3===a.rating&&f++,2===a.rating&&g++,1===a.rating&&h++});let i=b>0?(c/b).toFixed(1):0;return{total:b,averageRating:i,distribution:{5:d,4:e,3:f,2:g,1:h}}},[a]),loading:d,error:f,filters:{searchQuery:l,setSearchQuery:m,ratingFilter:j,setRatingFilter:k},pagination:{currentPage:n,setCurrentPage:o,totalPages:r},actions:{refresh:p}}}();return a?n&&0===l.length?(0,b.jsx)(k,{}):(0,b.jsxs)("div",{className:i.default.container,children:[(0,b.jsx)("div",{className:i.default.header,children:(0,b.jsxs)("div",{children:[(0,b.jsx)("h1",{className:i.default.title,children:"Customer Reviews"}),(0,b.jsx)("p",{style:{color:"var(--color-text-secondary)",marginTop:"4px"},children:"Monitor and manage customer feedback on your products."})]})}),o&&(0,b.jsx)("div",{className:i.default.errorText,children:o}),(0,b.jsxs)("div",{className:i.default.analyticsGrid,children:[(0,b.jsxs)("div",{className:i.default.analyticsCard,children:[(0,b.jsxs)("div",{className:i.default.cardTitle,children:[(0,b.jsx)(f,{size:16,style:{display:"inline",marginRight:8,verticalAlign:"middle"}}),"Total Reviews"]}),(0,b.jsx)("div",{className:i.default.cardValue,children:m.total})]}),(0,b.jsxs)("div",{className:i.default.analyticsCard,children:[(0,b.jsxs)("div",{className:i.default.cardTitle,children:[(0,b.jsx)(e.Star,{size:16,style:{display:"inline",marginRight:8,verticalAlign:"middle",color:"#fbbf24"}}),"Average Rating"]}),(0,b.jsxs)("div",{className:i.default.cardValue,children:[m.averageRating," / 5.0"]})]}),(0,b.jsx)("div",{className:i.default.analyticsCard,style:{flex:2,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:(0,b.jsxs)("div",{style:{flex:1},children:[(0,b.jsx)("div",{className:i.default.cardTitle,children:"Rating Distribution"}),(0,b.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4,marginTop:8},children:[5,4,3,2,1].map(a=>(0,b.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12},children:[(0,b.jsxs)("span",{children:[a," ★"]}),(0,b.jsx)("div",{style:{flex:1,height:6,background:"var(--color-border)",borderRadius:3,overflow:"hidden"},children:(0,b.jsx)("div",{style:{width:`${m.total>0?m.distribution[a]/m.total*100:0}%`,height:"100%",background:"#fbbf24"}})}),(0,b.jsx)("span",{style:{width:24,textAlign:"right"},children:m.distribution[a]})]},a))})]})})]}),(0,b.jsxs)("div",{className:i.default.actionsBar,children:[(0,b.jsxs)("div",{style:{position:"relative",flex:1,minWidth:"250px"},children:[(0,b.jsx)(d.Search,{size:18,style:{position:"absolute",left:12,top:12,color:"var(--color-text-secondary)"}}),(0,b.jsx)("input",{type:"text",placeholder:"Search reviews or products...",className:i.default.searchInput,style:{paddingLeft:40,width:"100%"},value:p.searchQuery,onChange:a=>p.setSearchQuery(a.target.value)})]}),(0,b.jsxs)("select",{className:i.default.selectInput,value:p.ratingFilter,onChange:a=>p.setRatingFilter(a.target.value),children:[(0,b.jsx)("option",{value:"all",children:"All Ratings"}),(0,b.jsx)("option",{value:"5",children:"5 Stars"}),(0,b.jsx)("option",{value:"4",children:"4 Stars"}),(0,b.jsx)("option",{value:"3",children:"3 Stars"}),(0,b.jsx)("option",{value:"2",children:"2 Stars"}),(0,b.jsx)("option",{value:"1",children:"1 Star"})]})]}),0===l.length?(0,b.jsx)("div",{className:i.default.emptyState,children:"No reviews found matching your criteria."}):(0,b.jsx)("div",{className:i.default.reviewsGrid,children:l.map(a=>(0,b.jsxs)("div",{className:i.default.reviewCard,children:[(0,b.jsxs)("div",{className:i.default.reviewHeader,children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:i.default.productName,children:a.products?.product_name||"Unknown Product"}),(0,b.jsxs)("div",{className:i.default.customerName,children:["By ",a.users?.name||a.users?.email||"Anonymous Customer"]})]}),(0,b.jsx)("div",{className:i.default.reviewDate,children:new Date(a.created_at).toLocaleDateString()})]}),(0,b.jsx)("div",{className:i.default.stars,children:[1,2,3,4,5].map(c=>(0,b.jsx)(e.Star,{size:16,fill:c<=a.rating?"#fbbf24":"none",color:c<=a.rating?"#fbbf24":"var(--color-border)"},c))}),a.comment&&(0,b.jsxs)("div",{className:i.default.reviewComment,children:['"',a.comment,'"']})]},a.id))}),q.totalPages>1&&(0,b.jsxs)("div",{className:i.default.pagination,children:[(0,b.jsxs)("span",{style:{color:"var(--color-text-secondary)",fontSize:14},children:["Showing Page ",q.currentPage," of ",q.totalPages]}),(0,b.jsxs)("div",{className:i.default.pageControls,children:[(0,b.jsx)("button",{className:i.default.pageButton,disabled:1===q.currentPage,onClick:()=>q.setCurrentPage(a=>a-1),children:"Previous"}),(0,b.jsx)("button",{className:i.default.pageButton,disabled:q.currentPage===q.totalPages,onClick:()=>q.setCurrentPage(a=>a+1),children:"Next"})]})]})]}):null}],66230)}];

//# sourceMappingURL=src_modules_reviews_01chwek._.js.map