(()=>{var e={};e.id=4936,e.ids=[4936],e.modules={3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12909:(e,t,r)=>{"use strict";function n(){let e=process.env.JWT_SECRET;if(!e)throw Error("JWT_SECRET is not set");return e}function s(e){let t=e.headers.get("authorization");if(t&&t.startsWith("Bearer "))return t.slice(7);let r=e.cookies.get("admin_token")?.value;if(r)return r;let n=e.cookies.get("token")?.value;return n||null}r.d(t,{V:()=>s,u:()=>n})},27910:e=>{"use strict";e.exports=require("stream")},28354:e=>{"use strict";e.exports=require("util")},29294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},42434:(e,t,r)=>{"use strict";r.r(t),r.d(t,{patchFetch:()=>g,routeModule:()=>w,serverHooks:()=>A,workAsyncStorage:()=>h,workUnitAsyncStorage:()=>j});var n={};r.r(n),r.d(n,{DELETE:()=>v,PUT:()=>f});var s=r(96559),o=r(48088),a=r(37719),i=r(32190),u=r(43205),c=r.n(u),d=r(96330),p=r(12909);let l=new d.PrismaClient,m=(0,p.u)();async function x(e){let t=(0,p.V)(e);if(!t)return null;try{let e=c().verify(t,m);if(e.isGlobalAdmin&&e.globalAdminId)return e}catch{}return null}async function f(e,{params:t}){try{if(!await x(e))return i.NextResponse.json({error:"Unauthorized"},{status:401});let r=await Promise.resolve(t),n=parseInt(r.id);if(isNaN(n))return i.NextResponse.json({error:"Invalid announcement ID"},{status:400});let{title:s,content:o,isActive:a}=await e.json();if(!s||!o)return i.NextResponse.json({error:"Title and content are required"},{status:400});let u=await l.announcement.update({where:{id:n},data:{title:s,content:o,isActive:void 0===a||a}});return await l.$disconnect(),i.NextResponse.json({message:"Announcement updated successfully",announcement:{id:u.id,title:u.title,content:u.content,isActive:u.isActive,createdAt:u.createdAt.toISOString(),updatedAt:u.updatedAt.toISOString()}})}catch(e){if(console.error("Update announcement error:",e),await l.$disconnect(),"P2025"===e.code)return i.NextResponse.json({error:"Announcement not found"},{status:404});return i.NextResponse.json({error:"Server error"},{status:500})}}async function v(e,{params:t}){try{if(!await x(e))return i.NextResponse.json({error:"Unauthorized"},{status:401});let r=await Promise.resolve(t),n=parseInt(r.id);if(isNaN(n))return i.NextResponse.json({error:"Invalid announcement ID"},{status:400});return await l.announcement.delete({where:{id:n}}),await l.$disconnect(),i.NextResponse.json({message:"Announcement deleted successfully"})}catch(e){if(console.error("Delete announcement error:",e),await l.$disconnect(),"P2025"===e.code)return i.NextResponse.json({error:"Announcement not found"},{status:404});return i.NextResponse.json({error:"Server error"},{status:500})}}let w=new s.AppRouteRouteModule({definition:{kind:o.RouteKind.APP_ROUTE,page:"/api/admin/announcements/[id]/route",pathname:"/api/admin/announcements/[id]",filename:"route",bundlePath:"app/api/admin/announcements/[id]/route"},resolvedPagePath:"/Users/mustafaseyhan/Project/PazarAnalist/src/app/api/admin/announcements/[id]/route.ts",nextConfigOutput:"standalone",userland:n}),{workAsyncStorage:h,workUnitAsyncStorage:j,serverHooks:A}=w;function g(){return(0,a.patchFetch)({workAsyncStorage:h,workUnitAsyncStorage:j})}},44870:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},55511:e=>{"use strict";e.exports=require("crypto")},63033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},78335:()=>{},79428:e=>{"use strict";e.exports=require("buffer")},96330:e=>{"use strict";e.exports=require("@prisma/client")},96487:()=>{}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),n=t.X(0,[4447,580,3205],()=>r(42434));module.exports=n})();