diff --git a/App.tsx b/App.tsx index 28169f5..a842948 100644 --- a/App.tsx +++ b/App.tsx @@ -21,6 +21,7 @@ const PERSONA_STORAGE_KEY = 'wohnprojekt_persona_cache'; const App: React.FC = () => { const [showLanding, setShowLanding] = useState(true); const [currentUser, setCurrentUser] = useState(null); + const [isLoggingIn, setIsLoggingIn] = useState(false); const [currentView, setCurrentView] = useState('chat'); const [isSidebarOpen, setIsSidebarOpen] = useState(false); @@ -95,13 +96,23 @@ const App: React.FC = () => { localStorage.setItem(PERSONA_STORAGE_KEY, JSON.stringify(personas)); }, [personas]); - const handleLogin = (email: string) => { - // If we have users loaded (from NC or Init), check them - const user = users.find(u => u.email.toLowerCase() === email.toLowerCase() && u.status === 'aktiv'); - if (user) { + const handleLogin = async (email: string) => { + setIsLoggingIn(true); + try { + // Simulate network delay for better UX + await new Promise(resolve => setTimeout(resolve, 750)); + const user = users.find(u => u.email.toLowerCase() === email.toLowerCase() && u.status === 'aktiv'); + + if (!user) { + throw new Error("User not found or inactive."); + } + setCurrentUser(user); - } else { + } catch (error) { + console.error("Login attempt failed:", error); alert("Zugang verweigert. Nur verifizierte Wohnpro-Bewohner können sich im Wohnpro Guide anmelden."); + } finally { + setIsLoggingIn(false); } }; @@ -256,7 +267,7 @@ const App: React.FC = () => { Synchronisiere mit Nextcloud... )} - + ); } diff --git a/components/Icons.tsx b/components/Icons.tsx index 6d8f925..fe51790 100644 --- a/components/Icons.tsx +++ b/components/Icons.tsx @@ -22,9 +22,11 @@ import { HelpCircle, ThumbsUp, ThumbsDown, - Download + Download, + Loader } from 'lucide-react'; +export const LoaderIcon = ({ className = "w-6 h-6" }) => ; export const ChatIcon = ({ className = "w-6 h-6" }) => ; export const MicIcon = ({ className = "w-6 h-6" }) => ; export const DocIcon = ({ className = "w-6 h-6" }) => ; diff --git a/components/LoginView.tsx b/components/LoginView.tsx index a7c3c0b..7ec51e5 100644 --- a/components/LoginView.tsx +++ b/components/LoginView.tsx @@ -1,13 +1,15 @@ import React, { useState } from 'react'; import { User } from '../types'; +import { LoaderIcon } from './Icons'; interface LoginViewProps { onLogin: (email: string) => void; error?: string; + isLoading: boolean; } -const LoginView: React.FC = ({ onLogin, error: externalError }) => { +const LoginView: React.FC = ({ onLogin, error: externalError, isLoading }) => { const [email, setEmail] = useState(''); const [error, setError] = useState(externalError || ''); @@ -48,9 +50,17 @@ const LoginView: React.FC = ({ onLogin, error: externalError })