"use strict";(()=>{var e={};e.id=3812,e.ids=[3812],e.modules={53524:e=>{e.exports=require("@prisma/client")},98432:e=>{e.exports=require("bcryptjs")},72934:e=>{e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},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")},27790:e=>{e.exports=require("assert")},78893:e=>{e.exports=require("buffer")},84770:e=>{e.exports=require("crypto")},17702:e=>{e.exports=require("events")},32615:e=>{e.exports=require("http")},35240:e=>{e.exports=require("https")},86624:e=>{e.exports=require("querystring")},17360:e=>{e.exports=require("url")},21764:e=>{e.exports=require("util")},71568:e=>{e.exports=require("zlib")},17112:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>v,patchFetch:()=>f,requestAsyncStorage:()=>m,routeModule:()=>x,serverHooks:()=>q,staticGenerationAsyncStorage:()=>w});var a={};t.r(a),t.d(a,{POST:()=>c});var s=t(73278),n=t(45002),o=t(54877),i=t(71309),p=t(18445),u=t(73275),d=t(82208),l=t(68172);async function c(e,{params:r}){try{let e=await (0,p.getServerSession)(u.Lz);if(!e?.user?.id)return i.NextResponse.json({error:"Unauthorized"},{status:401});let t=r.id,a=e.user.id,s=await d._.walletTransaction.findUnique({where:{id:t},include:{wallet:!0}});if(!s)return i.NextResponse.json({error:"Transaction not found"},{status:404});let n=await d._.user.findUnique({where:{id:a},select:{role:!0,companyId:!0}});if(!n)return i.NextResponse.json({error:"User not found"},{status:404});if(!("super_admin"===n.role||"company_admin"===n.role&&n.companyId===s.companyId))return i.NextResponse.json({error:"Insufficient permissions"},{status:403});if("pending"!==s.status)return i.NextResponse.json({error:"Transaction is not pending approval"},{status:400});return await d._.$transaction(async e=>{await e.walletTransaction.update({where:{id:t},data:{status:"completed",metadata:{...s.metadata||{},approvedBy:a,approvedAt:new Date}}}),await e.wallet.update({where:{id:s.walletId},data:{balance:{increment:s.amount}}})}),await (0,l.yx)(t),await (0,l.XL)(s.walletId),i.NextResponse.json({message:"Transaction approved successfully"})}catch(e){return console.error("Error approving transaction:",e),i.NextResponse.json({error:"Internal server error"},{status:500})}}let x=new s.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/wallet/transactions/[id]/approve/route",pathname:"/api/wallet/transactions/[id]/approve",filename:"route",bundlePath:"app/api/wallet/transactions/[id]/approve/route"},resolvedPagePath:"c:\\xampp\\htdocs\\propmaster.io\\src\\app\\api\\wallet\\transactions\\[id]\\approve\\route.ts",nextConfigOutput:"standalone",userland:a}),{requestAsyncStorage:m,staticGenerationAsyncStorage:w,serverHooks:q}=x,v="/api/wallet/transactions/[id]/approve/route";function f(){return(0,o.patchFetch)({serverHooks:q,staticGenerationAsyncStorage:w})}}};var r=require("../../../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[7787,9121,4833,3976],()=>t(17112));module.exports=a})();