KI-AGENT: Mobile Kundenerfassung und Logbücher erweitern
This commit is contained in:
@@ -17,6 +17,7 @@ import * as DocumentPicker from 'expo-document-picker';
|
||||
import * as WebBrowser from 'expo-web-browser';
|
||||
import { BarcodeScanningResult, BarcodeType, CameraView, useCameraPermissions } from 'expo-camera';
|
||||
|
||||
import { HistorySection } from '@/components/history-section';
|
||||
import {
|
||||
createCustomerInventoryItem,
|
||||
CreatedDocument,
|
||||
@@ -117,10 +118,18 @@ export default function CustomerDetailScreen() {
|
||||
return [
|
||||
{ label: 'Name', value: String(customer.name || '-') },
|
||||
{ label: 'Kundennummer', value: String(customer.customerNumber || '-') },
|
||||
{ label: 'Typ', value: String(customer.type || '-') },
|
||||
{ label: 'Kundentyp', value: customer.isCompany ? 'Firma' : 'Privat' },
|
||||
{ label: 'Namenszusatz', value: String(customer.nameAddition || '-') },
|
||||
{ label: 'E-Mail', value: String(infoData.email || customer.email || '-') },
|
||||
{ label: 'Rechnungs-E-Mail', value: String(infoData.invoiceEmail || '-') },
|
||||
{ label: 'Telefon', value: String(infoData.tel || customer.phone || '-') },
|
||||
{ label: 'Mobilnummer', value: String(infoData.mobileTel || '-') },
|
||||
{ label: 'Straße', value: String(infoData.street || '-') },
|
||||
{ label: 'Adresszusatz', value: String(infoData.special || '-') },
|
||||
{ label: 'PLZ / Stadt', value: [infoData.zip, infoData.city].filter(Boolean).join(' ') || '-' },
|
||||
{ label: 'Land', value: String(infoData.country || '-') },
|
||||
{ label: 'Webseite', value: String(infoData.web || '-') },
|
||||
{ label: 'USt-Id', value: String(infoData.ustid || '-') },
|
||||
{ label: 'Erstellt', value: formatDateTime(customer.createdAt || customer.created_at) },
|
||||
{ label: 'Aktualisiert', value: formatDateTime(customer.updatedAt || customer.updated_at) },
|
||||
];
|
||||
@@ -373,6 +382,8 @@ export default function CustomerDetailScreen() {
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
<HistorySection resource="customers" resourceId={customerId} />
|
||||
|
||||
<View style={styles.card}>
|
||||
<View style={styles.sectionHeader}>
|
||||
<Text style={styles.sectionTitle}>Kundeninventar ({inventoryItems.length})</Text>
|
||||
|
||||
@@ -34,8 +34,25 @@ export default function CustomersScreen() {
|
||||
const [createOpen, setCreateOpen] = useState(false);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [createError, setCreateError] = useState<string | null>(null);
|
||||
const [isCompanyInput, setIsCompanyInput] = useState(false);
|
||||
const [nameInput, setNameInput] = useState('');
|
||||
const [nameAdditionInput, setNameAdditionInput] = useState('');
|
||||
const [salutationInput, setSalutationInput] = useState('');
|
||||
const [titleInput, setTitleInput] = useState('');
|
||||
const [firstnameInput, setFirstnameInput] = useState('');
|
||||
const [lastnameInput, setLastnameInput] = useState('');
|
||||
const [numberInput, setNumberInput] = useState('');
|
||||
const [streetInput, setStreetInput] = useState('');
|
||||
const [addressAdditionInput, setAddressAdditionInput] = useState('');
|
||||
const [zipInput, setZipInput] = useState('');
|
||||
const [cityInput, setCityInput] = useState('');
|
||||
const [countryInput, setCountryInput] = useState('Deutschland');
|
||||
const [phoneInput, setPhoneInput] = useState('');
|
||||
const [mobileInput, setMobileInput] = useState('');
|
||||
const [emailInput, setEmailInput] = useState('');
|
||||
const [invoiceEmailInput, setInvoiceEmailInput] = useState('');
|
||||
const [websiteInput, setWebsiteInput] = useState('');
|
||||
const [vatIdInput, setVatIdInput] = useState('');
|
||||
const [notesInput, setNotesInput] = useState('');
|
||||
|
||||
const filtered = useMemo(
|
||||
@@ -72,17 +89,36 @@ export default function CustomersScreen() {
|
||||
function closeCreateModal() {
|
||||
setCreateOpen(false);
|
||||
setCreateError(null);
|
||||
setIsCompanyInput(false);
|
||||
setNameInput('');
|
||||
setNameAdditionInput('');
|
||||
setSalutationInput('');
|
||||
setTitleInput('');
|
||||
setFirstnameInput('');
|
||||
setLastnameInput('');
|
||||
setNumberInput('');
|
||||
setStreetInput('');
|
||||
setAddressAdditionInput('');
|
||||
setZipInput('');
|
||||
setCityInput('');
|
||||
setCountryInput('Deutschland');
|
||||
setPhoneInput('');
|
||||
setMobileInput('');
|
||||
setEmailInput('');
|
||||
setInvoiceEmailInput('');
|
||||
setWebsiteInput('');
|
||||
setVatIdInput('');
|
||||
setNotesInput('');
|
||||
}
|
||||
|
||||
async function onCreateCustomer() {
|
||||
if (!token) return;
|
||||
|
||||
const name = nameInput.trim();
|
||||
const name = isCompanyInput
|
||||
? nameInput.trim()
|
||||
: [salutationInput, titleInput, firstnameInput, lastnameInput].map((value) => value.trim()).filter(Boolean).join(' ');
|
||||
if (!name) {
|
||||
setCreateError('Bitte einen Namen eingeben.');
|
||||
setCreateError(isCompanyInput ? 'Bitte einen Firmennamen eingeben.' : 'Bitte mindestens Vor- oder Nachname eingeben.');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -93,6 +129,25 @@ export default function CustomersScreen() {
|
||||
await createCustomer(token, {
|
||||
name,
|
||||
customerNumber: numberInput.trim() || null,
|
||||
isCompany: isCompanyInput,
|
||||
nameAddition: nameAdditionInput.trim() || null,
|
||||
salutation: salutationInput.trim() || null,
|
||||
title: titleInput.trim() || null,
|
||||
firstname: firstnameInput.trim() || null,
|
||||
lastname: lastnameInput.trim() || null,
|
||||
infoData: {
|
||||
street: streetInput.trim() || null,
|
||||
special: addressAdditionInput.trim() || null,
|
||||
zip: zipInput.trim() || null,
|
||||
city: cityInput.trim() || null,
|
||||
country: countryInput.trim() || null,
|
||||
tel: phoneInput.trim() || null,
|
||||
mobileTel: mobileInput.trim() || null,
|
||||
email: emailInput.trim() || null,
|
||||
invoiceEmail: invoiceEmailInput.trim() || null,
|
||||
web: websiteInput.trim() || null,
|
||||
ustid: vatIdInput.trim() || null,
|
||||
},
|
||||
notes: notesInput.trim() || null,
|
||||
});
|
||||
closeCreateModal();
|
||||
@@ -168,30 +223,187 @@ export default function CustomersScreen() {
|
||||
<View style={styles.modalCard}>
|
||||
<Text style={styles.modalTitle}>Neuer Kunde</Text>
|
||||
|
||||
<TextInput
|
||||
placeholder="Name"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={styles.searchInput}
|
||||
value={nameInput}
|
||||
onChangeText={setNameInput}
|
||||
/>
|
||||
<TextInput
|
||||
placeholder="Kundennummer (optional)"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={styles.searchInput}
|
||||
value={numberInput}
|
||||
onChangeText={setNumberInput}
|
||||
/>
|
||||
<TextInput
|
||||
placeholder="Notizen (optional)"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={[styles.searchInput, styles.multilineInput]}
|
||||
value={notesInput}
|
||||
onChangeText={setNotesInput}
|
||||
multiline
|
||||
/>
|
||||
<ScrollView
|
||||
style={styles.modalScroll}
|
||||
contentContainerStyle={styles.modalForm}
|
||||
keyboardShouldPersistTaps="handled">
|
||||
<Text style={styles.fieldLabel}>Kundentyp</Text>
|
||||
<View style={styles.segmentedControl}>
|
||||
<Pressable
|
||||
style={[styles.segment, !isCompanyInput ? styles.segmentActive : null]}
|
||||
onPress={() => setIsCompanyInput(false)}>
|
||||
<Text style={[styles.segmentText, !isCompanyInput ? styles.segmentTextActive : null]}>Privat</Text>
|
||||
</Pressable>
|
||||
<Pressable
|
||||
style={[styles.segment, isCompanyInput ? styles.segmentActive : null]}
|
||||
onPress={() => setIsCompanyInput(true)}>
|
||||
<Text style={[styles.segmentText, isCompanyInput ? styles.segmentTextActive : null]}>Firma</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
|
||||
{createError ? <Text style={styles.error}>{createError}</Text> : null}
|
||||
<Text style={styles.sectionLabel}>Allgemeines</Text>
|
||||
{isCompanyInput ? (
|
||||
<>
|
||||
<TextInput
|
||||
placeholder="Firmenname *"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={styles.searchInput}
|
||||
value={nameInput}
|
||||
onChangeText={setNameInput}
|
||||
/>
|
||||
<TextInput
|
||||
placeholder="Firmenname Zusatz"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={styles.searchInput}
|
||||
value={nameAdditionInput}
|
||||
onChangeText={setNameAdditionInput}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<View style={styles.inputRow}>
|
||||
<TextInput
|
||||
placeholder="Anrede"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={[styles.searchInput, styles.flexInput]}
|
||||
value={salutationInput}
|
||||
onChangeText={setSalutationInput}
|
||||
/>
|
||||
<TextInput
|
||||
placeholder="Titel"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={[styles.searchInput, styles.flexInput]}
|
||||
value={titleInput}
|
||||
onChangeText={setTitleInput}
|
||||
/>
|
||||
</View>
|
||||
<TextInput
|
||||
placeholder="Vorname"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={styles.searchInput}
|
||||
value={firstnameInput}
|
||||
onChangeText={setFirstnameInput}
|
||||
/>
|
||||
<TextInput
|
||||
placeholder="Nachname"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={styles.searchInput}
|
||||
value={lastnameInput}
|
||||
onChangeText={setLastnameInput}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<TextInput
|
||||
placeholder="Kundennummer (wird sonst automatisch vergeben)"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={styles.searchInput}
|
||||
value={numberInput}
|
||||
onChangeText={setNumberInput}
|
||||
/>
|
||||
|
||||
<Text style={styles.sectionLabel}>Adresse</Text>
|
||||
<TextInput
|
||||
placeholder="Straße + Hausnummer"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={styles.searchInput}
|
||||
value={streetInput}
|
||||
onChangeText={setStreetInput}
|
||||
/>
|
||||
<TextInput
|
||||
placeholder="Adresszusatz"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={styles.searchInput}
|
||||
value={addressAdditionInput}
|
||||
onChangeText={setAddressAdditionInput}
|
||||
/>
|
||||
<View style={styles.inputRow}>
|
||||
<TextInput
|
||||
placeholder="PLZ"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={[styles.searchInput, styles.zipInput]}
|
||||
value={zipInput}
|
||||
onChangeText={setZipInput}
|
||||
keyboardType="numbers-and-punctuation"
|
||||
/>
|
||||
<TextInput
|
||||
placeholder="Stadt"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={[styles.searchInput, styles.flexInput]}
|
||||
value={cityInput}
|
||||
onChangeText={setCityInput}
|
||||
/>
|
||||
</View>
|
||||
<TextInput
|
||||
placeholder="Land"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={styles.searchInput}
|
||||
value={countryInput}
|
||||
onChangeText={setCountryInput}
|
||||
/>
|
||||
|
||||
<Text style={styles.sectionLabel}>Kontaktdaten</Text>
|
||||
<TextInput
|
||||
placeholder="E-Mail"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={styles.searchInput}
|
||||
value={emailInput}
|
||||
onChangeText={setEmailInput}
|
||||
autoCapitalize="none"
|
||||
keyboardType="email-address"
|
||||
/>
|
||||
<TextInput
|
||||
placeholder="E-Mail für Rechnungen"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={styles.searchInput}
|
||||
value={invoiceEmailInput}
|
||||
onChangeText={setInvoiceEmailInput}
|
||||
autoCapitalize="none"
|
||||
keyboardType="email-address"
|
||||
/>
|
||||
<TextInput
|
||||
placeholder="Telefon"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={styles.searchInput}
|
||||
value={phoneInput}
|
||||
onChangeText={setPhoneInput}
|
||||
keyboardType="phone-pad"
|
||||
/>
|
||||
<TextInput
|
||||
placeholder="Mobilnummer"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={styles.searchInput}
|
||||
value={mobileInput}
|
||||
onChangeText={setMobileInput}
|
||||
keyboardType="phone-pad"
|
||||
/>
|
||||
<TextInput
|
||||
placeholder="Webseite"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={styles.searchInput}
|
||||
value={websiteInput}
|
||||
onChangeText={setWebsiteInput}
|
||||
autoCapitalize="none"
|
||||
keyboardType="url"
|
||||
/>
|
||||
<TextInput
|
||||
placeholder="USt-Id"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={styles.searchInput}
|
||||
value={vatIdInput}
|
||||
onChangeText={setVatIdInput}
|
||||
autoCapitalize="characters"
|
||||
/>
|
||||
<TextInput
|
||||
placeholder="Notizen"
|
||||
placeholderTextColor="#9ca3af"
|
||||
style={[styles.searchInput, styles.multilineInput]}
|
||||
value={notesInput}
|
||||
onChangeText={setNotesInput}
|
||||
multiline
|
||||
/>
|
||||
|
||||
{createError ? <Text style={styles.formError}>{createError}</Text> : null}
|
||||
</ScrollView>
|
||||
|
||||
<View style={styles.modalActions}>
|
||||
<Pressable style={styles.secondaryButton} onPress={closeCreateModal} disabled={saving}>
|
||||
@@ -313,6 +525,7 @@ const styles = StyleSheet.create({
|
||||
borderRadius: 14,
|
||||
padding: 16,
|
||||
gap: 10,
|
||||
maxHeight: '92%',
|
||||
},
|
||||
modalTitle: {
|
||||
color: '#111827',
|
||||
@@ -323,6 +536,63 @@ const styles = StyleSheet.create({
|
||||
minHeight: 92,
|
||||
textAlignVertical: 'top',
|
||||
},
|
||||
modalScroll: {
|
||||
flexShrink: 1,
|
||||
},
|
||||
modalForm: {
|
||||
gap: 10,
|
||||
paddingBottom: 4,
|
||||
},
|
||||
fieldLabel: {
|
||||
color: '#374151',
|
||||
fontSize: 13,
|
||||
fontWeight: '600',
|
||||
},
|
||||
sectionLabel: {
|
||||
color: '#111827',
|
||||
fontSize: 14,
|
||||
fontWeight: '700',
|
||||
marginTop: 6,
|
||||
},
|
||||
segmentedControl: {
|
||||
flexDirection: 'row',
|
||||
borderWidth: 1,
|
||||
borderColor: '#d1d5db',
|
||||
borderRadius: 10,
|
||||
padding: 3,
|
||||
gap: 3,
|
||||
},
|
||||
segment: {
|
||||
flex: 1,
|
||||
minHeight: 36,
|
||||
borderRadius: 7,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
segmentActive: {
|
||||
backgroundColor: '#eff9ea',
|
||||
},
|
||||
segmentText: {
|
||||
color: '#6b7280',
|
||||
fontWeight: '600',
|
||||
},
|
||||
segmentTextActive: {
|
||||
color: '#3d7a30',
|
||||
},
|
||||
inputRow: {
|
||||
flexDirection: 'row',
|
||||
gap: 8,
|
||||
},
|
||||
flexInput: {
|
||||
flex: 1,
|
||||
},
|
||||
zipInput: {
|
||||
width: 105,
|
||||
},
|
||||
formError: {
|
||||
color: '#dc2626',
|
||||
fontSize: 13,
|
||||
},
|
||||
modalActions: {
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'flex-end',
|
||||
|
||||
@@ -5,6 +5,7 @@ import * as DocumentPicker from 'expo-document-picker';
|
||||
import * as ImagePicker from 'expo-image-picker';
|
||||
import * as WebBrowser from 'expo-web-browser';
|
||||
|
||||
import { HistorySection } from '@/components/history-section';
|
||||
import { fetchPlantById, fetchPlantFiles, Plant, ProjectFile, uploadPlantFile } from '@/src/lib/api';
|
||||
import { useAuth } from '@/src/providers/auth-provider';
|
||||
|
||||
@@ -233,6 +234,8 @@ export default function PlantDetailScreen() {
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<HistorySection resource="plants" resourceId={plantId} />
|
||||
|
||||
<View style={styles.card}>
|
||||
<View style={styles.sectionHeader}>
|
||||
<Text style={styles.sectionTitle}>Dokumente ({files.length})</Text>
|
||||
|
||||
Reference in New Issue
Block a user