docs updated v1.2.0

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-27 23:27:07 +00:00
parent e0f3060df9
commit 28a60f8141
8 changed files with 380 additions and 29 deletions

View File

@@ -1,6 +1,7 @@
# Zustand State Management
**Last Verified:** December 25, 2025
**Last Verified:** December 27, 2025
**Version:** 1.2.0
**Framework:** Zustand 4 with persist middleware
---
@@ -315,6 +316,80 @@ interface UIActions {
---
## Notification Store (`notificationStore.ts`) - v1.2.0
**Purpose:** In-app notifications for AI task completions and system events
```typescript
type NotificationType = 'success' | 'error' | 'warning' | 'info';
type NotificationCategory = 'ai_task' | 'system' | 'info';
interface Notification {
id: string;
apiId?: number; // Server ID for synced notifications
type: NotificationType;
category: NotificationCategory;
title: string;
message: string;
timestamp: Date;
read: boolean;
actionLabel?: string;
actionHref?: string;
metadata?: {
taskId?: string;
functionName?: string;
count?: number;
credits?: number;
};
}
interface NotificationStore {
notifications: Notification[];
unreadCount: number;
isLoading: boolean;
lastFetched: Date | null;
// Actions
addNotification(notification: Omit<Notification, 'id' | 'timestamp' | 'read'>): void;
markAsRead(id: string): void;
markAllAsRead(): void;
removeNotification(id: string): void;
clearAll(): void;
fetchFromAPI(): Promise<void>;
syncWithAPI(): Promise<void>;
}
```
**Features:**
- In-memory queue for optimistic UI updates
- API sync for persistent notifications
- Auto-dismissal with configurable timeout
- Read/unread state tracking
- Category-based filtering (ai_task, system, info)
**API Integration:** Uses `notifications.api.ts` service:
- `fetchNotifications()` - List with pagination
- `fetchUnreadCount()` - Unread count
- `markNotificationRead()` - Mark single as read
- `markAllNotificationsRead()` - Mark all as read
- `deleteNotification()` - Delete notification
**Usage:**
```typescript
const { notifications, unreadCount, addNotification, markAsRead } = useNotificationStore();
// Add AI task completion notification
addNotification({
type: 'success',
category: 'ai_task',
title: 'Content Generated',
message: 'Generated 5 articles successfully',
metadata: { count: 5, credits: 250 }
});
```
---
## Store Dependencies
```
@@ -329,6 +404,8 @@ authStore
├── automationStore (scoped to site)
└── integrationStore (scoped to site)
notificationStore (global, polls/syncs independently)
moduleStore (global, loads once per account)
billingStore (global, loads once per account)
uiStore (local only, no API)
@@ -345,6 +422,9 @@ frontend/src/store/
├── sectorStore.ts
├── moduleStore.ts
├── billingStore.ts
├── notificationStore.ts # v1.2.0
├── onboardingStore.ts
├── pageSizeStore.ts
├── plannerStore.ts
├── writerStore.ts
├── automationStore.ts