diff --git a/apps/mana/apps/web/src/lib/api/profile.test.ts b/apps/mana/apps/web/src/lib/api/profile.test.ts index 1352ca6f3..577433633 100644 --- a/apps/mana/apps/web/src/lib/api/profile.test.ts +++ b/apps/mana/apps/web/src/lib/api/profile.test.ts @@ -157,34 +157,4 @@ describe('profileService', () => { ); }); }); - - describe('uploadAvatar', () => { - it('should upload avatar to API and update profile', async () => { - const mockFile = new File(['image-data'], 'avatar.png', { type: 'image/png' }); - - global.fetch = vi - .fn() - .mockResolvedValueOnce({ - ok: true, - json: () => - Promise.resolve({ url: 'https://media.mana.how/avatar.png', mediaId: 'media-1' }), - }) - .mockResolvedValueOnce({ - ok: true, - json: () => - Promise.resolve({ - success: true, - user: { id: 'user-1', name: 'Test', email: 'test@mana.how' }, - }), - }); - - const result = await profileService.uploadAvatar(mockFile); - - expect(result.success).toBe(true); - expect(global.fetch).toHaveBeenCalledWith( - 'http://localhost:3060/api/v1/storage/avatar/upload', - expect.objectContaining({ method: 'POST' }) - ); - }); - }); }); diff --git a/apps/mana/apps/web/src/lib/api/profile.ts b/apps/mana/apps/web/src/lib/api/profile.ts index 51e7e9446..e7d0142dd 100644 --- a/apps/mana/apps/web/src/lib/api/profile.ts +++ b/apps/mana/apps/web/src/lib/api/profile.ts @@ -4,7 +4,7 @@ */ import { authStore } from '$lib/stores/auth.svelte'; -import { getManaAuthUrl, getManaApiUrl } from './config'; +import { getManaAuthUrl } from './config'; // Types export interface UserProfile { @@ -36,11 +36,6 @@ export interface ChangeEmailRequest { newEmail: string; } -export interface AvatarUploadResponse { - url: string; - mediaId: string; -} - // Helper function for authenticated requests async function fetchWithAuth(endpoint: string, options: RequestInit = {}): Promise { const token = await authStore.getValidToken(); @@ -114,23 +109,4 @@ export const profileService = { body: JSON.stringify(data), }); }, - - /** - * Upload avatar file directly, then update profile - */ - async uploadAvatar(file: File): Promise<{ success: boolean; user: UserProfile }> { - const token = await authStore.getValidToken(); - const formData = new FormData(); - formData.append('file', file); - - const uploadResponse = await fetch(`${getManaApiUrl()}/api/v1/storage/avatar/upload`, { - method: 'POST', - headers: { ...(token ? { Authorization: `Bearer ${token}` } : {}) }, - body: formData, - }); - - if (!uploadResponse.ok) throw new Error('Avatar-Upload fehlgeschlagen'); - const { url } = (await uploadResponse.json()) as AvatarUploadResponse; - return this.updateProfile({ image: url }); - }, }; diff --git a/apps/mana/apps/web/src/lib/components/profile/EditProfileModal.svelte b/apps/mana/apps/web/src/lib/components/profile/EditProfileModal.svelte index 51d8754f1..914e9ffc9 100644 --- a/apps/mana/apps/web/src/lib/components/profile/EditProfileModal.svelte +++ b/apps/mana/apps/web/src/lib/components/profile/EditProfileModal.svelte @@ -1,5 +1,6 @@