diff --git a/.gitignore b/.gitignore index a547bf3..3446cb9 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ dist-ssr *.njsproj *.sln *.sw? +pnpm-lock.yaml diff --git a/App.tsx b/App.tsx index 28169f5..d3c6192 100644 --- a/App.tsx +++ b/App.tsx @@ -95,8 +95,7 @@ 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 handleLogin = async (email: string): Promise => { const user = users.find(u => u.email.toLowerCase() === email.toLowerCase() && u.status === 'aktiv'); if (user) { setCurrentUser(user); diff --git a/components/LoginView.tsx b/components/LoginView.tsx index a7c3c0b..c44dff6 100644 --- a/components/LoginView.tsx +++ b/components/LoginView.tsx @@ -3,21 +3,27 @@ import React, { useState } from 'react'; import { User } from '../types'; interface LoginViewProps { - onLogin: (email: string) => void; + onLogin: (email: string) => Promise; error?: string; } const LoginView: React.FC = ({ onLogin, error: externalError }) => { const [email, setEmail] = useState(''); + const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(externalError || ''); - const handleSubmit = (e: React.FormEvent) => { + const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!email) { setError('Bitte gib deine Wohnpro E-Mail Adresse ein.'); return; } - onLogin(email); + setIsLoading(true); + try { + await onLogin(email); + } finally { + setIsLoading(false); + } }; return ( @@ -48,9 +54,17 @@ const LoginView: React.FC = ({ onLogin, error: externalError })