add crm auth, email, status update and search
All checks were successful
Auto Deploy / deploy (push) Successful in 1m7s

This commit is contained in:
deonisii
2026-04-17 21:29:14 +03:00
parent 246fb6d52d
commit 4f67bca4be
16 changed files with 502 additions and 35 deletions

View File

@@ -4,6 +4,7 @@ import { prisma } from "@/lib/prisma";
type LeadPayload = {
company?: string;
phone?: string;
email?: string;
message?: string;
};
@@ -13,11 +14,12 @@ export async function POST(request: Request) {
const company = body.company?.trim();
const phone = body.phone?.trim();
const email = body.email?.trim().toLowerCase();
const message = body.message?.trim() || "";
if (!company || !phone) {
if (!company || !phone || !email) {
return NextResponse.json(
{ error: "Компания и телефон обязательны" },
{ error: "Компания, телефон и email обязательны" },
{ status: 400 }
);
}
@@ -26,6 +28,7 @@ export async function POST(request: Request) {
data: {
company,
phone,
email,
message,
source: "website",
},
@@ -39,20 +42,4 @@ export async function POST(request: Request) {
{ status: 500 }
);
}
}
export async function GET() {
try {
const leads = await prisma.lead.findMany({
orderBy: { createdAt: "desc" },
});
return NextResponse.json(leads);
} catch (error) {
console.error("GET /api/leads error:", error);
return NextResponse.json(
{ error: "Не удалось получить заявки" },
{ status: 500 }
);
}
}