mein-solar: full feature set
- Schema: companyType, topics, salesScore, salesReason, offerPackage, approved, approvedAt, SearchHistory table - /api/search-history: GET (by mode) + POST (save query) - /api/ai-search: stadtwerke/industrie/custom prompts with history dedup - /api/enrich-leads: website scraping + GPT-4o-mini enrichment (fire-and-forget after each job) - /api/generate-email: personalized outreach via GPT-4o - Suche page: 3 mode tabs (Stadtwerke/Industrie/Freie Suche), Alle-Bundesländer queue button, AiSearchModal gets searchMode + history - Leadspeicher: Bewertung dots column, Paket badge column, Freigeben toggle button, email generator in SidePanel, approved-only export option - Leads API: approvedOnly + companyType filters, new fields in PATCH Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,8 @@ export async function PATCH(req: NextRequest, { params }: { params: Promise<{ id
|
||||
"status", "priority", "notes", "tags", "country", "headcount",
|
||||
"industry", "contactedAt", "companyName", "contactName", "contactTitle",
|
||||
"email", "phone", "linkedinUrl", "domain",
|
||||
"companyType", "topics", "salesScore", "salesReason", "offerPackage",
|
||||
"approved", "approvedAt",
|
||||
];
|
||||
|
||||
const data: Record<string, unknown> = {};
|
||||
|
||||
@@ -23,11 +23,13 @@ export async function GET(req: NextRequest) {
|
||||
{ email: { contains: search } },
|
||||
];
|
||||
}
|
||||
const approvedOnly = searchParams.get("approvedOnly") === "true";
|
||||
if (statuses.length > 0) where.status = { in: statuses };
|
||||
if (sourceTabs.length > 0) where.sourceTab = { in: sourceTabs };
|
||||
if (priorities.length > 0) where.priority = { in: priorities };
|
||||
if (hasEmail === "yes" || emailOnly) where.email = { not: null };
|
||||
else if (hasEmail === "no") where.email = null;
|
||||
if (approvedOnly) where.approved = true;
|
||||
|
||||
const leads = await prisma.lead.findMany({
|
||||
where,
|
||||
@@ -46,8 +48,14 @@ export async function GET(req: NextRequest) {
|
||||
"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" }),
|
||||
"Tags": l.tags ? (JSON.parse(l.tags) as string[]).join(", ") : "",
|
||||
"Unternehmenstyp": l.companyType || "",
|
||||
"Themen": l.topics ? (JSON.parse(l.topics) as string[]).join(", ") : "",
|
||||
"Vertriebsrelevanz": l.salesScore?.toString() || "",
|
||||
"Begründung": l.salesReason || "",
|
||||
"Angebotspaket": l.offerPackage || "",
|
||||
"Freigegeben": l.approved ? "Ja" : "Nein",
|
||||
"Erfasst am": new Date(l.capturedAt).toLocaleDateString("de-DE", { day: "2-digit", month: "2-digit", year: "numeric" }),
|
||||
}));
|
||||
|
||||
const filename = `onyva-leads-vault-${new Date().toISOString().split("T")[0]}`;
|
||||
|
||||
@@ -22,6 +22,8 @@ export async function GET(req: NextRequest) {
|
||||
const searchTerms = searchParams.getAll("searchTerm");
|
||||
const contacted = searchParams.get("contacted");
|
||||
const favorite = searchParams.get("favorite");
|
||||
const approvedOnly = searchParams.get("approvedOnly");
|
||||
const companyType = searchParams.get("companyType");
|
||||
|
||||
const where: Prisma.LeadWhereInput = {};
|
||||
|
||||
@@ -61,6 +63,9 @@ export async function GET(req: NextRequest) {
|
||||
where.tags = { contains: "favorit" };
|
||||
}
|
||||
|
||||
if (approvedOnly === "true") where.approved = true;
|
||||
if (companyType) where.companyType = companyType;
|
||||
|
||||
if (tags.length > 0) {
|
||||
// SQLite JSON contains — search for each tag in the JSON string
|
||||
where.AND = tags.map(tag => ({
|
||||
|
||||
Reference in New Issue
Block a user