refactor: Entscheider-Kategorie als Einzelauswahl (Radio)

- Nur noch eine Kategorie gleichzeitig wählbar (Array → einzelner Wert)
- ceo-Label: "CEO / Owner / President / Founder" mit Empfohlen-Badge
- API-Aufruf sendet [category] statt categories[]
- Überflüssige Validierungen entfernt

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Timo Uttenweiler
2026-03-17 13:05:14 +01:00
parent 717bc4f943
commit 39760b20a9
4 changed files with 61 additions and 71 deletions

View File

@@ -19,14 +19,12 @@ import { useAppStore } from "@/lib/store";
import type { DecisionMakerCategory } from "@/lib/services/anymailfinder";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
const DEFAULT_ROLES: DecisionMakerCategory[] = ["ceo"];
const CATEGORY_OPTIONS: { value: DecisionMakerCategory; label: string }[] = [
{ value: "ceo", label: "CEO / Inhaber / Gründer" },
{ value: "operations", label: "COO / Geschäftsführung" },
{ value: "engineering", label: "CTO / Technik" },
{ value: "marketing", label: "CMO / Marketing" },
{ value: "finance", label: "CFO / Finanzen" },
const CATEGORY_OPTIONS: { value: DecisionMakerCategory; label: string; recommended?: boolean }[] = [
{ value: "ceo", label: "CEO / Owner / President / Founder", recommended: true },
{ value: "operations", label: "COO" },
{ value: "engineering", label: "CTO" },
{ value: "marketing", label: "CMO" },
{ value: "finance", label: "CFO" },
{ value: "sales", label: "Vertriebsleiter" },
];
@@ -40,7 +38,7 @@ export default function AirScalePage() {
const [headers, setHeaders] = useState<string[]>([]);
const [domainCol, setDomainCol] = useState<string>("");
const [nameCol, setNameCol] = useState<string>("");
const [categories, setCategories] = useState<DecisionMakerCategory[]>(DEFAULT_ROLES);
const [category, setCategory] = useState<DecisionMakerCategory>("ceo");
const [jobId, setJobId] = useState<string | null>(null);
const [jobStatus, setJobStatus] = useState<string>("idle");
const [progress, setProgress] = useState({ current: 0, total: 0 });
@@ -70,7 +68,6 @@ export default function AirScalePage() {
const startEnrichment = async () => {
if (!companies.length) return toast.error("Keine Unternehmen mit Domains gefunden");
if (!categories.length) return toast.error("Mindestens eine Entscheider-Kategorie auswählen");
setRunning(true);
setResults([]);
@@ -80,7 +77,7 @@ export default function AirScalePage() {
const res = await fetch("/api/jobs/airscale-enrich", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ companies, categories }),
body: JSON.stringify({ companies, categories: [category] }),
});
const data = await res.json() as { jobId?: string; error?: string };
if (!res.ok || !data.jobId) throw new Error(data.error || "Failed to start job");
@@ -257,31 +254,24 @@ export default function AirScalePage() {
</h2>
<div className="space-y-3">
<Label className="text-gray-300 text-sm">Kategorien auswählen (nach Priorität sortiert)</Label>
<div className="flex flex-wrap gap-2">
{CATEGORY_OPTIONS.map(opt => (
<button
key={opt.value}
onClick={() => {
setCategories(prev =>
prev.includes(opt.value)
? prev.filter(c => c !== opt.value)
: [...prev, opt.value]
);
}}
className={`px-3 py-1.5 rounded-lg text-sm font-medium border transition-all ${
categories.includes(opt.value)
onClick={() => setCategory(opt.value)}
className={`flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium border transition-all ${
category === opt.value
? "bg-blue-500/20 text-blue-300 border-blue-500/40"
: "bg-[#0d0d18] text-gray-400 border-[#2e2e3e] hover:border-blue-500/30"
}`}
>
{opt.label}
{opt.recommended && (
<span className="text-[10px] bg-blue-500/30 text-blue-300 px-1.5 py-0.5 rounded font-semibold">Empfohlen</span>
)}
</button>
))}
</div>
<p className="text-xs text-gray-500">
Kategorien werden in Prioritätsreihenfolge durchsucht. Die erste Kategorie mit einem gültigen Ergebnis gewinnt.
</p>
</div>
</Card>
@@ -302,7 +292,7 @@ export default function AirScalePage() {
) : (
<Button
onClick={startEnrichment}
disabled={!withDomain || !domainCol || !categories.length}
disabled={!withDomain || !domainCol}
className="bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700 text-white font-medium px-8 shadow-lg hover:shadow-blue-500/25 transition-all"
>
Anreicherung starten ({withDomain} Unternehmen)