From 976c802b112c5db3dad2deba6a0f9f90cf8a75d5 Mon Sep 17 00:00:00 2001 From: sebseb7 Date: Fri, 1 Aug 2025 10:39:41 +0200 Subject: [PATCH] Enhance App component with view management by adding Tabs for Dashboard and Table views. Update DataViewer to receive current view and handle export data accordingly. Refactor BUTable to improve form validation and handle vst values more robustly. Update admin routes to ensure vst is correctly processed. --- client/src/App.js | 51 +++++++++++++++++++++++--- client/src/components/DataViewer.js | 20 +++------- client/src/components/admin/BUTable.js | 19 ++++++++-- src/routes/admin.js | 4 +- 4 files changed, 68 insertions(+), 26 deletions(-) diff --git a/client/src/App.js b/client/src/App.js index 1306eb3..7db0e2b 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -1,10 +1,11 @@ import React, { Component } from 'react'; import { ThemeProvider, createTheme } from '@mui/material/styles'; import CssBaseline from '@mui/material/CssBaseline'; -import { Container, AppBar, Toolbar, Typography, Button, Box } from '@mui/material'; +import { Container, AppBar, Toolbar, Typography, Button, Box, Tabs, Tab } from '@mui/material'; import LoginIcon from '@mui/icons-material/Login'; import DashboardIcon from '@mui/icons-material/Dashboard'; import DownloadIcon from '@mui/icons-material/Download'; +import TableChart from '@mui/icons-material/TableChart'; import AuthService from './services/AuthService'; import DataViewer from './components/DataViewer'; import Login from './components/Login'; @@ -29,6 +30,7 @@ class App extends Component { user: null, loading: true, exportData: null, // { selectedMonth, canExport, onExport } + currentView: 'dashboard', // 'dashboard' or 'tables' }; this.authService = new AuthService(); } @@ -77,8 +79,12 @@ class App extends Component { this.setState({ exportData }); }; + handleViewChange = (event, newValue) => { + this.setState({ currentView: newValue }); + }; + render() { - const { isAuthenticated, user, loading } = this.state; + const { isAuthenticated, user, loading, currentView } = this.state; if (loading) { return ( @@ -99,7 +105,7 @@ class App extends Component { - + FibDash {isAuthenticated && user && ( @@ -107,12 +113,42 @@ class App extends Component { Willkommen, {user.name} + + } + label="Dashboard" + value="dashboard" + sx={{ minHeight: 48 }} + /> + } + label="Stammdaten" + value="tables" + sx={{ minHeight: 48 }} + /> + {this.state.exportData && ( - diff --git a/src/routes/admin.js b/src/routes/admin.js index 7ce59a8..b5a404b 100644 --- a/src/routes/admin.js +++ b/src/routes/admin.js @@ -199,7 +199,7 @@ router.post('/buchungsschluessel', authenticateToken, async (req, res) => { try { await executeQuery( 'INSERT INTO fibdash.BU (bu, name, vst) VALUES (@bu, @name, @vst)', - { bu, name, vst: vst || null } + { bu, name, vst: vst !== undefined && vst !== '' ? vst : null } ); res.json({ message: 'Buchungsschlüssel erfolgreich erstellt' }); } catch (error) { @@ -224,7 +224,7 @@ router.put('/buchungsschluessel/:id', authenticateToken, async (req, res) => { try { await executeQuery( 'UPDATE fibdash.BU SET bu = @bu, name = @name, vst = @vst WHERE id = @id', - { bu, name, vst: vst || null, id } + { bu, name, vst: vst !== undefined && vst !== '' ? vst : null, id } ); res.json({ message: 'Buchungsschlüssel erfolgreich aktualisiert' }); } catch (error) {