Feature: Feature-Gating nach Tier — Pro-Seiten/Chips für Standard versteckt, Admin immer alles (SW by-v737)
This commit is contained in:
parent
11067d9ef8
commit
a6c25cf0f0
6 changed files with 76 additions and 18 deletions
|
|
@ -3,7 +3,7 @@
|
|||
Router, State-Management, Navigation, Initialisierung.
|
||||
============================================================ */
|
||||
|
||||
const APP_VER = '736'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VER = '737'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VERSION = '1.4.0'; // ← semantische Version, wird bei make release gesetzt
|
||||
const IS_STAGING = location.hostname === 'staging.banyaro.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,25 @@ 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;
|
||||
if (user.rolle === 'admin' || user.rolle === 'moderator') return true;
|
||||
if (user.is_moderator || user.is_social_media) return true;
|
||||
const t = user.subscription_tier || 'standard';
|
||||
return ['pro','breeder','pro_test','breeder_test'].includes(t);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// AUTH GUARD — Login-Gate Texte pro Seite
|
||||
// ----------------------------------------------------------
|
||||
|
|
@ -142,6 +153,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 = `
|
||||
<div style="max-width:420px;margin:40px auto;padding:var(--space-6) var(--space-4);text-align:center">
|
||||
<div style="font-size:3rem;margin-bottom:var(--space-4)">⭐</div>
|
||||
<h2 style="font-size:var(--text-xl);font-weight:800;margin:0 0 var(--space-3)">Ban Yaro Pro</h2>
|
||||
<p style="color:var(--c-text-secondary);margin:0 0 var(--space-6);line-height:1.6">
|
||||
Dieses Feature ist Teil von Ban Yaro Pro — verfügbar wenn wir die nächste Stufe zünden.<br>
|
||||
Du wirst benachrichtigt wenn es soweit ist.
|
||||
</p>
|
||||
<div style="background:var(--c-bg-card);border:1px solid var(--c-border);border-radius:var(--radius-lg);
|
||||
padding:var(--space-4);text-align:left;font-size:var(--text-sm);color:var(--c-text-secondary)">
|
||||
<div style="font-weight:700;margin-bottom:var(--space-2);color:var(--c-text)">Ban Yaro Pro enthält:</div>
|
||||
<ul style="margin:0;padding-left:var(--space-5);display:flex;flex-direction:column;gap:var(--space-1)">
|
||||
<li>Mehrere Hunde verwalten</li>
|
||||
<li>KI-Trainer für personalisiertes Training</li>
|
||||
<li>Direktnachrichten & Freunde</li>
|
||||
<li>Gassi-Treffen, Playdate, Ernährung, Reise</li>
|
||||
<li>Notizblock</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (page.module) {
|
||||
const hasParams = params && Object.keys(params).length > 0;
|
||||
if (hasParams) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue