82 lines
2.2 KiB
JavaScript
Executable File
82 lines
2.2 KiB
JavaScript
Executable File
/**
|
|
* Feature Toggle System
|
|
*
|
|
* Controls which features are available in FREE vs PRO versions
|
|
* Currently static, will be dynamic from database in the future
|
|
*/
|
|
|
|
// User tier - will be fetched from database/auth in the future
|
|
export const USER_TIER = {
|
|
FREE: 'free',
|
|
PRO: 'pro'
|
|
};
|
|
|
|
// Current user tier (static for now, will be dynamic)
|
|
// TODO: Replace with actual user tier from authentication/database
|
|
export const getCurrentUserTier = () => {
|
|
// For development/testing, you can change this
|
|
const staticTier = USER_TIER.PRO; // Change to USER_TIER.PRO to test pro features
|
|
|
|
// In the future, this will be:
|
|
// return getUserFromAuth()?.tier || USER_TIER.FREE;
|
|
|
|
return staticTier;
|
|
};
|
|
|
|
// Feature flags
|
|
export const FEATURES = {
|
|
// Advanced URL Fetch with headers, methods, body, auth
|
|
ADVANCED_URL_FETCH: {
|
|
name: 'Advanced URL Fetch',
|
|
description: 'Custom HTTP methods, headers, authentication, and request body',
|
|
tier: USER_TIER.PRO,
|
|
enabled: (userTier) => userTier === USER_TIER.PRO
|
|
},
|
|
|
|
// Future pro features can be added here
|
|
BULK_OPERATIONS: {
|
|
name: 'Bulk Operations',
|
|
description: 'Process multiple files or operations at once',
|
|
tier: USER_TIER.PRO,
|
|
enabled: (userTier) => userTier === USER_TIER.PRO
|
|
},
|
|
|
|
EXPORT_TEMPLATES: {
|
|
name: 'Export Templates',
|
|
description: 'Save and reuse custom export templates',
|
|
tier: USER_TIER.PRO,
|
|
enabled: (userTier) => userTier === USER_TIER.PRO
|
|
},
|
|
|
|
CLOUD_SYNC: {
|
|
name: 'Cloud Sync',
|
|
description: 'Sync your data and settings across devices',
|
|
tier: USER_TIER.PRO,
|
|
enabled: (userTier) => userTier === USER_TIER.PRO
|
|
}
|
|
};
|
|
|
|
// Helper function to check if a feature is enabled
|
|
export const isFeatureEnabled = (featureName) => {
|
|
const feature = FEATURES[featureName];
|
|
if (!feature) return false;
|
|
|
|
const userTier = getCurrentUserTier();
|
|
return feature.enabled(userTier);
|
|
};
|
|
|
|
// Helper function to get user tier
|
|
export const getUserTier = () => {
|
|
return getCurrentUserTier();
|
|
};
|
|
|
|
// Helper function to check if user is pro
|
|
export const isProUser = () => {
|
|
return getCurrentUserTier() === USER_TIER.PRO;
|
|
};
|
|
|
|
// Helper function to get feature info
|
|
export const getFeatureInfo = (featureName) => {
|
|
return FEATURES[featureName] || null;
|
|
};
|