ehsan-dashboards/dashboards/crm/.next/server/app/api/export/route.js

1 line
No EOL
2.5 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";(()=>{var e={};e.id=711,e.ids=[711],e.modules={399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},8765:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>h,patchFetch:()=>P,requestAsyncStorage:()=>d,routeModule:()=>c,serverHooks:()=>x,staticGenerationAsyncStorage:()=>m});var o={};r.r(o),r.d(o,{GET:()=>l});var n=r(3278),a=r(5002),s=r(4877),p=r(1309),i=r(1643),u=r(710);async function l(e){try{let e=(await i._.lead.findMany({include:{rooms:!0},orderBy:{createdAt:"desc"}})).map(e=>({شناسه:e.id,"نام مجموعه":e.name,شهر:e.city,منطقه:e.district||"",اتاق‌ها:e.rooms.map(e=>e.title).join("، "),"نام مدیر":e.ownerName,"شماره مدیر":e.ownerPhone,"شماره پشتیبانی":e.supportPhone||"",منبع:e.source,"مرحله فروش":e.stage,"اقدام بعدی":e.nextAction,"کانال بعدی":e.nextChannel,"تاریخ پیگیری بعدی":e.nextFollowupAt?new Date(e.nextFollowupAt).toISOString().split("T")[0]:"",دما:e.temperature,"نمره دما":e.temperatureScore,"چالش اصلی":e.painPoint||"",اعتراض:e.objection||"","وضعیت اعتراض":e.objectionStatus||"","فروش ماه قبل (تومان)":e.salesLastMonth||0,"عضو باشگاه":e.clubMember?"بله":"خیر"})),t=u.P6.json_to_sheet(e),r=u.P6.book_new();u.P6.book_append_sheet(r,t,"لیدهای اکیپا");let o=u.cW(r,{type:"buffer",bookType:"xlsx"});return new p.NextResponse(o,{status:200,headers:{"Content-Disposition":'attachment; filename="ekipa-crm-leads.xlsx"',"Content-Type":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}})}catch(e){return console.error("Export error:",e),p.NextResponse.json({success:!1,error:e.message},{status:500})}}let c=new n.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/export/route",pathname:"/api/export",filename:"route",bundlePath:"app/api/export/route"},resolvedPagePath:"/workspace/personal/crm/app/api/export/route.ts",nextConfigOutput:"",userland:o}),{requestAsyncStorage:d,staticGenerationAsyncStorage:m,serverHooks:x}=c,h="/api/export/route";function P(){return(0,s.patchFetch)({serverHooks:x,staticGenerationAsyncStorage:m})}},1643:(e,t,r)=>{r.d(t,{_:()=>n});let o=require("@prisma/client"),n=globalThis.prisma??new o.PrismaClient({log:["error"]})}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),o=t.X(0,[787,833,710],()=>r(8765));module.exports=o})();