fix(agenda): fix $.map crash and getPacientes type mismatch; restore preloader

AgendaView:
- Fix agendamentos?.filter(...).map(...) crash: optional chain didn't guard .map when agendamentos is null on initial render
- Fix getPacientes fetcher to extract .data array — API now returns {data, total} not Paciente[], causing searchResults.map crash

LoginView:
- Restore 3s preloader splash screen with {APP_VERSION} instead of hardcoded version string

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
VPS 4 Builder
2026-05-14 08:01:18 +02:00
parent e0be095055
commit 15ba7ffe95
2 changed files with 21 additions and 5 deletions
+18 -2
View File
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { Database, Lock, User, ArrowRight, ShieldCheck } from 'lucide-react';
import React, { useState, useEffect } from 'react';
import { Database, Lock, User, ArrowRight, ShieldCheck, Loader2 } from 'lucide-react';
import { HybridBackend } from '../services/backend.ts';
import { APP_VERSION } from '../constants.ts';
@@ -12,6 +12,22 @@ export const LoginView: React.FC<LoginViewProps> = ({ onLoginSuccess }) => {
const [password, setPassword] = useState('');
const [loading, setLoading] = useState(false);
const [error, setError] = useState('');
const [isInitializing, setIsInitializing] = useState(true);
useEffect(() => {
const timer = setTimeout(() => setIsInitializing(false), 3000);
return () => clearTimeout(timer);
}, []);
if (isInitializing) {
return (
<div className="min-h-screen bg-gray-50 flex flex-col items-center justify-center p-4">
<Loader2 className="animate-spin text-blue-600 mb-4" size={48} />
<h2 className="text-gray-500 font-bold uppercase tracking-widest text-sm">Inicializando Sistema...</h2>
<span className="text-gray-400 text-xs mt-2 font-mono font-bold bg-gray-200 px-2 py-1 rounded">{APP_VERSION}</span>
</div>
);
}
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();