Add Providers

This commit is contained in:
decolua
2026-02-20 17:05:46 +07:00
parent bd71298fb7
commit 3debf84b9a
30 changed files with 1583 additions and 670 deletions
+1
View File
@@ -2,4 +2,5 @@
export { default as useThemeStore } from "./themeStore";
export { default as useUserStore } from "./userStore";
export { default as useProviderStore } from "./providerStore";
export { useNotificationStore } from "./notificationStore";
+45
View File
@@ -0,0 +1,45 @@
/**
* Notification Store — Zustand-based global toast notification system.
* Centralized feedback for dashboard actions.
*/
import { create } from "zustand";
let idCounter = 0;
export const useNotificationStore = create((set, get) => ({
notifications: [],
addNotification: (notification) => {
const id = ++idCounter;
const entry = {
id,
type: notification.type || "info",
message: notification.message,
title: notification.title || null,
duration: notification.duration ?? 5000,
dismissible: notification.dismissible ?? true,
createdAt: Date.now(),
};
set((s) => ({ notifications: [...s.notifications, entry] }));
// Auto-dismiss
if (entry.duration > 0) {
setTimeout(() => get().removeNotification(id), entry.duration);
}
return id;
},
removeNotification: (id) => {
set((s) => ({ notifications: s.notifications.filter((n) => n.id !== id) }));
},
clearAll: () => set({ notifications: [] }),
success: (message, title) => get().addNotification({ type: "success", message, title }),
error: (message, title) => get().addNotification({ type: "error", message, title, duration: 8000 }),
warning: (message, title) => get().addNotification({ type: "warning", message, title }),
info: (message, title) => get().addNotification({ type: "info", message, title }),
}));