UNPKG

@eventcatalogtest/studio

Version:

A drag and drop UI for distributed systems that keeps your diagrams where they belong – in your repo

33 lines (29 loc) 862 B
// Create a zustand store to manage notifications import { create } from 'zustand'; interface Notification { id: string; message: string; type: 'error' | 'warning' | 'info'; duration: number; } interface NotificationsStore { notifications: Notification[]; addNotification: (notification: Omit<Notification, 'id'>) => void; dismissNotification: (id: string) => void; } export const useNotificationsStore = create<NotificationsStore>((set) => ({ notifications: [], addNotification: (notification) => set((state) => ({ notifications: [ ...state.notifications, { ...notification, id: Math.random().toString(36).substr(2, 9) }, ], })), dismissNotification: (id) => set((state) => ({ notifications: state.notifications.filter( (notification) => notification.id !== id ), })), }));