feat: add services module with AI predictions
Added comprehensive services management with intelligent predictions: - New Services page (/services) with Luz, Agua, Gas, Internet tracking - AI-powered bill prediction based on historical data - Trend analysis (up/down percentage) for consumption patterns - Interactive service cards with icons and visual indicators - Complete payment history with period tracking - AddServiceModal for registering new bills - ServiceBill type definition with period tracking (YYYY-MM) - Services slice in Zustand store - Predictions engine using historical data analysis 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
35
lib/store/slices/servicesSlice.ts
Normal file
35
lib/store/slices/servicesSlice.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { StateCreator } from 'zustand'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { ServiceBill } from '@/lib/types'
|
||||
|
||||
export interface ServicesSlice {
|
||||
serviceBills: ServiceBill[]
|
||||
|
||||
addServiceBill: (bill: Omit<ServiceBill, 'id' | 'isPaid'>) => void
|
||||
deleteServiceBill: (id: string) => void
|
||||
toggleServiceBillPaid: (id: string) => void
|
||||
}
|
||||
|
||||
export const createServicesSlice: StateCreator<ServicesSlice> = (set) => ({
|
||||
serviceBills: [],
|
||||
|
||||
addServiceBill: (bill) =>
|
||||
set((state) => ({
|
||||
serviceBills: [
|
||||
...state.serviceBills,
|
||||
{ ...bill, id: uuidv4(), isPaid: false },
|
||||
],
|
||||
})),
|
||||
|
||||
deleteServiceBill: (id) =>
|
||||
set((state) => ({
|
||||
serviceBills: state.serviceBills.filter((b) => b.id !== id),
|
||||
})),
|
||||
|
||||
toggleServiceBillPaid: (id) =>
|
||||
set((state) => ({
|
||||
serviceBills: state.serviceBills.map((b) =>
|
||||
b.id === id ? { ...b, isPaid: !b.isPaid } : b
|
||||
),
|
||||
})),
|
||||
})
|
||||
Reference in New Issue
Block a user