Add subcription feature

This commit is contained in:
Urtzi Alfaro
2026-01-13 22:22:38 +01:00
parent b931a5c45e
commit 6ddf608d37
61 changed files with 7915 additions and 1238 deletions

View File

@@ -11,9 +11,13 @@ import type { SubscriptionTier } from '../api';
* Generate register URL with proper query parameters
*
* @param planTier - Optional subscription plan tier (starter, professional, enterprise)
* @param billingCycle - Optional billing cycle ('monthly' or 'yearly')
* @returns Register URL with appropriate query parameters
*
* @example
* // In pilot mode with plan and billing cycle selected
* getRegisterUrl('starter', 'yearly') // => '/register?pilot=true&plan=starter&billing_cycle=yearly'
*
* // In pilot mode with plan selected
* getRegisterUrl('starter') // => '/register?pilot=true&plan=starter'
*
@@ -23,7 +27,7 @@ import type { SubscriptionTier } from '../api';
* // Not in pilot mode with plan
* getRegisterUrl('professional') // => '/register?plan=professional'
*/
export const getRegisterUrl = (planTier?: SubscriptionTier | string): string => {
export const getRegisterUrl = (planTier?: SubscriptionTier | string, billingCycle?: 'monthly' | 'yearly'): string => {
const params = new URLSearchParams();
// Add pilot parameter if pilot mode is enabled globally
@@ -36,6 +40,11 @@ export const getRegisterUrl = (planTier?: SubscriptionTier | string): string =>
params.set('plan', planTier);
}
// Add billing cycle parameter if specified
if (billingCycle) {
params.set('billing_cycle', billingCycle);
}
const queryString = params.toString();
return `/register${queryString ? '?' + queryString : ''}`;
};