'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 [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 handleSubmit = (e: React.FormEvent) => { e.preventDefault() if (!amount) return addServiceBill({ type: type as any, amount: parseFloat(amount), date: new Date(date).toISOString(), period: period, notes: '' }) // Reset setAmount('') onClose() } return (

Registrar Factura de Servicio

{/* Service Type Selection */}
{SERVICES.map((s) => { const Icon = s.icon const isSelected = type === s.id return (
setType(s.id)} className={cn( "cursor-pointer p-3 rounded-xl border flex flex-col items-center gap-2 transition-all", isSelected ? "border-cyan-500 bg-cyan-500/10 ring-1 ring-cyan-500" : "border-slate-800 bg-slate-950 hover:border-slate-700 hover:bg-slate-900" )} > {s.label}
) })}
{/* Amount */}
$ setAmount(e.target.value)} className="w-full pl-8 pr-4 py-3 bg-slate-950 border border-slate-800 rounded-lg focus:ring-2 focus:ring-cyan-500/50 focus:border-cyan-500 text-white text-lg font-mono outline-none" required autoFocus />
{/* Period */}
setPeriod(e.target.value)} className="w-full px-4 py-2.5 bg-slate-950 border border-slate-800 rounded-lg focus:ring-2 focus:ring-cyan-500/50 focus:border-cyan-500 text-white outline-none [color-scheme:dark]" required />
{/* Date */}
setDate(e.target.value)} className="w-full px-4 py-2.5 bg-slate-950 border border-slate-800 rounded-lg focus:ring-2 focus:ring-cyan-500/50 focus:border-cyan-500 text-white outline-none [color-scheme:dark]" required />
) }