ROLLBACK: complete removal of broken feature enforcement system
Reverts all feature enforcement changes (commits3745ebd,cbad50a,cd4d912,8415509) to restore original working functionality. Issues caused by feature enforcement implementation: - Export buttons disappeared and never reappeared - KI analysis counter not incrementing - New analyses not saving - Pipeline appearing twice - Many core features broken Restored files to working state before enforcement implementation (commit0210844): - Backend: auth.py, insights.py, exportdata.py, importdata.py, nutrition.py, activity.py - Frontend: Analysis.jsx, SettingsPage.jsx, api.js - Removed: FeatureGate.jsx, useFeatureAccess.js The original simple AI limit system (ai_enabled, ai_limit_day) is now active again. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
8415509f4c
commit
4fcde4abfb
11 files changed
+125
-376
No files matched your search
@@ -1,80 +0,0 @@
|
||||
import { useFeatureAccess } from '../hooks/useFeatureAccess'
|
||||
|
||||
/**
|
||||
* Feature Gate Component
|
||||
*
|
||||
* Hides children if feature is not available.
|
||||
* Optionally shows upgrade prompt or message.
|
||||
*
|
||||
* @param {string} feature - Feature slug (e.g. 'ai_calls', 'data_export')
|
||||
* @param {ReactNode} children - Content to gate
|
||||
* @param {ReactNode} fallback - Optional fallback when not allowed
|
||||
* @param {boolean} showUpgradePrompt - Show upgrade message instead of hiding
|
||||
*/
|
||||
export function FeatureGate({ feature, children, fallback = null, showUpgradePrompt = false }) {
|
||||
const { canUse, reason, loading, limit, remaining } = useFeatureAccess(feature)
|
||||
|
||||
// While loading, show children optimistically (better UX)
|
||||
if (loading) return <>{children}</>
|
||||
|
||||
// If allowed, render children
|
||||
if (canUse) return <>{children}</>
|
||||
|
||||
// Not allowed
|
||||
if (showUpgradePrompt) {
|
||||
return (
|
||||
<div style={{
|
||||
padding: 16,
|
||||
background: 'var(--accent-light)',
|
||||
borderRadius: 8,
|
||||
textAlign: 'center',
|
||||
color: 'var(--accent-dark)'
|
||||
}}>
|
||||
<div style={{ fontSize: 14, fontWeight: 600, marginBottom: 4 }}>
|
||||
Feature nicht verfügbar
|
||||
</div>
|
||||
<div style={{ fontSize: 12 }}>
|
||||
{reason === 'feature_disabled' && 'Dieses Feature ist in deinem Tier nicht enthalten.'}
|
||||
{reason === 'limit_exceeded' && `Limit erreicht (${limit}). Upgrade für mehr Zugriff.`}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// Hide completely
|
||||
return fallback
|
||||
}
|
||||
|
||||
/**
|
||||
* Feature Badge - Shows usage counter
|
||||
*
|
||||
* @param {string} feature - Feature slug
|
||||
* @param {string} label - Label text (optional)
|
||||
*/
|
||||
export function FeatureBadge({ feature, label }) {
|
||||
const { limit, used, remaining, loading } = useFeatureAccess(feature)
|
||||
|
||||
if (loading) return null
|
||||
if (limit === null) return null // Unlimited
|
||||
|
||||
const percentage = limit > 0 ? (used / limit) * 100 : 0
|
||||
const color = percentage > 90 ? 'var(--danger)' : percentage > 70 ? '#FFA726' : 'var(--accent)'
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
gap: 6,
|
||||
padding: '4px 10px',
|
||||
background: 'var(--surface2)',
|
||||
borderRadius: 12,
|
||||
fontSize: 11,
|
||||
fontWeight: 600,
|
||||
color: 'var(--text3)'
|
||||
}}>
|
||||
{label && <span>{label}:</span>}
|
||||
<span style={{ color }}>{used}/{limit}</span>
|
||||
{remaining !== null && remaining === 0 && <span style={{ color: 'var(--danger)' }}>⚠️</span>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user