mirror of https://github.com/kortix-ai/suna.git
closeable false
This commit is contained in:
parent
7e72fa4f3f
commit
d663de4c51
|
@ -1,3 +1,4 @@
|
||||||
|
NEXT_PUBLIC_ENV_MODE="LOCAL" #production, or staging
|
||||||
NEXT_PUBLIC_SUPABASE_URL=""
|
NEXT_PUBLIC_SUPABASE_URL=""
|
||||||
NEXT_PUBLIC_SUPABASE_ANON_KEY=""
|
NEXT_PUBLIC_SUPABASE_ANON_KEY=""
|
||||||
NEXT_PUBLIC_BACKEND_URL=""
|
NEXT_PUBLIC_BACKEND_URL=""
|
||||||
|
|
|
@ -39,7 +39,7 @@ export default function DashboardLayout({
|
||||||
<PricingAlert
|
<PricingAlert
|
||||||
open={showPricingAlert}
|
open={showPricingAlert}
|
||||||
onOpenChange={setShowPricingAlert}
|
onOpenChange={setShowPricingAlert}
|
||||||
closeable={true}
|
closeable={false}
|
||||||
accountId={personalAccount?.account_id}
|
accountId={personalAccount?.account_id}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@ import { setupNewSubscription } from "@/lib/actions/billing"
|
||||||
import { SubmitButton } from "@/components/ui/submit-button"
|
import { SubmitButton } from "@/components/ui/submit-button"
|
||||||
import { siteConfig } from "@/lib/home"
|
import { siteConfig } from "@/lib/home"
|
||||||
import { isLocalMode } from "@/lib/config"
|
import { isLocalMode } from "@/lib/config"
|
||||||
|
import { createClient } from "@/lib/supabase/client"
|
||||||
|
import { useEffect, useState } from "react"
|
||||||
|
import { SUBSCRIPTION_PLANS } from "./plan-comparison"
|
||||||
|
|
||||||
interface PricingAlertProps {
|
interface PricingAlertProps {
|
||||||
open: boolean
|
open: boolean
|
||||||
|
@ -20,9 +23,46 @@ interface PricingAlertProps {
|
||||||
|
|
||||||
export function PricingAlert({ open, onOpenChange, closeable = true, accountId }: PricingAlertProps) {
|
export function PricingAlert({ open, onOpenChange, closeable = true, accountId }: PricingAlertProps) {
|
||||||
const returnUrl = typeof window !== 'undefined' ? window.location.href : '';
|
const returnUrl = typeof window !== 'undefined' ? window.location.href : '';
|
||||||
|
const [hasActiveSubscription, setHasActiveSubscription] = useState(false);
|
||||||
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
// Skip rendering in local development mode
|
// Check if user has an active subscription
|
||||||
if (isLocalMode() || !open) return null;
|
useEffect(() => {
|
||||||
|
async function checkSubscription() {
|
||||||
|
if (!accountId) {
|
||||||
|
setHasActiveSubscription(false);
|
||||||
|
setIsLoading(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const supabase = createClient();
|
||||||
|
const { data } = await supabase
|
||||||
|
.schema('basejump')
|
||||||
|
.from('billing_subscriptions')
|
||||||
|
.select('price_id')
|
||||||
|
.eq('account_id', accountId)
|
||||||
|
.eq('status', 'active')
|
||||||
|
.single();
|
||||||
|
|
||||||
|
// Check if the user has a paid subscription (not free tier)
|
||||||
|
const isPaidSubscription = data?.price_id &&
|
||||||
|
data.price_id !== SUBSCRIPTION_PLANS.FREE;
|
||||||
|
|
||||||
|
setHasActiveSubscription(isPaidSubscription);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error checking subscription:", error);
|
||||||
|
setHasActiveSubscription(false);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkSubscription();
|
||||||
|
}, [accountId]);
|
||||||
|
|
||||||
|
// Skip rendering in local development mode or if user has an active subscription
|
||||||
|
if (isLocalMode() || !open || hasActiveSubscription || isLoading) return null;
|
||||||
|
|
||||||
// Filter plans to show only Pro and Enterprise
|
// Filter plans to show only Pro and Enterprise
|
||||||
const premiumPlans = siteConfig.cloudPricingItems.filter(plan =>
|
const premiumPlans = siteConfig.cloudPricingItems.filter(plan =>
|
||||||
|
|
Loading…
Reference in New Issue