KI-AGENT: Share-Upload an FEDEO-Design und Listenfilter angleichen

This commit is contained in:
2026-08-08 22:36:09 +02:00
parent ec4469e21f
commit ca91de2284
5 changed files with 166 additions and 130 deletions

View File

@@ -15,6 +15,7 @@ import {
import { useRouter } from 'expo-router';
import { createCustomer, Customer, fetchCustomers } from '@/src/lib/api';
import { filterCustomers } from '@/src/lib/resource-list-filters';
import { useAuth } from '@/src/providers/auth-provider';
const PRIMARY = '#69c350';
@@ -37,20 +38,10 @@ export default function CustomersScreen() {
const [numberInput, setNumberInput] = useState('');
const [notesInput, setNotesInput] = useState('');
const filtered = useMemo(() => {
const terms = search.trim().toLowerCase().split(/\s+/).filter(Boolean);
return customers.filter((customer) => {
if (!showArchived && customer.archived) return false;
if (terms.length === 0) return true;
const haystack = [customer.name, customer.customerNumber, customer.notes]
.map((value) => String(value || '').toLowerCase())
.join(' ');
return terms.every((term) => haystack.includes(term));
});
}, [customers, search, showArchived]);
const filtered = useMemo(
() => filterCustomers(customers, search, showArchived),
[customers, search, showArchived]
);
const load = useCallback(async (showSpinner = true) => {
if (!token) return;

View File

@@ -15,16 +15,11 @@ import {
import { useRouter } from 'expo-router';
import { createPlant, Customer, fetchCustomers, fetchPlants, Plant } from '@/src/lib/api';
import { filterPlants, getPlantCustomerName } from '@/src/lib/resource-list-filters';
import { useAuth } from '@/src/providers/auth-provider';
const PRIMARY = '#69c350';
function getCustomerName(raw: Plant['customer']): string | null {
if (!raw) return null;
if (typeof raw === 'object') return raw.name ? String(raw.name) : null;
return String(raw);
}
export default function PlantsScreen() {
const { token } = useAuth();
const router = useRouter();
@@ -47,20 +42,10 @@ export default function PlantsScreen() {
const [pickerMode, setPickerMode] = useState<'customer' | null>(null);
const [customerSearch, setCustomerSearch] = useState('');
const filtered = useMemo(() => {
const terms = search.trim().toLowerCase().split(/\s+/).filter(Boolean);
return plants.filter((plant) => {
if (!showArchived && plant.archived) return false;
if (terms.length === 0) return true;
const haystack = [plant.name, plant.description, getCustomerName(plant.customer)]
.map((value) => String(value || '').toLowerCase())
.join(' ');
return terms.every((term) => haystack.includes(term));
});
}, [plants, search, showArchived]);
const filtered = useMemo(
() => filterPlants(plants, search, showArchived),
[plants, search, showArchived]
);
const filteredCustomerOptions = useMemo(() => {
const terms = customerSearch.trim().toLowerCase().split(/\s+/).filter(Boolean);
@@ -189,8 +174,8 @@ export default function PlantsScreen() {
<Text style={styles.rowTitle} numberOfLines={1}>{plant.name}</Text>
{plant.archived ? <Text style={styles.badge}>Abgeschlossen</Text> : null}
</View>
{getCustomerName(plant.customer) ? (
<Text style={styles.rowSubtitle} numberOfLines={1}>Kunde: {getCustomerName(plant.customer)}</Text>
{getPlantCustomerName(plant.customer) ? (
<Text style={styles.rowSubtitle} numberOfLines={1}>Kunde: {getPlantCustomerName(plant.customer)}</Text>
) : null}
{plant.description ? <Text style={styles.rowSubtitle} numberOfLines={1}>{String(plant.description)}</Text> : null}
</Pressable>