notifciations issues fixed final

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-28 00:52:14 +00:00
parent 28a60f8141
commit 0605f650b1
12 changed files with 1384 additions and 18 deletions

View File

@@ -83,21 +83,30 @@ const generateId = () => `notif_${Date.now()}_${Math.random().toString(36).slice
*/
function apiToStoreNotification(api: NotificationAPI): Notification {
// Map API notification_type to store category
const categoryMap: Record<string, NotificationCategory> = {
'ai_task': 'ai_task',
'system': 'system',
'credit': 'system',
'billing': 'system',
'integration': 'system',
'content': 'ai_task',
'info': 'info',
// All ai_* types map to 'ai_task', everything else to appropriate category
const getCategory = (type: string): NotificationCategory => {
if (type.startsWith('ai_')) return 'ai_task';
if (type.startsWith('content_') || type === 'keywords_imported') return 'ai_task';
if (type.startsWith('wordpress_') || type.startsWith('credits_') || type.startsWith('site_')) return 'system';
if (type === 'system_info' || type === 'system') return 'system';
// Legacy mappings
const legacyMap: Record<string, NotificationCategory> = {
'ai_task': 'ai_task',
'system': 'system',
'credit': 'system',
'billing': 'system',
'integration': 'system',
'content': 'ai_task',
'info': 'info',
};
return legacyMap[type] || 'info';
};
return {
id: `api_${api.id}`,
apiId: api.id,
type: api.severity as NotificationType,
category: categoryMap[api.notification_type] || 'info',
category: getCategory(api.notification_type),
title: api.title,
message: api.message,
timestamp: new Date(api.created_at),