/** 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 { return api.post(RESOURCE, body) } /** List all feedback tickets, newest first. */ export function listFeedback(): Promise { return api.get(RESOURCE) } /** Edit a ticket's message and/or status. */ export function updateFeedback(id: string, body: FeedbackUpdate): Promise { return api.put(`${RESOURCE}/${id}`, body) } /** Convenience: submit the breeder's answer to a ticket's clarifying question. */ export function answerTicket(id: string, answer: string): Promise { return updateFeedback(id, { answer }) } /** Delete a ticket. */ export function deleteFeedback(id: string): Promise { return api.delete(`${RESOURCE}/${id}`) }