Implemented mailbox in ConsoleUI

This commit is contained in:
2026-10-22 18:01:22 +02:00
parent 6ff016e7ec
commit cb89817d88
20 changed files with 3208 additions and 19 deletions
@@ -98,6 +98,8 @@ import {
Claim,
CreateUserRequest,
AddUserClaimRequest,
CreateNotificationRequest,
UpdateNotificationRequest,
} from '../types';
import {
@@ -1614,6 +1616,53 @@ export const getNotifications = async (organisationId?: string | number): Promis
return [];
};
export const getUserNotifications = async (userId?: string): Promise<Notification[]> => {
try {
const url = userId ? `/v1/api/communications/notifications/user/${encodeURIComponent(userId)}` : `/v1/api/communications/notifications/inbox`;
const res = await apiClient.get<Notification[]>(url);
if (res.data && Array.isArray(res.data)) {
return res.data;
}
} catch (err: any) {
console.warn('[getUserNotifications] API error:', err);
}
return [];
};
export const createNotification = async (payload: CreateNotificationRequest): Promise<void> => {
const tenantId = getCurrentUserTenantId();
const orgId = payload.organisationId !== undefined && payload.organisationId !== '' && payload.organisationId !== null
? toIntegerId(payload.organisationId)
: (tenantId !== null ? tenantId : 1);
await apiClient.post('/v1/api/communications/notifications', {
organisationId: orgId,
recipient: payload.recipient,
platform: payload.platform,
subject: payload.subject || null,
destination: payload.destination || 'In-App User Inbox',
message: payload.message,
status: payload.status !== undefined ? payload.status : undefined,
});
};
export const updateNotification = async (payload: UpdateNotificationRequest): Promise<void> => {
await apiClient.put('/v1/api/communications/notifications', {
notificationId: toIntegerId(payload.notificationId),
destination: payload.destination || undefined,
status: payload.status,
sentAt: payload.sentAt || new Date().toISOString(),
error: payload.error || null,
});
};
export const markNotificationAsRead = async (notificationId: number | string): Promise<void> => {
await updateNotification({
notificationId: toIntegerId(notificationId),
status: NotificationStatus.Read,
});
};
// ==========================================
// 9. Governance: Tenants APIs
// ==========================================