diff --git a/apps/web/modules/settings/billing/components/BillingCredits.tsx b/apps/web/modules/settings/billing/components/BillingCredits.tsx index 36ae8b24453d02..04fc8ae1704549 100644 --- a/apps/web/modules/settings/billing/components/BillingCredits.tsx +++ b/apps/web/modules/settings/billing/components/BillingCredits.tsx @@ -1,7 +1,8 @@ "use client"; +import { useSession } from "next-auth/react"; import Link from "next/link"; -import { useRouter } from "next/navigation"; +import { useRouter, usePathname } from "next/navigation"; import { useState, useMemo } from "react"; import { useForm } from "react-hook-form"; @@ -53,6 +54,8 @@ const getMonthOptions = (): MonthOption[] => { export default function BillingCredits() { const { t } = useLocale(); const router = useRouter(); + const pathname = usePathname(); + const session = useSession(); const monthOptions = useMemo(() => getMonthOptions(), []); const [selectedMonth, setSelectedMonth] = useState(monthOptions[0]); const [isDownloading, setIsDownloading] = useState(false); @@ -66,7 +69,9 @@ export default function BillingCredits() { } = useForm<{ quantity: number }>({ defaultValues: { quantity: 50 } }); const params = useParamsWithFallback(); - const teamId = params.id ? Number(params.id) : undefined; + const orgId = session.data?.user?.org?.id; + + const teamId = params.id ? Number(params.id) : orgId; const { data: creditsData, isLoading } = trpc.viewer.credits.getAllCredits.useQuery({ teamId }); @@ -106,6 +111,11 @@ export default function BillingCredits() { return null; } + if (orgId && !pathname?.includes("/organizations/")) { + // Don't show credits on personal billing if user is an org member + return null; + } + if (isLoading && teamId) return ; if (!creditsData) return null; @@ -206,7 +216,7 @@ export default function BillingCredits() {
-
+