UI improvements: Leadspeicher, Maps enrichment, exports

- Rename LeadVault → Leadspeicher throughout (sidebar, topbar, page)
- SidePanel: full lead detail view with contact, source, tags (read-only), Google Maps link for address
- Tags: kontaktiert stored as tag (toggleable), favorit tag toggle
- Remove Status column, StatusBadge dropdown, Priority feature
- Remove Aktualisieren button from Leadspeicher
- Bulk actions: remove status dropdown
- Export: LeadVault Excel-only, clean columns, freeze row + autofilter
- Export dropdown: click-based (fix overflow-hidden clipping)
- ExportButtons: remove CSV, Excel only everywhere
- Maps page: post-search Anymailfinder enrichment button
- ProgressCard: "Suche läuft..." instead of "Warte auf Anymailfinder-Server..."
- Quick SERP renamed to "Schnell neue Suche"
- Results page: Excel export, always-enabled download button
- Anymailfinder: fix bulk field names, array-of-arrays format
- Apify: fix countryCode lowercase
- API: sourceTerm search, contacted/favorite tag filters

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Timo Uttenweiler
2026-03-21 18:12:31 +01:00
parent f914ab6e47
commit 115cdacd08
26 changed files with 511 additions and 521 deletions

View File

@@ -36,30 +36,18 @@ export async function GET(req: NextRequest) {
});
const rows = leads.map(l => ({
"Status": l.status,
"Priorität": l.priority,
"Unternehmen": l.companyName || "",
"Domain": l.domain || "",
"Kontaktname": l.contactName || "",
"Jobtitel": l.contactTitle || "",
"E-Mail": l.email || "",
"E-Mail Konfidenz": l.emailConfidence != null ? Math.round(l.emailConfidence * 100) + "%" : "",
"LinkedIn": l.linkedinUrl || "",
"Telefon": l.phone || "",
"Quelle": l.sourceTab,
"Suchbegriff": l.sourceTerm || "",
"Tags": l.tags ? JSON.parse(l.tags).join(", ") : "",
"Land": l.country || "",
"Mitarbeiter": l.headcount || "",
"Branche": l.industry || "",
"Notizen": l.notes || "",
"Erfasst am": new Date(l.capturedAt).toLocaleString("de-DE"),
"Kontaktiert am": l.contactedAt ? new Date(l.contactedAt).toLocaleString("de-DE") : "",
"SERP Rang": l.serpRank?.toString() || "",
"SERP URL": l.serpUrl || "",
"SERP Titel": l.serpTitle || "",
"SERP Snippet": l.serpSnippet || "",
"Lead ID": l.id,
"Unternehmen": l.companyName || "",
"Domain": l.domain || "",
"Kontaktname": l.contactName || "",
"Position": l.contactTitle || "",
"E-Mail": l.email || "",
"Telefon": l.phone || "",
"Adresse": l.address || "",
"LinkedIn": l.linkedinUrl || "",
"Branche": l.industry || "",
"Suchbegriff": l.sourceTerm || "",
"Tags": l.tags ? (JSON.parse(l.tags) as string[]).join(", ") : "",
"Erfasst am": new Date(l.capturedAt).toLocaleDateString("de-DE", { day: "2-digit", month: "2-digit", year: "numeric" }),
}));
const filename = `leadflow-vault-${new Date().toISOString().split("T")[0]}`;
@@ -67,22 +55,36 @@ export async function GET(req: NextRequest) {
if (format === "xlsx") {
const ws = XLSX.utils.json_to_sheet(rows);
// Column widths
// Column widths (one per column)
ws["!cols"] = [
{ wch: 14 }, { wch: 10 }, { wch: 28 }, { wch: 28 }, { wch: 22 },
{ wch: 22 }, { wch: 32 }, { wch: 14 }, { wch: 30 }, { wch: 16 },
{ wch: 12 }, { wch: 24 }, { wch: 20 }, { wch: 8 }, { wch: 10 },
{ wch: 16 }, { wch: 30 }, { wch: 18 }, { wch: 18 }, { wch: 8 },
{ wch: 40 }, { wch: 30 }, { wch: 40 }, { wch: 28 },
{ wch: 30 }, // Unternehmen
{ wch: 28 }, // Domain
{ wch: 24 }, // Kontaktname
{ wch: 24 }, // Position
{ wch: 34 }, // E-Mail
{ wch: 18 }, // Telefon
{ wch: 36 }, // Adresse
{ wch: 36 }, // LinkedIn
{ wch: 22 }, // Branche
{ wch: 30 }, // Suchbegriff
{ wch: 28 }, // Tags
{ wch: 14 }, // Erfasst am
];
// Freeze header row
ws["!freeze"] = { xSplit: 0, ySplit: 1 };
// Autofilter across all columns
const colCount = Object.keys(rows[0] ?? {}).length || 17;
const lastCol = String.fromCharCode(64 + colCount);
ws["!autofilter"] = { ref: `A1:${lastCol}1` };
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "LeadVault");
const arr = XLSX.write(wb, { type: "array", bookType: "xlsx" }) as number[];
const buf = new Uint8Array(arr).buffer;
return new NextResponse(buf, {
return new NextResponse(new Uint8Array(arr).buffer, {
headers: {
"Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"Content-Disposition": `attachment; filename="${filename}.xlsx"`,
@@ -90,26 +92,19 @@ export async function GET(req: NextRequest) {
});
}
// CSV — UTF-8 BOM so Excel opens it correctly + \r\n line endings
const headers = Object.keys(rows[0] ?? {
"Status": "", "Priorität": "", "Unternehmen": "", "Domain": "", "Kontaktname": "",
"Jobtitel": "", "E-Mail": "", "E-Mail Konfidenz": "", "LinkedIn": "", "Telefon": "",
"Quelle": "", "Suchbegriff": "", "Tags": "", "Land": "", "Mitarbeiter": "",
"Branche": "", "Notizen": "", "Erfasst am": "", "Kontaktiert am": "",
"SERP Rang": "", "SERP URL": "", "SERP Titel": "", "SERP Snippet": "", "Lead ID": "",
});
// CSV — UTF-8 BOM so Excel opens it correctly
const colKeys = Object.keys(rows[0] ?? {});
const escape = (v: string) =>
v.includes(",") || v.includes('"') || v.includes("\n") || v.includes("\r")
? `"${v.replace(/"/g, '""')}"`
: v;
const csv =
"\uFEFF" + // UTF-8 BOM — tells Excel to use UTF-8
"\uFEFF" +
[
headers.map(escape).join(","),
...rows.map(r => headers.map(h => escape(String(r[h as keyof typeof r] ?? ""))).join(",")),
].join("\r\n"); // Windows line endings for Excel
colKeys.map(escape).join(","),
...rows.map(r => colKeys.map(h => escape(String(r[h as keyof typeof r] ?? ""))).join(",")),
].join("\r\n");
return new NextResponse(csv, {
headers: {