Fixed members handling

This commit is contained in:
Torsten Schulz
2024-09-25 17:23:01 +02:00
parent 3181a6628d
commit edcfd8130a
6 changed files with 56 additions and 37 deletions

View File

@@ -302,7 +302,7 @@ export default {
}
},
async loadMembers() {
const response = await apiClient.get(`/clubmembers/${this.currentClub}`);
const response = await apiClient.get(`/clubmembers/get/${this.currentClub}/false`);
this.members = response.data;
},
async loadParticipants(dateId) {
@@ -630,7 +630,7 @@ export default {
},
async loadMemberImage(member) {
try {
const response = await apiClient.get(`/clubmembers/${this.currentClub}/image/${member.id}`, {
const response = await apiClient.get(`/clubmembers/image/${this.currentClub}/${member.id}`, {
responseType: 'blob',
});
const imageUrl = URL.createObjectURL(response.data);
@@ -664,7 +664,7 @@ export default {
},
async loadMemberImage(member) {
try {
const response = await apiClient.get(`/clubmembers/${this.currentClub}/image/${member.id}`, {
const response = await apiClient.get(`/clubmembers/image/${this.currentClub}/${member.id}`, {
responseType: 'blob',
});
this.imageUrl = URL.createObjectURL(response.data);

View File

@@ -125,7 +125,10 @@ export default {
},
methods: {
async init() {
const response = await apiClient.get(`/clubmembers/${this.currentClub}`);
await this.loadMembers();
},
async loadMembers() {
const response = await apiClient.get(`/clubmembers/get/${this.currentClub}/true`);
this.members = response.data;
this.members.forEach(member => {
this.loadMemberImage(member);
@@ -149,8 +152,6 @@ export default {
onFileSelected(event) {
const file = event.target.files[0];
this.memberImage = file;
// Bildvorschau erstellen
if (file) {
const reader = new FileReader();
reader.onload = (e) => {
@@ -174,8 +175,8 @@ export default {
let response;
try {
response = await apiClient.post(`/clubmembers/${this.currentClub}`, memberData);
this.members = response.data;
response = await apiClient.post(`/clubmembers/set/${this.currentClub}`, memberData);
this.loadMembers();
} catch (error) {
console.error("Fehler beim Speichern des Mitglieds:", error);
return;
@@ -186,7 +187,7 @@ export default {
formData.append('image', this.memberImage);
formData.append('clubId', this.currentClub);
try {
await apiClient.post(`/clubmembers/${this.currentClub}/image/${this.memberToEdit.id}`, formData, {
await apiClient.post(`/clubmembers/image/${this.currentClub}/${this.memberToEdit.id}`, formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
@@ -210,8 +211,7 @@ export default {
this.newEmail = member.email;
this.newActive = member.active;
try {
const response = await apiClient.get(`/clubmembers/${member.id}/image`, {
params: { clubId: this.currentClub },
const response = await apiClient.get(`/clubmembers/image/${member.id}`, {
responseType: 'blob'
});
this.memberImagePreview = URL.createObjectURL(response.data);
@@ -265,7 +265,7 @@ export default {
},
async loadMemberImage(member) {
try {
const response = await apiClient.get(`/clubmembers/${this.currentClub}/image/${member.id}`, {
const response = await apiClient.get(`/clubmembers/image/${this.currentClub}/${member.id}`, {
responseType: 'blob',
});
const imageUrl = URL.createObjectURL(response.data);