1import{r as _,j as e,i as d,o as g,p as v,l as o,k as c,B as i,L as N,ak as k,X as M,ad as w}from"./index-Bj3g7Z6n.js";import{d as z,e as T,f as P}from"./useRetailerReviews-CHws5xj3.js";import{A as E,a as S,b as B}from"./avatar-BLrjWkok.js";import{A as F,a as L,b as $,c as H,d as U,e as q,f as I,g as V,h as X}from"./alert-dialog-CCwV5umb.js";import{E as G}from"./eye-C93GB6sI.js";import{T as J}from"./trash-2-C3_qP8oE.js";import{M as K}from"./message-square-CPPHq-BU.js";import{f as O}from"./format-B7hN-bk8.js";import"./index-BanJ7jo1.js";import"./en-US-ClfMaaVW.js";import"./differenceInCalendarDays-DauCbfGV.js";import"./normalizeDates-DzYoqby6.js";function de(){const{data:a,isLoading:b}=z(),l=T(),A=P(),[r,n]=_.useState("pending"),p=(a==null?void 0:a.filter(s=>r==="all"?!0:r==="pending"?s.is_approved===!1:r==="approved"?s.is_approved===!0:!1))||[],y=s=>{l.mutate({reviewId:s,approved:!0})},R=s=>{l.mutate({reviewId:s,approved:!1})},C=s=>{A.mutate(s)},D=s=>e.jsx("div",{className:"flex",children:[1,2,3,4,5].map(t=>e.jsx(w,{className:`w-4 h-4 ${t<=s?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`},t))});if(b)return e.jsxs(d,{children:[e.jsx(g,{children:e.jsx(v,{children:"Retailer Reviews Management"})}),e.jsx(o,{children:e.jsx("div",{className:"space-y-4",children:[...Array(5)].map((s,t)=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-20 bg-muted rounded"})},t))})})]});const m=(a==null?void 0:a.filter(s=>!s.is_approved).length)||0,x=(a==null?void 0:a.filter(s=>s.is_approved).length)||0;return e.jsxs(d,{children:[e.jsx(g,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(v,{children:"Retailer Reviews Management"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(c,{variant:r==="pending"?"default":"outline",children:["Pending (",m,")"]}),e.jsxs(c,{variant:r==="approved"?"default":"outline",children:["Approved (",x,")"]})]})]})}),e.jsxs(o,{children:[e.jsxs("div",{className:"flex gap-2 mb-6",children:[e.jsxs(i,{variant:r==="pending"?"default":"outline",size:"sm",onClick:()=>n("pending"),children:["Pending (",m,")"]}),e.jsxs(i,{variant:r==="approved"?"default":"outline",size:"sm",onClick:()=>n("approved"),children:["Approved (",x,")"]}),e.jsxs(i,{variant:r==="all"?"default":"outline",size:"sm",onClick:()=>n("all"),children:["All (",(a==null?void 0:a.length)||0,")"]})]}),p.length>0?e.jsx("div",{className:"space-y-4",children:p.map(s=>{var t,h,u,j,f;return e.jsx(d,{className:"border-l-4 border-l-primary/20",children:e.jsx(o,{className:"p-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[e.jsxs(E,{children:[e.jsx(S,{src:(t=s.profiles)==null?void 0:t.avatar_url}),e.jsx(B,{children:(((h=s.profiles)==null?void 0:h.display_name)||((u=s.profiles)==null?void 0:u.username)||"U").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:((j=s.profiles)==null?void 0:j.display_name)||((f=s.profiles)==null?void 0:f.username)||"Anonymous"}),D(s.rating),e.jsx(c,{variant:s.is_approved?"default":"destructive",className:"text-xs",children:s.is_approved?"Approved":"Pending"})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-2",children:[e.jsx(N,{to:`/retailer/${s.retailers.slug}`,className:"hover:text-primary transition-colors font-medium",children:s.retailers.name}),e.jsx("span",{children:O(new Date(s.created_at),"MMM d, yyyy")})]}),s.review_text&&e.jsx("p",{className:"text-foreground whitespace-pre-wrap mb-3",children:s.review_text})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 pt-2 border-t border-border",children:[e.jsx(N,{to:`/retailer/${s.retailers.slug}`,children:e.jsxs(i,{variant:"ghost",size:"sm",children:[e.jsx(G,{className:"w-4 h-4 mr-1"}),"View Retailer"]})}),!s.is_approved&&e.jsxs(i,{size:"sm",onClick:()=>y(s.id),disabled:l.isPending,children:[e.jsx(k,{className:"w-4 h-4 mr-1"}),"Approve"]}),s.is_approved&&e.jsxs(i,{size:"sm",variant:"outline",onClick:()=>
1R(s.id),disabled:l.isPending,children:[e.jsx(M,{className:"w-4 h-4 mr-1"}),"Reject"]}),e.jsxs(F,{children:[e.jsx(L,{asChild:!0,children:e.jsxs(i,{variant:"destructive",size:"sm",children:[e.jsx(J,{className:"w-4 h-4 mr-1"}),"Delete"]})}),e.jsxs($,{children:[e.jsxs(H,{children:[e.jsx(U,{children:"Delete Review"}),e.jsx(q,{children:"Are you sure you want to delete this review? This action cannot be undone."})]}),e.jsxs(I,{children:[e.jsx(V,{children:"Cancel"}),e.jsx(X,{onClick:()=>C(s.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]})})},s.id)})}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(K,{className:"w-16 h-16 mx-auto mb-4 opacity-50"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:r==="pending"?"No pending reviews":r==="approved"?"No approved reviews":"No reviews found"}),e.jsx("p",{children:r==="pending"?"All retailer reviews have been moderated.":r==="approved"?"No retailer reviews have been approved yet.":"No retailer reviews have been submitted yet."})]})]})]})}export{de 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.