feat: initial commit - finanzas app
Complete personal finance management application with: - Dashboard with financial metrics and alerts - Credit card management and payments - Fixed and variable debt tracking - Monthly budget planning - Intelligent alert system - Responsive design with Tailwind CSS Tech stack: Next.js 14, TypeScript, Zustand, Recharts 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
45
lib/store/slices/alertsSlice.ts
Normal file
45
lib/store/slices/alertsSlice.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { StateCreator } from 'zustand'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { Alert } from '@/lib/types'
|
||||
|
||||
export interface AlertsSlice {
|
||||
alerts: Alert[]
|
||||
|
||||
addAlert: (alert: Omit<Alert, 'id' | 'date'>) => void
|
||||
markAlertAsRead: (id: string) => void
|
||||
deleteAlert: (id: string) => void
|
||||
clearAllAlerts: () => void
|
||||
}
|
||||
|
||||
export const createAlertsSlice: StateCreator<AlertsSlice> = (set) => ({
|
||||
alerts: [],
|
||||
|
||||
addAlert: (alert) =>
|
||||
set((state) => ({
|
||||
alerts: [
|
||||
...state.alerts,
|
||||
{
|
||||
...alert,
|
||||
id: uuidv4(),
|
||||
date: new Date().toISOString(),
|
||||
},
|
||||
],
|
||||
})),
|
||||
|
||||
markAlertAsRead: (id) =>
|
||||
set((state) => ({
|
||||
alerts: state.alerts.map((a) =>
|
||||
a.id === id ? { ...a, isRead: true } : a
|
||||
),
|
||||
})),
|
||||
|
||||
deleteAlert: (id) =>
|
||||
set((state) => ({
|
||||
alerts: state.alerts.filter((a) => a.id !== id),
|
||||
})),
|
||||
|
||||
clearAllAlerts: () =>
|
||||
set(() => ({
|
||||
alerts: [],
|
||||
})),
|
||||
})
|
||||
Reference in New Issue
Block a user