'use client'; import { useState } from 'react'; interface FreeItemModalProps { onAdd: (item: { name: string; unitPriceCents: number }) => void; onClose: () => void; } export default function FreeItemModal({ onAdd, onClose }: FreeItemModalProps) { const [name, setName] = useState(''); const [price, setPrice] = useState(''); const [error, setError] = useState(''); const submit = (event: React.FormEvent) => { event.preventDefault(); const normalized = price.trim().replace(',', '.'); const unitPriceCents = /^\d+(?:\.\d{1,2})?$/.test(normalized) ? Math.round(Number(normalized) * 100) : 0; if (!name.trim() || unitPriceCents <= 0) { setError('Indica un nombre y un precio positivo'); return; } onAdd({ name: name.trim(), unitPriceCents }); }; return (

Sin producto de almacén

Artículo libre

{error && (

{error}

)}
); }