/** FEAT-2: Kontakte-Liste — Gridify-Namenssuche + Paging, Link auf Detailseite. */ import { useState } from 'react' import { Link } from 'react-router-dom' import { de } from '../strings/de' import { listContactsPaged } from '../api/contacts' import { condition, type GridifyQuery } from '../api/gridify' import { useApi } from '../hooks/useApi' const PAGE_SIZE = 20 export default function KontaktePage() { const t = de.pages.kontakte const [search, setSearch] = useState('') const [page, setPage] = useState(1) const filter = search.trim() ? condition({ field: 'name', op: 'contains', value: search.trim() }) : undefined const query: GridifyQuery = { filter, orderBy: 'name', page, pageSize: PAGE_SIZE } const contacts = useApi(() => listContactsPaged(query), [filter, page]) const total = contacts.data?.totalCount ?? 0 const totalPages = Math.max(1, Math.ceil(total / PAGE_SIZE)) const items = contacts.data?.items ?? [] return (

{t.title}

{contacts.data && (

{total} {t.countLabel}

)}
+ {t.newButton}
{ setSearch(e.target.value) setPage(1) }} aria-label={t.fields.name} />
{contacts.loading &&

{de.common.loading}

} {contacts.error && (
{contacts.error}
)} {!contacts.loading && !contacts.error && items.length === 0 && (

{t.empty}

)} {items.length > 0 && ( )} {totalPages > 1 && ( )}
) }