use-billing.tsx1.7 KBView on GitHub // Billing is disabled. Autumn (the billing provider) has been removed from the codebase, so
// this hook is a no-op stub that keeps the billing-aware UI compiling and rendering its
// "no subscription" branches. Restore the Autumn-backed implementation to re-enable billing.
type FeatureState = {
total: number;
remaining: number;
unlimited: boolean;
enabled: boolean;
usage: number;
nextResetAt: number | null;
interval: string;
included_usage: number;
};
type Features = {
chatMessages: FeatureState;
connections: FeatureState;
brainActivity: FeatureState;
};
const DISABLED_FEATURE: FeatureState = {
total: 0,
remaining: 0,
unlimited: false,
enabled: false,
usage: 0,
nextResetAt: null,
interval: '',
included_usage: 0,
};
const DEFAULT_FEATURES: Features = {
chatMessages: DISABLED_FEATURE,
connections: DISABLED_FEATURE,
brainActivity: DISABLED_FEATURE,
};
/** Only the fields the UI reads off the billing customer. */
type BillingCustomer = { stripe_id?: string | null };
type BillingResult = { data: null; error: null };
type BillingData = Features & {
isLoading: boolean;
customer: BillingCustomer | undefined;
refetch: () => Promise<void>;
attach: (options?: unknown) => Promise<BillingResult>;
track: (options?: unknown) => Promise<BillingResult>;
openBillingPortal: (options?: unknown) => Promise<BillingResult>;
isPro: boolean;
};
const noop = async (): Promise<BillingResult> => ({ data: null, error: null });
const DISABLED_BILLING: BillingData = {
isLoading: false,
customer: undefined,
refetch: async () => {},
attach: noop,
track: noop,
openBillingPortal: noop,
isPro: false,
...DEFAULT_FEATURES,
};
export const useBilling = (): BillingData => DISABLED_BILLING;