feat(akquise): Uebernommene Eintraege bleiben in der Liste

Bisher verschwand ein Fund mit der Uebernahme aus Eingang und Archiv.
Beim Durchgehen blieb damit offen, ob er schon angefasst wurde. Jetzt
bleibt der Eintrag stehen und zeigt statt "Opportunity" den blauen Knopf
"Uebernommen" mit Haken; ein Klick springt zur Opportunity.

Dafuer entscheidet nicht mehr IS_OPEN ueber die Listen, sondern die neuen
Regeln IN_INBOX und RETURNED: ein Rueckfaeller (Opportunity im Papierkorb
oder geloescht) gehoert weiter ins Archiv, alles andere bleibt in seiner
Liste. Zaehler und Menuezahl folgen derselben Regel. IS_OPEN bleibt fuer
den Loeschlauf: was zu einer lebenden Opportunity gehoert, wird nicht
weggeraeumt.

Solange die Opportunity lebt, sind Bearbeiten, Loeschen und "Zurueck in
die Akquise" am Eintrag gesperrt - er ist ihr Herkunftsnachweis, und der
Rueckweg von der Opportunity braucht ihn. Das Loeschen weist auch das
Backend ab, nicht nur die Oberflaeche.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Sascha Wolf
2026-09-21 15:46:26 +02:00
co-authored by Claude Opus 5
parent 86aa7468af
commit 3e76a73f2e
8 changed files with 154 additions and 61 deletions
+65 -21
View File
@@ -26,6 +26,8 @@ interface AcquisitionTableProps {
onEdit: (entry: Acquisition) => void;
onDelete: (entry: Acquisition) => void;
onConvert: (entry: Acquisition) => void;
/** Sprung zur bereits angelegten Opportunity. */
onOpenOpportunity: (entry: Acquisition) => void;
/** Nur im Archiv gesetzt - im Eingang gibt es nichts zurueckzuholen. */
onReopen?: (entry: Acquisition) => void;
}
@@ -76,13 +78,22 @@ function safeLink(value: string | null): string | null {
return /^https?:\/\//i.test(value) ? value : null;
}
/**
* Uebernommen und die Opportunity lebt noch. Ein Rueckfaeller (Opportunity im
* Papierkorb oder geloescht) zaehlt nicht dazu - der darf erneut uebernommen
* werden und bekommt deshalb wieder den normalen Knopf.
*/
function isConverted(entry: Acquisition): boolean {
return entry.converted_at !== null && !entry.opportunity_gone;
}
/**
* Kennzeichen fuer eine Bewerbung, die ins Archiv zurueckgefallen ist: sie war
* schon eine Opportunity, und die ist weg. Ohne den Hinweis stuende sie
* unerklaerlich im Archiv.
*/
function returnedNote(entry: Acquisition): string | null {
if (entry.converted_at === null) return null;
if (entry.converted_at === null || isConverted(entry)) return null;
if (entry.opportunity_deleted_at) return 'Opportunity im Papierkorb';
return 'Opportunity gelöscht';
}
@@ -119,6 +130,7 @@ export const AcquisitionTable: React.FC<AcquisitionTableProps> = ({
onEdit,
onDelete,
onConvert,
onOpenOpportunity,
onReopen,
}) => (
<div className="overflow-hidden rounded-2xl border border-ink-200 bg-surface shadow-card">
@@ -156,6 +168,7 @@ export const AcquisitionTable: React.FC<AcquisitionTableProps> = ({
const extraParts = extras(entry);
const returned = returnedNote(entry);
const isBusy = busyId === entry.id;
const converted = isConverted(entry);
// Entscheidet nur die Beschriftung: bei mehreren Beratern entsteht
// beim Uebernehmen je Berater eine Opportunity.
const consultantCount = splitConsultants(entry.consultant).length;
@@ -221,26 +234,47 @@ export const AcquisitionTable: React.FC<AcquisitionTableProps> = ({
</td>
<td className="px-4 py-3">
<button
onClick={() => onConvert(entry)}
disabled={isBusy}
title={
consultantCount > 1
? `Je Berater eine Opportunity in der Phase „Erstgespräch Berater“ anlegen - ${consultantCount} insgesamt. Der Eintrag verschwindet danach aus dieser Liste.`
: 'Als neue Opportunity in der Phase „Erstgespräch Berater“ anlegen. Der Eintrag verschwindet danach aus dieser Liste.'
}
className="flex items-center gap-1.5 whitespace-nowrap rounded-xl bg-brand-500 px-3 py-1.5 text-xs font-bold text-white shadow-card transition hover:bg-brand-600 disabled:opacity-50"
>
<svg className="h-3.5 w-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2.2} d="M12 4v16m8-8H4" />
</svg>
{isBusy ? 'Lege an...' : 'Opportunity'}
</button>
{/*
Ein uebernommener Eintrag bleibt in der Liste stehen - der
Knopf wird blau und fuehrt zur angelegten Opportunity.
*/}
{converted ? (
<button
onClick={() => onOpenOpportunity(entry)}
title={
entry.opportunity_title
? `Übernommen: „${entry.opportunity_title}“ öffnen`
: 'Übernommen - Opportunity öffnen'
}
className="flex items-center gap-1.5 whitespace-nowrap rounded-xl bg-blue-600 px-3 py-1.5 text-xs font-bold text-white shadow-card transition hover:bg-blue-700"
>
Übernommen
<svg className="h-3.5 w-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2.6} d="M5 13l4 4L19 7" />
</svg>
</button>
) : (
<button
onClick={() => onConvert(entry)}
disabled={isBusy}
title={
consultantCount > 1
? `Je Berater eine Opportunity in der Phase „Erstgespräch Berater“ anlegen - ${consultantCount} insgesamt. Der Eintrag bleibt stehen und ist danach als übernommen gekennzeichnet.`
: 'Als neue Opportunity in der Phase „Erstgespräch Berater“ anlegen. Der Eintrag bleibt stehen und ist danach als übernommen gekennzeichnet.'
}
className="flex items-center gap-1.5 whitespace-nowrap rounded-xl bg-brand-500 px-3 py-1.5 text-xs font-bold text-white shadow-card transition hover:bg-brand-600 disabled:opacity-50"
>
<svg className="h-3.5 w-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2.2} d="M12 4v16m8-8H4" />
</svg>
{isBusy ? 'Lege an...' : 'Opportunity'}
</button>
)}
</td>
<td className="whitespace-nowrap px-4 py-3 text-right">
<div className="inline-flex gap-1">
{onReopen && (
{onReopen && !converted && (
<button
onClick={() => onReopen(entry)}
disabled={isBusy}
@@ -260,9 +294,14 @@ export const AcquisitionTable: React.FC<AcquisitionTableProps> = ({
)}
<button
onClick={() => onEdit(entry)}
title="Bearbeiten"
disabled={converted}
title={
converted
? 'Übernommen - gepflegt wird jetzt in der Opportunity.'
: 'Bearbeiten'
}
aria-label={`${entry.title} bearbeiten`}
className="rounded-lg p-2 text-ink-400 transition hover:bg-brand-50 hover:text-brand-700"
className="rounded-lg p-2 text-ink-400 transition hover:bg-brand-50 hover:text-brand-700 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-ink-400"
>
<svg className="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
@@ -275,9 +314,14 @@ export const AcquisitionTable: React.FC<AcquisitionTableProps> = ({
</button>
<button
onClick={() => onDelete(entry)}
title="Löschen"
disabled={converted}
title={
converted
? 'Übernommen - der Eintrag gehört zur Opportunity und bleibt als Herkunftsnachweis stehen.'
: 'Löschen'
}
aria-label={`${entry.title} löschen`}
className="rounded-lg p-2 text-ink-400 transition hover:bg-red-50 hover:text-red-600"
className="rounded-lg p-2 text-ink-400 transition hover:bg-red-50 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-ink-400"
>
<svg className="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
@@ -152,6 +152,16 @@ export const Acquisitions: React.FC<AcquisitionsProps> = ({ view = 'eingang', re
}
};
/*
* Sprung zur Opportunity, die aus dem Eintrag entstanden ist. Bei mehreren
* Beratern merkt sich der Eintrag die erste - die Liste zeigt daneben ohnehin
* alle, die zum Projekt gehoeren.
*/
const openOpportunity = (entry: Acquisition) => {
if (entry.opportunity_id === null) return;
goTo('Opportunities', { opportunityId: entry.opportunity_id });
};
const reopen = async (entry: Acquisition) => {
setBusyId(entry.id);
try {
@@ -311,6 +321,7 @@ export const Acquisitions: React.FC<AcquisitionsProps> = ({ view = 'eingang', re
onEdit={setEditing}
onDelete={setToDelete}
onConvert={convert}
onOpenOpportunity={openOpportunity}
onReopen={isArchive ? handleReopen : undefined}
/>
)}