diff --git a/frontend/src/components/AccountMenu.tsx b/frontend/src/components/AccountMenu.tsx index a8bdb3236..25adb3a85 100644 --- a/frontend/src/components/AccountMenu.tsx +++ b/frontend/src/components/AccountMenu.tsx @@ -13,7 +13,7 @@ import { FileText, ChevronLeft } from "lucide-react"; -import { isMobile, isTauri } from "@/utils/platform"; +import { isMobile, isTauri, isIOS } from "@/utils/platform"; import { Button } from "@/components/ui/button"; import { @@ -51,6 +51,7 @@ import { useState } from "react"; import type { TeamStatus } from "@/types/team"; import { TeamManagementDialog } from "@/components/team/TeamManagementDialog"; import { ApiKeyManagementDialog } from "@/components/apikeys/ApiKeyManagementDialog"; +import packageJson from "../../package.json"; function ConfirmDeleteDialog() { const { clearHistory } = useLocalState(); @@ -129,10 +130,47 @@ export function AccountMenu() { enabled: isTeamPlan && !!os.auth.user && !!billingStatus }); + // Fetch products with version check for iOS to determine API Management availability + const isIOSPlatform = isIOS(); + const { data: products } = useQuery({ + queryKey: ["products-version-check", isIOSPlatform], + queryFn: async () => { + try { + const billingService = getBillingService(); + // Send version for iOS builds (App Store restrictions) + if (isIOSPlatform) { + const version = `v${packageJson.version}`; + return await billingService.getProducts(version); + } + return await billingService.getProducts(); + } catch (error) { + console.error("Error fetching products for version check:", error); + return null; + } + }, + enabled: isIOSPlatform + }); + // Show alert badge if user has team plan but hasn't created team yet const showTeamSetupAlert = isTeamPlan && teamStatus?.has_team_subscription && !teamStatus?.team_created; + // Determine if API Management should be shown + // On desktop/web/Android: always show + // On iOS only: only show if version is approved (at least one product is available) + const showApiManagement = (() => { + if (!isIOSPlatform) { + return true; // Always show on desktop/web/Android + } + // On iOS, check if version is approved + // If products is null/undefined, default to false (hide until we know) + if (!products) { + return false; + } + // Show if at least one product is available (meaning version is approved) + return products.some((product) => product.is_available !== false); + })(); + const handleManageSubscription = async () => { if (!hasStripeAccount) return; @@ -300,7 +338,7 @@ export function AccountMenu() { )} - {!isMobile() && ( + {showApiManagement && ( setIsApiKeyDialogOpen(true)}> API Management