rem maintenance popup, auth redirect on dashboard, free tier intro again temp

This commit is contained in:
marko-kraemer 2025-04-24 17:29:32 +01:00
parent 0fc3c4a573
commit 63f2d8e5ec
3 changed files with 33 additions and 7 deletions

View File

@ -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:

View File

@ -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'])

View File

@ -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 (
<div className="flex items-center justify-center min-h-screen">
<Loader2 className="h-8 w-8 animate-spin text-primary" />
</div>
)
}
// Don't render anything if not authenticated
if (!user) {
return null
}
return (
<SidebarProvider>
<SidebarLeft />
@ -50,4 +76,4 @@ export default function DashboardLayout({
/>
</SidebarProvider>
)
}
}