Update FalukantService and PoliticsView to enhance election data handling

- Modified the FalukantService to use getOpenPolitics instead of getElections for retrieving accessible elections, improving alignment with frontend data display.
- Updated the PoliticsView to handle the response from the application submission more effectively, ensuring that already applied positions remain pre-selected after submission.
- These changes aim to streamline the election data flow and enhance user experience in the application process.
This commit is contained in:
Torsten Schulz (local)
2025-12-03 17:19:13 +01:00
parent d6ea09b3e2
commit e5ef334f7c
2 changed files with 18 additions and 6 deletions

View File

@@ -324,11 +324,18 @@ export default {
async submitApplications() {
try {
await apiClient.post(
const response = await apiClient.post(
'/api/falukant/politics/open',
{ electionIds: this.selectedApplications }
);
// Speichere die IDs der erfolgreich beworbenen Positionen
const appliedIds = response.data?.applied || [];
// Lade die Daten neu
await this.loadOpenPolitics();
// Stelle sicher, dass alle bereits beworbenen Positionen (inkl. der gerade beworbenen) vorselektiert bleiben
this.selectedApplications = this.openPolitics
.filter(e => e.alreadyApplied || appliedIds.includes(e.id))
.map(e => e.id);
} catch (err) {
console.error('Error submitting applications', err);
}