mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2026-02-17 13:52:14 +01:00
<img width="996" height="621" alt="image" src="https://github.com/user-attachments/assets/1ac87414-09ed-4307-8f7c-25984e0c89d1" /> <img width="608" height="351" alt="image" src="https://github.com/user-attachments/assets/c271f75e-4844-4034-8905-007cc7ab1265" /> <img width="660" height="355" alt="image" src="https://github.com/user-attachments/assets/34913b74-d4fa-418a-b098-fda48b41f0dd" /> <img width="1371" height="906" alt="image" src="https://github.com/user-attachments/assets/35b61389-fd67-41b3-9969-e5409e53b362" /> <img width="639" height="450" alt="image" src="https://github.com/user-attachments/assets/ae018bf3-0fcf-4221-892f-440d7325540a" /> <img width="963" height="599" alt="image" src="https://github.com/user-attachments/assets/f6f67682-f43c-46f3-8632-16b209780b15" /> <img width="982" height="628" alt="image" src="https://github.com/user-attachments/assets/45a7c171-3eb4-4271-a299-f3a6e78c1a52" />
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
/**
|
|
* Shared utilities for plan tier comparisons and button logic
|
|
*/
|
|
|
|
export type PlanTier = 'free' | 'server' | 'enterprise';
|
|
|
|
const TIER_HIERARCHY: Record<PlanTier, number> = {
|
|
'free': 1,
|
|
'server': 2,
|
|
'enterprise': 3,
|
|
};
|
|
|
|
/**
|
|
* Get numeric level for a tier
|
|
*/
|
|
export function getTierLevel(tier: PlanTier | string | null | undefined): number {
|
|
if (!tier) return 1;
|
|
return TIER_HIERARCHY[tier as PlanTier] || 1;
|
|
}
|
|
|
|
/**
|
|
* Check if target tier is the current tier
|
|
*/
|
|
export function isCurrentTier(currentTier: PlanTier | string | null | undefined, targetTier: PlanTier | string): boolean {
|
|
return getTierLevel(currentTier) === getTierLevel(targetTier);
|
|
}
|
|
|
|
/**
|
|
* Check if target tier is a downgrade from current tier
|
|
*/
|
|
export function isDowngrade(currentTier: PlanTier | string | null | undefined, targetTier: PlanTier | string): boolean {
|
|
return getTierLevel(currentTier) > getTierLevel(targetTier);
|
|
}
|
|
|
|
/**
|
|
* Check if enterprise is blocked for free tier users
|
|
*/
|
|
export function isEnterpriseBlockedForFree(currentTier: PlanTier | string | null | undefined, targetTier: PlanTier | string): boolean {
|
|
return currentTier === 'free' && targetTier === 'enterprise';
|
|
}
|