feat: refine data retention adjustment logic in SiteSettingsPage to snap to nearest valid option upon subscription load
This commit is contained in:
@@ -109,7 +109,7 @@ export default function SiteSettingsPage() {
|
||||
}
|
||||
}
|
||||
|
||||
// * Clamp data_retention_months when subscription loads: if current value exceeds plan max, sync to max
|
||||
// * Snap data_retention_months to nearest valid option when subscription loads
|
||||
useEffect(() => {
|
||||
if (!subscription) return
|
||||
const opts = getRetentionOptionsForPlan(subscription.plan_id)
|
||||
@@ -117,7 +117,8 @@ export default function SiteSettingsPage() {
|
||||
const maxVal = Math.max(...values)
|
||||
setFormData(prev => {
|
||||
if (values.includes(prev.data_retention_months)) return prev
|
||||
return { ...prev, data_retention_months: Math.min(prev.data_retention_months, maxVal) }
|
||||
const bestFit = values.filter(v => v <= prev.data_retention_months).pop() ?? maxVal
|
||||
return { ...prev, data_retention_months: Math.min(bestFit, maxVal) }
|
||||
})
|
||||
}, [subscription])
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export function generatePrivacySnippet(site: Site): string {
|
||||
const screen = site.collect_screen_resolution ?? true
|
||||
const perf = site.enable_performance_insights ?? false
|
||||
const filterBots = site.filter_bots ?? true
|
||||
const retentionMonths = site.data_retention_months ?? 12
|
||||
const retentionMonths = site.data_retention_months ?? 6
|
||||
|
||||
const parts: string[] = []
|
||||
if (paths) parts.push('which pages are viewed')
|
||||
|
||||
Reference in New Issue
Block a user