feat: add data retention settings to SiteSettingsPage, including subscription-based options and UI updates for user interaction
This commit is contained in:
39
lib/plans.ts
39
lib/plans.ts
@@ -40,3 +40,42 @@ export function getLimitForTierIndex(index: number): number {
|
||||
if (index < 0 || index >= TRAFFIC_TIERS.length) return 100000
|
||||
return TRAFFIC_TIERS[index].value
|
||||
}
|
||||
|
||||
/** Maximum data retention (months) allowed per plan. */
|
||||
export function getMaxRetentionMonthsForPlan(planId: string | null | undefined): number {
|
||||
switch (planId) {
|
||||
case 'business': return 60
|
||||
case 'team': return 24
|
||||
case 'solo': return 12
|
||||
default: return 6
|
||||
}
|
||||
}
|
||||
|
||||
/** Selectable retention options (months) for the given plan. */
|
||||
export function getRetentionOptionsForPlan(planId: string | null | undefined): { label: string; value: number }[] {
|
||||
const base = [
|
||||
{ label: '1 month', value: 1 },
|
||||
{ label: '3 months', value: 3 },
|
||||
{ label: '6 months', value: 6 },
|
||||
]
|
||||
const solo = [...base, { label: '1 year', value: 12 }]
|
||||
const team = [...solo, { label: '2 years', value: 24 }]
|
||||
const business = [...team, { label: '3 years', value: 36 }, { label: '5 years', value: 60 }]
|
||||
|
||||
switch (planId) {
|
||||
case 'business': return business
|
||||
case 'team': return team
|
||||
case 'solo': return solo
|
||||
default: return base
|
||||
}
|
||||
}
|
||||
|
||||
/** Human-readable label for a retention value in months. */
|
||||
export function formatRetentionMonths(months: number): string {
|
||||
if (months === 0) return 'Forever'
|
||||
if (months === 1) return '1 month'
|
||||
if (months < 12) return `${months} months`
|
||||
const years = months / 12
|
||||
if (Number.isInteger(years)) return years === 1 ? '1 year' : `${years} years`
|
||||
return `${months} months`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user