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
23 changes: 17 additions & 6 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const PERSONA_STORAGE_KEY = 'wohnprojekt_persona_cache';
const App: React.FC = () => {
const [showLanding, setShowLanding] = useState(true);
const [currentUser, setCurrentUser] = useState<User | null>(null);
const [isLoggingIn, setIsLoggingIn] = useState(false);
const [currentView, setCurrentView] = useState<View>('chat');
const [isSidebarOpen, setIsSidebarOpen] = useState(false);

Expand Down Expand Up @@ -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);
}
};

Expand Down Expand Up @@ -256,7 +267,7 @@ const App: React.FC = () => {
Synchronisiere mit Nextcloud...
</div>
)}
<LoginView onLogin={handleLogin} />
<LoginView onLogin={handleLogin} isLoading={isLoggingIn} />
</>
);
}
Expand Down
4 changes: 3 additions & 1 deletion components/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ import {
HelpCircle,
ThumbsUp,
ThumbsDown,
Download
Download,
Loader
} from 'lucide-react';

export const LoaderIcon = ({ className = "w-6 h-6" }) => <Loader className={className} />;
export const ChatIcon = ({ className = "w-6 h-6" }) => <MessageSquare className={className} />;
export const MicIcon = ({ className = "w-6 h-6" }) => <Mic className={className} />;
export const DocIcon = ({ className = "w-6 h-6" }) => <FileText className={className} />;
Expand Down
16 changes: 13 additions & 3 deletions components/LoginView.tsx
Original file line number Diff line number Diff line change
@@ -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<LoginViewProps> = ({ onLogin, error: externalError }) => {
const LoginView: React.FC<LoginViewProps> = ({ onLogin, error: externalError, isLoading }) => {
const [email, setEmail] = useState('');
const [error, setError] = useState(externalError || '');

Expand Down Expand Up @@ -48,9 +50,17 @@ const LoginView: React.FC<LoginViewProps> = ({ onLogin, error: externalError })

<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"
disabled={isLoading}
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:bg-gray-800"
>
Guide öffnen
{isLoading ? (
<>
<LoaderIcon className="w-6 h-6 animate-spin" />
<span className="sr-only">Wird geladen...</span>
</>
) : (
'Guide öffnen'
)}
</button>
</form>

Expand Down