Tickets können jetzt eine Rückfrage (Question) tragen und die Züchterin kann
in-app antworten. Feedback um FK-freie Felder Question/Answer/AnsweredAt erweitert
(überlebt Ingest-Wipe); Status-Lebenszyklus Open → NeedsInfo (Rückfrage gestellt)
→ Answered (beantwortet) → Resolved. Migration AddFeedbackQuestionAnswer.
PUT /feedback/{id}: question → NeedsInfo, answer → Answered+AnsweredAt; DTO gibt
die Felder zurück. Tickets-Seite (/hilfe/tickets) zeigt die Rückfrage hervorgehoben
und bietet ein Antwort-Feld + „Antworten"; Status-Badges Offen/Rückfrage offen/
Beantwortet/Gelöst.
Tests: FeedbackEndpointTests (Frage→NeedsInfo, Antwort→Answered, übersteht Ingest),
e2e tickets.spec.ts. dotnet/vitest/playwright grün.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
91 lines
2.9 KiB
TypeScript
91 lines
2.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'
|
|
|
|
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
|
|
}
|
|
|
|
/** 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
|
|
}
|
|
|
|
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}`)
|
|
}
|