Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion frontend/src/components/AccountMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function AccountMenu() {
const isPro = productName.toLowerCase().includes("pro");
const isMax = productName.toLowerCase().includes("max");
const isStarter = productName.toLowerCase().includes("starter");
const isTeamPlan = productName.toLowerCase().includes("team");
const isTeamPlan = productName.toLowerCase().includes("team") ?? false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: The ?? false is redundant here since String.prototype.includes() always returns a boolean value, never null or undefined

Suggested change
const isTeamPlan = productName.toLowerCase().includes("team") ?? false;
const isTeamPlan = productName.toLowerCase().includes("team");

const showUpgrade = !isMax && !isTeamPlan;
const showManage = (isPro || isMax || isStarter || isTeamPlan) && hasStripeAccount;

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/BillingStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function BillingStatus() {
});

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

// Fetch team status if user has team plan
const { data: teamStatus } = useQuery<TeamStatus>({
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") ?? false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: The string matching approach for detecting team plans is fragile - consider using a more explicit field if available in the API response


// 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
Loading