feat: add support tickets backend and dashboard
هذا الالتزام موجود في:
45
oudelaa_dashboard/lib/api/support.ts
Normal file
45
oudelaa_dashboard/lib/api/support.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
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<string, string | number | boolean | null | undefined> = {},
|
||||
) {
|
||||
return fetchWithAuth<SupportTicketsResponse>(apiEndpoints.support.adminTickets(params));
|
||||
}
|
||||
|
||||
export async function getSupportTicket(ticketId: string) {
|
||||
return fetchWithAuth<SupportTicketDetailResponse>(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<SupportMessageResponse>(apiEndpoints.support.adminReply(ticketId), {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateSupportTicketStatus(ticketId: string, status: SupportTicketStatus) {
|
||||
return fetchWithAuth<SupportTicketUpdateResponse>(apiEndpoints.support.adminStatus(ticketId), {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify({ status }),
|
||||
});
|
||||
}
|
||||
|
||||
export async function assignSupportTicket(ticketId: string, adminId: string) {
|
||||
return fetchWithAuth<SupportTicketUpdateResponse>(apiEndpoints.support.adminAssign(ticketId), {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify({ adminId: adminId || null }),
|
||||
});
|
||||
}
|
||||
المرجع في مشكلة جديدة
حظر مستخدم