Compare commits
1 Commits
codex/remo
...
codex/wrap
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec9d2f922e |
351
backend/app.py
351
backend/app.py
@@ -48,6 +48,8 @@ load_dotenv(backend_dir / '.env') # backend/.env
|
|||||||
load_dotenv(project_root / '.env') # root .env (fallback)
|
load_dotenv(project_root / '.env') # root .env (fallback)
|
||||||
load_dotenv() # CWD .env (fallback)
|
load_dotenv() # CWD .env (fallback)
|
||||||
|
|
||||||
|
PODCAST_ONLY_DEMO_MODE = os.getenv("PODCAST_ONLY_DEMO_MODE", "false").lower() in {"1", "true", "yes", "on"}
|
||||||
|
|
||||||
# Set up clean logging for end users
|
# Set up clean logging for end users
|
||||||
from logging_config import setup_clean_logging
|
from logging_config import setup_clean_logging
|
||||||
setup_clean_logging()
|
setup_clean_logging()
|
||||||
@@ -110,36 +112,37 @@ from services.startup_health import (
|
|||||||
# Import OAuth token monitoring routes
|
# Import OAuth token monitoring routes
|
||||||
from api.oauth_token_monitoring_routes import router as oauth_token_monitoring_router
|
from api.oauth_token_monitoring_routes import router as oauth_token_monitoring_router
|
||||||
|
|
||||||
# Import SEO Dashboard endpoints
|
if not PODCAST_ONLY_DEMO_MODE:
|
||||||
from api.seo_dashboard import (
|
# Import SEO Dashboard endpoints only when non-demo features are enabled
|
||||||
get_seo_dashboard_data,
|
from api.seo_dashboard import (
|
||||||
get_seo_health_score,
|
get_seo_dashboard_data,
|
||||||
get_seo_metrics,
|
get_seo_health_score,
|
||||||
get_platform_status,
|
get_seo_metrics,
|
||||||
get_ai_insights,
|
get_platform_status,
|
||||||
seo_dashboard_health_check,
|
get_ai_insights,
|
||||||
analyze_seo_comprehensive,
|
seo_dashboard_health_check,
|
||||||
analyze_seo_full,
|
analyze_seo_comprehensive,
|
||||||
get_seo_metrics_detailed,
|
analyze_seo_full,
|
||||||
get_analysis_summary,
|
get_seo_metrics_detailed,
|
||||||
batch_analyze_urls,
|
get_analysis_summary,
|
||||||
SEOAnalysisRequest,
|
batch_analyze_urls,
|
||||||
get_seo_dashboard_overview,
|
SEOAnalysisRequest,
|
||||||
get_gsc_raw_data,
|
get_seo_dashboard_overview,
|
||||||
get_bing_raw_data,
|
get_gsc_raw_data,
|
||||||
get_competitive_insights,
|
get_bing_raw_data,
|
||||||
get_deep_competitor_analysis,
|
get_competitive_insights,
|
||||||
run_strategic_insights,
|
get_deep_competitor_analysis,
|
||||||
get_strategic_insights_history,
|
run_strategic_insights,
|
||||||
refresh_analytics_data,
|
get_strategic_insights_history,
|
||||||
analyze_urls_ai,
|
refresh_analytics_data,
|
||||||
AnalyzeURLsRequest,
|
analyze_urls_ai,
|
||||||
get_analyzed_pages,
|
AnalyzeURLsRequest,
|
||||||
get_semantic_health,
|
get_analyzed_pages,
|
||||||
get_semantic_cache_stats,
|
get_semantic_health,
|
||||||
get_sif_indexing_health,
|
get_semantic_cache_stats,
|
||||||
get_onboarding_task_health,
|
get_sif_indexing_health,
|
||||||
)
|
get_onboarding_task_health,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# Initialize FastAPI app
|
# Initialize FastAPI app
|
||||||
@@ -259,194 +262,184 @@ async def onboarding_status():
|
|||||||
return onboarding_manager.get_onboarding_status()
|
return onboarding_manager.get_onboarding_status()
|
||||||
|
|
||||||
# Include routers using modular utilities
|
# Include routers using modular utilities
|
||||||
router_manager.include_core_routers()
|
if not PODCAST_ONLY_DEMO_MODE:
|
||||||
router_manager.include_optional_routers()
|
router_manager.include_core_routers()
|
||||||
|
router_manager.include_optional_routers()
|
||||||
|
else:
|
||||||
|
logger.info("PODCAST_ONLY_DEMO_MODE enabled: including only podcast and subscription feature routers.")
|
||||||
|
app.include_router(subscription_router)
|
||||||
|
|
||||||
# Include assets serving router (must be mounted to serve generated images)
|
# Include assets serving router (must be mounted to serve generated images)
|
||||||
app.include_router(assets_serving_router)
|
app.include_router(assets_serving_router)
|
||||||
|
|
||||||
# SEO Dashboard endpoints
|
if not PODCAST_ONLY_DEMO_MODE:
|
||||||
@app.get("/api/seo-dashboard/data")
|
# SEO Dashboard endpoints
|
||||||
async def seo_dashboard_data():
|
@app.get("/api/seo-dashboard/data")
|
||||||
"""Get complete SEO dashboard data."""
|
async def seo_dashboard_data():
|
||||||
return await get_seo_dashboard_data()
|
"""Get complete SEO dashboard data."""
|
||||||
|
return await get_seo_dashboard_data()
|
||||||
|
|
||||||
@app.get("/api/seo-dashboard/health-score")
|
@app.get("/api/seo-dashboard/health-score")
|
||||||
async def seo_health_score():
|
async def seo_health_score():
|
||||||
"""Get SEO health score."""
|
"""Get SEO health score."""
|
||||||
return await get_seo_health_score()
|
return await get_seo_health_score()
|
||||||
|
|
||||||
@app.get("/api/seo-dashboard/metrics")
|
@app.get("/api/seo-dashboard/metrics")
|
||||||
async def seo_metrics():
|
async def seo_metrics():
|
||||||
"""Get SEO metrics."""
|
"""Get SEO metrics."""
|
||||||
return await get_seo_metrics()
|
return await get_seo_metrics()
|
||||||
|
|
||||||
@app.get("/api/seo-dashboard/platforms")
|
@app.get("/api/seo-dashboard/platforms")
|
||||||
async def seo_platforms(current_user: dict = Depends(get_current_user)):
|
async def seo_platforms(current_user: dict = Depends(get_current_user)):
|
||||||
"""Get platform status."""
|
"""Get platform status."""
|
||||||
return await get_platform_status(current_user)
|
return await get_platform_status(current_user)
|
||||||
|
|
||||||
@app.get("/api/seo-dashboard/insights")
|
@app.get("/api/seo-dashboard/insights")
|
||||||
async def seo_insights():
|
async def seo_insights():
|
||||||
"""Get AI insights."""
|
"""Get AI insights."""
|
||||||
return await get_ai_insights()
|
return await get_ai_insights()
|
||||||
|
|
||||||
# New SEO Dashboard endpoints with real data
|
# New SEO Dashboard endpoints with real data
|
||||||
@app.get("/api/seo-dashboard/overview")
|
@app.get("/api/seo-dashboard/overview")
|
||||||
async def seo_dashboard_overview_endpoint(current_user: dict = Depends(get_current_user), site_url: str = None):
|
async def seo_dashboard_overview_endpoint(current_user: dict = Depends(get_current_user), site_url: str = None):
|
||||||
"""Get comprehensive SEO dashboard overview with real GSC/Bing data."""
|
"""Get comprehensive SEO dashboard overview with real GSC/Bing data."""
|
||||||
return await get_seo_dashboard_overview(current_user, site_url)
|
return await get_seo_dashboard_overview(current_user, site_url)
|
||||||
|
|
||||||
@app.get("/api/seo-dashboard/gsc/raw")
|
@app.get("/api/seo-dashboard/gsc/raw")
|
||||||
async def gsc_raw_data_endpoint(current_user: dict = Depends(get_current_user), site_url: str = None):
|
async def gsc_raw_data_endpoint(current_user: dict = Depends(get_current_user), site_url: str = None):
|
||||||
"""Get raw GSC data for the specified site."""
|
"""Get raw GSC data for the specified site."""
|
||||||
return await get_gsc_raw_data(current_user, site_url)
|
return await get_gsc_raw_data(current_user, site_url)
|
||||||
|
|
||||||
@app.get("/api/seo-dashboard/bing/raw")
|
@app.get("/api/seo-dashboard/bing/raw")
|
||||||
async def bing_raw_data_endpoint(current_user: dict = Depends(get_current_user), site_url: str = None):
|
async def bing_raw_data_endpoint(current_user: dict = Depends(get_current_user), site_url: str = None):
|
||||||
"""Get raw Bing data for the specified site."""
|
"""Get raw Bing data for the specified site."""
|
||||||
return await get_bing_raw_data(current_user, site_url)
|
return await get_bing_raw_data(current_user, site_url)
|
||||||
|
|
||||||
@app.get("/api/seo-dashboard/competitive-insights")
|
@app.get("/api/seo-dashboard/competitive-insights")
|
||||||
async def competitive_insights_endpoint(current_user: dict = Depends(get_current_user), site_url: str = None):
|
async def competitive_insights_endpoint(current_user: dict = Depends(get_current_user), site_url: str = None):
|
||||||
"""Get competitive insights from onboarding step 3 data."""
|
"""Get competitive insights from onboarding step 3 data."""
|
||||||
return await get_competitive_insights(current_user, site_url)
|
return await get_competitive_insights(current_user, site_url)
|
||||||
|
|
||||||
@app.get("/api/seo-dashboard/deep-competitor-analysis")
|
@app.get("/api/seo-dashboard/deep-competitor-analysis")
|
||||||
async def deep_competitor_analysis_endpoint(current_user: dict = Depends(get_current_user), site_url: str = None):
|
async def deep_competitor_analysis_endpoint(current_user: dict = Depends(get_current_user), site_url: str = None):
|
||||||
"""Get deep competitor analysis results (auto-scheduled post-onboarding)."""
|
"""Get deep competitor analysis results (auto-scheduled post-onboarding)."""
|
||||||
return await get_deep_competitor_analysis(current_user, site_url)
|
return await get_deep_competitor_analysis(current_user, site_url)
|
||||||
|
|
||||||
@app.post("/api/seo-dashboard/strategic-insights/run")
|
@app.post("/api/seo-dashboard/strategic-insights/run")
|
||||||
async def run_strategic_insights_endpoint(current_user: dict = Depends(get_current_user)):
|
async def run_strategic_insights_endpoint(current_user: dict = Depends(get_current_user)):
|
||||||
"""Run AI-powered strategic insights analysis manually."""
|
"""Run AI-powered strategic insights analysis manually."""
|
||||||
return await run_strategic_insights(current_user)
|
return await run_strategic_insights(current_user)
|
||||||
|
|
||||||
@app.get("/api/seo-dashboard/strategic-insights/history")
|
@app.get("/api/seo-dashboard/strategic-insights/history")
|
||||||
async def get_strategic_insights_history_endpoint(current_user: dict = Depends(get_current_user)):
|
async def get_strategic_insights_history_endpoint(current_user: dict = Depends(get_current_user)):
|
||||||
"""Fetch the history of strategic insights for the user."""
|
"""Fetch the history of strategic insights for the user."""
|
||||||
return await get_strategic_insights_history(current_user)
|
return await get_strategic_insights_history(current_user)
|
||||||
|
|
||||||
@app.post("/api/seo-dashboard/refresh")
|
@app.post("/api/seo-dashboard/refresh")
|
||||||
async def refresh_analytics_data_endpoint(current_user: dict = Depends(get_current_user), site_url: str = None):
|
async def refresh_analytics_data_endpoint(current_user: dict = Depends(get_current_user), site_url: str = None):
|
||||||
"""Refresh analytics data by invalidating cache and fetching fresh data."""
|
"""Refresh analytics data by invalidating cache and fetching fresh data."""
|
||||||
return await refresh_analytics_data(current_user, site_url)
|
return await refresh_analytics_data(current_user, site_url)
|
||||||
|
|
||||||
|
@app.get("/api/seo-dashboard/onboarding-task-health")
|
||||||
|
async def onboarding_task_health_endpoint(current_user: dict = Depends(get_current_user), site_url: str = None):
|
||||||
|
"""Get consolidated health for onboarding-scheduled SEO tasks."""
|
||||||
|
return await get_onboarding_task_health(current_user, site_url)
|
||||||
|
|
||||||
|
@app.get("/api/seo-dashboard/health")
|
||||||
|
async def seo_dashboard_health():
|
||||||
|
"""Health check for SEO dashboard."""
|
||||||
|
return await seo_dashboard_health_check()
|
||||||
|
|
||||||
@app.get("/api/seo-dashboard/onboarding-task-health")
|
# Phase 2B: Semantic health monitoring endpoint (24-hour polling)
|
||||||
async def onboarding_task_health_endpoint(current_user: dict = Depends(get_current_user), site_url: str = None):
|
@app.get("/api/seo-dashboard/semantic-health")
|
||||||
"""Get consolidated health for onboarding-scheduled SEO tasks."""
|
async def semantic_health_endpoint(current_user: dict = Depends(get_current_user)):
|
||||||
return await get_onboarding_task_health(current_user, site_url)
|
"""Get real-time semantic health metrics for content and competitors."""
|
||||||
|
return await get_semantic_health(current_user)
|
||||||
|
|
||||||
@app.get("/api/seo-dashboard/health")
|
@app.get("/api/seo-dashboard/cache-stats")
|
||||||
async def seo_dashboard_health():
|
async def semantic_cache_stats_endpoint(current_user: dict = Depends(get_current_user)):
|
||||||
"""Health check for SEO dashboard."""
|
"""Get semantic cache performance statistics."""
|
||||||
return await seo_dashboard_health_check()
|
return await get_semantic_cache_stats(current_user)
|
||||||
|
|
||||||
# Phase 2B: Semantic health monitoring endpoint (24-hour polling)
|
@app.get("/api/seo-dashboard/sif-health")
|
||||||
@app.get("/api/seo-dashboard/semantic-health")
|
async def sif_indexing_health_endpoint(current_user: dict = Depends(get_current_user)):
|
||||||
async def semantic_health_endpoint(current_user: dict = Depends(get_current_user)):
|
"""Get SIF indexing health summary for the current user."""
|
||||||
"""
|
return await get_sif_indexing_health(current_user)
|
||||||
Get real-time semantic health metrics for content and competitors.
|
|
||||||
This endpoint provides Phase 2B semantic intelligence monitoring data.
|
|
||||||
|
|
||||||
Returns semantic health score, status, and recommendations.
|
|
||||||
Data is cached and updated every 24 hours via scheduler.
|
|
||||||
"""
|
|
||||||
return await get_semantic_health(current_user)
|
|
||||||
|
|
||||||
|
# Comprehensive SEO Analysis endpoints
|
||||||
|
@app.post("/api/seo-dashboard/analyze-comprehensive")
|
||||||
|
async def analyze_seo_comprehensive_endpoint(request: SEOAnalysisRequest):
|
||||||
|
"""Analyze a URL for comprehensive SEO performance."""
|
||||||
|
return await analyze_seo_comprehensive(request)
|
||||||
|
|
||||||
@app.get("/api/seo-dashboard/cache-stats")
|
@app.post("/api/seo-dashboard/analyze-full")
|
||||||
async def semantic_cache_stats_endpoint(current_user: dict = Depends(get_current_user)):
|
async def analyze_seo_full_endpoint(request: SEOAnalysisRequest):
|
||||||
"""
|
"""Analyze a URL for comprehensive SEO performance."""
|
||||||
Get semantic cache performance statistics.
|
return await analyze_seo_full(request)
|
||||||
Returns hit rate, memory usage, and eviction counts.
|
|
||||||
"""
|
|
||||||
return await get_semantic_cache_stats(current_user)
|
|
||||||
|
|
||||||
|
@app.get("/api/seo-dashboard/metrics-detailed")
|
||||||
|
async def seo_metrics_detailed(url: str):
|
||||||
|
"""Get detailed SEO metrics for a URL."""
|
||||||
|
return await get_seo_metrics_detailed(url)
|
||||||
|
|
||||||
@app.get("/api/seo-dashboard/sif-health")
|
@app.get("/api/seo-dashboard/analysis-summary")
|
||||||
async def sif_indexing_health_endpoint(current_user: dict = Depends(get_current_user)):
|
async def seo_analysis_summary(url: str):
|
||||||
"""
|
"""Get a quick summary of SEO analysis for a URL."""
|
||||||
Get SIF indexing health summary for the current user.
|
return await get_analysis_summary(url)
|
||||||
Used by the Semantic Indexing Status widget on the dashboard.
|
|
||||||
"""
|
|
||||||
return await get_sif_indexing_health(current_user)
|
|
||||||
|
|
||||||
# Comprehensive SEO Analysis endpoints
|
@app.post("/api/seo-dashboard/batch-analyze")
|
||||||
@app.post("/api/seo-dashboard/analyze-comprehensive")
|
async def batch_analyze_urls_endpoint(urls: list[str]):
|
||||||
async def analyze_seo_comprehensive_endpoint(request: SEOAnalysisRequest):
|
"""Analyze multiple URLs in batch."""
|
||||||
"""Analyze a URL for comprehensive SEO performance."""
|
return await batch_analyze_urls(urls)
|
||||||
return await analyze_seo_comprehensive(request)
|
|
||||||
|
|
||||||
@app.post("/api/seo-dashboard/analyze-full")
|
@app.post("/api/seo-dashboard/analyze-urls-ai")
|
||||||
async def analyze_seo_full_endpoint(request: SEOAnalysisRequest):
|
async def analyze_urls_ai_endpoint(request: AnalyzeURLsRequest, current_user: dict = Depends(get_current_user)):
|
||||||
"""Analyze a URL for comprehensive SEO performance."""
|
"""Run AI-powered SEO analysis on selected URLs."""
|
||||||
return await analyze_seo_full(request)
|
return await analyze_urls_ai(request, current_user)
|
||||||
|
|
||||||
@app.get("/api/seo-dashboard/metrics-detailed")
|
# Include platform analytics router
|
||||||
async def seo_metrics_detailed(url: str):
|
from routers.platform_analytics import router as platform_analytics_router
|
||||||
"""Get detailed SEO metrics for a URL."""
|
app.include_router(platform_analytics_router)
|
||||||
return await get_seo_metrics_detailed(url)
|
# Include Bing Analytics Storage router to expose storage-backed endpoints
|
||||||
|
from routers.bing_analytics_storage import router as bing_analytics_storage_router
|
||||||
|
app.include_router(bing_analytics_storage_router)
|
||||||
|
app.include_router(images_router)
|
||||||
|
app.include_router(image_studio_router)
|
||||||
|
app.include_router(product_marketing_router)
|
||||||
|
app.include_router(campaign_creator_router)
|
||||||
|
|
||||||
@app.get("/api/seo-dashboard/analysis-summary")
|
# Include content assets router
|
||||||
async def seo_analysis_summary(url: str):
|
from api.content_assets.router import router as content_assets_router
|
||||||
"""Get a quick summary of SEO analysis for a URL."""
|
app.include_router(content_assets_router)
|
||||||
return await get_analysis_summary(url)
|
|
||||||
|
|
||||||
@app.post("/api/seo-dashboard/batch-analyze")
|
|
||||||
async def batch_analyze_urls_endpoint(urls: list[str]):
|
|
||||||
"""Analyze multiple URLs in batch."""
|
|
||||||
return await batch_analyze_urls(urls)
|
|
||||||
|
|
||||||
@app.post("/api/seo-dashboard/analyze-urls-ai")
|
|
||||||
async def analyze_urls_ai_endpoint(request: AnalyzeURLsRequest, current_user: dict = Depends(get_current_user)):
|
|
||||||
"""Run AI-powered SEO analysis on selected URLs."""
|
|
||||||
return await analyze_urls_ai(request, current_user)
|
|
||||||
|
|
||||||
# Include platform analytics router
|
|
||||||
from routers.platform_analytics import router as platform_analytics_router
|
|
||||||
app.include_router(platform_analytics_router)
|
|
||||||
# Include Bing Analytics Storage router to expose storage-backed endpoints
|
|
||||||
from routers.bing_analytics_storage import router as bing_analytics_storage_router
|
|
||||||
app.include_router(bing_analytics_storage_router)
|
|
||||||
app.include_router(images_router)
|
|
||||||
app.include_router(image_studio_router)
|
|
||||||
app.include_router(product_marketing_router)
|
|
||||||
app.include_router(campaign_creator_router)
|
|
||||||
|
|
||||||
# Include content assets router
|
|
||||||
from api.content_assets.router import router as content_assets_router
|
|
||||||
app.include_router(content_assets_router)
|
|
||||||
|
|
||||||
# Include Podcast Maker router
|
# Include Podcast Maker router
|
||||||
from api.podcast.router import router as podcast_router
|
from api.podcast.router import router as podcast_router
|
||||||
app.include_router(podcast_router)
|
app.include_router(podcast_router)
|
||||||
|
|
||||||
# Include YouTube Creator Studio router
|
if not PODCAST_ONLY_DEMO_MODE:
|
||||||
from api.youtube.router import router as youtube_router
|
# Include YouTube Creator Studio router
|
||||||
app.include_router(youtube_router, prefix="/api")
|
from api.youtube.router import router as youtube_router
|
||||||
|
app.include_router(youtube_router, prefix="/api")
|
||||||
|
|
||||||
# Include research configuration router
|
# Include research configuration router
|
||||||
app.include_router(research_config_router, prefix="/api/research", tags=["research"])
|
app.include_router(research_config_router, prefix="/api/research", tags=["research"])
|
||||||
|
|
||||||
# Include Research Engine router (standalone AI research module)
|
# Include Research Engine router (standalone AI research module)
|
||||||
from api.research.router import router as research_engine_router
|
from api.research.router import router as research_engine_router
|
||||||
app.include_router(research_engine_router, tags=["Research Engine"])
|
app.include_router(research_engine_router, tags=["Research Engine"])
|
||||||
|
|
||||||
# Scheduler dashboard routes
|
# Scheduler dashboard routes
|
||||||
from api.scheduler_dashboard import router as scheduler_dashboard_router
|
from api.scheduler_dashboard import router as scheduler_dashboard_router
|
||||||
app.include_router(scheduler_dashboard_router)
|
app.include_router(scheduler_dashboard_router)
|
||||||
app.include_router(oauth_token_monitoring_router)
|
app.include_router(oauth_token_monitoring_router)
|
||||||
|
|
||||||
# Autonomous Agents API routes (Phase 3A)
|
# Autonomous Agents API routes (Phase 3A)
|
||||||
from api.agents_api import router as agents_router
|
from api.agents_api import router as agents_router
|
||||||
app.include_router(agents_router)
|
app.include_router(agents_router)
|
||||||
|
|
||||||
# Today workflow routes
|
# Today workflow routes
|
||||||
from api.today_workflow import router as today_workflow_router
|
from api.today_workflow import router as today_workflow_router
|
||||||
app.include_router(today_workflow_router)
|
app.include_router(today_workflow_router)
|
||||||
|
|
||||||
# Setup frontend serving using modular utilities
|
# Setup frontend serving using modular utilities
|
||||||
frontend_serving.setup_frontend_serving()
|
frontend_serving.setup_frontend_serving()
|
||||||
|
|||||||
@@ -52,27 +52,6 @@ export interface SubscriptionPlan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const PricingPage: React.FC = () => {
|
const PricingPage: React.FC = () => {
|
||||||
const pricingMode = (process.env.REACT_APP_PRICING_MODE || 'alpha').toLowerCase();
|
|
||||||
const isAlphaMode = pricingMode === 'alpha';
|
|
||||||
const tierPolicyByMode: Record<string, { visible: string[]; selectable: string[]; unavailableLabels: Record<string, string> }> = {
|
|
||||||
alpha: {
|
|
||||||
visible: ['free', 'basic', 'pro', 'enterprise'],
|
|
||||||
selectable: ['free', 'basic'],
|
|
||||||
unavailableLabels: { pro: 'Coming Soon', enterprise: 'Contact Sales' },
|
|
||||||
},
|
|
||||||
demo: {
|
|
||||||
visible: ['free', 'basic', 'pro', 'enterprise'],
|
|
||||||
selectable: ['free', 'basic', 'pro'],
|
|
||||||
unavailableLabels: { enterprise: 'Contact Sales' },
|
|
||||||
},
|
|
||||||
production: {
|
|
||||||
visible: ['free', 'basic', 'pro', 'enterprise'],
|
|
||||||
selectable: ['free', 'basic', 'pro'],
|
|
||||||
unavailableLabels: { enterprise: 'Contact Sales' },
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const activeTierPolicy = tierPolicyByMode[pricingMode] || tierPolicyByMode.alpha;
|
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [plans, setPlans] = useState<SubscriptionPlan[]>([]);
|
const [plans, setPlans] = useState<SubscriptionPlan[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
@@ -97,11 +76,9 @@ const PricingPage: React.FC = () => {
|
|||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const response = await apiClient.get('/api/subscription/plans');
|
const response = await apiClient.get('/api/subscription/plans');
|
||||||
// Filter out legacy alpha-named plans and enforce tier visibility policy.
|
// Filter out any alpha plans and ensure we only show the 4 main tiers
|
||||||
const filteredPlans = response.data.data.plans.filter(
|
const filteredPlans = response.data.data.plans.filter(
|
||||||
(plan: SubscriptionPlan) =>
|
(plan: SubscriptionPlan) => !plan.name.toLowerCase().includes('alpha')
|
||||||
!plan.name.toLowerCase().includes('alpha') &&
|
|
||||||
activeTierPolicy.visible.includes(plan.tier)
|
|
||||||
);
|
);
|
||||||
setPlans(filteredPlans);
|
setPlans(filteredPlans);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -134,13 +111,10 @@ const PricingPage: React.FC = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!activeTierPolicy.selectable.includes(plan.tier)) {
|
// For alpha testing, only allow Free and Basic plans (Pro features not ready)
|
||||||
|
if (plan.tier !== 'free' && plan.tier !== 'basic') {
|
||||||
console.error('[PricingPage] Plan tier not available:', plan.tier);
|
console.error('[PricingPage] Plan tier not available:', plan.tier);
|
||||||
setError(
|
setError('This plan is not available for alpha testing');
|
||||||
isAlphaMode
|
|
||||||
? 'This plan is not available during alpha testing'
|
|
||||||
: 'This plan is currently not available for self-serve checkout'
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,8 +351,6 @@ const PricingPage: React.FC = () => {
|
|||||||
yearlyBilling={yearlyBilling}
|
yearlyBilling={yearlyBilling}
|
||||||
selectedPlanId={selectedPlan}
|
selectedPlanId={selectedPlan}
|
||||||
subscribing={subscribing}
|
subscribing={subscribing}
|
||||||
canSelectPlan={activeTierPolicy.selectable.includes(plan.tier)}
|
|
||||||
unavailableLabel={activeTierPolicy.unavailableLabels[plan.tier]}
|
|
||||||
onSelectPlan={setSelectedPlan}
|
onSelectPlan={setSelectedPlan}
|
||||||
onSubscribe={handleSubscribe}
|
onSubscribe={handleSubscribe}
|
||||||
openKnowMoreModal={openKnowMoreModal}
|
openKnowMoreModal={openKnowMoreModal}
|
||||||
@@ -420,48 +392,42 @@ const PricingPage: React.FC = () => {
|
|||||||
}}>
|
}}>
|
||||||
<Typography variant="h6" component="h2" gutterBottom sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
<Typography variant="h6" component="h2" gutterBottom sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
||||||
<Warning sx={{ color: 'warning.main' }} />
|
<Warning sx={{ color: 'warning.main' }} />
|
||||||
{isAlphaMode ? 'Alpha Testing Subscription' : 'Confirm Subscription'}
|
Alpha Testing Subscription
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
{isAlphaMode ? (
|
{/* Alpha Testing Notice */}
|
||||||
<>
|
<Alert severity="warning" sx={{ mb: 2 }}>
|
||||||
<Alert severity="warning" sx={{ mb: 2 }}>
|
<Typography variant="body2" sx={{ fontWeight: 600, mb: 0.5 }}>
|
||||||
<Typography variant="body2" sx={{ fontWeight: 600, mb: 0.5 }}>
|
⚠️ Alpha Testing Mode - No Payment Required
|
||||||
⚠️ Alpha Testing Mode - No Payment Required
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="caption" sx={{ display: 'block' }}>
|
|
||||||
Payment integration is coming soon. For now, subscriptions are activated without charge.
|
|
||||||
</Typography>
|
|
||||||
</Alert>
|
|
||||||
|
|
||||||
<Typography variant="body1" sx={{ mb: 2 }}>
|
|
||||||
Thank you for participating in our alpha testing! We're crediting this plan to your account.
|
|
||||||
</Typography>
|
|
||||||
|
|
||||||
<Box sx={{
|
|
||||||
p: 2,
|
|
||||||
mb: 3,
|
|
||||||
bgcolor: 'info.lighter',
|
|
||||||
borderRadius: 1,
|
|
||||||
border: '1px solid',
|
|
||||||
borderColor: 'info.light'
|
|
||||||
}}>
|
|
||||||
<Typography variant="body2" color="info.dark">
|
|
||||||
<strong>Coming in Production:</strong>
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="caption" color="info.dark" sx={{ display: 'block', mt: 0.5 }}>
|
|
||||||
• Secure Stripe/PayPal payment processing<br />
|
|
||||||
• Automatic renewal management<br />
|
|
||||||
• Payment verification & receipts<br />
|
|
||||||
• Upgrade/downgrade options
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<Typography variant="body1" sx={{ mb: 3 }}>
|
|
||||||
Please confirm to continue with your selected subscription plan.
|
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
<Typography variant="caption" sx={{ display: 'block' }}>
|
||||||
|
Payment integration is coming soon. For now, subscriptions are activated without charge.
|
||||||
|
</Typography>
|
||||||
|
</Alert>
|
||||||
|
|
||||||
|
<Typography variant="body1" sx={{ mb: 2 }}>
|
||||||
|
Thank you for participating in our alpha testing! We're crediting the Basic plan ($29 value) to your account.
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
{/* TODO: Payment Integration Notice */}
|
||||||
|
<Box sx={{
|
||||||
|
p: 2,
|
||||||
|
mb: 3,
|
||||||
|
bgcolor: 'info.lighter',
|
||||||
|
borderRadius: 1,
|
||||||
|
border: '1px solid',
|
||||||
|
borderColor: 'info.light'
|
||||||
|
}}>
|
||||||
|
<Typography variant="body2" color="info.dark">
|
||||||
|
<strong>Coming in Production:</strong>
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="caption" color="info.dark" sx={{ display: 'block', mt: 0.5 }}>
|
||||||
|
• Secure Stripe/PayPal payment processing<br />
|
||||||
|
• Automatic renewal management<br />
|
||||||
|
• Payment verification & receipts<br />
|
||||||
|
• Upgrade/downgrade options
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
|
||||||
{/* Note: Current behavior allows renewal without payment verification */}
|
{/* Note: Current behavior allows renewal without payment verification */}
|
||||||
{/* This is intentional for alpha testing but will be secured in production */}
|
{/* This is intentional for alpha testing but will be secured in production */}
|
||||||
|
|||||||
@@ -69,8 +69,6 @@ interface PlanCardProps {
|
|||||||
yearlyBilling: boolean;
|
yearlyBilling: boolean;
|
||||||
selectedPlanId: number | null;
|
selectedPlanId: number | null;
|
||||||
subscribing: boolean;
|
subscribing: boolean;
|
||||||
canSelectPlan: boolean;
|
|
||||||
unavailableLabel?: string;
|
|
||||||
onSelectPlan: (planId: number) => void;
|
onSelectPlan: (planId: number) => void;
|
||||||
onSubscribe: (planId: number) => void;
|
onSubscribe: (planId: number) => void;
|
||||||
openKnowMoreModal: (title: string, content: React.ReactNode) => void;
|
openKnowMoreModal: (title: string, content: React.ReactNode) => void;
|
||||||
@@ -81,8 +79,6 @@ const PlanCard: React.FC<PlanCardProps> = ({
|
|||||||
yearlyBilling,
|
yearlyBilling,
|
||||||
selectedPlanId,
|
selectedPlanId,
|
||||||
subscribing,
|
subscribing,
|
||||||
canSelectPlan,
|
|
||||||
unavailableLabel,
|
|
||||||
onSelectPlan,
|
onSelectPlan,
|
||||||
onSubscribe,
|
onSubscribe,
|
||||||
openKnowMoreModal,
|
openKnowMoreModal,
|
||||||
@@ -913,9 +909,13 @@ const PlanCard: React.FC<PlanCardProps> = ({
|
|||||||
</CardContent>
|
</CardContent>
|
||||||
|
|
||||||
<CardActions sx={{ justifyContent: 'center', pb: 3, flexDirection: 'column', gap: 1 }}>
|
<CardActions sx={{ justifyContent: 'center', pb: 3, flexDirection: 'column', gap: 1 }}>
|
||||||
{!canSelectPlan ? (
|
{plan.tier === 'pro' ? (
|
||||||
<Button variant="outlined" size="large" fullWidth disabled sx={{ mb: 1 }}>
|
<Button variant="outlined" size="large" fullWidth disabled sx={{ mb: 1 }}>
|
||||||
{unavailableLabel || 'Unavailable'}
|
Coming Soon
|
||||||
|
</Button>
|
||||||
|
) : plan.tier === 'enterprise' ? (
|
||||||
|
<Button variant="outlined" size="large" fullWidth disabled sx={{ mb: 1 }}>
|
||||||
|
Contact Sales
|
||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
@@ -951,3 +951,4 @@ const PlanCard: React.FC<PlanCardProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default PlanCard;
|
export default PlanCard;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user