import { useState } from 'react'; import { useQuery } from '@tanstack/react-query'; import { Link } from 'react-router-dom'; import { customerApi } from '../../services/api'; import { useAuth } from '../../context/AuthContext'; import Card from '../../components/ui/Card'; import Button from '../../components/ui/Button'; import Input from '../../components/ui/Input'; import Badge from '../../components/ui/Badge'; import { Plus, Search, Eye, Edit } from 'lucide-react'; export default function CustomerList() { const [search, setSearch] = useState(''); const [type, setType] = useState(''); const [page, setPage] = useState(1); const { hasPermission } = useAuth(); const { data, isLoading } = useQuery({ queryKey: ['customers', search, type, page], queryFn: () => customerApi.getAll({ search, type: type || undefined, page, limit: 20 }), }); return (
| Kundennr. | Name | Typ | Verträge | Aktionen | |
|---|---|---|---|---|---|
| {customer.customerNumber} | {customer.type === 'BUSINESS' && customer.companyName ? customer.companyName : `${customer.firstName} ${customer.lastName}`} |
|
{customer.email || '-'} | {(customer as any)._count?.contracts || 0} |
{hasPermission('customers:update') && (
)}
|
Seite {data.pagination.page} von {data.pagination.totalPages} ({data.pagination.total} Einträge)