diff --git a/backend/auth.py b/backend/auth.py index a4d5af3..0b3bff1 100644 --- a/backend/auth.py +++ b/backend/auth.py @@ -87,7 +87,7 @@ def get_current_user( user_id = int(payload["sub"]) with db() as conn: row = conn.execute( - "SELECT id, email, name, rolle, is_premium, is_moderator, is_banned, ban_reason, is_social_media, notes_ki_enabled, gassi_stunde_push, breeder_status, is_founder, is_partner, founder_number, email_verified, luna_trial_until FROM users WHERE id=?", + "SELECT id, email, name, rolle, is_premium, is_moderator, is_banned, ban_reason, is_social_media, notes_ki_enabled, gassi_stunde_push, breeder_status, is_founder, is_partner, founder_number, email_verified, luna_trial_until, subscription_tier FROM users WHERE id=?", (user_id,) ).fetchone() @@ -130,6 +130,32 @@ def require_admin(user=Depends(get_current_user)): return user +def has_pro_access(user: dict) -> bool: + """True wenn User Pro-Features nutzen darf.""" + if not user: + return False + role = user.get("rolle", "user") + tier = user.get("subscription_tier", "standard") + if role in ("admin", "moderator"): + return True + if user.get("is_moderator") or user.get("is_social_media"): + return True + return tier in ("pro", "breeder", "pro_test", "breeder_test") + + +def has_breeder_access(user: dict) -> bool: + """True wenn User Züchter-Features nutzen darf.""" + if not user: + return False + role = user.get("rolle", "user") + tier = user.get("subscription_tier", "standard") + if role in ("admin", "moderator"): + return True + if user.get("is_moderator") or user.get("is_social_media"): + return True + return tier in ("breeder", "breeder_test") or role == "breeder" + + def require_social_media(user=Depends(get_current_user)): """Dependency: Social-Media-Manager, Luna-Probezugang oder Admin.""" from datetime import datetime as _dt diff --git a/backend/database.py b/backend/database.py index efb9266..c56a2f6 100644 --- a/backend/database.py +++ b/backend/database.py @@ -2075,6 +2075,14 @@ def _migrate(conn_factory): _seed_help_articles(conn) logger.info("Migration: Hilfe/FAQ-Tabelle bereit.") + # ---- Feature: Subscription-Tier ---- + try: + conn.execute("ALTER TABLE users ADD COLUMN subscription_tier TEXT DEFAULT 'standard'") + conn.execute("CREATE INDEX IF NOT EXISTS idx_users_tier ON users(subscription_tier)") + logger.info("Migration: subscription_tier Spalte hinzugefügt.") + except Exception: + pass # Spalte existiert bereits + def _seed_help_articles(conn): """Befüllt help_articles mit Starter-FAQs — nur wenn die Tabelle noch leer ist.""" diff --git a/backend/main.py b/backend/main.py index dff2344..8eebbd2 100644 --- a/backend/main.py +++ b/backend/main.py @@ -327,7 +327,7 @@ MEDIA_DIR = os.getenv("MEDIA_DIR", "/data/media") os.makedirs(MEDIA_DIR, exist_ok=True) app.mount("/media", StaticFiles(directory=MEDIA_DIR), name="media") -APP_VER = "727" # muss mit APP_VER in app.js übereinstimmen +APP_VER = "741" # muss mit APP_VER in app.js übereinstimmen @app.get("/api/version") async def app_version(): @@ -378,6 +378,7 @@ async def sitemap(): urls = [ ("https://banyaro.app/", "weekly", "1.0"), ("https://banyaro.app/info", "monthly", "0.9"), + ("https://banyaro.app/presse", "monthly", "0.8"), ("https://banyaro.app/wiki/rassen", "weekly", "0.8"), ("https://banyaro.app/knigge", "monthly", "0.8"), ("https://banyaro.app/wurfboerse", "daily", "0.8"), diff --git a/backend/routes/admin.py b/backend/routes/admin.py index c2ffebb..5e82927 100644 --- a/backend/routes/admin.py +++ b/backend/routes/admin.py @@ -81,12 +81,15 @@ def require_admin(user=Depends(get_current_user)): # ------------------------------------------------------------------ # Schemas # ------------------------------------------------------------------ +_VALID_TIERS = {"standard", "pro", "breeder", "standard_test", "pro_test", "breeder_test"} + class UserPatch(BaseModel): - rolle: Optional[str] = None # user | moderator | admin - is_moderator: Optional[int] = None - is_banned: Optional[int] = None - ban_reason: Optional[str] = None - is_social_media: Optional[int] = None + rolle: Optional[str] = None # user | moderator | admin + is_moderator: Optional[int] = None + is_banned: Optional[int] = None + ban_reason: Optional[str] = None + is_social_media: Optional[int] = None + subscription_tier: Optional[str] = None class WikiEnrichBody(BaseModel): limit: int = 10 @@ -331,7 +334,7 @@ async def list_users( SELECT u.id, u.name, {_email_col}, u.rolle, u.is_premium, u.is_moderator, u.is_banned, u.ban_reason, u.is_founder, u.is_partner, u.founder_number, - u.created_at, u.last_login, + u.created_at, u.last_login, u.subscription_tier, (SELECT COUNT(*) FROM dogs d WHERE d.user_id=u.id) AS dog_count, (SELECT COUNT(*) FROM forum_threads t WHERE t.user_id=u.id AND t.is_deleted=0) AS thread_count, ROUND(COALESCE((SELECT SUM(r.distanz_km) FROM routes r WHERE r.user_id=u.id), 0), 1) AS total_km, @@ -365,6 +368,10 @@ async def patch_user(uid: int, data: UserPatch, user=Depends(require_mod)): raise HTTPException(403, "is_moderator darf nur von Admins geändert werden.") if data.is_social_media is not None and user["rolle"] != "admin": raise HTTPException(403, "is_social_media darf nur von Admins geändert werden.") + if data.subscription_tier is not None and user["rolle"] != "admin": + raise HTTPException(403, "subscription_tier darf nur von Admins geändert werden.") + if data.subscription_tier is not None and data.subscription_tier not in _VALID_TIERS: + raise HTTPException(400, f"Ungültiger Tier. Erlaubt: {', '.join(sorted(_VALID_TIERS))}") with db() as conn: target = conn.execute("SELECT id, rolle, name FROM users WHERE id=?", (uid,)).fetchone() @@ -385,7 +392,7 @@ async def patch_user(uid: int, data: UserPatch, user=Depends(require_mod)): cols = ", ".join(f"{k}=?" for k in updates) conn.execute(f"UPDATE users SET {cols} WHERE id=?", [*updates.values(), uid]) row = conn.execute( - "SELECT id, name, email, rolle, is_moderator, is_banned, ban_reason FROM users WHERE id=?", + "SELECT id, name, email, rolle, is_moderator, is_banned, ban_reason, subscription_tier FROM users WHERE id=?", (uid,) ).fetchone() @@ -395,6 +402,8 @@ async def patch_user(uid: int, data: UserPatch, user=Depends(require_mod)): detail_parts.append("gesperrt" if updates["is_banned"] else "entsperrt") if "rolle" in updates: detail_parts.append(f"Rolle→{updates['rolle']}") + if "subscription_tier" in updates: + detail_parts.append(f"Tier→{updates['subscription_tier']}") _audit(conn, user, "user_patch", f"user:{uid} ({target['name']})", ", ".join(detail_parts) or None) return dict(row) diff --git a/backend/static/css/components.css b/backend/static/css/components.css index d3dcc37..2f95c24 100644 --- a/backend/static/css/components.css +++ b/backend/static/css/components.css @@ -7792,7 +7792,7 @@ svg.empty-state-icon { #worlds-overlay { position: fixed; inset: 0; - z-index: 50; + z-index: 450; overflow: hidden; background: var(--c-bg); display: none; diff --git a/backend/static/img/demo/app-demo.mp4 b/backend/static/img/demo/app-demo.mp4 new file mode 100644 index 0000000..95d8c83 Binary files /dev/null and b/backend/static/img/demo/app-demo.mp4 differ diff --git a/backend/static/index.html b/backend/static/index.html index 9fb7cef..2f22a0a 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -95,7 +95,7 @@ - + @@ -578,7 +578,7 @@ - + diff --git a/backend/static/js/app.js b/backend/static/js/app.js index f2245de..263fa80 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,8 +3,8 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '727'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen -const APP_VERSION = '1.4.0'; // ← semantische Version, wird bei make release gesetzt +const APP_VER = '741'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VERSION = '1.5.0'; // ← semantische Version, wird bei make release gesetzt const IS_STAGING = location.hostname === 'staging.banyaro.app'; const App = (() => { @@ -43,7 +43,7 @@ const App = (() => { routes: { title: 'Routen', module: null }, events: { title: 'Events', module: null }, poison: { title: 'Giftköder-Alarm', module: null }, - walks: { title: 'Gassi-Treffen', module: null, requiresAuth: true }, + walks: { title: 'Gassi-Treffen', module: null, requiresAuth: true, requiresPro: true }, sitting: { title: 'Sitting', module: null, requiresAuth: true }, forum: { title: 'Forum', module: null }, wiki: { title: 'Wiki', module: null }, @@ -51,12 +51,12 @@ const App = (() => { movies: { title: 'Filme', module: null }, trainingsplaene: { title: 'Trainingspläne', module: null }, uebungen: { title: 'Übungsbibliothek', module: null }, - notes: { title: 'Notizblock', module: null, requiresAuth: true }, + notes: { title: 'Notizblock', module: null, requiresAuth: true, requiresPro: true }, 'erste-hilfe': { title: 'Erste Hilfe', module: null }, settings: { title: 'Einstellungen', module: null }, lost: { title: 'Verlorener Hund', module: null }, - friends: { title: 'Freunde', module: null, requiresAuth: true }, - chat: { title: 'Nachrichten', module: null, requiresAuth: true }, + friends: { title: 'Freunde', module: null, requiresAuth: true, requiresPro: true }, + chat: { title: 'Nachrichten', module: null, requiresAuth: true, requiresPro: true }, social: { title: 'Social Media', module: null, requiresAuth: true }, admin: { title: 'Admin', module: null, requiresAuth: true }, moderation: { title: 'Moderation', module: null, requiresAuth: true }, @@ -74,14 +74,28 @@ const App = (() => { expenses: { title: 'Ausgaben', module: null, requiresAuth: true }, recalls: { title: 'Rückrufe', module: null }, adoption: { title: 'Adoption', module: null }, - playdate: { title: 'Playdate', module: null, requiresAuth: true }, + playdate: { title: 'Playdate', module: null, requiresAuth: true, requiresPro: true }, wetter: { title: 'Wetter', module: null }, - ernaehrung: { title: 'Ernährung', module: null, requiresAuth: true }, + ernaehrung: { title: 'Ernährung', module: null, requiresAuth: true, requiresPro: true }, personality: { title: 'Persönlichkeitstest', module: null }, - reise: { title: 'Reise mit Hund', module: null }, + reise: { title: 'Reise mit Hund', module: null, requiresPro: true }, hilfe: { title: 'Hilfe & FAQ', module: null }, }; + // ---------------------------------------------------------- + // TIER-CHECK — Frontend-Pendant zu has_pro_access() in auth.py + // ---------------------------------------------------------- + function _hasPro(user) { + if (!user) return false; + const t = user.subscription_tier || 'standard'; + // _test-Tiers simulieren ihren Tier ohne Admin-Override — so sieht Admin was echte User sehen + if (t.endsWith('_test')) return ['pro_test','breeder_test'].includes(t); + // Normale Prüfung: Admin/Mod/Social bekommen immer Pro + if (user.rolle === 'admin' || user.rolle === 'moderator') return true; + if (user.is_moderator || user.is_social_media) return true; + return ['pro','breeder'].includes(t); + } + // ---------------------------------------------------------- // AUTH GUARD — Login-Gate Texte pro Seite // ---------------------------------------------------------- @@ -142,6 +156,34 @@ const App = (() => { return; } + // Pro-Guard — nur wenn User eingeloggt aber kein Pro-Zugang + if (page.requiresPro && state.user && !_hasPro(state.user)) { + const container = document.querySelector(`#page-${pageId} .page-body`); + if (container) { + container.innerHTML = ` +
+
+

Ban Yaro Pro

+

+ Dieses Feature ist Teil von Ban Yaro Pro — verfügbar wenn wir die nächste Stufe zünden.
+ Du wirst benachrichtigt wenn es soweit ist. +

+
+
Ban Yaro Pro enthält:
+ +
+
`; + } + return; + } + if (page.module) { const hasParams = params && Object.keys(params).length > 0; if (hasParams) { @@ -819,6 +861,7 @@ const App = (() => { try { localStorage.removeItem('by_wissen_open'); } catch (_) {} + _initVersionCheck(); await _checkAuth(); // Einladungslink /teilen/{token} → direkt annehmen @@ -916,6 +959,124 @@ const App = (() => { }); } + // ---------------------------------------------------------- + // ---------------------------------------------------------- + // VERSION-CHECK — persistentes Banner wenn neue Version verfügbar + // ---------------------------------------------------------- + let _updateBannerShown = false; + + async function _checkVersion() { + try { + const r = await fetch('/api/version', { cache: 'no-store' }); + if (!r.ok) return; + const { version } = await r.json(); + if (version && version !== APP_VER && !_updateBannerShown) { + _updateBannerShown = true; + _showUpdateBanner(version); + } + } catch { /* offline — ignorieren */ } + } + + function _showUpdateBanner(newVersion) { + const isIos = /iphone|ipad|ipod/i.test(navigator.userAgent); + const existing = document.getElementById('app-update-banner'); + if (existing) return; + + const banner = document.createElement('div'); + banner.id = 'app-update-banner'; + banner.style.cssText = [ + 'position:fixed;bottom:calc(env(safe-area-inset-bottom,0px) + 72px);left:12px;right:12px', + 'z-index:9000;background:var(--c-primary);color:#fff;border-radius:16px', + 'padding:14px 16px;box-shadow:0 4px 20px rgba(0,0,0,0.3)', + 'display:flex;flex-direction:column;gap:10px', + ].join(';'); + + banner.innerHTML = ` +
+
+
+ Neue Version verfügbar (v${newVersion}) +
+
+ Tippe auf Aktualisieren um die neueste Version zu laden. +
+
+
+ + +
+
+ + `; + + document.body.appendChild(banner); + + banner.querySelector('#upd-btn-close').addEventListener('click', () => banner.remove()); + + banner.querySelector('#upd-btn-reload').addEventListener('click', async () => { + const btn = banner.querySelector('#upd-btn-reload'); + btn.textContent = 'Lädt…'; + btn.disabled = true; + sessionStorage.setItem('by_update_reload', APP_VER); + try { + // SW aktivieren + alle Caches leeren für sauberen Reload + const reg = await navigator.serviceWorker?.getRegistration(); + if (reg?.waiting) reg.waiting.postMessage({ type: 'SKIP_WAITING' }); + await reg?.update(); + const keys = await caches.keys(); + await Promise.all(keys.map(k => caches.delete(k))); + } catch { /* ignorieren */ } + setTimeout(() => location.reload(), 600); + }); + } + + function _initVersionCheck() { + // Beim Start nach 10 Sekunden prüfen (nicht sofort — Prio für Auth) + setTimeout(_checkVersion, 10_000); + // Dann alle 30 Minuten + setInterval(_checkVersion, 30 * 60_000); + // Beim Wiedereinstieg in die App + document.addEventListener('visibilitychange', () => { + if (document.visibilityState === 'visible') _checkVersion(); + }); + // Nach Reload: war das ein Update-Reload? Falls Version immer noch alt → iOS-Hinweis + const reloadVer = sessionStorage.getItem('by_update_reload'); + if (reloadVer && reloadVer === APP_VER) { + // Version hat sich nicht geändert nach Reload → iOS-Cache-Problem + sessionStorage.removeItem('by_update_reload'); + setTimeout(() => { + fetch('/api/version', { cache: 'no-store' }) + .then(r => r.json()) + .then(({ version }) => { + if (version && version !== APP_VER) { + _updateBannerShown = true; + _showUpdateBanner(version); + // iOS-Hinweis sofort aufklappen + setTimeout(() => { + document.getElementById('upd-ios-hint')?.style.setProperty('display', 'block'); + }, 300); + } + }).catch(() => {}); + }, 2000); + } + } + // ---------------------------------------------------------- // ÖFFENTLICHE API // (andere Module können App.state, App.navigate etc. nutzen) diff --git a/backend/static/js/pages/admin.js b/backend/static/js/pages/admin.js index 3e485d5..0dfa8c7 100644 --- a/backend/static/js/pages/admin.js +++ b/backend/static/js/pages/admin.js @@ -795,6 +795,9 @@ window.Page_admin = (() => { ${_esc(u.rolle)} + · + ${_esc(u.subscription_tier || 'standard')} + · ${u.dog_count} Hund${u.dog_count !== 1 ? 'e' : ''} · ${u.thread_count} Threads @@ -823,6 +826,11 @@ window.Page_admin = (() => { title="Rolle ändern"> + + `).join('')} + + `, + }); + + document.querySelectorAll('.adm-tier-choice:not([disabled])').forEach(btn => { + btn.addEventListener('click', async () => { + UI.modal.close(); + try { + await API.patch(`/admin/users/${uid}`, { subscription_tier: btn.dataset.tier }); + // Eigenes Tier geändert → User-State neu laden + Welten neu rendern + if (String(uid) === String(_appState?.user?.id)) { + _appState.user.subscription_tier = btn.dataset.tier; + if (window.Worlds) { + window.Worlds.init(_appState); + } + UI.toast.success(`Dein Tier ist jetzt ${btn.dataset.tier} — Ansicht aktualisiert.`); + } else { + UI.toast.success(`${name}: Abo-Stufe ist jetzt ${btn.dataset.tier}.`); + } + _renderTab(); + } catch (e) { UI.toast.error(e.message); } + }); + }); + } + async function _deleteUser(uid, name) { const ok = await UI.modal.confirm({ title: `${name} löschen?`, diff --git a/backend/static/js/pages/datenschutz.js b/backend/static/js/pages/datenschutz.js index 73c2ba8..d2a8af8 100644 --- a/backend/static/js/pages/datenschutz.js +++ b/backend/static/js/pages/datenschutz.js @@ -82,6 +82,16 @@ window.Page_datenschutz = (() => { Plattformsicherheit).

`)} + ${sec('Direktnachrichten', ` +

+ Nachrichten zwischen Nutzern (z. B. zwischen Hundesitter und Hundeeigentümer oder + zwischen Interessenten und Züchtern) werden auf unserem Server gespeichert, bis du + das Gespräch oder deinen Account löschst. Admins können gemeldete Nachrichten zur + Missbrauchsprüfung einsehen (Art. 6 Abs. 1 lit. f DSGVO — berechtigtes Interesse + an Plattformsicherheit). Nachrichten werden nicht an Dritte weitergegeben. + Du kannst Gespräche jederzeit selbst löschen. +

`)} + ${sec('KI-Funktionen', `

Ban Yaro bietet KI-gestützte Funktionen (Trainingsempfehlungen, Terminvorschläge, @@ -99,12 +109,34 @@ window.Page_datenschutz = (() => { anthropic.com/privacy.

+

+ Der KI-Trainer analysiert deinen bisherigen Trainingsfortschritt + (Übungshistorie, Erfolgsquoten, Streaks) und gibt personalisierte Empfehlungen. + Diese Analyse läuft auf unserem lokalen Server in Deutschland — deine Trainingsdaten + verlassen dabei nicht unsere Infrastruktur. Es findet kein Training oder Fine-Tuning + von KI-Modellen auf Basis deiner Nutzerdaten statt. +

KI-Empfehlungen sind Vorschläge und ersetzen keine tierärztliche Beratung. Eine automatisierte Entscheidungsfindung mit rechtlicher Wirkung (Art. 22 DSGVO) findet nicht statt.

`)} + ${sec('Wetterdaten (Open-Meteo)', ` +

+ Die Wetter-Funktion übermittelt auf Wunsch deine GPS-Koordinaten einmalig an + Open-Meteo (Österreich, DSGVO-konform), um die lokale + Wettervorhersage abzurufen. Es werden ausschließlich anonyme Koordinaten übertragen — + keine Account- oder Profildaten. Open-Meteo protokolliert keine personenbezogenen + Daten. Die Funktion wird nur aktiv, wenn du deinen Standort im Browser freigibst. + Rechtsgrundlage: Einwilligung gem. Art. 6 Abs. 1 lit. a DSGVO. +

+

+ Datenschutzerklärung von Open-Meteo: + open-meteo.com/en/terms +

`)} + ${sec('Routenvorschläge (OpenRouteService)', `

Die Funktion „Routenvorschläge" berechnet auf Wunsch einen Rundweg diff --git a/backend/static/js/pages/settings.js b/backend/static/js/pages/settings.js index beb8ae0..743004e 100644 --- a/backend/static/js/pages/settings.js +++ b/backend/static/js/pages/settings.js @@ -276,6 +276,13 @@ window.Page_settings = (() => { Hilfe & FAQ + ${!_appState.user?.subscription_tier || _appState.user.subscription_tier === 'standard' || _appState.user.subscription_tier === 'standard_test' ? ` +

+ ⭐ Ban Yaro Pro kommt bald — mehr Features, mehrere Hunde. +
+ ` : ''} @@ -242,7 +250,7 @@ window.Page_welcome = (() => {
- App installieren + Immer griffbereit — kein App Store
${_installHTML()}
@@ -481,7 +489,7 @@ window.Page_welcome = (() => {
- App installieren + Immer griffbereit — kein App Store
${_installHTML()}
@@ -1069,11 +1077,11 @@ window.Page_welcome = (() => { if (hasPrompt) { return `

- Kein App Store nötig — direkt auf den Home-Bildschirm. + Ban Yaro immer griffbereit — einmal hinzufügen, dann direkt vom Home-Bildschirm öffnen.

`; } @@ -1095,7 +1103,7 @@ window.Page_welcome = (() => { if (isIOS && !isSafari) { return `

- Auf dem iPhone geht die Installation nur über Safari. + Auf dem iPhone funktioniert das Hinzufügen nur über Safari.

${_steps([ ['safari-logo', 'Öffne Safari auf deinem iPhone'], diff --git a/backend/static/js/worlds.js b/backend/static/js/worlds.js index 8d76dae..2a56755 100644 --- a/backend/static/js/worlds.js +++ b/backend/static/js/worlds.js @@ -457,14 +457,14 @@ window.Worlds = (() => { // Alle verfügbaren Chips mit Metadaten const _ALL_CHIPS = [ - { icon:'note-pencil', label:'Notizblock', page:'notes', + { icon:'note-pencil', label:'Notizblock', page:'notes', pro: true, fab:[{ icon:'note-pencil', color:'#10B981', label:'Neue Notiz', sub:'Schnellnotiz erstellen', page:'notes', action:'openNew' }] }, { icon:'currency-eur', label:'Ausgaben', page:'expenses', fab:[{ icon:'currency-eur', color:'#3B82F6', label:'Ausgabe eintragen', sub:'Einmalig oder Dauerauftrag', page:'expenses', action:'openNew' }] }, { icon:'first-aid', label:'Erste Hilfe', page:'erste-hilfe' }, - { icon:'handshake', label:'Playdate', page:'playdate', + { icon:'handshake', label:'Playdate', page:'playdate', pro: true, fab:[{ icon:'handshake', color:'#F59E0B', label:'Playdate anfragen', sub:'Treffen mit anderen Hunden', page:'playdate', action:'openNew' }] }, - { icon:'chat-circle-dots', label:'Nachrichten', page:'chat' }, + { icon:'chat-circle-dots', label:'Nachrichten', page:'chat', pro: true }, { icon:'sun', label:'Wetter', page:'wetter' }, { icon:'book-open', label:'Tagebuch', page:'diary', @@ -486,9 +486,9 @@ window.Worlds = (() => { fab:[{ icon:'map-pin', color:'#10B981', label:'Ort vorschlagen', sub:'Neuen POI auf der Karte', page:'map' }] }, { icon:'push-pin', label:'Forum', page:'forum', fab:[{ icon:'push-pin', color:'#8B5CF6', label:'Forum-Beitrag', sub:'Thema oder Frage erstellen', page:'forum', action:'openNew' }] }, - { icon:'users', label:'Freunde', page:'friends', + { icon:'users', label:'Freunde', page:'friends', pro: true, fab:[{ icon:'users', color:'#3B82F6', label:'Freund einladen', sub:'Per Link einladen', page:'friends', action:'openNew' }] }, - { icon:'paw-print', label:'Gassi', page:'walks', + { icon:'paw-print', label:'Gassi', page:'walks', pro: true, fab:[{ icon:'paw-print', color:'#F59E0B', label:'Gassirunde', sub:'Neue Runde starten', page:'walks', action:'openNew' }, { icon:'paw-print', color:'#10B981', label:'Schnell-Gassi', sub:'Kurze Runde ohne GPS eintragen', page:'walks', action:'quickGassi' }] }, { icon:'skull', label:'Giftköder', page:'poison', @@ -513,9 +513,9 @@ window.Worlds = (() => { { icon:'shield-check', label:'Moderation', page:'moderation', role:'mod' }, { icon:'gear', label:'Admin', page:'admin', role:'admin' }, // ── NEUE FEATURES ──────────────────────────────────────────── - { icon:'fork-knife', label:'Ernährung', page:'ernaehrung', + { icon:'fork-knife', label:'Ernährung', page:'ernaehrung', pro: true, fab:[{ icon:'fork-knife', color:'#F97316', label:'Futter-Tagebuch', sub:'Mahlzeit oder Futtercheck', page:'ernaehrung' }] }, - { icon:'airplane', label:'Reise', page:'reise' }, + { icon:'airplane', label:'Reise', page:'reise', pro: true }, { icon:'smiley', label:'Persönlichkeit', page:'personality' }, ]; @@ -567,13 +567,31 @@ window.Worlds = (() => { } function _chipAllowed(chip) { const u = _state?.user; + const tier = u?.subscription_tier || 'standard'; + const isTest = tier.endsWith('_test'); + // Role-Checks (hart — komplett ausblenden) if (!chip?.role) return true; - if (chip.role === 'breeder') return u?.rolle === 'breeder' || u?.rolle === 'admin'; + if (chip.role === 'breeder') { + if (isTest) return tier === 'breeder_test'; + return u?.rolle === 'breeder' || u?.rolle === 'admin'; + } if (chip.role === 'social') return u?.is_social_media || u?.rolle === 'admin'; if (chip.role === 'mod') return u?.rolle === 'admin' || u?.rolle === 'moderator' || u?.is_moderator; if (chip.role === 'admin') return u?.rolle === 'admin'; return true; } + + // Gibt true zurück wenn User vollen Pro-Zugriff hat + function _hasProAccess() { + const u = _state?.user; + if (!u) return false; + const tier = u.subscription_tier || 'standard'; + if (tier.endsWith('_test')) return ['pro_test','breeder_test'].includes(tier); + if (u.rolle === 'admin' || u.rolle === 'moderator') return true; + if (u.is_moderator || u.is_social_media) return true; + return ['pro','breeder'].includes(tier); + } + function _chipsForWorld(world) { const pages = _getConfig()[world] || _DEFAULT_CONFIG[world]; return pages.map(_chipMeta).filter(c => c && _chipAllowed(c)); @@ -869,9 +887,10 @@ window.Worlds = (() => { // ── CHIP-HELPER ────────────────────────────────────────────── - function _chip(icon, label, page) { + function _chip(icon, label, page, locked = false) { + const style = locked ? 'opacity:0.25;cursor:default;' : ''; return ` -
+
@@ -1240,7 +1259,7 @@ window.Worlds = (() => { ` : ''}
- ${chips.map(c => _chip(c.icon, c.label, c.page)).join('')} + ${chips.map(c => _chip(c.icon, c.label, c.page, !!(c.pro && !_hasProAccess()))).join('')}