All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 12s
- Sidebar: dynamic brand-accent colors, brainstorm section restyled - AI chat general: popup panel with expand/collapse, hides when contextual AI open - AI chat contextual: tabs reordered (Actions first), X close button, height fix - Settings: all tabs restyled, 6 new color presets (sage, terracotta, iron, etc.) - Global color cleanup: emerald/orange hardcoded → brand-accent dynamic - Brainstorm page: orange → brand-accent throughout - PageEntry animation component added to key pages - Floating AI button: bg-brand-accent instead of hardcoded black - i18n: all 15 locales updated with new AI/billing keys - Billing: freemium quota tracking, BYOK, stripe subscription scaffolding - Admin: integrated into new design - AGENTS.md + CLAUDE.md project rules added
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import type { SubscriptionTier } from '@/lib/entitlements';
|
|
|
|
export type BillingTier = 'PRO' | 'BUSINESS';
|
|
export type BillingInterval = 'month' | 'year';
|
|
|
|
export function resolvePriceId(tier: BillingTier, interval: BillingInterval): string {
|
|
const map: Record<BillingTier, Record<BillingInterval, string>> = {
|
|
PRO: {
|
|
month: process.env.STRIPE_PRICE_PRO_MONTHLY!,
|
|
year: process.env.STRIPE_PRICE_PRO_ANNUAL!,
|
|
},
|
|
BUSINESS: {
|
|
month: process.env.STRIPE_PRICE_BUSINESS_MONTHLY!,
|
|
year: process.env.STRIPE_PRICE_BUSINESS_ANNUAL!,
|
|
},
|
|
};
|
|
const priceId = map[tier][interval];
|
|
if (!priceId) {
|
|
throw new Error(`No Stripe price ID configured for ${tier}/${interval}`);
|
|
}
|
|
return priceId;
|
|
}
|
|
|
|
export function priceIdToTier(priceId: string): SubscriptionTier | null {
|
|
const entries: Array<[string | undefined, SubscriptionTier]> = [
|
|
[process.env.STRIPE_PRICE_PRO_MONTHLY, 'PRO'],
|
|
[process.env.STRIPE_PRICE_PRO_ANNUAL, 'PRO'],
|
|
[process.env.STRIPE_PRICE_BUSINESS_MONTHLY, 'BUSINESS'],
|
|
[process.env.STRIPE_PRICE_BUSINESS_ANNUAL, 'BUSINESS'],
|
|
];
|
|
for (const [envPriceId, tier] of entries) {
|
|
if (envPriceId && envPriceId === priceId) return tier;
|
|
}
|
|
return null;
|
|
}
|