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) {
|
||||
|
|
|
|||
|
|
@ -276,6 +276,13 @@ window.Page_settings = (() => {
|
|||
<span>Hilfe & FAQ</span>
|
||||
<span style="margin-left:auto;color:var(--c-text-secondary)">›</span>
|
||||
</div>
|
||||
${!_appState.user?.subscription_tier || _appState.user.subscription_tier === 'standard' || _appState.user.subscription_tier === 'standard_test' ? `
|
||||
<div style="margin:var(--space-3) 0;padding:var(--space-3) var(--space-4);
|
||||
background:rgba(196,132,58,0.1);border-radius:var(--radius-md);
|
||||
font-size:var(--text-xs);color:var(--c-text-secondary)">
|
||||
⭐ <strong>Ban Yaro Pro</strong> kommt bald — mehr Features, mehrere Hunde.
|
||||
</div>
|
||||
` : ''}
|
||||
<div class="sidebar-item" id="settings-logout-btn"
|
||||
style="padding:var(--space-4);border-radius:0;cursor:pointer;
|
||||
color:var(--c-danger)">
|
||||
|
|
|
|||
|
|
@ -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,6 +567,18 @@ window.Worlds = (() => {
|
|||
}
|
||||
function _chipAllowed(chip) {
|
||||
const u = _state?.user;
|
||||
// Pro-Check
|
||||
if (chip.pro) {
|
||||
if (!u) return false;
|
||||
const role = u.rolle;
|
||||
if (role === 'admin' || role === 'moderator') {} // erlaubt
|
||||
else if (u.is_moderator || u.is_social_media) {} // erlaubt
|
||||
else {
|
||||
const t = u.subscription_tier || 'standard';
|
||||
if (!['pro','breeder','pro_test','breeder_test'].includes(t)) return false;
|
||||
}
|
||||
}
|
||||
// bestehende role-Checks
|
||||
if (!chip?.role) return true;
|
||||
if (chip.role === 'breeder') return u?.rolle === 'breeder' || u?.rolle === 'admin';
|
||||
if (chip.role === 'social') return u?.is_social_media || u?.rolle === 'admin';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue