erp-construccion-frontend-v2/web/src/stores/toastStore.ts
Adrian Flores Cortes 380b96e159 feat(theme): Implement Dark Mode and Toast notifications
- Add dark:* classes to 10 common components
- Create ThemeProvider with Zustand persistence
- Create ThemeToggle component (simple and full modes)
- Implement Toast notification system (toastStore, useToast, ToastContainer)
- Support success, error, warning, info toast types
- Integrate ToastContainer in App.tsx

Components updated:
- Modal, EmptyState, StatusBadge, SearchInput
- ConfirmDialog, PageHeader, FormField, ActionButtons
- DataTable, LoadingSpinner

Closes: G-005, G-008

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 01:14:11 -06:00

47 lines
876 B
TypeScript

/**
* Toast Store - Global state for toast notifications
*/
import { create } from 'zustand';
export type ToastType = 'success' | 'error' | 'warning' | 'info';
export interface Toast {
id: string;
type: ToastType;
message: string;
title?: string;
duration?: number;
}
interface ToastState {
toasts: Toast[];
addToast: (toast: Omit<Toast, 'id'>) => string;
removeToast: (id: string) => void;
clearToasts: () => void;
}
let toastId = 0;
export const useToastStore = create<ToastState>((set) => ({
toasts: [],
addToast: (toast) => {
const id = `toast-${++toastId}`;
set((state) => ({
toasts: [...state.toasts, { ...toast, id }],
}));
return id;
},
removeToast: (id) => {
set((state) => ({
toasts: state.toasts.filter((t) => t.id !== id),
}));
},
clearToasts: () => {
set({ toasts: [] });
},
}));