"use strict";(()=>{var e={};e.id=5314,e.ids=[5314],e.modules={53524:e=>{e.exports=require("@prisma/client")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},25528:e=>{e.exports=require("next/dist/client/components/action-async-storage.external.js")},91877:e=>{e.exports=require("next/dist/client/components/request-async-storage.external.js")},25319:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},39491:e=>{e.exports=require("assert")},14300:e=>{e.exports=require("buffer")},6113:e=>{e.exports=require("crypto")},82361:e=>{e.exports=require("events")},13685:e=>{e.exports=require("http")},95687:e=>{e.exports=require("https")},63477:e=>{e.exports=require("querystring")},57310:e=>{e.exports=require("url")},73837:e=>{e.exports=require("util")},59796:e=>{e.exports=require("zlib")},65963:(e,r,t)=>{t.r(r),t.d(r,{headerHooks:()=>g,originalPathname:()=>h,requestAsyncStorage:()=>v,routeModule:()=>m,serverHooks:()=>q,staticGenerationAsyncStorage:()=>w,staticGenerationBailout:()=>f});var s={};t.r(s),t.d(s,{GET:()=>l,PATCH:()=>c}),t(95655);var n=t(83323),a=t(54647),i=t(66886),o=t(30953),u=t(3471),p=t(69542);async function d(){let e=await (0,u.getServerSession)(p.L);return e?.user?.role==="ADMIN"}async function l(e){if(!await d())return i.Z.json({error:"Unauthorized"},{status:401});let{searchParams:r}=new URL(e.url),t=r.get("status"),s=r.get("productId"),n={};t&&(n.status=t),s&&(n.productId=s);try{let e=await o._.review.findMany({where:n,include:{product:{select:{nameEn:!0,image:!0}},user:{select:{name:!0,email:!0}}},orderBy:{createdAt:"desc"}});return i.Z.json(e)}catch(e){return console.error("Error fetching admin reviews:",e),i.Z.json({error:"Internal Server Error"},{status:500})}}async function c(e){if(!await d())return i.Z.json({error:"Unauthorized"},{status:401});try{let{id:r,status:t}=await e.json();if(!r||!["APPROVED","REJECTED","PENDING"].includes(t))return i.Z.json({error:"Invalid input"},{status:400});let s=await o._.review.update({where:{id:r},data:{status:t}});return i.Z.json(s)}catch(e){return console.error("Error updating review status:",e),i.Z.json({error:"Internal Server Error"},{status:500})}}let x=n.AppRouteRouteModule,m=new x({definition:{kind:a.x.APP_ROUTE,page:"/api/admin/reviews/route",pathname:"/api/admin/reviews",filename:"route",bundlePath:"app/api/admin/reviews/route"},resolvedPagePath:".\\app\\api\\admin\\reviews\\route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:v,staticGenerationAsyncStorage:w,serverHooks:q,headerHooks:g,staticGenerationBailout:f}=m,h="/api/admin/reviews/route"},30953:(e,r,t)=>{t.d(r,{_:()=>a});var s=t(53524);let n=globalThis,a=n.prisma??new s.PrismaClient}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[4650,9727,3497,6886,6161,9542],()=>t(65963));module.exports=s})();