`;
+ // Avatar-Hover-Overlay
+ const avatarBtn = document.getElementById('settings-avatar-btn');
+ const avatarOverlay = avatarBtn?.querySelector('.avatar-overlay');
+ if (avatarBtn && avatarOverlay) {
+ avatarBtn.addEventListener('mouseenter', () => { avatarOverlay.style.opacity = '1'; });
+ avatarBtn.addEventListener('mouseleave', () => { avatarOverlay.style.opacity = '0'; });
+ }
+
+ // Avatar-Upload
+ avatarBtn?.addEventListener('click', () => {
+ document.getElementById('settings-avatar-input')?.click();
+ });
+ document.getElementById('settings-avatar-input')?.addEventListener('change', async e => {
+ const file = e.target.files?.[0];
+ if (!file) return;
+ try {
+ const fd = new FormData();
+ fd.append('file', file);
+ const res = await API.post('/api/profile/avatar', fd);
+ _appState.user.avatar_url = res.avatar_url;
+ UI.toast.success('Avatar aktualisiert.');
+ _render();
+ } catch {
+ UI.toast.error('Avatar-Upload fehlgeschlagen.');
+ }
+ });
+
+ // Profil bearbeiten
+ document.getElementById('settings-profile-edit-btn')?.addEventListener('click', () => {
+ const u = _appState.user;
+ const inputStyle = `width:100%;box-sizing:border-box;padding:var(--space-2) var(--space-3);
+ border:1.5px solid var(--c-border);border-radius:var(--radius-md);
+ font-size:var(--text-sm);font-family:inherit;
+ background:var(--c-surface);color:var(--c-text)`;
+
+ const erfahrungOpts = [
+ ['', 'Bitte wählen...'],
+ ['einsteiger', 'Einsteiger (erster Hund)'],
+ ['erfahren', 'Erfahrener Hundehalter'],
+ ['trainer', 'Trainer / Ausbilder'],
+ ['zuechter', 'Züchter'],
+ ].map(([val, label]) =>
+ `
`
+ ).join('');
+
+ const sichtbarkeitOpts = [
+ ['public', 'Öffentlich'],
+ ['friends', 'Nur Freunde'],
+ ['private', 'Privat'],
+ ].map(([val, label]) =>
+ `
`
+ ).join('');
+
+ UI.modal.open({
+ title: 'Profil bearbeiten',
+ body: `
+
+ `,
+ footer: `
+
+
+ `,
+ });
+
+ document.getElementById('profile-form')?.addEventListener('submit', async e => {
+ e.preventDefault();
+ const btn = document.querySelector('[form="profile-form"]');
+ const fd = UI.formData(e.target);
+ await UI.asyncButton(btn, async () => {
+ const updated = await API.patch('/api/profile', {
+ bio: fd.bio || '',
+ wohnort: fd.wohnort || '',
+ erfahrung: fd.erfahrung || '',
+ social_link: fd.social_link || '',
+ profil_sichtbarkeit: fd.profil_sichtbarkeit || 'public',
+ });
+ Object.assign(_appState.user, updated);
+ UI.modal.close?.();
+ UI.toast.success('Profil gespeichert.');
+ _render();
+ });
+ });
+ });
+
document.getElementById('settings-logout-btn')?.addEventListener('click', async () => {
const ok = await UI.modal.confirm({
title : 'Abmelden?',