Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> => {
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) => {
Expand Down
17 changes: 17 additions & 0 deletions components/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,20 @@ export const ChevronDownIcon = ({ className = "w-6 h-6" }) => <ChevronDown class
export const ThumbsUpIcon = ({ className = "w-6 h-6" }) => <ThumbsUp className={className} />;
export const ThumbsDownIcon = ({ className = "w-6 h-6" }) => <ThumbsDown className={className} />;
export const DownloadIcon = ({ className = "w-6 h-6" }) => <Download className={className} />;

export const SpinnerIcon = ({ className = "w-6 h-6" }) => (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className={`${className} animate-spin`}
>
<path d="M21 12a9 9 0 1 1-6.219-8.56" />
</svg>
);
20 changes: 15 additions & 5 deletions components/LoginView.tsx
Original file line number Diff line number Diff line change
@@ -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<boolean>;
error?: string;
}

const LoginView: React.FC<LoginViewProps> = ({ 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 (
Expand All @@ -42,15 +50,17 @@ const LoginView: React.FC<LoginViewProps> = ({ 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 && <p className="mt-2 text-sm text-red-500 text-left px-2">{error}</p>}
</div>

<button
type="submit"
className="w-full bg-black text-white rounded-2xl py-4 font-semibold text-lg hover:bg-gray-900 active:scale-[0.98] transition-all shadow-lg shadow-black/5"
className="w-full bg-black text-white rounded-2xl py-4 font-semibold text-lg hover:bg-gray-900 active:scale-[0.98] transition-all shadow-lg shadow-black/5 flex items-center justify-center disabled:opacity-50 disabled:cursor-not-allowed"
disabled={isLoading}
>
Guide öffnen
{isLoading ? <SpinnerIcon /> : 'Guide öffnen'}
</button>
</form>

Expand Down