- New Topbar: logo, 2-tab pill switcher, live "Neu" badge - /suche page: SearchCard, LoadingCard, ExamplePills - /leadspeicher page: full leads table with filters, pagination - StatusBadge, StatusPopover, LeadSidePanel, BulkActionBar - POST /api/search: unified search entry point → serp-enrich - Remove Sidebar + old TopBar from layout - Title: OnyvaLeads, redirect / → /suche Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
|
|
export async function POST(req: NextRequest) {
|
|
try {
|
|
const body = await req.json() as { query: string; region: string; count: number };
|
|
const { query, region, count } = body;
|
|
|
|
if (!query || typeof query !== "string") {
|
|
return NextResponse.json({ error: "query is required" }, { status: 400 });
|
|
}
|
|
|
|
const searchQuery = region ? `${query} ${region}` : query;
|
|
|
|
const baseUrl = req.nextUrl.origin;
|
|
const res = await fetch(`${baseUrl}/api/jobs/serp-enrich`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
query: searchQuery,
|
|
maxPages: Math.ceil((count || 50) / 10),
|
|
countryCode: "de",
|
|
languageCode: "de",
|
|
filterSocial: true,
|
|
categories: ["ceo"],
|
|
enrichEmails: true,
|
|
}),
|
|
});
|
|
|
|
if (!res.ok) {
|
|
const err = await res.json() as { error?: string };
|
|
return NextResponse.json({ error: err.error || "Failed to start job" }, { status: 500 });
|
|
}
|
|
|
|
const data = await res.json() as { jobId: string };
|
|
return NextResponse.json({ jobId: data.jobId });
|
|
} catch (err) {
|
|
console.error("POST /api/search error:", err);
|
|
return NextResponse.json({ error: "Failed to start search" }, { status: 500 });
|
|
}
|
|
}
|