"use strict";(()=>{var e={};e.id=4765,e.ids=[4765],e.modules={53524:e=>{e.exports=require("@prisma/client")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},33605:(e,r,t)=>{t.r(r),t.d(r,{headerHooks:()=>P,originalPathname:()=>f,requestAsyncStorage:()=>m,routeModule:()=>c,serverHooks:()=>p,staticGenerationAsyncStorage:()=>l,staticGenerationBailout:()=>A});var a={};t.r(a),t.d(a,{POST:()=>u}),t(95655);var s=t(83323),o=t(54647),n=t(66886),i=t(30953);async function u(){try{let e=await i._.order.findMany({where:{customerId:null,email:{not:null}}}),r=0,t=0;for(let a of e){if(!a.email)continue;let e=await i._.customer.findUnique({where:{email:a.email}});!e&&(e=await i._.customer.create({data:{email:a.email,name:a.customerName,phone:a.phone}}),r++),e&&(await i._.order.update({where:{id:a.id},data:{customerId:e.id}}),t++)}return n.Z.json({success:!0,message:`Processed ${e.length} orders. Created ${r} customers. Linked ${t} orders.`})}catch(e){return console.error("Sync customers error:",e),n.Z.json({error:"Failed to sync customers",details:e instanceof Error?e.message:String(e)},{status:500})}}let d=s.AppRouteRouteModule,c=new d({definition:{kind:o.x.APP_ROUTE,page:"/api/admin/sync-customers/route",pathname:"/api/admin/sync-customers",filename:"route",bundlePath:"app/api/admin/sync-customers/route"},resolvedPagePath:"D:\\Code\\MusaFoods_New\\musafoods\\app\\api\\admin\\sync-customers\\route.ts",nextConfigOutput:"standalone",userland:a}),{requestAsyncStorage:m,staticGenerationAsyncStorage:l,serverHooks:p,headerHooks:P,staticGenerationBailout:A}=c,f="/api/admin/sync-customers/route"},30953:(e,r,t)=>{t.d(r,{_:()=>o});var a=t(53524);let s=globalThis,o=s.prisma??new a.PrismaClient},54647:(e,r)=>{var t;Object.defineProperty(r,"x",{enumerable:!0,get:function(){return t}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE"}(t||(t={}))}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[9727,3497,6886],()=>t(33605));module.exports=a})();