1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4451],{89168:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/reviews",function(){return s(37267)}])},37267:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return j}});var a=s(85893),i=s(67294),n=s(9008),l=s.n(n),r=s(25675),d=s.n(r),o=s(11163),c=s(85412),x=s(67694),m=s(61258),h=s(9475),p=s(60641),u=s(8267),b=s(70088),g=s(60493),f=s(37864),y=s(43832),w=s(15928);function j(){let{theme:e}=(0,x.F)(),t=(0,o.useRouter)(),[s,n]=(0,i.useState)(""),[r,j]=(0,i.useState)("pending"),[v,N]=(0,i.useState)([]),[k,F]=(0,i.useState)({pending:0,published:0,liveOnSite:0}),[S,C]=(0,i.useState)(!0),[Z,_]=(0,i.useState)(""),[D,E]=(0,i.useState)(null),A=(0,i.useCallback)(async(e,s)=>{C(!0),_("");try{var a,i,n,l;let r=await fetch("/api/admin/reviews?status=".concat("pending"===s?"pending":"published","&limit=60"),{headers:{"x-admin-key":e},credentials:"include"});if(401===r.status||403===r.status){localStorage.removeItem("admin_key"),t.push("/admin");return}let d=await r.json().catch(()=>({}));if(!r.ok)throw Error(d.message||d.error||"HTTP ".concat(r.status));N(d.reviews||[]),d.counts&&F({pending:null!==(a=d.counts.pending)&&void 0!==a?a:0,published:null!==(i=d.counts.published)&&void 0!==i?i:0,liveOnSite:null!==(l=null!==(n=d.counts.liveOnSite)&&void 0!==n?n:d.counts.published)&&void 0!==l?l:0})}catch(e){_((null==e?void 0:e.message)||"Failed to load reviews")}finally{C(!1)}},[t]);(0,i.useEffect)(()=>{let e=localStorage.getItem("admin_key");if(!e){t.push("/admin");return}n(e),A(e,r)},[t,r,A]);let O=async(e,t)=>{let a=s||localStorage.getItem("admin_key")||"";E({id:e,action:t}),_("");try{let s=await fetch("/api/admin/reviews",{method:"POST",headers:{"Content-Type":"application/json","x-admin-key":a},credentials:"include",body:JSON.stringify({id:e,action:t})}),i=await s.json();if(!s.ok)throw Error(i.message||i.error||"action_failed");await A(a,r)}catch(e){_((null==e?void 0:e.message)||"Action failed")}finally{E(null)}},T=(e,t)=>(null==D?void 0:D.id)===e&&(null==D?void 0:D.action)===t,P=null!==D,I="dark"===e?"glass glass-dark":"glass";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l(),{children:(0,a.jsx)("title",{children:"Customer reviews â Admin"})}),(0,a.jsx)(c.Z,{}),(0,a.jsx)("div",{className:"min-h-screen pt-16 ".concat("dark"===e?"bg-[#030303] text-[#F4F7F9]":"bg-gray-50 text-gray-900"),children:(0,a.jsxs)("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 py-8",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>t.push("/admin"),className:"flex items-center gap-2 text-sm font-medium mb-6 ".concat("dark"===e?"text-[#818384] hover:text-white":"text-gray-600 hover:text-gray-900"),children:[(0,a.jsx)(m.Z,{className:"w-4 h-4"}),"Back to dashboard"]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end sm:justify-between gap-4 mb-8",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("h1",{className:"text-sharp text-3xl font-bold",style:{fontFamily:"Rajdhani, sans-serif"},children:"Customer reviews"}),(0,a.jsxs)("button",{type:"button",onClick:()=>A(s,r),disabled:S,title:"Refresh",className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs font-medium border transition-colors ".concat("dark"===e?"border-[#343536] text-[#818384] hover:text-white hover:border-[#FF4500]":"border-gray-200 text-gray-500 hover:text-gray-900 hover:border-[#FF4500]"," disabled:opacity-50"),children:[(0,a.jsx)(m.Z,{className:"w-3.5 h-3.5 rotate-90 ".concat(S?"animate-spin":"")}),"Refresh"]})]}),(0,a.jsxs)("p",{className:"text-sm mt-1 ".concat("dark"===e?"text-[#818384]":"text-gray-600"),children:["Approve to publish, hide to remove from the site without deleting, show to re-enable, or delete permanently."," ",(0,a.jsx)("span",{className:"font-medium text-[#FF4500]",children:k.liveOnSite})," visible on site now."]})]}),(0,a.jsxs)("div",{className:"inline-flex rounded-xl p-1 border ".concat("dark"===e?"border-[#343536] bg-[#1A1A1B]":"border-[#EDEFF1] bg-white"),children:[(0,a.jsxs)("button",{type:"button",onClick:()=>j("pending"),className:"px-4 py-2 rounded-lg text-sm font-semibold transition-colors ".concat("pending"===r?"bg-[#FF4500] text-white":"dark"===e?"text-[#818384] hover:text-white":"text-gray-600 hover:text-gray-900"),children:["Pending (",k.pending,")"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>j("published"),className:"px-4 py-2 rounded-lg text-sm font-semibold transition-colors ".concat("published"===r?"bg-[#FF4500] text-white":"dark"===e?"text-[#818384] hover:text-white":"text-gray-600 hover:text-gray-900"),children:["Published (",k.published,")"]})]})]}),Z?(0,a.jsxs)("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-red-500 text-sm",children:[(0,a.jsx)(h.Z,{className:"w-4 h-4 shrink-0"}),(0,a.jsx)("span",{className:"break-all",children:Z})]}),(0,a.jsx)("button",{type:"button",onClick:()=>A(s,r),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold bg-[#FF4500] text-white hover:bg-[#
1E03D00]",children:"Retry"})]}):null,S?(0,a.jsx)("div",{className:"flex justify-center py-20",children:(0,a.jsx)(p.Z,{className:"w-10 h-10 animate-spin text-[#FF4500]"})}):0===v.length?(0,a.jsx)("div",{className:"".concat(I," rounded-2xl p-10 text-center"),children:(0,a.jsx)("p",{className:"dark"===e?"text-[#818384]":"text-gray-600",children:"pending"===r?"No reviews waiting for approval.":"No published reviews yet."})}):(0,a.jsx)("ul",{className:"space-y-4",children:v.map(t=>(0,a.jsx)("li",{className:"".concat(I," rounded-2xl p-5 shadow-premium"),children:(0,a.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)("div",{className:"w-20 h-20 rounded-2xl overflow-hidden flex items-center justify-center ".concat("dark"===e?"bg-[#272729]":"bg-gray-100"),children:t.photoUrl?(0,a.jsx)(d(),{src:t.photoUrl,alt:"",width:80,height:80,className:"w-full h-full object-cover",unoptimized:!0}):(0,a.jsx)(u.Z,{className:"h-9 w-9 ".concat("dark"===e?"text-[#818384]":"text-gray-400"),"aria-hidden":!0})})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0 space-y-2",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"font-bold text-lg ".concat("dark"===e?"text-white":"text-gray-900"),children:t.displayName}),t.roleTitle?(0,a.jsxs)("span",{className:"text-sm ".concat("dark"===e?"text-[#818384]":"text-gray-500"),children:["\xb7 ",t.roleTitle]}):null,(0,a.jsx)("span",{className:"flex items-center gap-0.5 ml-auto",children:Array.from({length:5},(e,s)=>(0,a.jsx)(b.Z,{className:"w-4 h-4 ".concat(s<t.rating?"text-amber-400 fill-amber-400":"text-gray-400 fill-transparent")},s))})]}),t.email?(0,a.jsx)("p",{className:"text-xs ".concat("dark"===e?"text-[#818384]":"text-gray-500"),children:t.email}):null,(0,a.jsx)("p",{className:"text-sm leading-relaxed whitespace-pre-wrap ".concat("dark"===e?"text-[#D7DADC]":"text-gray-700"),children:t.body}),t.createdAt?(0,a.jsxs)("p",{className:"text-xs ".concat("dark"===e?"text-[#5F5F61]":"text-gray-400"),children:["Submitted ",new Date(t.createdAt).toLocaleString()]}):null]}),"pending"===r?(0,a.jsxs)("div",{className:"flex md:flex-col gap-2 shrink-0",children:[(0,a.jsxs)("button",{type:"button",disabled:P,onClick:()=>O(t.id,"approve"),className:"inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl bg-emerald-600 hover:bg-emerald-500 text-white text-sm font-semibold disabled:opacity-50",children:[T(t.id,"approve")?(0,a.jsx)(p.Z,{className:"w-4 h-4 animate-spin"}):(0,a.jsx)(g.Z,{className:"w-4 h-4"}),"Post to site"]}),(0,a.jsxs)("button",{type:"button",disabled:P,onClick:()=>{window.confirm("Delete this review permanently? It cannot be undone.")&&O(t.id,"delete")},className:"inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-semibold border disabled:opacity-50 ".concat("dark"===e?"border-red-500/40 text-red-400 hover:bg-red-500/10":"border-red-300 text-red-700 hover:bg-red-50"),children:[T(t.id,"delete")?(0,a.jsx)(p.Z,{className:"w-4 h-4 animate-spin"}):(0,a.jsx)(f.Z,{className:"w-4 h-4"}),"Delete"]})]}):(0,a.jsxs)("div",{className:"flex shrink-0 flex-col gap-2 md:items-stretch",children:[(0,a.jsx)("div",{className:"flex flex-wrap justify-end gap-2 md:justify-end",children:t.hiddenFromSite?(0,a.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wide text-amber-500",children:"Hidden from site"}):(0,a.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wide text-emerald-500",children:"Visible on site"})}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:justify-end",children:[t.hiddenFromSite?(0,a.jsxs)("button",{type:"button",disabled:P,onClick:()=>O(t.id,"unhide"),className:"inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl bg-emerald-600 text-sm font-semibold text-white hover:bg-emerald-500 disabled:opacity-50",children:[T(t.id,"unhide")?(0,a.jsx)(p.Z,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(w.Z,{className:"h-4 w-4"}),"Show on site"]}):(0,a.jsxs)("button",{type:"button",disabled:P,onClick:()=>{window.confirm("Hide this review from the public site? You can show it again later. Nothing is deleted.")&&O(t.id,"hide")},className:"inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-semibold border disabled:opacity-50 ".concat("dark"===e?"border-white/20 text-[#D7DADC] hover:bg-white/10":"border-gray-300 text-gray-800 hover:bg-gray-100"),children:[T(t.id,"hide")?(0,a.jsx)(p.Z,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(y.Z,{className:"h-4 w-4"}),"Hide from site"]}),(0,a.jsxs)("button",{type:"button",disabled:P,onClick:()=>{window.confirm("Delete this review permanently? It cannot be undone.")&&O(t.id,"delete")},className:"inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-semibold border disabled:opacity-50 ".concat("dark"===e?"border-red-500/40 text-red-400 hover:bg-red-500/10":"border-red-300 text-red-700 hover:bg-red-50"),children:[T(t.id,"delete")?(0,a.jsx)(p.Z,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(f.Z,{className:"h-4 w-4"}),"Delete"]})]})]})]})},t.id))})]})})]})}}}
1,function(e){e.O(0,[4968,1296,860,5412,2888,9774,179],function(){return e(e.s=89168)}),_N_E=e.O()}]);
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.