'use client' import { useState } from 'react' import { useFinanzasStore } from '@/lib/store' import { X, Calendar, Zap, Droplets, Flame, Wifi } from 'lucide-react' import { cn } from '@/lib/utils' interface AddServiceModalProps { isOpen: boolean onClose: () => void } const SERVICES = [ { id: 'electricity', label: 'Luz', icon: Zap, color: 'text-yellow-400' }, { id: 'water', label: 'Agua', icon: Droplets, color: 'text-blue-400' }, { id: 'gas', label: 'Gas', icon: Flame, color: 'text-orange-400' }, { id: 'internet', label: 'Internet', icon: Wifi, color: 'text-cyan-400' }, ] export function AddServiceModal({ isOpen, onClose }: AddServiceModalProps) { const addServiceBill = useFinanzasStore((state) => state.addServiceBill) const [type, setType] = useState('electricity') const [amount, setAmount] = useState('') const [usage, setUsage] = useState('') const [period, setPeriod] = useState(new Date().toISOString().slice(0, 7)) // YYYY-MM const [date, setDate] = useState(new Date().toISOString().split('T')[0]) if (!isOpen) return null const getUnit = (serviceType: string) => { switch (serviceType) { case 'electricity': return 'kW' case 'gas': return 'm³' case 'water': return 'm³' default: return '' } } const unit = getUnit(type) const showUsage = type !== 'internet' const handleSubmit = (e: React.FormEvent) => { e.preventDefault() if (!amount) return addServiceBill({ type: type as any, amount: parseFloat(amount), usage: usage ? parseFloat(usage) : undefined, unit: unit || undefined, date: new Date(date).toISOString(), period: period, notes: '' }) // Reset setAmount('') setUsage('') onClose() } return (