Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions frontend/src/components/BillingStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ export function BillingStatus() {
const status = await billingService.getBillingStatus();
setBillingStatus(status);
return status;
}
},
enabled: !!os.auth.user
});

// Check if user has team plan
const isTeamPlan = billingStatus?.product_name?.toLowerCase().includes("team");

// Fetch team status if user has team plan
// Fetch team status only if user has team plan
const { data: teamStatus } = useQuery<TeamStatus>({
queryKey: ["teamStatus"],
queryFn: async () => {
Expand Down
18 changes: 16 additions & 2 deletions frontend/src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { TeamManagementDialog } from "@/components/team/TeamManagementDialog";
import { useQuery } from "@tanstack/react-query";
import { getBillingService } from "@/billing/billingService";
import type { TeamStatus } from "@/types/team";
import type { BillingStatus as BillingStatusType } from "@/billing/billingApi";

const homeVariants = cva("grid h-full w-full overflow-hidden", {
variants: {
Expand Down Expand Up @@ -69,14 +70,27 @@ function Index() {
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
const [teamDialogOpen, setTeamDialogOpen] = useState(false);

// Fetch team status for the dialog
// Fetch billing status first to check if user has team plan
const { data: billingStatus } = useQuery<BillingStatusType>({
queryKey: ["billingStatus"],
queryFn: async () => {
const billingService = getBillingService();
return await billingService.getBillingStatus();
},
enabled: !!os.auth.user
});

// Check if user has team plan
const isTeamPlan = billingStatus?.product_name?.toLowerCase().includes("team");

// Fetch team status only if user has team plan
const { data: teamStatus } = useQuery<TeamStatus>({
queryKey: ["teamStatus"],
queryFn: async () => {
const billingService = getBillingService();
return await billingService.getTeamStatus();
},
enabled: !!os.auth.user
enabled: isTeamPlan && !!os.auth.user && !!billingStatus
});

// Auto-open team dialog if team_setup is true
Expand Down