(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5687],{62442:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});var n=r(65531);/**
 * @license lucide-react v0.446.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let s=(0,n.Z)("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},63715:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});var n=r(65531);/**
 * @license lucide-react v0.446.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let s=(0,n.Z)("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},55340:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});var n=r(65531);/**
 * @license lucide-react v0.446.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let s=(0,n.Z)("Star",[["polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2",key:"8f66p6"}]])},48409:function(e,t,r){Promise.resolve().then(r.bind(r,71606))},71606:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return x}});var n=r(57437),s=r(2265),a=r(32553),i=r(29155),l=r(93023),o=r(8866),c=r(71424),d=r(63715),u=r(62442),f=r(82549),m=r(16691),p=r.n(m);function x(){let[e,t]=(0,s.useState)([]),[r,m]=(0,s.useState)(!0),[x,h]=(0,s.useState)(null),g=async()=>{try{let e=await fetch("/api/admin/reviews");if(e.ok){let r=await e.json();t(r)}}catch(e){c.Am.error("Failed to fetch reviews")}finally{m(!1)}};(0,s.useEffect)(()=>{g()},[]);let v=async(e,r)=>{h(e);try{let n=await fetch("/api/admin/reviews",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,status:r})});if(!n.ok)throw Error("Failed to update status");c.Am.success("Review ".concat(r.toLowerCase())),t(t=>t.map(t=>t.id===e?{...t,status:r}:t))}catch(e){c.Am.error("Failed to update status")}finally{h(null)}};return r?(0,n.jsx)("div",{className:"p-8",children:(0,n.jsx)(d.Z,{className:"animate-spin"})}):(0,n.jsxs)("div",{className:"p-8 space-y-6",children:[(0,n.jsx)("div",{className:"flex justify-between items-center",children:(0,n.jsx)("h1",{className:"text-3xl font-bold",children:"Product Reviews"})}),(0,n.jsx)("div",{className:"bg-white rounded-md border",children:(0,n.jsxs)(a.iA,{children:[(0,n.jsx)(a.xD,{children:(0,n.jsxs)(a.SC,{children:[(0,n.jsx)(a.ss,{children:"Product"}),(0,n.jsx)(a.ss,{children:"Customer"}),(0,n.jsx)(a.ss,{children:"Rating"}),(0,n.jsx)(a.ss,{className:"w-[300px]",children:"Review"}),(0,n.jsx)(a.ss,{children:"Status"}),(0,n.jsx)(a.ss,{children:"Date"}),(0,n.jsx)(a.ss,{className:"text-right",children:"Actions"})]})}),(0,n.jsxs)(a.RM,{children:[e.map(e=>{var t,r;return(0,n.jsxs)(a.SC,{children:[(0,n.jsx)(a.pj,{children:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("div",{className:"relative w-8 h-8 rounded overflow-hidden bg-gray-100",children:e.product.image&&(0,n.jsx)(p(),{src:e.product.image,alt:"",fill:!0,className:"object-cover"})}),(0,n.jsx)("span",{className:"font-medium text-sm truncate max-w-[150px]",title:e.product.nameEn,children:e.product.nameEn})]})}),(0,n.jsx)(a.pj,{children:(0,n.jsxs)("div",{className:"flex flex-col",children:[(0,n.jsx)("span",{className:"font-medium text-sm",children:(null===(t=e.user)||void 0===t?void 0:t.name)||"Guest"}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:(null===(r=e.user)||void 0===r?void 0:r.email)||"N/A"})]})}),(0,n.jsx)(a.pj,{children:(0,n.jsx)(o.Z,{rating:e.rating,readOnly:!0,size:14})}),(0,n.jsx)(a.pj,{children:(0,n.jsxs)("div",{className:"space-y-1",children:[e.title&&(0,n.jsx)("p",{className:"font-semibold text-xs",children:e.title}),(0,n.jsx)("p",{className:"text-sm text-gray-600 line-clamp-2",title:e.content,children:e.content}),e.image&&(0,n.jsx)("a",{href:e.image,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-blue-500 hover:underline",children:"View Photo"})]})}),(0,n.jsx)(a.pj,{children:(0,n.jsx)(i.C,{variant:"APPROVED"===e.status?"default":"REJECTED"===e.status?"destructive":"secondary",children:e.status})}),(0,n.jsx)(a.pj,{className:"text-xs text-muted-foreground",children:new Date(e.createdAt).toLocaleDateString()}),(0,n.jsx)(a.pj,{className:"text-right",children:(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:["PENDING"===e.status&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(l.z,{size:"sm",variant:"outline",className:"h-8 w-8 p-0 text-green-600 hover:text-green-700 hover:bg-green-50 border-green-200",onClick:()=>v(e.id,"APPROVED"),disabled:x===e.id,children:x===e.id?(0,n.jsx)(d.Z,{className:"h-4 w-4 animate-spin"}):(0,n.jsx)(u.Z,{className:"h-4 w-4"})}),(0,n.jsx)(l.z,{size:"sm",variant:"outline",className:"h-8 w-8 p-0 text-red-600 hover:text-red-700 hover:bg-red-50 border-red-200",onClick:()=>v(e.id,"REJECTED"),disabled:x===e.id,children:x===e.id?(0,n.jsx)(d.Z,{className:"h-4 w-4 animate-spin"}):(0,n.jsx)(f.Z,{className:"h-4 w-4"})})]}),"PENDING"!==e.status&&(0,n.jsx)(l.z,{size:"sm",variant:"ghost",className:"text-xs h-8",onClick:()=>v(e.id,"APPROVED"===e.status?"REJECTED":"APPROVED"),disabled:x===e.id,children:"APPROVED"===e.status?"Reject":"Approve"})]})})]},e.id)}),0===e.length&&(0,n.jsx)(a.SC,{children:(0,n.jsx)(a.pj,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No reviews found"})})]})]})})]})}},8866:function(e,t,r){"use strict";r.d(t,{Z:function(){return o}});var n=r(57437),s=r(2265),a=r(55340),i=r(39311),l=r(68329);function o(e){let{rating:t,setRating:r,readOnly:o=!1,size:c=20}=e,[d,u]=(0,s.useState)(0),f=d||t;return(0,n.jsx)("div",{className:"flex gap-1",children:[1,2,3,4,5].map(e=>(0,n.jsx)(l.E.button,{type:"button",whileHover:{scale:o?1:1.2},whileTap:{scale:o?1:.9},onClick:()=>!o&&r&&r(e),onMouseEnter:()=>!o&&u(e),onMouseLeave:()=>!o&&u(0),className:(0,i.cn)("focus:outline-none transition-colors duration-200",o?"cursor-default":"cursor-pointer"),disabled:o,children:(0,n.jsx)(a.Z,{size:c,className:(0,i.cn)("transition-all",e<=f?"fill-[#D4AF37] text-[#D4AF37]":"fill-transparent text-gray-300")})},e))})}},29155:function(e,t,r){"use strict";r.d(t,{C:function(){return l}});var n=r(57437);r(2265);var s=r(96061),a=r(39311);let i=(0,s.j)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function l(e){let{className:t,variant:r,...s}=e;return(0,n.jsx)("div",{className:(0,a.cn)(i({variant:r}),t),...s})}},93023:function(e,t,r){"use strict";r.d(t,{d:function(){return o},z:function(){return c}});var n=r(57437),s=r(2265),a=r(83474),i=r(96061),l=r(39311);let o=(0,i.j)("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),c=s.forwardRef((e,t)=>{let{className:r,variant:s,size:i,asChild:c=!1,...d}=e,u=c?a.g7:"button";return(0,n.jsx)(u,{className:(0,l.cn)(o({variant:s,size:i,className:r})),ref:t,...d})});c.displayName="Button"},32553:function(e,t,r){"use strict";r.d(t,{RM:function(){return o},SC:function(){return d},iA:function(){return i},pj:function(){return f},ss:function(){return u},xD:function(){return l}});var n=r(57437),s=r(2265),a=r(39311);let i=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,n.jsx)("div",{className:"relative w-full overflow-auto",children:(0,n.jsx)("table",{ref:t,className:(0,a.cn)("w-full caption-bottom text-sm",r),...s})})});i.displayName="Table";let l=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,n.jsx)("thead",{ref:t,className:(0,a.cn)("[&_tr]:border-b",r),...s})});l.displayName="TableHeader";let o=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,n.jsx)("tbody",{ref:t,className:(0,a.cn)("[&_tr:last-child]:border-0",r),...s})});o.displayName="TableBody";let c=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,n.jsx)("tfoot",{ref:t,className:(0,a.cn)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",r),...s})});c.displayName="TableFooter";let d=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,n.jsx)("tr",{ref:t,className:(0,a.cn)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",r),...s})});d.displayName="TableRow";let u=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,n.jsx)("th",{ref:t,className:(0,a.cn)("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",r),...s})});u.displayName="TableHead";let f=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,n.jsx)("td",{ref:t,className:(0,a.cn)("p-4 align-middle [&:has([role=checkbox])]:pr-0",r),...s})});f.displayName="TableCell";let m=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,n.jsx)("caption",{ref:t,className:(0,a.cn)("mt-4 text-sm text-muted-foreground",r),...s})});m.displayName="TableCaption"},39311:function(e,t,r){"use strict";r.d(t,{cn:function(){return a}});var n=r(57042),s=r(74769);function a(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,s.m6)((0,n.W)(t))}},67650:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"RouterContext",{enumerable:!0,get:function(){return a}});let n=r(21024),s=n._(r(2265)),a=s.default.createContext(null)},83474:function(e,t,r){"use strict";r.d(t,{g7:function(){return u},Z8:function(){return d}});var n=r(2265),s=r.t(n,2);function a(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}var i=r(57437),l=Symbol.for("react.lazy"),o=s[" use ".trim().toString()];function c(e){var t;return null!=e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===l&&"_payload"in e&&"object"==typeof(t=e._payload)&&null!==t&&"then"in t}function d(e){let t=function(e){let t=n.forwardRef((e,t)=>{let{children:r,...s}=e;if(c(r)&&"function"==typeof o&&(r=o(r._payload)),n.isValidElement(r)){var i;let e,l;let o=(i=r,(e=Object.getOwnPropertyDescriptor(i.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning?i.ref:(e=Object.getOwnPropertyDescriptor(i,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning?i.props.ref:i.props.ref||i.ref),c=function(e,t){let r={...t};for(let n in t){let s=e[n],a=t[n],i=/^on[A-Z]/.test(n);i?s&&a?r[n]=(...e)=>{let t=a(...e);return s(...e),t}:s&&(r[n]=s):"style"===n?r[n]={...s,...a}:"className"===n&&(r[n]=[s,a].filter(Boolean).join(" "))}return{...e,...r}}(s,r.props);return r.type!==n.Fragment&&(c.ref=t?function(...e){return t=>{let r=!1,n=e.map(e=>{let n=a(e,t);return r||"function"!=typeof n||(r=!0),n});if(r)return()=>{for(let t=0;t<n.length;t++){let r=n[t];"function"==typeof r?r():a(e[t],null)}}}}(t,o):o),n.cloneElement(r,c)}return n.Children.count(r)>1?n.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}(e),r=n.forwardRef((e,r)=>{let{children:s,...a}=e;c(s)&&"function"==typeof o&&(s=o(s._payload));let l=n.Children.toArray(s),d=l.find(m);if(d){let e=d.props.children,s=l.map(t=>t!==d?t:n.Children.count(e)>1?n.Children.only(null):n.isValidElement(e)?e.props.children:null);return(0,i.jsx)(t,{...a,ref:r,children:n.isValidElement(e)?n.cloneElement(e,void 0,s):null})}return(0,i.jsx)(t,{...a,ref:r,children:s})});return r.displayName=`${e}.Slot`,r}var u=d("Slot"),f=Symbol("radix.slottable");function m(e){return n.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===f}}},function(e){e.O(0,[6207,389,2774,1424,2971,7864,1744],function(){return e(e.s=48409)}),_N_E=e.O()}]);