notifciations issues fixed final
This commit is contained in:
@@ -9,7 +9,43 @@ import { fetchAPI } from './api';
|
||||
// TYPES
|
||||
// ============================================================================
|
||||
|
||||
export type NotificationTypeAPI = 'ai_task' | 'system' | 'credit' | 'billing' | 'integration' | 'content' | 'info';
|
||||
// Notification types - match backend NotificationType choices
|
||||
export type NotificationTypeAPI =
|
||||
// AI Operations
|
||||
| 'ai_cluster_complete'
|
||||
| 'ai_cluster_failed'
|
||||
| 'ai_ideas_complete'
|
||||
| 'ai_ideas_failed'
|
||||
| 'ai_content_complete'
|
||||
| 'ai_content_failed'
|
||||
| 'ai_images_complete'
|
||||
| 'ai_images_failed'
|
||||
| 'ai_prompts_complete'
|
||||
| 'ai_prompts_failed'
|
||||
// Workflow
|
||||
| 'content_ready_review'
|
||||
| 'content_published'
|
||||
| 'content_publish_failed'
|
||||
// WordPress Sync
|
||||
| 'wordpress_sync_success'
|
||||
| 'wordpress_sync_failed'
|
||||
// Credits/Billing
|
||||
| 'credits_low'
|
||||
| 'credits_depleted'
|
||||
// Setup
|
||||
| 'site_setup_complete'
|
||||
| 'keywords_imported'
|
||||
// System
|
||||
| 'system_info'
|
||||
// Legacy/fallback
|
||||
| 'ai_task'
|
||||
| 'system'
|
||||
| 'credit'
|
||||
| 'billing'
|
||||
| 'integration'
|
||||
| 'content'
|
||||
| 'info';
|
||||
|
||||
export type NotificationSeverityAPI = 'info' | 'success' | 'warning' | 'error';
|
||||
|
||||
export interface NotificationAPI {
|
||||
@@ -59,7 +95,7 @@ export async function fetchNotifications(params?: {
|
||||
if (params?.notification_type) searchParams.set('notification_type', params.notification_type);
|
||||
|
||||
const queryString = searchParams.toString();
|
||||
const url = `v1/notifications/${queryString ? `?${queryString}` : ''}`;
|
||||
const url = `/v1/notifications/${queryString ? `?${queryString}` : ''}`;
|
||||
|
||||
return fetchAPI(url);
|
||||
}
|
||||
@@ -68,14 +104,14 @@ export async function fetchNotifications(params?: {
|
||||
* Get unread notification count
|
||||
*/
|
||||
export async function fetchUnreadCount(): Promise<UnreadCountResponse> {
|
||||
return fetchAPI('v1/notifications/unread-count/');
|
||||
return fetchAPI('/v1/notifications/unread-count/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a single notification as read
|
||||
*/
|
||||
export async function markNotificationRead(id: number): Promise<NotificationAPI> {
|
||||
return fetchAPI(`v1/notifications/${id}/read/`, {
|
||||
return fetchAPI(`/v1/notifications/${id}/read/`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
@@ -84,7 +120,7 @@ export async function markNotificationRead(id: number): Promise<NotificationAPI>
|
||||
* Mark all notifications as read
|
||||
*/
|
||||
export async function markAllNotificationsRead(): Promise<{ message: string; count: number }> {
|
||||
return fetchAPI('v1/notifications/read-all/', {
|
||||
return fetchAPI('/v1/notifications/read-all/', {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
@@ -93,7 +129,7 @@ export async function markAllNotificationsRead(): Promise<{ message: string; cou
|
||||
* Delete a notification
|
||||
*/
|
||||
export async function deleteNotification(id: number): Promise<void> {
|
||||
await fetchAPI(`v1/notifications/${id}/`, {
|
||||
await fetchAPI(`/v1/notifications/${id}/`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user