diff --git a/src/client/App.js b/src/client/App.js
index d4c588e..fcf2d22 100644
--- a/src/client/App.js
+++ b/src/client/App.js
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { useState } from 'react';
import { ThemeProvider, createTheme, CssBaseline, AppBar, Toolbar, Typography, Container, Box, Button, Chip } from '@mui/material';
import Dashboard from './Dashboard';
import RuleManager from './RuleManager';
@@ -43,19 +43,8 @@ const darkTheme = createTheme({
});
function AppContent() {
- const { user, loading, logout, isAuthenticated, isAdmin } = useAuth();
-
- if (loading) {
- return (
-
- Loading...
-
- );
- }
-
- if (!isAuthenticated) {
- return ;
- }
+ const { user, loading, login, logout, isAuthenticated, isAdmin } = useAuth();
+ const [showLogin, setShowLogin] = useState(false);
return (
@@ -65,43 +54,65 @@ function AppContent() {
Tischlerei Dashboard
-
- {isAdmin && (
-
+
+ {isAdmin && (
+
+ )}
+
+ >
+ ) : (
+
)}
-
+ {/* Dashboard is always visible to everyone */}
+
+ {/* Rule Manager only visible to logged-in admins */}
{isAdmin && }
+
+ {/* Login dialog - shown on demand */}
+ setShowLogin(false)}
+ />
);
}
diff --git a/src/client/LoginDialog.js b/src/client/LoginDialog.js
index 7f7fe05..e0dcaa6 100644
--- a/src/client/LoginDialog.js
+++ b/src/client/LoginDialog.js
@@ -19,7 +19,7 @@ import { useAuth } from './AuthContext';
const VisibilityIcon = () => 👁;
const VisibilityOffIcon = () => 👁🗨;
-export default function LoginDialog({ open }) {
+export default function LoginDialog({ open, onClose }) {
const { login } = useAuth();
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
@@ -34,6 +34,10 @@ export default function LoginDialog({ open }) {
try {
await login(username, password);
+ // Success - close dialog and reset form
+ setUsername('');
+ setPassword('');
+ if (onClose) onClose();
} catch (err) {
setError(err.message);
} finally {
@@ -41,9 +45,15 @@ export default function LoginDialog({ open }) {
}
};
+ const handleClose = () => {
+ setError('');
+ if (onClose) onClose();
+ };
+
return (