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.

This commit is contained in:
sebseb7
2025-08-01 10:39:41 +02:00
parent 5470bebfc4
commit 976c802b11
4 changed files with 68 additions and 26 deletions

View File

@@ -72,7 +72,7 @@ class BUTable extends Component {
formData: bu ? {
bu: bu.bu,
name: bu.name,
vst: bu.vst || '',
vst: bu.vst !== null && bu.vst !== undefined ? bu.vst.toString() : '',
} : {
bu: '',
name: '',
@@ -102,13 +102,20 @@ class BUTable extends Component {
});
};
isFormValid = () => {
const { formData } = this.state;
return formData.bu.trim() !== '' &&
formData.name.trim() !== '' &&
formData.vst !== '';
};
handleSave = async () => {
const { editingBU, formData } = this.state;
// Convert vst to number or null
const payload = {
...formData,
vst: formData.vst ? parseFloat(formData.vst) : null,
vst: formData.vst !== '' ? parseFloat(formData.vst) : null,
};
try {
@@ -220,7 +227,7 @@ class BUTable extends Component {
<TableCell>{bu.bu}</TableCell>
<TableCell>{bu.name}</TableCell>
<TableCell align="right">
{bu.vst ? `${bu.vst}%` : '-'}
{bu.vst !== null && bu.vst !== undefined ? `${bu.vst}%` : '-'}
</TableCell>
<TableCell align="right">
<IconButton
@@ -287,7 +294,11 @@ class BUTable extends Component {
</DialogContent>
<DialogActions>
<Button onClick={this.handleCloseDialog}>Abbrechen</Button>
<Button onClick={this.handleSave} variant="contained">
<Button
onClick={this.handleSave}
variant="contained"
disabled={!this.isFormValid()}
>
Speichern
</Button>
</DialogActions>