"use client"; import { useSession } from "next-auth/react"; import { usePathname } from "next/navigation"; import { WEBAPP_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import classNames from "@calcom/ui/classNames"; import { Button } from "@calcom/ui/components/button"; import BillingCredits from "~/settings/billing/components/BillingCredits"; interface CtaRowProps { title: string; description: string; children: React.ReactNode; className?: string; } declare global { interface Window { Support?: { open: () => void; shouldShowTriggerButton: (showTrigger: boolean) => void; }; } } export const CtaRow = ({ title, description, className, children }: CtaRowProps) => { return ( <>

{title}

{description}

{children}
); }; const BillingView = () => { const pathname = usePathname(); const session = useSession(); const { t } = useLocale(); const returnTo = pathname; // Determine the billing context and extract appropriate team/org ID const getTeamIdFromContext = () => { if (!pathname) return null; // Team billing: /settings/teams/{id}/billing if (pathname.includes("/teams/") && pathname.includes("/billing")) { const teamIdMatch = pathname.match(/\/teams\/(\d+)\/billing/); return teamIdMatch ? teamIdMatch[1] : null; } // Organization billing: /settings/organizations/billing if (pathname.includes("/organizations/billing")) { const orgId = session.data?.user?.org?.id; return typeof orgId === "number" ? orgId.toString() : null; } }; const teamId = getTeamIdFromContext(); const billingHref = teamId ? `/api/integrations/stripepayment/portal?teamId=${teamId}&returnTo=${WEBAPP_URL}${returnTo}` : `/api/integrations/stripepayment/portal?returnTo=${WEBAPP_URL}${returnTo}`; const onContactSupportClick = async () => { if (window.Support) { window.Support.open(); } }; return ( <>
); }; export default BillingView;