supermemory/apps/web/hooks/use-connector-access.ts
MaheshtheDev 59b148e5b2 feat(web): sell Company Brain on Max as well as Scale (#1440)
Company Brain workspaces could only buy Scale at $399/mo, which is roughly eight times what the median team uses. Adds the $100/mo Max card to the Company Brain plan picker, notes what a Scale trial loses on the way down, and flags that Scale is cheaper above about $400/mo of credits.
2026-08-10 00:10:46 +00:00

22 lines
874 B
TypeScript

import { useCustomer } from "autumn-js/react"
import { hasActivePlan } from "@lib/queries"
import { useHasCompanyBrain } from "@/hooks/use-company-brain"
// Connector entitlement (pro tier or company_brain) — mirrors backend canAccessConnector. Not for plugins.
export function useConnectorAccess(opts?: { enabled?: boolean }) {
const enabled = opts?.enabled ?? true
const autumn = useCustomer({ queryOptions: { enabled } })
const hasCompanyBrain = useHasCompanyBrain()
const hasPro = enabled && hasActivePlan(autumn.data?.subscriptions, "api_pro")
const hasMax = enabled && hasActivePlan(autumn.data?.subscriptions, "api_max")
const hasScale =
enabled && hasActivePlan(autumn.data?.subscriptions, "api_scale")
return {
hasPro,
hasMax,
hasScale,
hasCompanyBrain,
connectorAccess: hasPro || hasCompanyBrain,
loading: enabled && autumn.isLoading,
}
}