import { useState } from 'react'; import { Device } from './InventoryManagement'; interface DeviceFormProps { onAddDevice: (device: Device) => void; } export default function DeviceForm({ onAddDevice }: DeviceFormProps) { const [name, setName] = useState(''); const [quantity, setQuantity] = useState(''); const [serialNumber, setSerialNumber] = useState(''); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); const newDevice: Device = { id: Date.now().toString(), name, quantity: parseInt(quantity), serialNumber, }; onAddDevice(newDevice); setName(''); setQuantity(''); setSerialNumber(''); }; return (

添加新设备

setName(e.target.value)} placeholder="设备名称" required className="border rounded p-2 w-full" /> setQuantity(e.target.value)} placeholder="数量" required className="border rounded p-2 w-full" /> setSerialNumber(e.target.value)} placeholder="序列号" required className="border rounded p-2 w-full" />
); }