Leads: Kundenart ist beim Anlegen Pflicht

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Sonnet 5.5 committed 2026-10-16 13:18:10 +00:00
1 parent 45b2b145b0
commit cbf4b265e0
2 files changed
+15 -3

No files matched your search

+6 -2
View File
@@ -1,5 +1,6 @@
import { databases, DATABASE_ID, COLLECTIONS, Query, ID } from './appwrite'
import { rejectionLine, notesWithRejection } from './leadDuplicates'
import { kundenartPruefen } from './kundenFelder'
/** Pflichtfelder eines festen Kunden: Name, E-Mail und vollständige Anschrift (Voraussetzung für „Zum festen Kunden machen“). */
export function isInvoiceReady(c) {
@@ -55,13 +56,16 @@ export async function createAcquisitionTicket(customer, user) {
return databases.createDocument(DATABASE_ID, COLLECTIONS.WORKORDERS, ID.unique(), data)
}
/** Legt einen Lead an (Unternehmen, E-Mail, Telefon) und erstellt das Akquise-Ticket. */
export async function createLead({ company, email, phone }, user) {
/** Legt einen Lead an (Unternehmen, E-Mail, Telefon, Kundenart) und erstellt das Akquise-Ticket. Ohne gültige Kundenart wird nichts geschrieben. */
export async function createLead({ company, email, phone, kundenart }, user) {
const fehler = kundenartPruefen(kundenart)
if (fehler) throw new Error(fehler)
const customer = await databases.createDocument(DATABASE_ID, COLLECTIONS.CUSTOMERS, ID.unique(), {
name: company,
companyName: company,
email: email || '',
phone: phone || '',
kundenart,
customerStatus: 'lead',
updatedAt: new Date().toISOString(),
})
+9 -1
View File
@@ -7,6 +7,8 @@ import { CUSTOMER_TABS, customerBadges, customerTitle, filterCustomers, stageCou
import { isRowActivation } from '../lib/rowClick'
import { findDuplicates } from '../lib/leadDuplicates'
import DuplicateWarning from '../components/customer/DuplicateWarning'
import KundenartAuswahl from '../components/KundenartAuswahl'
import { kundenartPruefen, KUNDENART_AUSWAHL_HINWEIS } from '../lib/kundenFelder'
import { PageHeader, Tabs, Button, Badge, EmptyState, Field, Dialog } from '../components/ui'
export default function CustomersPage() {
@@ -138,6 +140,7 @@ function CreateLeadForm({ customers, onCancel, onDone }) {
const [company, setCompany] = useState('')
const [email, setEmail] = useState('')
const [phone, setPhone] = useState('')
const [kundenart, setKundenart] = useState('')
const [busy, setBusy] = useState(false)
const [error, setError] = useState(null)
// Abgleich mit allen Kunden (auch archivierten und abgesagten), damit niemand doppelt angerufen wird
@@ -146,9 +149,11 @@ function CreateLeadForm({ customers, onCancel, onDone }) {
const submit = async (e) => {
e.preventDefault()
if (!company.trim()) { setError('Unternehmen erforderlich'); return }
const f = kundenartPruefen(kundenart)
if (f) { setError(f); return }
setBusy(true); setError(null)
try {
await onDone({ company: company.trim(), email: email.trim(), phone: phone.trim() })
await onDone({ company: company.trim(), email: email.trim(), phone: phone.trim(), kundenart })
} catch (err) {
setError(err.message || 'Fehler')
setBusy(false)
@@ -189,6 +194,9 @@ function CreateLeadForm({ customers, onCancel, onDone }) {
<input id="lead-phone" className="input" type="tel" value={phone} onChange={(e) => setPhone(e.target.value)} />
</Field>
</div>
<Field label="Kundenart" hint={KUNDENART_AUSWAHL_HINWEIS}>
<KundenartAuswahl value={kundenart} onChange={setKundenart} disabled={busy} />
</Field>
</Dialog>
)
}