Feature: Feature-Gating nach Tier — Pro-Seiten/Chips für Standard versteckt, Admin immer alles (SW by-v737)

This commit is contained in:
rene 2026-05-06 19:06:37 +02:00
parent 11067d9ef8
commit a6c25cf0f0
6 changed files with 76 additions and 18 deletions

View file

@ -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';