Tickets: Zeit-Spalte (Bloecke, 3 parallel, 200 Zeilen), Ticket-Suche per woid oder ID, Anfrage-Zaehler

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-06 06:02:55 +00:00
1 parent 9fec381056
commit 0b53fc825a
6 files changed
+201

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
/* Ticket zu einer Adresse wie /tickets/<ref>: erst die Nummer (woid), dann die Dokument-ID.
Kennt kein Appwrite, die Seite reicht die Abfragen herein. */
const NOT_FOUND_CODES = [400, 404]
export async function lookupWorkorder(ref, { findByWoid, getById }) {
const key = String(ref ?? '').trim()
if (!key) return { status: 'notfound' }
const byWoid = await findByWoid(key)
if (byWoid) return { status: 'ok', ticket: byWoid }
try {
const byId = await getById(key)
return byId ? { status: 'ok', ticket: byId } : { status: 'notfound' }
} catch (error) {
// Appwrite: 404 = keine solche ID, 400 = keine gueltige ID
if (NOT_FOUND_CODES.includes(Number(error?.code))) return { status: 'notfound' }
throw error
}
}