diff --git a/frontend/src/views/ClubView.vue b/frontend/src/views/ClubView.vue index 4e8c3555..bcc85120 100644 --- a/frontend/src/views/ClubView.vue +++ b/frontend/src/views/ClubView.vue @@ -110,19 +110,33 @@ export default { this.confirmDialog.isOpen = false; }, + getClubId() { + return this.currentClub || this.$route.params.clubId; + }, + canAccessClub() { + return this.isClubOwner || this.userRole === 'admin' + || this.hasPermission('members', 'read') + || this.hasPermission('diary', 'read') + || this.hasPermission('statistics', 'read') + || this.hasPermission('tournaments', 'read') + || this.hasPermission('schedule', 'read'); + }, async loadClub() { try { - const response = await apiClient.get(`/clubs/${this.currentClub}`); - this.club = response.data; - this.accessAllowed = true; + const clubId = this.getClubId(); + const response = await apiClient.get(`/clubs/${clubId}`); + this.club = response.data || { name: '' }; + this.accessAllowed = this.canAccessClub(); } catch (error) { + this.accessAllowed = false; const message = safeErrorMessage(error, this.$t('club.accessDenied')); await this.showInfo(this.$t('messages.error'), message, '', 'error'); } }, async loadOpenRequests() { try { - const response = await apiClient.get(`/clubmembers/notapproved/${this.currentClub}`); + const clubId = this.getClubId(); + const response = await apiClient.get(`/clubmembers/notapproved/${clubId}`); this.openRequests = response.data; } catch (error) { this.showInfo(this.$t('messages.error'), this.$t('club.errorLoadingRequests'), '', 'error'); @@ -130,7 +144,8 @@ export default { }, async requestAccess() { try { - const response = await apiClient.get(`/clubs/request/${this.currentClub}`); + const clubId = this.getClubId(); + const response = await apiClient.get(`/clubs/request/${clubId}`); if (response.status === 200) { await this.showInfo(this.$t('messages.info'), this.$t('club.accessRequested'), '', 'info'); } @@ -155,7 +170,7 @@ export default { } }, computed: { - ...mapGetters(['isAuthenticated', 'currentClub', 'clubs']), + ...mapGetters(['isAuthenticated', 'currentClub', 'clubs', 'hasPermission', 'isClubOwner', 'userRole']), displayedMembers() { const members = Array.isArray(this.club.members) ? this.club.members : []; const onlyActive = members.filter(m => m && (m.active === true));