72 lines
1.7 KiB
TypeScript
72 lines
1.7 KiB
TypeScript
|
|
/**
|
||
|
|
* Navigation Utilities
|
||
|
|
*
|
||
|
|
* Centralized functions for generating navigation URLs with proper parameters
|
||
|
|
*/
|
||
|
|
|
||
|
|
import PILOT_CONFIG from '../config/pilot';
|
||
|
|
import type { SubscriptionTier } from '../api';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Generate register URL with proper query parameters
|
||
|
|
*
|
||
|
|
* @param planTier - Optional subscription plan tier (starter, professional, enterprise)
|
||
|
|
* @returns Register URL with appropriate query parameters
|
||
|
|
*
|
||
|
|
* @example
|
||
|
|
* // In pilot mode with plan selected
|
||
|
|
* getRegisterUrl('starter') // => '/register?pilot=true&plan=starter'
|
||
|
|
*
|
||
|
|
* // In pilot mode without plan
|
||
|
|
* getRegisterUrl() // => '/register?pilot=true'
|
||
|
|
*
|
||
|
|
* // Not in pilot mode with plan
|
||
|
|
* getRegisterUrl('professional') // => '/register?plan=professional'
|
||
|
|
*/
|
||
|
|
export const getRegisterUrl = (planTier?: SubscriptionTier | string): string => {
|
||
|
|
const params = new URLSearchParams();
|
||
|
|
|
||
|
|
// Add pilot parameter if pilot mode is enabled globally
|
||
|
|
if (PILOT_CONFIG.enabled) {
|
||
|
|
params.set('pilot', 'true');
|
||
|
|
}
|
||
|
|
|
||
|
|
// Add plan parameter if specified
|
||
|
|
if (planTier) {
|
||
|
|
params.set('plan', planTier);
|
||
|
|
}
|
||
|
|
|
||
|
|
const queryString = params.toString();
|
||
|
|
return `/register${queryString ? '?' + queryString : ''}`;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Generate login URL
|
||
|
|
*/
|
||
|
|
export const getLoginUrl = (): string => {
|
||
|
|
return '/login';
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Generate demo URL
|
||
|
|
*/
|
||
|
|
export const getDemoUrl = (): string => {
|
||
|
|
return '/demo';
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Check if current URL has pilot parameter
|
||
|
|
*/
|
||
|
|
export const isPilotUrl = (): boolean => {
|
||
|
|
const searchParams = new URLSearchParams(window.location.search);
|
||
|
|
return searchParams.get('pilot') === 'true';
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get plan from current URL
|
||
|
|
*/
|
||
|
|
export const getPlanFromUrl = (): string | null => {
|
||
|
|
const searchParams = new URLSearchParams(window.location.search);
|
||
|
|
return searchParams.get('plan');
|
||
|
|
};
|