import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "../ui/card"; import { Alert, AlertDescription, AlertTitle } from "../ui/alert"; import { createClient } from "@/lib/supabase/server"; import { SubmitButton } from "../ui/submit-button"; import { manageSubscription, setupNewSubscription } from "@/lib/actions/billing"; type Props = { accountId: string; returnUrl: string; } export default async function AccountBillingStatus({ accountId, returnUrl }: Props) { const supabaseClient = createClient(); const { data, error } = await supabaseClient.functions.invoke('billing-functions', { body: { action: "get_billing_status", args: { account_id: accountId } } }); return ( Subscription Status Manage your subscription and payment details {!Boolean(data?.billing_enabled) ? ( Billing Not Enabled Billing is not enabled for this account. Check out usebasejump.com for more info or remove this component if you don't plan on enabling billing. ) : (
Status {data.status === 'active' ? 'Active' : 'Inactive'}
{data.plan_name && (
Plan {data.plan_name}
)}
)}
{Boolean(data?.billing_enabled) && (
{data.status === 'not_setup' ? ( Set Up Subscription ) : ( Manage Subscription )}
)}
) }