diff --git a/App.tsx b/App.tsx index 28169f5..a967197 100644 --- a/App.tsx +++ b/App.tsx @@ -95,14 +95,20 @@ 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) { - setCurrentUser(user); - } else { - alert("Zugang verweigert. Nur verifizierte Wohnpro-Bewohner können sich im Wohnpro Guide anmelden."); - } + const handleLogin = (email: string): Promise => { + return new Promise((resolve) => { + setTimeout(() => { + const user = users.find(u => u.email.toLowerCase() === email.toLowerCase() && u.status === 'aktiv'); + if (user) { + setCurrentUser(user); + resolve(true); + } else { + // In a real app, you'd show a proper error message. + // alert("Zugang verweigert. Nur verifizierte Wohnpro-Bewohner können sich im Wohnpro Guide anmelden."); + resolve(false); + } + }, 1500); // Simulate network delay + }); }; const sendMessage = async (text: string) => { diff --git a/components/Icons.tsx b/components/Icons.tsx index 6d8f925..addc63b 100644 --- a/components/Icons.tsx +++ b/components/Icons.tsx @@ -46,3 +46,20 @@ export const ChevronDownIcon = ({ className = "w-6 h-6" }) => ; export const ThumbsDownIcon = ({ className = "w-6 h-6" }) => ; export const DownloadIcon = ({ className = "w-6 h-6" }) => ; + +export const SpinnerIcon = ({ className = "w-6 h-6" }) => ( + + + + ); diff --git a/components/LoginView.tsx b/components/LoginView.tsx index a7c3c0b..2da5d12 100644 --- a/components/LoginView.tsx +++ b/components/LoginView.tsx @@ -1,23 +1,31 @@ import React, { useState } from 'react'; import { User } from '../types'; +import { SpinnerIcon } from './Icons'; interface LoginViewProps { - onLogin: (email: string) => void; + onLogin: (email: string) => Promise; error?: string; } const LoginView: React.FC = ({ onLogin, error: externalError }) => { const [email, setEmail] = useState(''); const [error, setError] = useState(externalError || ''); + const [isLoading, setIsLoading] = useState(false); - const handleSubmit = (e: React.FormEvent) => { + const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); + setError(''); if (!email) { setError('Bitte gib deine Wohnpro E-Mail Adresse ein.'); return; } - onLogin(email); + setIsLoading(true); + const success = await onLogin(email); + if (!success) { + setError('E-Mail Adresse nicht gefunden oder inaktiv.'); + setIsLoading(false); + } }; return ( @@ -42,15 +50,17 @@ const LoginView: React.FC = ({ onLogin, error: externalError }) onChange={(e) => { setEmail(e.target.value); setError(''); }} placeholder="Wohnpro E-Mail Adresse" className={`w-full bg-gray-50 border ${error ? 'border-red-200' : 'border-gray-100'} rounded-2xl px-6 py-4 focus:outline-none focus:ring-2 focus:ring-black/5 transition-all text-lg placeholder:text-gray-300`} + disabled={isLoading} /> {error &&

{error}

}