IHR SERVICE. IM ÜBERBLICK.
Alle Anfragen im Blick. Gemeinsam schneller zur Lösung.
@@ -515,22 +515,16 @@ function App() {
{[
- [Inbox, 'Offene Tickets', active.length, 'Alle laufenden Anfragen', 'teal'],
+ [Inbox, 'Offene Tickets', counts.open, 'Alle laufenden Anfragen', 'teal'],
[
MessageSquare,
'Neue Anfragen',
- active.filter((t) => t.behavior === 'new').length,
+ counts.new,
'Bereit für den ersten Kontakt',
'blue',
],
- [Clock3, 'Wartende Tickets', waiting.length, 'Kunde, Termin oder Ware', 'amber'],
- [
- CircleCheck,
- 'Erledigte Tickets',
- tickets.length - active.length,
- 'Gemeinsam gelöst',
- 'purple',
- ],
+ [Clock3, 'Wartende Tickets', counts.waiting, 'Kunde, Termin oder Ware', 'amber'],
+ [CircleCheck, 'Erledigte Tickets', counts.closed, 'Gemeinsam gelöst', 'purple'],
].map(([Icon, label, count, sub, color]: any) => (
@@ -547,17 +541,11 @@ function App() {
))}
-
+
- {!ticketsReady && (
+ {!ticketList.ready && !ticketList.error && (
Tickets werden geladen …
)}
- {ticketsReady && !rows.length && (
+ {ticketList.ready && !rows.length && (
Hier ist alles aufgeräumt.
@@ -758,10 +746,68 @@ function App() {
)}
diff --git a/src/GlobalSearch.tsx b/src/GlobalSearch.tsx
index b4d6287..e5f28b8 100644
--- a/src/GlobalSearch.tsx
+++ b/src/GlobalSearch.tsx
@@ -1,12 +1,19 @@
import { useEffect, useId, useRef, useState } from 'react'
import { Search, X } from 'lucide-react'
import { Input } from './components/ui/input'
+import { Button } from './components/ui/button'
import { api, number } from './api'
export function GlobalSearch({ onSelect }: { onSelect: (id: number) => void }) {
const [query, setQuery] = useState(''),
[open, setOpen] = useState(false),
- [result, setResult] = useState<{ items: any[]; total: number }>({ items: [], total: 0 }),
+ [result, setResult] = useState<{
+ items: any[]
+ total: number
+ page: number
+ totalPages: number
+ }>({ items: [], total: 0, page: 1, totalPages: 0 }),
+ [pageNumber, setPageNumber] = useState(1),
[loading, setLoading] = useState(false),
[error, setError] = useState(''),
[active, setActive] = useState(0)
@@ -15,7 +22,7 @@ export function GlobalSearch({ onSelect }: { onSelect: (id: number) => void }) {
listId = useId()
useEffect(() => {
let alive = true
- setResult({ items: [], total: 0 })
+ setResult((current) => ({ ...current, items: [] }))
setError('')
setActive(0)
if (!open || !query.trim()) {
@@ -23,11 +30,20 @@ export function GlobalSearch({ onSelect }: { onSelect: (id: number) => void }) {
return
}
setLoading(true)
+ const controller = new AbortController()
const timer = setTimeout(
() =>
- api(`/search?q=${encodeURIComponent(query.trim())}`)
+ api(
+ `/search?q=${encodeURIComponent(query.trim())}&page=${pageNumber}&pageSize=20`,
+ 'GET',
+ undefined,
+ { signal: controller.signal },
+ )
.then((data) => {
- if (alive) setResult(data)
+ if (alive) {
+ setResult(data)
+ if (data.page !== pageNumber) setPageNumber(data.page)
+ }
})
.catch((e) => {
if (alive) setError(e.message)
@@ -40,8 +56,9 @@ export function GlobalSearch({ onSelect }: { onSelect: (id: number) => void }) {
return () => {
alive = false
clearTimeout(timer)
+ controller.abort()
}
- }, [query, open])
+ }, [query, open, pageNumber])
useEffect(() => {
const outside = (event: PointerEvent) => {
if (!root.current?.contains(event.target as Node)) setOpen(false)
@@ -79,6 +96,8 @@ export function GlobalSearch({ onSelect }: { onSelect: (id: number) => void }) {
onFocus={() => setOpen(true)}
onChange={(event) => {
setQuery(event.target.value)
+ setPageNumber(1)
+ setResult({ items: [], total: 0, page: 1, totalPages: 0 })
setOpen(true)
}}
onKeyDown={(event) => {
@@ -118,7 +137,7 @@ export function GlobalSearch({ onSelect }: { onSelect: (id: number) => void }) {
? 'Suche läuft …'
: error ||
(result.total
- ? `${result.total} Treffer${result.total > 20 ? ' · erste 20 angezeigt' : ''}`
+ ? `${(result.page - 1) * 20 + 1}–${(result.page - 1) * 20 + result.items.length} von ${result.total} Treffern`
: 'Keine passenden Tickets gefunden.')}
@@ -144,6 +163,39 @@ export function GlobalSearch({ onSelect }: { onSelect: (id: number) => void }) {
))}
+ {result.totalPages > 1 && (
+
+
+
+ Seite {pageNumber} / {result.totalPages}
+
+
+
+ )}
)}
diff --git a/src/api.ts b/src/api.ts
index 2310b76..163aca5 100644
--- a/src/api.ts
+++ b/src/api.ts
@@ -1,8 +1,14 @@
-export async function api(path: string, method = 'GET', data?: unknown) {
+export async function api(
+ path: string,
+ method = 'GET',
+ data?: unknown,
+ options: { signal?: AbortSignal } = {},
+) {
const r = await fetch('/api' + path, {
method,
headers: { 'Content-Type': 'application/json' },
body: data === undefined ? undefined : JSON.stringify(data),
+ signal: options.signal,
})
const result = await r.json()
if (!r.ok) {
diff --git a/src/styles.css b/src/styles.css
index b7ab0ce..040f33d 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -2686,3 +2686,65 @@ input[type='color'] {
width: 100%;
}
}
+.table-footer {
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 12px;
+}
+.ticket-pagination,
+.ticket-pagination nav,
+.ticket-pagination > label {
+ display: flex;
+ align-items: center;
+ gap: 7px;
+}
+.ticket-pagination {
+ flex-wrap: wrap;
+ justify-content: flex-end;
+}
+.ticket-pagination > label {
+ color: var(--muted);
+ font-size: 11px;
+}
+.ticket-pagination select {
+ padding: 4px 7px;
+ font-size: 11px;
+ min-height: 30px;
+ width: 65px;
+}
+.ticket-pagination nav > span {
+ white-space: nowrap;
+ font-size: 11px;
+ margin: 0 5px;
+}
+.global-search-panel {
+ display: flex;
+ flex-direction: column;
+ overflow: hidden;
+}
+.global-search-panel [role='listbox'] {
+ overflow: auto;
+ min-height: 0;
+}
+.search-summary,
+.search-pagination {
+ flex-shrink: 0;
+}
+.search-pagination {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
+ border-top: 1px solid var(--border);
+ padding: 8px 12px;
+ font-size: 11px;
+ color: var(--muted);
+}
+@media (max-width: 600px) {
+ .ticket-pagination {
+ justify-content: flex-start;
+ }
+ .ticket-pagination nav {
+ gap: 4px;
+ }
+}
diff --git a/src/useTicketPage.ts b/src/useTicketPage.ts
new file mode 100644
index 0000000..c2c0404
--- /dev/null
+++ b/src/useTicketPage.ts
@@ -0,0 +1,94 @@
+import { useCallback, useEffect, useRef, useState } from 'react'
+import { api } from './api'
+
+export function useTicketPage(
+ boot: any,
+ filters: Record