fix(club): improve error handling and access logic in loadClub method

- Refactored the loadClub method to handle access checks more effectively, ensuring fallback club data is used when access is denied.
- Enhanced error handling to manage access request status and provide appropriate user feedback based on backend responses.
This commit is contained in:
Torsten Schulz (local)
2026-02-04 13:32:41 +01:00
parent a2e9e5e510
commit 6ff672c5f1

View File

@@ -128,17 +128,20 @@ export default {
async loadClub() {
try {
const clubId = this.getClubId();
// Wenn keine Berechtigung: Clubnamen aus der Liste verwenden, kein /clubs/:id Request
if (!this.canAccessClub()) {
const club = this.clubs.find(c => String(c.id) === String(clubId));
this.club = club || { name: '' };
this.accessAllowed = false;
return;
}
this.accessRequested = false;
const response = await apiClient.get(`/clubs/${clubId}`);
this.club = response.data || { name: '' };
this.accessAllowed = true;
} catch (error) {
// Kein Zugriff: Status vom Backend nutzen (requested/notrequested)
if (error?.response?.status === 403 && error?.response?.data?.status) {
const clubId = this.getClubId();
const club = this.clubs.find(c => String(c.id) === String(clubId));
this.club = club || { name: '' };
this.accessAllowed = false;
this.accessRequested = error.response.data.status === 'requested';
return;
}
this.accessAllowed = false;
const message = safeErrorMessage(error, this.$t('club.accessDenied'));
await this.showInfo(this.$t('messages.error'), message, '', 'error');