- Feedback: fixNote (Changelog), agentContext (intern), thread (Q&A-Verlauf); 3 gefilterte Ansichten (Rückfragen/Offen/Geschlossen) - Tickets-Text: klickbare Tier-Links (ID→Name), Ticket→Ticket-Links (?focus=), Markdown-Links; Antwort-Entwurf pro Ticket in localStorage - "Fehler melden": Entwurf übersteht App-Wechsel/Schließen (ein gemeinsamer Entwurf) - entityName als Hyperlink zum referenzierten Datensatz Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
113 lines
3.9 KiB
TypeScript
113 lines
3.9 KiB
TypeScript
/** FEEDBACK: API client for the "Fehler melden" report sink (POST /feedback). */
|
|
import { api } from './client'
|
|
|
|
const RESOURCE = '/feedback'
|
|
|
|
/** Which view a report was filed from (matches the backend Context contract). */
|
|
export type FeedbackContext = 'stammbaum' | 'gerbil-detail' | 'litter-detail' | 'contact-detail'
|
|
|
|
/** Payload for POST /feedback. Debug fields are captured automatically by the caller. */
|
|
export interface FeedbackInput {
|
|
message: string
|
|
context: FeedbackContext
|
|
gerbilId?: string | null
|
|
litterId?: string | null
|
|
contactId?: string | null
|
|
entityName?: string | null
|
|
url?: string | null
|
|
clientTimestamp?: string | null
|
|
}
|
|
|
|
/**
|
|
* Ticket lifecycle status (matches the backend Status contract).
|
|
* - Open — neu, noch keine Rückfrage.
|
|
* - NeedsInfo — eine Rückfrage wurde gestellt, wartet auf die Antwort der Züchterin.
|
|
* - Answered — die Züchterin hat geantwortet.
|
|
* - Resolved — erledigt.
|
|
*/
|
|
export type FeedbackStatus = 'Open' | 'NeedsInfo' | 'Answered' | 'Resolved'
|
|
|
|
/** Eine vergangene Frage/Antwort-Runde im Verlauf (Thread) eines Tickets. */
|
|
export interface FeedbackThreadEntry {
|
|
/** „maintainer" = Rückfrage, „breeder" = Antwort der Züchterin. */
|
|
role: 'maintainer' | 'breeder'
|
|
text: string
|
|
/** Zeitpunkt der Runde (ISO-8601) oder null. */
|
|
at: string | null
|
|
}
|
|
|
|
export interface Feedback {
|
|
id: string
|
|
message: string
|
|
context: string
|
|
gerbilId: string | null
|
|
litterId: string | null
|
|
contactId: string | null
|
|
entityName: string | null
|
|
url: string | null
|
|
clientTimestamp: string | null
|
|
userAgent: string | null
|
|
createdAt: string
|
|
status: FeedbackStatus
|
|
resolvedAt: string | null
|
|
/** Rückfrage einer/eines Betreuenden an die Züchterin (falls vorhanden). */
|
|
question: string | null
|
|
/** Antwort der Züchterin auf die Rückfrage (falls vorhanden). */
|
|
answer: string | null
|
|
/** Zeitpunkt der Antwort der Züchterin. */
|
|
answeredAt: string | null
|
|
/** Laienverständlicher Changelog, der beim Schließen geschrieben wird (sichtbar). */
|
|
fixNote: string | null
|
|
/**
|
|
* INTERN: Arbeitsgedächtnis des Agenten — wird vom Backend geliefert, darf aber
|
|
* NIEMALS in der Züchterin-UI angezeigt werden.
|
|
*/
|
|
agentContext: string | null
|
|
/** Frühere Frage/Antwort-Runden (älteste zuerst); die aktuelle offene Runde bleibt in question/answer. */
|
|
thread: FeedbackThreadEntry[]
|
|
}
|
|
|
|
/** Alias used by the "Meine Tickets" area for readability. */
|
|
export type FeedbackTicket = Feedback
|
|
|
|
/**
|
|
* Payload for PUT /feedback/{id}: edit the message, toggle the status, attach a
|
|
* clarifying question (Rückfrage) or submit the breeder's answer.
|
|
*/
|
|
export interface FeedbackUpdate {
|
|
message?: string
|
|
status?: FeedbackStatus
|
|
/** Rückfrage anhängen (nicht leer ⇒ Status wird serverseitig auf NeedsInfo gesetzt). */
|
|
question?: string
|
|
/** Antwort der Züchterin (nicht leer ⇒ Status Answered + answeredAt). */
|
|
answer?: string
|
|
/** Laienverständlicher Changelog (typisch zusammen mit status: "Resolved" gesetzt). */
|
|
fixNote?: string
|
|
/** INTERN: Arbeitsgedächtnis des Agenten (ändert den Status nicht). */
|
|
agentContext?: string
|
|
}
|
|
|
|
export function submitFeedback(body: FeedbackInput): Promise<Feedback> {
|
|
return api.post<Feedback>(RESOURCE, body)
|
|
}
|
|
|
|
/** List all feedback tickets, newest first. */
|
|
export function listFeedback(): Promise<Feedback[]> {
|
|
return api.get<Feedback[]>(RESOURCE)
|
|
}
|
|
|
|
/** Edit a ticket's message and/or status. */
|
|
export function updateFeedback(id: string, body: FeedbackUpdate): Promise<Feedback> {
|
|
return api.put<Feedback>(`${RESOURCE}/${id}`, body)
|
|
}
|
|
|
|
/** Convenience: submit the breeder's answer to a ticket's clarifying question. */
|
|
export function answerTicket(id: string, answer: string): Promise<Feedback> {
|
|
return updateFeedback(id, { answer })
|
|
}
|
|
|
|
/** Delete a ticket. */
|
|
export function deleteFeedback(id: string): Promise<void> {
|
|
return api.delete(`${RESOURCE}/${id}`)
|
|
}
|