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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user