feat: add support tickets backend and dashboard
هذا الالتزام موجود في:
@@ -119,6 +119,14 @@ export const apiEndpoints = {
|
||||
`/reports/superadmin?${toQueryString(params)}`,
|
||||
updateStatus: (reportId: string) => `/reports/superadmin/${reportId}/status`,
|
||||
},
|
||||
support: {
|
||||
adminTickets: (params: Record<string, string | number | boolean | null | undefined> = {}) =>
|
||||
`/support/admin/tickets?${toQueryString(params)}`,
|
||||
adminTicket: (ticketId: string) => `/support/admin/tickets/${ticketId}`,
|
||||
adminReply: (ticketId: string) => `/support/admin/tickets/${ticketId}/messages`,
|
||||
adminStatus: (ticketId: string) => `/support/admin/tickets/${ticketId}/status`,
|
||||
adminAssign: (ticketId: string) => `/support/admin/tickets/${ticketId}/assign`,
|
||||
},
|
||||
marketplace: {
|
||||
home: (params: Record<string, string | number | boolean | null | undefined> = {}) =>
|
||||
`/marketplace/home?${toQueryString(params)}`,
|
||||
|
||||
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 }),
|
||||
});
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
PackageSearch,
|
||||
Settings,
|
||||
ShieldCheck,
|
||||
LifeBuoy,
|
||||
ShoppingBag,
|
||||
SquareKanban,
|
||||
Users,
|
||||
@@ -55,6 +56,12 @@ export const dashboardNav = [
|
||||
icon: Flag,
|
||||
requiredPermissions: [SUPERADMIN_PERMISSIONS.CONTENT_MODERATE],
|
||||
},
|
||||
{
|
||||
href: "/dashboard/support",
|
||||
label: "Support",
|
||||
icon: LifeBuoy,
|
||||
requiredPermissions: [SUPERADMIN_PERMISSIONS.CASES_MANAGE],
|
||||
},
|
||||
{
|
||||
href: "/marketplace",
|
||||
label: "Marketplace",
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم