Skip to content
Open
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: 14 additions & 9 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const App: React.FC = () => {
const [sessions, setSessions] = useState<ChatSession[]>([]);
const [currentSessionId, setCurrentSessionId] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState(false);
const [isLoggingIn, setIsLoggingIn] = useState(false);
const [isFaqGenerating, setIsFaqGenerating] = useState(false);
const [generatingStatus, setGeneratingStatus] = useState('');
const [isSyncing, setIsSyncing] = useState(false);
Expand Down Expand Up @@ -95,14 +96,18 @@ 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) => {
setIsLoggingIn(true);
// Simulate network delay for UX demo
setTimeout(() => {
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.");
}
setIsLoggingIn(false);
}, 1500);
};

const sendMessage = async (text: string) => {
Expand Down Expand Up @@ -256,7 +261,7 @@ const App: React.FC = () => {
Synchronisiere mit Nextcloud...
</div>
)}
<LoginView onLogin={handleLogin} />
<LoginView onLogin={handleLogin} isLoading={isLoggingIn} />
</>
);
}
Expand Down
14 changes: 11 additions & 3 deletions components/LoginView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { User } from '../types';
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 = false }) => {
const [email, setEmail] = useState('');
const [error, setError] = useState(externalError || '');

Expand Down Expand Up @@ -48,9 +49,16 @@ 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 disabled:bg-gray-800 disabled:cursor-not-allowed flex items-center justify-center gap-3"
>
Guide öffnen
{isLoading && (
<>
<div className="w-5 h-5 border-2 border-white/20 border-t-white rounded-full animate-spin" />
<span className="sr-only">Wird geladen...</span>
</>
)}
{isLoading ? 'Prüfe Zugang...' : 'Guide öffnen'}
</button>
</form>

Expand Down