"use strict";(()=>{var e={};e.id=8127,e.ids=[8127],e.modules={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")},15814:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>x,patchFetch:()=>k,requestAsyncStorage:()=>m,routeModule:()=>l,serverHooks:()=>f,staticGenerationAsyncStorage:()=>p});var a={};r.r(a),r.d(a,{GET:()=>d});var s=r(49303),n=r(88716),o=r(60670),i=r(87070),u=r(8194),c=r(15230);async function d(e,{params:t}){try{let{token:e}=await t;if(!e)return i.NextResponse.json({error:"Token tidak valid"},{status:400});let r=await u._.order.findFirst({where:{feedbackToken:e},select:{id:!0,orderNumber:!0,customerName:!0,createdAt:!0,total:!0,tenantId:!0,storeId:!0,tenant:{select:{slug:!0,name:!0,logo:!0,isActive:!0}},store:{select:{slug:!0,name:!0,isActive:!0}}}});if(!r||!r.tenant.isActive)return i.NextResponse.json({error:"Link feedback tidak valid"},{status:404});let a=await (0,c.p6)(r.tenantId);if(!(0,c.U6)(a.features,"feedback"))return i.NextResponse.json({error:"Fitur feedback tidak tersedia"},{status:403});let s=await u._.feedback.findFirst({where:{orderId:r.id},select:{id:!0,rating:!0,comment:!0,categories:!0,customerName:!0,createdAt:!0}});return i.NextResponse.json({hasFeedback:!!s,feedback:s||null,order:{orderNumber:r.orderNumber,customerName:r.customerName,createdAt:r.createdAt,total:Number(r.total)},tenant:{slug:r.tenant.slug,name:r.tenant.name,logo:r.tenant.logo},store:{slug:r.store.slug,name:r.store.name}})}catch{return i.NextResponse.json({error:"Server error"},{status:500})}}let l=new s.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/public/feedback/resolve/[token]/route",pathname:"/api/public/feedback/resolve/[token]",filename:"route",bundlePath:"app/api/public/feedback/resolve/[token]/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\public\\feedback\\resolve\\[token]\\route.ts",nextConfigOutput:"",userland:a}),{requestAsyncStorage:m,staticGenerationAsyncStorage:p,serverHooks:f}=l,x="/api/public/feedback/resolve/[token]/route";function k(){return(0,o.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:p})}},8194:(e,t,r)=>{r.d(t,{_:()=>s});let a=require("@prisma/client"),s=globalThis.prisma??new a.PrismaClient},15230:(e,t,r)=>{r.d(t,{MN:()=>n,U6:()=>o,p6:()=>s});var a=r(8194);async function s(e){let t=await a._.subscription.findFirst({where:{tenantId:e,status:{in:["active","trial"]}},include:{plan:!0},orderBy:{createdAt:"desc"}});return t?{maxStores:t.plan.maxStores,maxStaff:t.plan.maxStaff,maxMenuItems:t.plan.maxMenuItems,maxOrders:t.plan.maxOrders,features:JSON.parse(t.plan.features)}:{maxStores:1,maxStaff:3,maxMenuItems:30,maxOrders:100,features:["pos","qr_menu"]}}async function n(e,t){let r=await s(e),n=0,o=0;switch(t){case"stores":n=await a._.store.count({where:{tenantId:e,isActive:!0}}),o=r.maxStores;break;case"staff":n=await a._.user.count({where:{tenantId:e,isActive:!0}}),o=r.maxStaff;break;case"menuItems":n=await a._.menuItem.count({where:{tenantId:e,isActive:!0}}),o=r.maxMenuItems;break;case"orders":let i=new Date;i.setDate(1),i.setHours(0,0,0,0),n=await a._.order.count({where:{tenantId:e,createdAt:{gte:i}}}),o=r.maxOrders}return 0===o?{allowed:!0,current:n,max:o}:{allowed:n<o,current:n,max:o}}function o(e,t){return e.includes(t)}}};var t=require("../../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,5972],()=>r(15814));module.exports=a})();