`); w.document.close(); }; const InfoRow = ({ icon, label, value, extra }) => (
{icon} {label}
{value} {extra}
); return (
{/* Banner de calibragem */}
{cs === 'expired' ? '🔴' : cs === 'near' ? '🟡' : '🟢'}

Calibragem {ci.label}

{cs === 'expired' ? `Vencida há ${Math.abs(days)} dia(s) — venç. em ${fmtDate(eq.nextCalibration)}` : cs === 'near' ? `Vence em ${days} dia(s) — ${fmtDate(eq.nextCalibration)}` : `Próxima calibragem: ${fmtDate(eq.nextCalibration)}`}

{/* Card principal */}

{eq.name}

Nº de Série: {eq.serialNumber}

{cs === 'expired' ? '⚠ VENCIDA' : '⚡ PRÓXIMA'} )} />
🔧 Status {si.label}
{eq.observations ? (

📝 Observações

{eq.observations}

) :
}
{/* Seção QR Code */}

QR Code do Equipamento

Aponte a câmera para acessar a ficha

{showQR && ( )}
{showQR && (

URL codificada no QR:

{qrUrl}

💡 Dica: para QR funcionar em outros dispositivos, hospede o arquivo em um servidor web

)}
{/* Botão editar (admin) */} {user.role === 'admin' && ( )}
); } // ═══════════════════════════════════════════════════════════════ // COMPONENTE: FORMULÁRIO (Cadastro / Edição) // ═══════════════════════════════════════════════════════════════ function EqForm({ eq, onSave, onCancel, onDelete }) { const isNew = !eq; const [form, setForm] = useState(() => eq ? { ...eq } : { name: '', serialNumber: '', location: '', lastCalibration: '', nextCalibration: '', responsible: '', status: 'active', observations: '' }); const [errs, setErrs] = useState({}); const [delConfirm, setDelConfirm] = useState(false); const set = useCallback((k, v) => setForm(f => ({ ...f, [k]: v })), []); const validate = () => { const e = {}; if (!form.name.trim()) e.name = 'Nome é obrigatório'; if (!form.serialNumber.trim()) e.serialNumber = 'Número de série é obrigatório'; if (!form.location.trim()) e.location = 'Localização é obrigatória'; setErrs(e); return !Object.keys(e).length; }; const handleSubmit = (e) => { e.preventDefault(); if (!validate()) return; onSave({ ...form, id: form.id || genId() }); }; const calPreview = getCalStatus(form.nextCalibration); const calDays = daysUntil(form.nextCalibration); const Field = ({ label, name, type = 'text', req, placeholder }) => (
set(name, e.target.value)} placeholder={placeholder} className={`w-full border-2 rounded-2xl px-4 py-3 text-sm focus:outline-none focus:border-blue-500 transition-colors ${errs[name] ? 'border-red-400 bg-red-50' : 'border-slate-200'}`} /> {errs[name] &&

{errs[name]}

}
); return (
{/* Informações */}

📋 Informações do Equipamento

{/* Calibragem */}

📅 Calibragem

{form.nextCalibration && (
{calPreview === 'expired' ? '🔴' : calPreview === 'near' ? '🟡' : '🟢'}

{calPreview === 'expired' ? `Vencida há ${Math.abs(calDays)} dia(s)` : calPreview === 'near' ? `Vence em ${calDays} dia(s)` : `Em dia — vence em ${calDays} dia(s)`}

)}
{/* Observações */}

📝 Observações