import { create } from 'zustand' export type NotificationType = 'success' | 'error' | 'info' | 'warning' export interface Notification { id: string type: NotificationType title: string message?: string duration?: number timestamp: Date } interface NotificationStore { notifications: Notification[] addNotification: (notification: Omit) => void removeNotification: (id: string) => void clearNotifications: () => void } /** * Store for managing notifications */ export const useNotificationStore = create((set) => ({ notifications: [], addNotification: (notification) => { const id = `notif-${Date.now()}-${Math.random().toString(36).substr(2, 9)}` const newNotification: Notification = { ...notification, id, timestamp: new Date(), duration: notification.duration || 5000 } set((state) => ({ notifications: [...state.notifications, newNotification] })) if (newNotification.duration && newNotification.duration > 0) { setTimeout(() => { set((state) => ({ notifications: state.notifications.filter(n => n.id !== id) })) }, newNotification.duration) } }, removeNotification: (id) => { set((state) => ({ notifications: state.notifications.filter(n => n.id !== id) })) }, clearNotifications: () => { set({ notifications: [] }) } }))