feat: campana multi-módulo estilo inventario
This commit is contained in:
1 parent
b1cddbac6c
commit
e83bc239c0
5 files changed
+416
-6
No files matched your search
@@ -462,3 +462,45 @@ export async function syncInboundEmail() {
|
||||
error?: string;
|
||||
}>("/api/helpdesk/email/inbound/sync", { method: "POST" });
|
||||
}
|
||||
|
||||
// ==================== Notificaciones in-app (estándar multi-módulo) ====================
|
||||
export interface AppNotification {
|
||||
id: number;
|
||||
module: string;
|
||||
ticketId?: number;
|
||||
notifRef?: string;
|
||||
type: string;
|
||||
title: string;
|
||||
body?: string;
|
||||
isRead: boolean;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export async function getNotifications(limit = 50, module = "", unreadOnly = false) {
|
||||
const query = new URLSearchParams({ limit: String(limit) });
|
||||
if (module) query.set("module", module);
|
||||
if (unreadOnly) query.set("unreadOnly", "true");
|
||||
return fetchApi<AppNotification[]>(`/api/notifications?${query.toString()}`);
|
||||
}
|
||||
|
||||
export async function getUnreadCount(module = "") {
|
||||
const query = new URLSearchParams();
|
||||
if (module) query.set("module", module);
|
||||
const qs = query.toString();
|
||||
return fetchApi<{ count: number }>(`/api/notifications/unread-count${qs ? `?${qs}` : ""}`);
|
||||
}
|
||||
|
||||
export async function markNotificationRead(id: number) {
|
||||
return fetchApi<{ id: number }>(`/api/notifications/${id}/read`, {
|
||||
method: "PUT",
|
||||
});
|
||||
}
|
||||
|
||||
export async function markAllNotificationsRead(module = "") {
|
||||
const query = new URLSearchParams();
|
||||
if (module) query.set("module", module);
|
||||
const qs = query.toString();
|
||||
return fetchApi<{ updated: number }>(`/api/notifications/read-all${qs ? `?${qs}` : ""}`, {
|
||||
method: "PUT",
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user