Built the Sentinel Tab
This commit is contained in:
@@ -9,9 +9,11 @@ import type {
|
||||
DashboardMetrics,
|
||||
LeadVelocityData,
|
||||
Unit,
|
||||
SystemStatus
|
||||
SystemStatus,
|
||||
VelocityNotification,
|
||||
} from '@/types';
|
||||
|
||||
|
||||
// Auth State
|
||||
interface AuthState {
|
||||
isAuthenticated: boolean;
|
||||
@@ -75,6 +77,17 @@ interface SystemState {
|
||||
updateStatus: (status: Partial<SystemStatus>) => void;
|
||||
}
|
||||
|
||||
// Notification State (Active Notification Center)
|
||||
interface NotificationState {
|
||||
notifications: VelocityNotification[];
|
||||
unreadCount: number;
|
||||
addNotification: (notification: Omit<VelocityNotification, 'id' | 'isRead' | 'timestamp'>) => void;
|
||||
markAllRead: () => void;
|
||||
markAsRead: (id: string) => void;
|
||||
clearNotifications: () => void;
|
||||
}
|
||||
|
||||
|
||||
// Combined Store
|
||||
interface StoreState extends
|
||||
AuthState,
|
||||
@@ -83,7 +96,9 @@ interface StoreState extends
|
||||
SentinelState,
|
||||
DashboardState,
|
||||
InventoryState,
|
||||
SystemState { }
|
||||
SystemState,
|
||||
NotificationState { }
|
||||
|
||||
|
||||
// Mock Data
|
||||
const mockLeads: Lead[] = [
|
||||
@@ -324,7 +339,39 @@ export const useStore = create<StoreState>()(
|
||||
},
|
||||
updateStatus: (status) => set((state) => ({
|
||||
status: { ...state.status, ...status },
|
||||
}))
|
||||
})),
|
||||
|
||||
// Notification State
|
||||
notifications: [],
|
||||
unreadCount: 0,
|
||||
addNotification: (notif) => set((state) => {
|
||||
const newNotif: VelocityNotification = {
|
||||
...notif,
|
||||
id: `notif-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
||||
isRead: false,
|
||||
timestamp: new Date(),
|
||||
};
|
||||
const updated = [newNotif, ...state.notifications].slice(0, 50);
|
||||
return {
|
||||
notifications: updated,
|
||||
unreadCount: updated.filter((n) => !n.isRead).length,
|
||||
};
|
||||
}),
|
||||
markAllRead: () => set((state) => ({
|
||||
notifications: state.notifications.map((n) => ({ ...n, isRead: true })),
|
||||
unreadCount: 0,
|
||||
})),
|
||||
markAsRead: (id) => set((state) => {
|
||||
const updated = state.notifications.map((n) =>
|
||||
n.id === id ? { ...n, isRead: true } : n
|
||||
);
|
||||
return {
|
||||
notifications: updated,
|
||||
unreadCount: updated.filter((n) => !n.isRead).length,
|
||||
};
|
||||
}),
|
||||
clearNotifications: () => set({ notifications: [], unreadCount: 0 }),
|
||||
|
||||
}),
|
||||
{
|
||||
name: 'velocity-webos-storage',
|
||||
|
||||
Reference in New Issue
Block a user