"use strict";(()=>{var e={};e.id=6652,e.ids=[6652,2331],e.modules={53524:e=>{e.exports=require("@prisma/client")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},15540:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>g,patchFetch:()=>h,requestAsyncStorage:()=>c,routeModule:()=>u,serverHooks:()=>m,staticGenerationAsyncStorage:()=>l});var a={};t.r(a),t.d(a,{GET:()=>p});var s=t(49303),o=t(88716),n=t(60670),i=t(87070);let d=t(72331).prisma;async function p(e){try{let{searchParams:r}=new URL(e.url),t=r.get("status")||"",a=parseInt(r.get("page")??"1"),s=parseInt(r.get("limit")??"20"),o=(a-1)*s,n={};t&&["pending","approved","rejected"].includes(t)&&(n.status=t);let[p,u,c]=await Promise.all([d.scoreReward.findMany({where:n,orderBy:{createdAt:"desc"},skip:o,take:s,include:{user:{select:{userId:!0,premiumTier:!0,totalPoints:!0}}}}),d.scoreReward.count({where:n}),d.scoreReward.count({where:{status:"pending"}})]),l=p.map(e=>({id:e.id,user_id:e.user?.userId??"-",premium_tier:e.user?.premiumTier??"free",match_info:e.matchInfo,amount:e.amount,status:e.status,approved_by:e.approvedBy,approved_at:e.approvedAt?.toISOString()??null,note:e.note,created_at:e.createdAt.toISOString()}));return i.NextResponse.json({success:!0,data:l,pagination:{total:u,page:a,limit:s,total_pages:Math.ceil(u/s)},pending_count:c})}catch(e){return console.error("Score rewards GET error:",e),i.NextResponse.json({success:!1,message:"Gagal memuat data hadiah"},{status:500})}}let u=new s.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/admin/score-rewards/route",pathname:"/api/admin/score-rewards",filename:"route",bundlePath:"app/api/admin/score-rewards/route"},resolvedPagePath:"C:\\xampp\\htdocs\\Bolafest\\app\\api\\admin\\score-rewards\\route.ts",nextConfigOutput:"standalone",userland:a}),{requestAsyncStorage:c,staticGenerationAsyncStorage:l,serverHooks:m}=u,g="/api/admin/score-rewards/route";function h(){return(0,n.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:l})}},72331:(e,r,t)=>{t.d(r,{prisma:()=>s});var a=t(53524);let s=globalThis.prisma??new a.PrismaClient({log:["error"]})}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[9276,5972],()=>t(15540));module.exports=a})();