import { apiEndpoints } from "@/lib/api/endpoints"; import { fetchWithAuth } from "@/lib/auth/client"; import type { SupportTicketDetailResponse, SupportTicketStatus, SupportTicketsResponse, SupportTicketUpdateResponse, SupportMessageResponse, } from "@/types/api"; export async function listSupportTickets( params: Record = {}, ) { return fetchWithAuth(apiEndpoints.support.adminTickets(params)); } export async function getSupportTicket(ticketId: string) { return fetchWithAuth(apiEndpoints.support.adminTicket(ticketId)); } export async function replyToSupportTicket(ticketId: string, message: string, image?: File | null) { const formData = new FormData(); formData.set("message", message); if (image) { formData.set("image", image); } return fetchWithAuth(apiEndpoints.support.adminReply(ticketId), { method: "POST", body: formData, }); } export async function updateSupportTicketStatus(ticketId: string, status: SupportTicketStatus) { return fetchWithAuth(apiEndpoints.support.adminStatus(ticketId), { method: "PATCH", body: JSON.stringify({ status }), }); } export async function assignSupportTicket(ticketId: string, adminId: string) { return fetchWithAuth(apiEndpoints.support.adminAssign(ticketId), { method: "PATCH", body: JSON.stringify({ adminId: adminId || null }), }); }