Feature: Abo-Kündigung + Ablaufdatum + Dog-Auswahl nach Downgrade (SW by-v945)
This commit is contained in:
parent
44b3fba191
commit
3b666c545f
10 changed files with 341 additions and 11 deletions
|
|
@ -3,7 +3,7 @@
|
|||
Router, State-Management, Navigation, Initialisierung.
|
||||
============================================================ */
|
||||
|
||||
const APP_VER = '944'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VER = '945'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VERSION = '1.5.1'; // ← semantische Version, wird bei make release gesetzt
|
||||
const IS_STAGING = location.hostname === 'staging.banyaro.app';
|
||||
// Cache-Bust-Parameter nach Update-Reload sofort entfernen
|
||||
|
|
@ -567,6 +567,11 @@ const App = (() => {
|
|||
navigate('onboarding');
|
||||
}
|
||||
|
||||
// Abo abgelaufen mit mehreren Hunden → Haupthund auswählen
|
||||
if (state.user.needs_dog_selection && state.dogs.length > 1) {
|
||||
_showDogSelectionModal();
|
||||
}
|
||||
|
||||
// Theme aus DB-Profil übernehmen (überschreibt localStorage-Wert)
|
||||
_applyUserTheme(state.user);
|
||||
|
||||
|
|
@ -668,6 +673,57 @@ const App = (() => {
|
|||
document.getElementById('meta-theme-color')?.setAttribute('content', isDark ? '#0f1623' : '#C4843A');
|
||||
}
|
||||
|
||||
function _showDogSelectionModal() {
|
||||
const dogs = state.dogs;
|
||||
const optionHtml = dogs.map(d => `
|
||||
<label style="display:flex;align-items:center;gap:var(--space-3);padding:var(--space-3);
|
||||
border-radius:var(--radius-md);border:1.5px solid var(--c-border);
|
||||
cursor:pointer;margin-bottom:var(--space-2)">
|
||||
<input type="radio" name="select-dog" value="${d.id}" style="width:18px;height:18px">
|
||||
${d.foto_url
|
||||
? `<img src="${UI.escape(d.foto_url)}" style="width:40px;height:40px;border-radius:50%;object-fit:cover">`
|
||||
: `<div style="width:40px;height:40px;border-radius:50%;background:var(--c-border);display:flex;align-items:center;justify-content:center">🐕</div>`}
|
||||
<div>
|
||||
<div style="font-weight:600;font-size:var(--text-sm)">${UI.escape(d.name)}</div>
|
||||
${d.rasse ? `<div style="font-size:var(--text-xs);color:var(--c-text-muted)">${UI.escape(d.rasse)}</div>` : ''}
|
||||
</div>
|
||||
</label>`).join('');
|
||||
|
||||
UI.modal.open({
|
||||
title: 'Haupthund auswählen',
|
||||
body: `
|
||||
<p style="font-size:var(--text-sm);color:var(--c-text-secondary);margin-bottom:var(--space-4)">
|
||||
Dein Abo ist ausgelaufen. Wähle einen Haupthund für deinen kostenlosen Account.
|
||||
Alle anderen Hunde-Profile bleiben vollständig gespeichert — du kannst sie nach
|
||||
einem erneuten Upgrade wieder aktivieren.
|
||||
</p>
|
||||
<form id="dog-select-form">${optionHtml}</form>`,
|
||||
footer: `
|
||||
<button id="dog-select-confirm" class="btn btn-primary" style="width:100%">
|
||||
Auswahl bestätigen
|
||||
</button>`
|
||||
});
|
||||
|
||||
document.getElementById('dog-select-confirm')?.addEventListener('click', async () => {
|
||||
const chosen = document.querySelector('[name="select-dog"]:checked')?.value;
|
||||
if (!chosen) { UI.toast.warning('Bitte einen Hund auswählen.'); return; }
|
||||
const btn = document.getElementById('dog-select-confirm');
|
||||
btn.disabled = true; btn.textContent = '…';
|
||||
try {
|
||||
await API.auth.selectPrimaryDog(parseInt(chosen));
|
||||
state.user.needs_dog_selection = 0;
|
||||
state.activeDog = state.dogs.find(d => String(d.id) === chosen) || state.dogs[0];
|
||||
localStorage.setItem('by_active_dog', String(state.activeDog.id));
|
||||
UI.modal.close();
|
||||
UI.toast.success('Haupthund festgelegt.');
|
||||
_renderDogSwitcher();
|
||||
} catch (e) {
|
||||
btn.disabled = false; btn.textContent = 'Auswahl bestätigen';
|
||||
UI.toast.error(e.message || 'Fehler.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function _showAndroidBetaBanner() {
|
||||
// Nur auf Android, nur einmalig, nur für eingeloggte Nutzer
|
||||
if (!/android/i.test(navigator.userAgent)) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue