From 63f2d8e5ec977a23b179fff17135b9bd4fef3780 Mon Sep 17 00:00:00 2001 From: marko-kraemer Date: Thu, 24 Apr 2025 17:29:32 +0100 Subject: [PATCH] rem maintenance popup, auth redirect on dashboard, free tier intro again temp --- backend/api.py | 2 +- backend/utils/billing.py | 8 +++---- frontend/src/app/(dashboard)/layout.tsx | 30 +++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/backend/api.py b/backend/api.py index 6c5949c6..68702ccf 100644 --- a/backend/api.py +++ b/backend/api.py @@ -113,7 +113,7 @@ app = FastAPI(lifespan=lifespan) # return await call_next(request) # Define allowed origins based on environment -allowed_origins = ["https://www.suna.so", "https://suna.so", "https://staging.suna.so"] +allowed_origins = ["https://www.suna.so", "https://suna.so", "https://staging.suna.so", "http://localhost:3000"] #"http://localhost:3000" # Add staging-specific origins if config.ENV_MODE == EnvMode.STAGING: diff --git a/backend/utils/billing.py b/backend/utils/billing.py index cf0fa120..f2be0751 100644 --- a/backend/utils/billing.py +++ b/backend/utils/billing.py @@ -5,7 +5,7 @@ from utils.config import config, EnvMode # Define subscription tiers and their monthly limits (in minutes) SUBSCRIPTION_TIERS = { - 'price_1RGJ9GG6l1KZGqIroxSqgphC': {'name': 'free', 'minutes': 0}, + 'price_1RGJ9GG6l1KZGqIroxSqgphC': {'name': 'free', 'minutes': 8}, 'price_1RGJ9LG6l1KZGqIrd9pwzeNW': {'name': 'base', 'minutes': 300}, 'price_1RGJ9JG6l1KZGqIrVUU4ZRv6': {'name': 'extra', 'minutes': 2400} } @@ -91,11 +91,11 @@ async def check_billing_status(client, account_id: str) -> Tuple[bool, str, Opti if not subscription: subscription = { 'price_id': 'price_1RGJ9GG6l1KZGqIroxSqgphC', # Free tier - 'plan_name': 'Free' + 'plan_name': 'free' } - if not subscription or subscription.get('price_id') is None or subscription.get('price_id') == 'price_1RGJ9GG6l1KZGqIroxSqgphC': - return False, "You are not subscribed to any plan. Please upgrade your plan to continue.", subscription + # if not subscription or subscription.get('price_id') is None or subscription.get('price_id') == 'price_1RGJ9GG6l1KZGqIroxSqgphC': + # return False, "You are not subscribed to any plan. Please upgrade your plan to continue.", subscription # Get tier info tier_info = SUBSCRIPTION_TIERS.get(subscription['price_id']) diff --git a/frontend/src/app/(dashboard)/layout.tsx b/frontend/src/app/(dashboard)/layout.tsx index 03976416..5af08621 100644 --- a/frontend/src/app/(dashboard)/layout.tsx +++ b/frontend/src/app/(dashboard)/layout.tsx @@ -9,6 +9,9 @@ import { import { PricingAlert } from "@/components/billing/pricing-alert" import { MaintenanceAlert } from "@/components/maintenance-alert" import { useAccounts } from "@/hooks/use-accounts" +import { useAuth } from "@/components/AuthProvider" +import { useRouter } from "next/navigation" +import { Loader2 } from "lucide-react" interface DashboardLayoutProps { children: React.ReactNode @@ -21,12 +24,35 @@ export default function DashboardLayout({ const [showMaintenanceAlert, setShowMaintenanceAlert] = useState(false) const { data: accounts } = useAccounts() const personalAccount = accounts?.find(account => account.personal_account) + const { user, isLoading } = useAuth() + const router = useRouter() useEffect(() => { - setShowPricingAlert(true) + setShowPricingAlert(false) setShowMaintenanceAlert(false) }, []) + // Check authentication status + useEffect(() => { + if (!isLoading && !user) { + router.push('/auth') + } + }, [user, isLoading, router]) + + // Show loading state while checking auth + if (isLoading) { + return ( +
+ +
+ ) + } + + // Don't render anything if not authenticated + if (!user) { + return null + } + return ( @@ -50,4 +76,4 @@ export default function DashboardLayout({ /> ) -} \ No newline at end of file +} \ No newline at end of file