Add validation endpoint for meeting reports and enhance frontend functionality
This commit introduces a new API endpoint in the backend for validating meeting reports, allowing for improved error handling and cookie management. The frontend has been updated to include a validation function that checks the report data before submission, providing users with feedback on validation warnings and errors. These changes enhance the overall user experience by ensuring data integrity and improving interaction with the meeting report feature.
This commit is contained in:
@@ -1467,6 +1467,55 @@ Wir wünschen den Spielen einen schönen, spannenden und fairen Verlauf und begr
|
||||
}
|
||||
},
|
||||
|
||||
async validateReport() {
|
||||
try {
|
||||
if (!this.meetingData || !this.meetingData.nuLigaMeetingUuid) {
|
||||
console.warn('⚠️ Keine Meeting-UUID verfügbar für Validierung');
|
||||
return;
|
||||
}
|
||||
|
||||
// Erstelle eine Kopie des aktuellen Match-Objekts
|
||||
const matchData = JSON.parse(JSON.stringify(this.match));
|
||||
|
||||
// Aktualisiere die Match-Daten mit unseren Eingaben
|
||||
this.updateMatchData(matchData);
|
||||
|
||||
const uuid = this.meetingData.nuLigaMeetingUuid;
|
||||
|
||||
console.log('🔄 Validiere Spielbericht...');
|
||||
|
||||
const response = await fetch(`${backendBaseUrl}/api/nuscore/validate/${uuid}`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(matchData)
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
console.log('✅ Validierung erfolgreich:', result);
|
||||
|
||||
// Zeige Validierungswarnungen falls vorhanden
|
||||
if (result.validationWarnings && result.validationWarnings.length > 0) {
|
||||
console.warn('⚠️ Validierungswarnungen:', result.validationWarnings);
|
||||
}
|
||||
|
||||
// Zeige Validierungsfehler falls vorhanden
|
||||
if (result.validationErrors && result.validationErrors.length > 0) {
|
||||
console.error('❌ Validierungsfehler:', result.validationErrors);
|
||||
}
|
||||
} else {
|
||||
console.warn('⚠️ Validierung mit Fehlern:', result);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Fehler beim Validieren:', error);
|
||||
// Validierungsfehler sind nicht kritisch, daher kein Alert
|
||||
}
|
||||
},
|
||||
|
||||
showMatchDataDialog(matchData) {
|
||||
// Erstelle einen neuen Dialog für die Datenanzeige
|
||||
const dialog = document.createElement('div');
|
||||
@@ -2837,8 +2886,8 @@ Wir wünschen den Spielen einen schönen, spannenden und fairen Verlauf und begr
|
||||
// Intelligente Navigation nach Zertifizierung
|
||||
this.navigateAfterCertification();
|
||||
|
||||
// TODO: Hier würden wir die signierte Aufstellung an das Backend senden
|
||||
// await this.submitSignedLineup(team);
|
||||
// Validiere und speichere die Änderungen
|
||||
await this.validateReport();
|
||||
} else {
|
||||
this.showSigningError(team);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user